cc: Fix hudLayer size and paint rects scale for deviceScaleFactor != 1

This fixes the hudLayer on retina displays, where the FPS counter appears offscreen and the paint rects at wrong locations.

BUG=163014


Review URL: https://chromiumcodereview.appspot.com/11415208

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170512 0039d316-1c4b-4281-b951-d872f2087c98
parent fe2c420f
......@@ -35,12 +35,12 @@ void HeadsUpDisplayLayer::update(ResourceUpdateQueue&, const OcclusionTracker*,
matrix.MakeIdentity();
if (debugState.showPlatformLayerTree || debugState.showHudRects()) {
int width = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize().width());
int height = std::min(maxTextureSize, layerTreeHost()->deviceViewportSize().height());
int width = std::min(maxTextureSize, layerTreeHost()->layoutViewportSize().width());
int height = std::min(maxTextureSize, layerTreeHost()->layoutViewportSize().height());
bounds = gfx::Size(width, height);
} else {
bounds = gfx::Size(256, 128);
matrix.Translate(layerTreeHost()->deviceViewportSize().width() - 256, 0);
matrix.Translate(layerTreeHost()->layoutViewportSize().width() - 256, 0);
}
setBounds(bounds);
......
......@@ -311,6 +311,10 @@ void HeadsUpDisplayLayerImpl::drawFPSCounterGraphAndHistogram(SkCanvas* canvas,
void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory* debugRectHistory)
{
const std::vector<DebugRect>& debugRects = debugRectHistory->debugRects();
float rectScale = 1 / layerTreeHostImpl()->deviceScaleFactor();
canvas->save();
canvas->scale(rectScale, rectScale);
for (size_t i = 0; i < debugRects.size(); ++i) {
SkColor strokeColor = 0;
......@@ -366,6 +370,8 @@ void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory*
paint.setStrokeWidth(SkFloatToScalar(strokeWidth));
canvas->drawRect(skRect, paint);
}
canvas->restore();
}
const char* HeadsUpDisplayLayerImpl::layerTypeAsString() const
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment