Bug 1056190 - Delete Scrollgraph. r=benwa

This commit is contained in:
Mason Chang 2014-08-20 17:42:03 -07:00
Родитель 17644f670e
Коммит 3db44baa85
3 изменённых файлов: 0 добавлений и 144 удалений

Просмотреть файл

@ -86,27 +86,6 @@ GetOpaqueRect(Layer* aLayer)
return result;
}
struct LayerVelocityUserData : public LayerUserData {
public:
LayerVelocityUserData() {
MOZ_COUNT_CTOR(LayerVelocityUserData);
}
~LayerVelocityUserData() {
MOZ_COUNT_DTOR(LayerVelocityUserData);
}
struct VelocityData {
VelocityData(TimeStamp frameTime, int scrollX, int scrollY)
: mFrameTime(frameTime)
, mPoint(scrollX, scrollY)
{}
TimeStamp mFrameTime;
gfx::Point mPoint;
};
std::vector<VelocityData> mData;
};
static gfx::Point GetScrollData(Layer* aLayer) {
gfx::Matrix matrix;
if (aLayer->GetLocalTransform().Is2D(&matrix)) {
@ -143,120 +122,6 @@ static void DrawLayerInfo(const RenderTargetIntRect& aClipRect,
}
static LayerVelocityUserData* GetVelocityData(Layer* aLayer) {
static char sLayerVelocityUserDataKey;
void* key = reinterpret_cast<void*>(&sLayerVelocityUserDataKey);
if (!aLayer->HasUserData(key)) {
LayerVelocityUserData* newData = new LayerVelocityUserData();
aLayer->SetUserData(key, newData);
}
return static_cast<LayerVelocityUserData*>(aLayer->GetUserData(key));
}
static void DrawVelGraph(const RenderTargetIntRect& aClipRect,
LayerManagerComposite* aManager,
Layer* aLayer) {
Compositor* compositor = aManager->GetCompositor();
gfx::Rect clipRect(aClipRect.x, aClipRect.y,
aClipRect.width, aClipRect.height);
TimeStamp now = TimeStamp::Now();
LayerVelocityUserData* velocityData = GetVelocityData(aLayer);
if (velocityData->mData.size() >= 1 &&
now > velocityData->mData[velocityData->mData.size() - 1].mFrameTime +
TimeDuration::FromMilliseconds(200)) {
// clear stale data
velocityData->mData.clear();
}
const gfx::Point layerTransform = GetScrollData(aLayer);
velocityData->mData.push_back(
LayerVelocityUserData::VelocityData(now,
static_cast<int>(layerTransform.x), static_cast<int>(layerTransform.y)));
// TODO: dump to file
// XXX: Uncomment these lines to enable ScrollGraph logging. This is
// useful for HVGA phones or to output the data to accurate
// graphing software.
// printf_stderr("ScrollGraph (%p): %f, %f\n",
// aLayer, layerTransform.x, layerTransform.y);
// Keep a circular buffer of 100.
size_t circularBufferSize = 100;
if (velocityData->mData.size() > circularBufferSize) {
velocityData->mData.erase(velocityData->mData.begin());
}
if (velocityData->mData.size() == 1) {
return;
}
// Clear and disable the graph when it's flat
for (size_t i = 1; i < velocityData->mData.size(); i++) {
if (velocityData->mData[i - 1].mPoint != velocityData->mData[i].mPoint) {
break;
}
if (i == velocityData->mData.size() - 1) {
velocityData->mData.clear();
return;
}
}
if (aLayer->GetEffectiveVisibleRegion().GetBounds().width < 300 ||
aLayer->GetEffectiveVisibleRegion().GetBounds().height < 300) {
// Don't want a graph for smaller layers
return;
}
aManager->SetDebugOverlayWantsNextFrame(true);
const Matrix4x4& transform = aLayer->GetEffectiveTransform();
nsIntRect bounds = aLayer->GetEffectiveVisibleRegion().GetBounds();
IntSize graphSize = IntSize(200, 100);
Rect graphRect = Rect(bounds.x, bounds.y, graphSize.width, graphSize.height);
RefPtr<DrawTarget> dt = aManager->CreateDrawTarget(graphSize, SurfaceFormat::B8G8R8A8);
dt->FillRect(Rect(0, 0, graphSize.width, graphSize.height),
ColorPattern(Color(0.2f,0,0,1)));
int yScaleFactor = 3;
Point prev = Point(0,0);
bool first = true;
for (int32_t i = (int32_t)velocityData->mData.size() - 2; i >= 0; i--) {
const gfx::Point& p1 = velocityData->mData[i+1].mPoint;
const gfx::Point& p2 = velocityData->mData[i].mPoint;
int vel = sqrt((p1.x - p2.x).value * (p1.x - p2.x).value +
(p1.y - p2.y).value * (p1.y - p2.y).value);
Point next = Point(graphRect.width / circularBufferSize * i,
graphRect.height - vel/yScaleFactor);
if (first) {
first = false;
} else {
dt->StrokeLine(prev, next, ColorPattern(Color(0,1,0,1)));
}
prev = next;
}
RefPtr<DataTextureSource> textureSource = compositor->CreateDataTextureSource();
RefPtr<SourceSurface> snapshot = dt->Snapshot();
RefPtr<DataSourceSurface> data = snapshot->GetDataSurface();
textureSource->Update(data);
EffectChain effectChain;
effectChain.mPrimaryEffect = CreateTexturedEffect(SurfaceFormat::B8G8R8A8,
textureSource,
Filter::POINT,
true);
compositor->DrawQuad(graphRect,
clipRect,
effectChain,
1.0f,
transform);
}
static void PrintUniformityInfo(Layer* aLayer)
{
// Don't want to print a log for smaller layers
@ -440,10 +305,6 @@ RenderLayers(ContainerT* aContainer,
layerToRender->SetShadowVisibleRegion(preparedData.mSavedVisibleRegion);
}
if (gfxPrefs::LayersScrollGraph()) {
DrawVelGraph(clipRect, aManager, layerToRender->GetLayer());
}
if (gfxPrefs::UniformityInfo()) {
PrintUniformityInfo(layerToRender->GetLayer());
}

Просмотреть файл

@ -248,7 +248,6 @@ private:
DECL_GFX_PREF(Once, "layers.prefer-d3d9", LayersPreferD3D9, bool, false);
DECL_GFX_PREF(Once, "layers.prefer-opengl", LayersPreferOpenGL, bool, false);
DECL_GFX_PREF(Once, "layers.progressive-paint", UseProgressiveTilePainting, bool, false);
DECL_GFX_PREF(Once, "layers.scroll-graph", LayersScrollGraph, bool, false);
DECL_GFX_PREF(Once, "layers.uniformity-info", UniformityInfo, bool, false);
DECL_GFX_PREF(Live, "layers.invert", Invert, bool, false);
DECL_GFX_PREF(Live, "layers.grayscale", Grayscale, bool, false);

Просмотреть файл

@ -3780,10 +3780,6 @@ pref("layers.tile-width", 256);
pref("layers.tile-height", 256);
// Max number of layers per container. See Overwrite in mobile prefs.
pref("layers.max-active", -1);
// When a layer is moving it will add a scroll graph to measure the smoothness
// of the movement. NOTE: This pref triggers composites to refresh
// the graph.
pref("layers.scroll-graph", false);
// Set the default values, and then override per-platform as needed
pref("layers.offmainthreadcomposition.enabled", false);