| Index: cc/layers/heads_up_display_layer_impl.cc
|
| diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc
|
| index c01841dc1f119731df2999db59ab42b766aec081..2210067f6b3c193083e762c3329d23127d8f68a5 100644
|
| --- a/cc/layers/heads_up_display_layer_impl.cc
|
| +++ b/cc/layers/heads_up_display_layer_impl.cc
|
| @@ -28,6 +28,7 @@
|
| #include "third_party/skia/include/effects/SkColorMatrixFilter.h"
|
| #include "ui/gfx/geometry/point.h"
|
| #include "ui/gfx/geometry/size.h"
|
| +#include "ui/gfx/geometry/size_conversions.h"
|
|
|
| namespace cc {
|
|
|
| @@ -69,6 +70,7 @@ double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() {
|
| HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* tree_impl,
|
| int id)
|
| : LayerImpl(tree_impl, id),
|
| + internal_contents_scale_(1.f),
|
| fps_graph_(60.0, 80.0),
|
| paint_time_graph_(16.0, 48.0),
|
| fade_step_(0) {
|
| @@ -94,8 +96,8 @@ void HeadsUpDisplayLayerImpl::AcquireResource(
|
|
|
| scoped_ptr<ScopedResource> resource =
|
| ScopedResource::Create(resource_provider);
|
| - resource->Allocate(
|
| - content_bounds(), ResourceProvider::TextureHintImmutable, RGBA_8888);
|
| + resource->Allocate(internal_content_bounds_,
|
| + ResourceProvider::TextureHintImmutable, RGBA_8888);
|
| resources_.push_back(resource.Pass());
|
| }
|
|
|
| @@ -115,7 +117,7 @@ class ResourceSizeIsEqualTo {
|
| void HeadsUpDisplayLayerImpl::ReleaseUnmatchedSizeResources(
|
| ResourceProvider* resource_provider) {
|
| ScopedPtrVector<ScopedResource>::iterator it_erase =
|
| - resources_.partition(ResourceSizeIsEqualTo(content_bounds()));
|
| + resources_.partition(ResourceSizeIsEqualTo(internal_content_bounds_));
|
| resources_.erase(it_erase, resources_.end());
|
| }
|
|
|
| @@ -124,6 +126,10 @@ bool HeadsUpDisplayLayerImpl::WillDraw(DrawMode draw_mode,
|
| if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE)
|
| return false;
|
|
|
| + internal_contents_scale_ = draw_properties().ideal_contents_scale;
|
| + internal_content_bounds_ =
|
| + gfx::ToCeiledSize(gfx::ScaleSize(bounds(), internal_contents_scale_));
|
| +
|
| ReleaseUnmatchedSizeResources(resource_provider);
|
| AcquireResource(resource_provider);
|
| return LayerImpl::WillDraw(draw_mode, resource_provider);
|
| @@ -138,9 +144,9 @@ void HeadsUpDisplayLayerImpl::AppendQuads(
|
|
|
| SharedQuadState* shared_quad_state =
|
| render_pass->CreateAndAppendSharedQuadState();
|
| - PopulateSharedQuadState(shared_quad_state);
|
| + PopulateScaledSharedQuadState(shared_quad_state, internal_contents_scale_);
|
|
|
| - gfx::Rect quad_rect(content_bounds());
|
| + gfx::Rect quad_rect(internal_content_bounds_);
|
| gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect());
|
| gfx::Rect visible_quad_rect(quad_rect);
|
| bool premultiplied_alpha = true;
|
| @@ -177,12 +183,13 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
|
| else
|
| canvas_size.set(0, 0);
|
|
|
| - if (canvas_size.width() != content_bounds().width() ||
|
| - canvas_size.height() != content_bounds().height() || !hud_surface_) {
|
| + if (canvas_size.width() != internal_content_bounds_.width() ||
|
| + canvas_size.height() != internal_content_bounds_.height() ||
|
| + !hud_surface_) {
|
| TRACE_EVENT0("cc", "ResizeHudCanvas");
|
|
|
| hud_surface_ = skia::AdoptRef(SkSurface::NewRasterN32Premul(
|
| - content_bounds().width(), content_bounds().height()));
|
| + internal_content_bounds_.width(), internal_content_bounds_.height()));
|
| }
|
|
|
| UpdateHudContents();
|
| @@ -191,7 +198,8 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
|
| TRACE_EVENT0("cc", "DrawHudContents");
|
| hud_surface_->getCanvas()->clear(SkColorSetARGB(0, 0, 0, 0));
|
| hud_surface_->getCanvas()->save();
|
| - hud_surface_->getCanvas()->scale(contents_scale_x(), contents_scale_y());
|
| + hud_surface_->getCanvas()->scale(internal_contents_scale_,
|
| + internal_contents_scale_);
|
|
|
| DrawHudContents(hud_surface_->getCanvas());
|
|
|
| @@ -203,7 +211,7 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture(
|
| size_t row_bytes = 0;
|
| const void* pixels = hud_surface_->getCanvas()->peekPixels(&info, &row_bytes);
|
| DCHECK(pixels);
|
| - gfx::Rect content_rect(content_bounds());
|
| + gfx::Rect content_rect(internal_content_bounds_);
|
| DCHECK(info.colorType() == kN32_SkColorType);
|
| resource_provider->SetPixels(resources_.back()->id(),
|
| static_cast<const uint8_t*>(pixels),
|
| @@ -677,8 +685,9 @@ void HeadsUpDisplayLayerImpl::DrawDebugRect(
|
| SkColor fill_color,
|
| float stroke_width,
|
| const std::string& label_text) const {
|
| - gfx::Rect debug_layer_rect = gfx::ScaleToEnclosingRect(
|
| - rect.rect, 1.0 / contents_scale_x(), 1.0 / contents_scale_y());
|
| + gfx::Rect debug_layer_rect =
|
| + gfx::ScaleToEnclosingRect(rect.rect, 1.0 / internal_contents_scale_,
|
| + 1.0 / internal_contents_scale_);
|
| SkIRect sk_rect = RectToSkIRect(debug_layer_rect);
|
| paint->setColor(fill_color);
|
| paint->setStyle(SkPaint::kFill_Style);
|
| @@ -696,7 +705,7 @@ void HeadsUpDisplayLayerImpl::DrawDebugRect(
|
| // The debug_layer_rect may be huge, and converting to a floating point may
|
| // be lossy, so intersect with the HUD layer bounds first to prevent that.
|
| gfx::Rect clip_rect = debug_layer_rect;
|
| - clip_rect.Intersect(gfx::Rect(content_bounds()));
|
| + clip_rect.Intersect(gfx::Rect(internal_content_bounds_));
|
| SkRect sk_clip_rect = RectToSkRect(clip_rect);
|
|
|
| canvas->save();
|
|
|