diff options
author | enne <enne@chromium.org> | 2015-02-13 10:55:58 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-13 18:56:40 +0000 |
commit | 73f6bd0f123b64ccd4f98d7fca237bbeb4604c83 (patch) | |
tree | 2f39cbf100b12886c1903ab3120d3753f087fc9f /cc | |
parent | 1afb35a1a63e53497245625b1052be436830a95f (diff) | |
download | chromium_src-73f6bd0f123b64ccd4f98d7fca237bbeb4604c83.zip chromium_src-73f6bd0f123b64ccd4f98d7fca237bbeb4604c83.tar.gz chromium_src-73f6bd0f123b64ccd4f98d7fca237bbeb4604c83.tar.bz2 |
cc: Make HeadsUpDisplayLayer no longer a ContentsScalingLayer
The HUD layer can just get its scale from the compositor thread rather
than the main thread. This change makes it possible to remove content
scale calculations off of the main thread once TiledLayer is removed.
Review URL: https://codereview.chromium.org/913243003
Cr-Commit-Position: refs/heads/master@{#316248}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/heads_up_display_layer.h | 4 | ||||
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.cc | 35 | ||||
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.h | 3 | ||||
-rw-r--r-- | cc/layers/heads_up_display_layer_impl_unittest.cc | 3 |
4 files changed, 29 insertions, 16 deletions
diff --git a/cc/layers/heads_up_display_layer.h b/cc/layers/heads_up_display_layer.h index 7ca09925..ddc34f2 100644 --- a/cc/layers/heads_up_display_layer.h +++ b/cc/layers/heads_up_display_layer.h @@ -9,11 +9,11 @@ #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" -#include "cc/layers/contents_scaling_layer.h" +#include "cc/layers/layer.h" namespace cc { -class CC_EXPORT HeadsUpDisplayLayer : public ContentsScalingLayer { +class CC_EXPORT HeadsUpDisplayLayer : public Layer { public: static scoped_refptr<HeadsUpDisplayLayer> Create(); diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index 5c0c43b2..5b2613e 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(); diff --git a/cc/layers/heads_up_display_layer_impl.h b/cc/layers/heads_up_display_layer_impl.h index 0f90a16..d8ed845 100644 --- a/cc/layers/heads_up_display_layer_impl.h +++ b/cc/layers/heads_up_display_layer_impl.h @@ -128,6 +128,9 @@ class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl { ScopedPtrVector<ScopedResource> resources_; skia::RefPtr<SkSurface> hud_surface_; + float internal_contents_scale_; + gfx::Size internal_content_bounds_; + Graph fps_graph_; Graph paint_time_graph_; MemoryHistory::Entry memory_entry_; diff --git a/cc/layers/heads_up_display_layer_impl_unittest.cc b/cc/layers/heads_up_display_layer_impl_unittest.cc index d342d4f..6c83506 100644 --- a/cc/layers/heads_up_display_layer_impl_unittest.cc +++ b/cc/layers/heads_up_display_layer_impl_unittest.cc @@ -37,7 +37,8 @@ TEST(HeadsUpDisplayLayerImplTest, ResourcelessSoftwareDrawAfterResourceLoss) { host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); scoped_ptr<HeadsUpDisplayLayerImpl> layer = HeadsUpDisplayLayerImpl::Create(host_impl.pending_tree(), 1); - layer->SetContentBounds(gfx::Size(100, 100)); + layer->SetBounds(gfx::Size(100, 100)); + layer->draw_properties().ideal_contents_scale = 1.f; // Check regular hardware draw is ok. CheckDrawLayer( |