diff options
Diffstat (limited to 'cc')
51 files changed, 296 insertions, 331 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index c03f712..ec679d1 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -176,7 +176,6 @@ 'test/layer_tree_test.h', 'test/mock_quad_culler.cc', 'test/mock_quad_culler.h', - 'test/occlusion_tracker_test_common.h', 'test/ordered_texture_map.cc', 'test/ordered_texture_map.h', 'test/paths.cc', @@ -207,6 +206,7 @@ 'test/test_context_support.h', 'test/test_gles2_interface.cc', 'test/test_gles2_interface.h', + 'test/test_occlusion_tracker.h', 'test/test_texture.cc', 'test/test_texture.h', 'test/test_tile_priorities.cc', diff --git a/cc/debug/debug_rect_history.cc b/cc/debug/debug_rect_history.cc index 4241823..47c952e 100644 --- a/cc/debug/debug_rect_history.cc +++ b/cc/debug/debug_rect_history.cc @@ -6,6 +6,7 @@ #include "cc/base/math_util.h" #include "cc/layers/layer_impl.h" +#include "cc/layers/layer_iterator.h" #include "cc/layers/layer_utils.h" #include "cc/layers/render_surface_impl.h" #include "cc/trees/damage_tracker.h" diff --git a/cc/layers/content_layer.cc b/cc/layers/content_layer.cc index 8585977..edca5ed 100644 --- a/cc/layers/content_layer.cc +++ b/cc/layers/content_layer.cc @@ -88,7 +88,7 @@ void ContentLayer::SetTexturePriorities( } bool ContentLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { { base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_, true); diff --git a/cc/layers/content_layer.h b/cc/layers/content_layer.h index 783e094..9bef22b 100644 --- a/cc/layers/content_layer.h +++ b/cc/layers/content_layer.h @@ -45,7 +45,7 @@ class CC_EXPORT ContentLayer : public TiledLayer { virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual bool NeedMoreUpdates() OVERRIDE; virtual void SetContentsOpaque(bool contents_opaque) OVERRIDE; diff --git a/cc/layers/contents_scaling_layer.cc b/cc/layers/contents_scaling_layer.cc index 44a3f37..6fcaf1f 100644 --- a/cc/layers/contents_scaling_layer.cc +++ b/cc/layers/contents_scaling_layer.cc @@ -35,9 +35,8 @@ void ContentsScalingLayer::CalculateContentsScale( ideal_contents_scale); } -bool ContentsScalingLayer::Update( - ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { +bool ContentsScalingLayer::Update(ResourceUpdateQueue* queue, + const OcclusionTracker<Layer>* occlusion) { bool updated = Layer::Update(queue, occlusion); if (draw_properties().contents_scale_x == last_update_contents_scale_x_ && diff --git a/cc/layers/contents_scaling_layer.h b/cc/layers/contents_scaling_layer.h index a2648d1..52abc4bc 100644 --- a/cc/layers/contents_scaling_layer.h +++ b/cc/layers/contents_scaling_layer.h @@ -23,9 +23,8 @@ class CC_EXPORT ContentsScalingLayer : public Layer { float* contents_scale_y, gfx::Size* content_bounds) OVERRIDE; - virtual bool Update( - ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + virtual bool Update(ResourceUpdateQueue* queue, + const OcclusionTracker<Layer>* occlusion) OVERRIDE; protected: ContentsScalingLayer(); diff --git a/cc/layers/delegated_renderer_layer.cc b/cc/layers/delegated_renderer_layer.cc index aaee787..1dab3c8 100644 --- a/cc/layers/delegated_renderer_layer.cc +++ b/cc/layers/delegated_renderer_layer.cc @@ -113,7 +113,7 @@ static bool FrameDataRequiresFilterContext(const DelegatedFrameData* frame) { } bool DelegatedRendererLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { bool updated = Layer::Update(queue, occlusion); if (!should_collect_new_frame_) return updated; diff --git a/cc/layers/delegated_renderer_layer.h b/cc/layers/delegated_renderer_layer.h index a0b67df..a229543 100644 --- a/cc/layers/delegated_renderer_layer.h +++ b/cc/layers/delegated_renderer_layer.h @@ -26,7 +26,7 @@ class CC_EXPORT DelegatedRendererLayer : public Layer { OVERRIDE; virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* impl) OVERRIDE; // Set the size at which the frame should be displayed, with the origin at the diff --git a/cc/layers/image_layer.cc b/cc/layers/image_layer.cc index 2f90bfc..562525b 100644 --- a/cc/layers/image_layer.cc +++ b/cc/layers/image_layer.cc @@ -41,7 +41,7 @@ void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) { } bool ImageLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { CreateUpdaterIfNeeded(); if (!updater_->UsingBitmap(bitmap_)) { updater_->SetBitmap(bitmap_); diff --git a/cc/layers/image_layer.h b/cc/layers/image_layer.h index 6cd8275..5d9b656 100644 --- a/cc/layers/image_layer.h +++ b/cc/layers/image_layer.h @@ -23,7 +23,7 @@ class CC_EXPORT ImageLayer : public TiledLayer { virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void CalculateContentsScale(float ideal_contents_scale, float device_scale_factor, float page_scale_factor, diff --git a/cc/layers/io_surface_layer.cc b/cc/layers/io_surface_layer.cc index 209827d..98d3dfe 100644 --- a/cc/layers/io_surface_layer.cc +++ b/cc/layers/io_surface_layer.cc @@ -41,7 +41,7 @@ void IOSurfaceLayer::PushPropertiesTo(LayerImpl* layer) { } bool IOSurfaceLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { bool updated = Layer::Update(queue, occlusion); // This layer doesn't update any resources from the main thread side, diff --git a/cc/layers/io_surface_layer.h b/cc/layers/io_surface_layer.h index 9939f56..80e5b69 100644 --- a/cc/layers/io_surface_layer.h +++ b/cc/layers/io_surface_layer.h @@ -21,7 +21,7 @@ class CC_EXPORT IOSurfaceLayer : public Layer { virtual bool DrawsContent() const OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; protected: IOSurfaceLayer(); diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 63b1288..d016571 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -1071,7 +1071,7 @@ void Layer::SavePaintProperties() { } bool Layer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { DCHECK(layer_tree_host_); DCHECK_EQ(layer_tree_host_->source_frame_number(), paint_properties_.source_frame_number) << diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 37772e9..97d3753 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -24,7 +24,6 @@ #include "cc/layers/paint_properties.h" #include "cc/layers/render_surface.h" #include "cc/output/filter_operations.h" -#include "cc/trees/occlusion_tracker.h" #include "skia/ext/refptr.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkImageFilter.h" @@ -61,6 +60,8 @@ class RenderingStatsInstrumentation; class ResourceUpdateQueue; class ScrollbarLayerInterface; struct AnimationEvent; +template <typename LayerType> +class OcclusionTracker; // Base class for composited layers. Special layer types are derived from // this class. @@ -352,7 +353,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, virtual void SavePaintProperties(); // Returns true iff any resources were updated that need to be committed. virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion); + const OcclusionTracker<Layer>* occlusion); virtual bool NeedMoreUpdates(); virtual void SetIsMask(bool is_mask) {} virtual void ReduceMemoryUsage() {} diff --git a/cc/layers/nine_patch_layer_unittest.cc b/cc/layers/nine_patch_layer_unittest.cc index b052481..94e75eb 100644 --- a/cc/layers/nine_patch_layer_unittest.cc +++ b/cc/layers/nine_patch_layer_unittest.cc @@ -57,7 +57,7 @@ TEST_F(NinePatchLayerTest, SetLayerProperties) { EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); ResourceUpdateQueue queue; - OcclusionTracker occlusion_tracker(gfx::Rect(), false); + OcclusionTracker<Layer> occlusion_tracker(gfx::Rect(), false); test_layer->SavePaintProperties(); test_layer->Update(&queue, &occlusion_tracker); diff --git a/cc/layers/painted_scrollbar_layer.cc b/cc/layers/painted_scrollbar_layer.cc index 9060994..320ea30 100644 --- a/cc/layers/painted_scrollbar_layer.cc +++ b/cc/layers/painted_scrollbar_layer.cc @@ -202,7 +202,7 @@ void PaintedScrollbarLayer::UpdateThumbAndTrackGeometry() { } bool PaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { UpdateThumbAndTrackGeometry(); gfx::Rect track_layer_rect = gfx::Rect(location_, bounds()); diff --git a/cc/layers/painted_scrollbar_layer.h b/cc/layers/painted_scrollbar_layer.h index 56bacae..1ff9169 100644 --- a/cc/layers/painted_scrollbar_layer.h +++ b/cc/layers/painted_scrollbar_layer.h @@ -38,7 +38,7 @@ class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, // Layer interface virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual void PushScrollClipPropertiesTo(LayerImpl* layer) OVERRIDE; diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc index 6707307..ec73e09 100644 --- a/cc/layers/picture_layer.cc +++ b/cc/layers/picture_layer.cc @@ -81,7 +81,7 @@ void PictureLayer::SetNeedsDisplayRect(const gfx::RectF& layer_rect) { } bool PictureLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { update_source_frame_number_ = layer_tree_host()->source_frame_number(); bool updated = Layer::Update(queue, occlusion); diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h index d986a9b..853f449 100644 --- a/cc/layers/picture_layer.h +++ b/cc/layers/picture_layer.h @@ -30,9 +30,8 @@ class CC_EXPORT PictureLayer : public Layer { virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual void SetNeedsDisplayRect(const gfx::RectF& layer_rect) OVERRIDE; - virtual bool Update( - ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + virtual bool Update(ResourceUpdateQueue* queue, + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void SetIsMask(bool is_mask) OVERRIDE; virtual bool SupportsLCDText() const OVERRIDE; virtual skia::RefPtr<SkPicture> GetPicture() const OVERRIDE; diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index 8f13fd0..dc434157 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -35,7 +35,7 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { layer->SetIsDrawable(true); layer->SavePaintProperties(); - OcclusionTracker occlusion(gfx::Rect(0, 0, 1000, 1000), false); + OcclusionTracker<Layer> occlusion(gfx::Rect(0, 0, 1000, 1000), false); scoped_ptr<ResourceUpdateQueue> queue(new ResourceUpdateQueue); layer->Update(queue.get(), &occlusion); diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 794a60e..2b2b010 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -24,6 +24,7 @@ #include "cc/test/test_web_graphics_context_3d.h" #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_impl.h" +#include "cc/trees/occlusion_tracker.h" #include "cc/trees/single_thread_proxy.h" #include "cc/trees/tree_synchronizer.h" #include "testing/gmock/include/gmock/gmock.h" @@ -651,7 +652,7 @@ class ScrollbarLayerTestResourceCreation : public testing::Test { EXPECT_EQ(scrollbar_layer->layer_tree_host(), layer_tree_host_.get()); ResourceUpdateQueue queue; - OcclusionTracker occlusion_tracker(gfx::Rect(), false); + OcclusionTracker<Layer> occlusion_tracker(gfx::Rect(), false); scrollbar_layer->SavePaintProperties(); for (int update_counter = 0; update_counter < num_updates; update_counter++) @@ -737,7 +738,7 @@ class ScaledScrollbarLayerTestResourceCreation : public testing::Test { EXPECT_EQ(scrollbar_layer->layer_tree_host(), layer_tree_host_.get()); ResourceUpdateQueue queue; - OcclusionTracker occlusion_tracker(gfx::Rect(), false); + OcclusionTracker<Layer> occlusion_tracker(gfx::Rect(), false); scrollbar_layer->SavePaintProperties(); scrollbar_layer->Update(&queue, &occlusion_tracker); @@ -813,7 +814,7 @@ class ScaledScrollbarLayerTestScaledRasterization : public testing::Test { scaled_size.height()); ResourceUpdateQueue queue; - OcclusionTracker occlusion_tracker(gfx::Rect(), false); + OcclusionTracker<Layer> occlusion_tracker(gfx::Rect(), false); scrollbar_layer->SavePaintProperties(); scrollbar_layer->Update(&queue, &occlusion_tracker); diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc index bc6b58a..3260b44 100644 --- a/cc/layers/texture_layer.cc +++ b/cc/layers/texture_layer.cc @@ -217,7 +217,7 @@ bool TextureLayer::DrawsContent() const { } bool TextureLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { bool updated = Layer::Update(queue, occlusion); if (client_) { if (uses_mailbox_) { diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h index bb179a6..6ef413c 100644 --- a/cc/layers/texture_layer.h +++ b/cc/layers/texture_layer.h @@ -138,7 +138,7 @@ class CC_EXPORT TextureLayer : public Layer { virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; virtual bool DrawsContent() const OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; virtual Region VisibleContentOpaqueRegion() const OVERRIDE; diff --git a/cc/layers/tiled_layer.cc b/cc/layers/tiled_layer.cc index d4ec763..8ad494c 100644 --- a/cc/layers/tiled_layer.cc +++ b/cc/layers/tiled_layer.cc @@ -17,6 +17,7 @@ #include "cc/resources/prioritized_resource.h" #include "cc/resources/priority_calculator.h" #include "cc/trees/layer_tree_host.h" +#include "cc/trees/occlusion_tracker.h" #include "third_party/khronos/GLES2/gl2.h" #include "ui/gfx/rect_conversions.h" @@ -326,7 +327,7 @@ bool TiledLayer::UpdateTiles(int left, int right, int bottom, ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, + const OcclusionTracker<Layer>* occlusion, bool* updated) { CreateUpdaterIfNeeded(); @@ -358,7 +359,7 @@ void TiledLayer::MarkOcclusionsAndRequestTextures( int top, int right, int bottom, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { // There is some difficult dependancies between occlusions, recording // occlusion metrics and requesting memory so those are encapsulated in this // function: - We only want to call RequestLate on unoccluded textures (to @@ -477,7 +478,7 @@ void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect, int right, int bottom, ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { // The update_rect should be in layer space. So we have to convert the // paint_rect from content space to layer space. float width_scale = @@ -732,7 +733,7 @@ void TiledLayer::UpdateScrollPrediction() { } bool TiledLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { DCHECK(!skips_draw_ && !failed_update_); // Did ResetUpdateState get skipped? // Tiled layer always causes commits to wait for activation, as it does diff --git a/cc/layers/tiled_layer.h b/cc/layers/tiled_layer.h index 50e2b67..e272497 100644 --- a/cc/layers/tiled_layer.h +++ b/cc/layers/tiled_layer.h @@ -35,7 +35,7 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer { OVERRIDE; virtual Region VisibleContentOpaqueRegion() const OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void OnOutputSurfaceCreated() OVERRIDE; protected: @@ -85,18 +85,19 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer { bool TileOnlyNeedsPartialUpdate(UpdatableTile* tile); bool TileNeedsBufferedUpdate(UpdatableTile* tile); - void MarkOcclusionsAndRequestTextures(int left, - int top, - int right, - int bottom, - const OcclusionTracker* occlusion); + void MarkOcclusionsAndRequestTextures( + int left, + int top, + int right, + int bottom, + const OcclusionTracker<Layer>* occlusion); bool UpdateTiles(int left, int top, int right, int bottom, ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion, + const OcclusionTracker<Layer>* occlusion, bool* did_paint); bool HaveTexturesForTiles(int left, int top, @@ -117,7 +118,7 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer { int right, int bottom, ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion); + const OcclusionTracker<Layer>* occlusion); void UpdateScrollPrediction(); UpdatableTile* TileAt(int i, int j) const; diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc index 3204280..f784a52 100644 --- a/cc/layers/tiled_layer_unittest.cc +++ b/cc/layers/tiled_layer_unittest.cc @@ -22,6 +22,7 @@ #include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/tiled_layer_test_common.h" +#include "cc/trees/occlusion_tracker.h" #include "cc/trees/single_thread_proxy.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/rect_conversions.h" @@ -30,7 +31,7 @@ namespace cc { namespace { -class TestOcclusionTracker : public OcclusionTracker { +class TestOcclusionTracker : public OcclusionTracker<Layer> { public: TestOcclusionTracker() : OcclusionTracker(gfx::Rect(0, 0, 1000, 1000), true) { stack_.push_back(StackObject()); diff --git a/cc/layers/ui_resource_layer_unittest.cc b/cc/layers/ui_resource_layer_unittest.cc index 0bb02b6..c05d312 100644 --- a/cc/layers/ui_resource_layer_unittest.cc +++ b/cc/layers/ui_resource_layer_unittest.cc @@ -58,7 +58,7 @@ TEST_F(UIResourceLayerTest, SetBitmap) { EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); ResourceUpdateQueue queue; - OcclusionTracker occlusion_tracker(gfx::Rect(), false); + OcclusionTracker<Layer> occlusion_tracker(gfx::Rect(), false); test_layer->SavePaintProperties(); test_layer->Update(&queue, &occlusion_tracker); @@ -86,7 +86,7 @@ TEST_F(UIResourceLayerTest, SetUIResourceId) { EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get()); ResourceUpdateQueue queue; - OcclusionTracker occlusion_tracker(gfx::Rect(), false); + OcclusionTracker<Layer> occlusion_tracker(gfx::Rect(), false); test_layer->SavePaintProperties(); test_layer->Update(&queue, &occlusion_tracker); diff --git a/cc/layers/video_layer.cc b/cc/layers/video_layer.cc index 8d728e0..4ddfdae 100644 --- a/cc/layers/video_layer.cc +++ b/cc/layers/video_layer.cc @@ -23,7 +23,7 @@ scoped_ptr<LayerImpl> VideoLayer::CreateLayerImpl(LayerTreeImpl* tree_impl) { } bool VideoLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { bool updated = Layer::Update(queue, occlusion); // Video layer doesn't update any resources from the main thread side, diff --git a/cc/layers/video_layer.h b/cc/layers/video_layer.h index 4d14f80..dd2c4e1 100644 --- a/cc/layers/video_layer.h +++ b/cc/layers/video_layer.h @@ -25,7 +25,8 @@ class CC_EXPORT VideoLayer : public Layer { OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; + private: explicit VideoLayer(VideoFrameProvider* provider); virtual ~VideoLayer(); diff --git a/cc/test/fake_content_layer.cc b/cc/test/fake_content_layer.cc index 9eaa6f7..ebeff11 100644 --- a/cc/test/fake_content_layer.cc +++ b/cc/test/fake_content_layer.cc @@ -37,7 +37,7 @@ scoped_ptr<LayerImpl> FakeContentLayer::CreateLayerImpl( } bool FakeContentLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { bool updated = ContentLayer::Update(queue, occlusion); update_count_++; return updated || always_update_resources_; diff --git a/cc/test/fake_content_layer.h b/cc/test/fake_content_layer.h index 07cfd4c..ee6cfb4 100644 --- a/cc/test/fake_content_layer.h +++ b/cc/test/fake_content_layer.h @@ -25,9 +25,8 @@ class FakeContentLayer : public ContentLayer { size_t push_properties_count() const { return push_properties_count_; } void reset_push_properties_count() { push_properties_count_ = 0; } - virtual bool Update( - ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + virtual bool Update(ResourceUpdateQueue* queue, + const OcclusionTracker<Layer>* occlusion) OVERRIDE; gfx::Rect LastPaintRect() const; diff --git a/cc/test/fake_painted_scrollbar_layer.cc b/cc/test/fake_painted_scrollbar_layer.cc index 72ef420..b238d80 100644 --- a/cc/test/fake_painted_scrollbar_layer.cc +++ b/cc/test/fake_painted_scrollbar_layer.cc @@ -35,8 +35,9 @@ FakePaintedScrollbarLayer::FakePaintedScrollbarLayer( FakePaintedScrollbarLayer::~FakePaintedScrollbarLayer() {} -bool FakePaintedScrollbarLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { +bool FakePaintedScrollbarLayer::Update( + ResourceUpdateQueue* queue, + const OcclusionTracker<Layer>* occlusion) { bool updated = PaintedScrollbarLayer::Update(queue, occlusion); ++update_count_; return updated; diff --git a/cc/test/fake_painted_scrollbar_layer.h b/cc/test/fake_painted_scrollbar_layer.h index 9b1b13d..5e2fa18 100644 --- a/cc/test/fake_painted_scrollbar_layer.h +++ b/cc/test/fake_painted_scrollbar_layer.h @@ -21,7 +21,7 @@ class FakePaintedScrollbarLayer : public PaintedScrollbarLayer { void reset_update_count() { update_count_ = 0; } virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; diff --git a/cc/test/fake_picture_layer.cc b/cc/test/fake_picture_layer.cc index 69292c3..98e658e 100644 --- a/cc/test/fake_picture_layer.cc +++ b/cc/test/fake_picture_layer.cc @@ -26,7 +26,7 @@ scoped_ptr<LayerImpl> FakePictureLayer::CreateLayerImpl( } bool FakePictureLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) { + const OcclusionTracker<Layer>* occlusion) { bool updated = PictureLayer::Update(queue, occlusion); update_count_++; return updated || always_update_resources_; diff --git a/cc/test/fake_picture_layer.h b/cc/test/fake_picture_layer.h index 824ac6c..99217c2 100644 --- a/cc/test/fake_picture_layer.h +++ b/cc/test/fake_picture_layer.h @@ -31,7 +31,7 @@ class FakePictureLayer : public PictureLayer { } virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE; + const OcclusionTracker<Layer>* occlusion) OVERRIDE; virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index 2dbab11..8e5a43b 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -17,7 +17,6 @@ #include "cc/test/animation_test_common.h" #include "cc/test/fake_layer_tree_host_client.h" #include "cc/test/fake_output_surface.h" -#include "cc/test/occlusion_tracker_test_common.h" #include "cc/test/test_context_provider.h" #include "cc/test/tiled_layer_test_common.h" #include "cc/trees/layer_tree_host_client.h" diff --git a/cc/test/occlusion_tracker_test_common.h b/cc/test/occlusion_tracker_test_common.h deleted file mode 100644 index 5468b99..0000000 --- a/cc/test/occlusion_tracker_test_common.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_ -#define CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_ - -#include "cc/layers/render_surface.h" -#include "cc/layers/render_surface_impl.h" -#include "cc/trees/occlusion_tracker.h" - -namespace cc { - -// A subclass to expose the total current occlusion. -template <typename LayerType, typename RenderSurfaceType> -class TestOcclusionTrackerBase - : public OcclusionTrackerBase<LayerType, RenderSurfaceType> { - public: - TestOcclusionTrackerBase(const gfx::Rect& screen_scissor_rect, - bool record_metrics_for_frame) - : OcclusionTrackerBase<LayerType, RenderSurfaceType>( - screen_scissor_rect, - record_metrics_for_frame) {} - - Region occlusion_from_inside_target() const { - return OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back(). - occlusion_from_inside_target; - } - Region occlusion_from_outside_target() const { - return OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back(). - occlusion_from_outside_target; - } - - void set_occlusion_from_outside_target(const Region& region) { - OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back(). - occlusion_from_outside_target = region; - } - void set_occlusion_from_inside_target(const Region& region) { - OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back(). - occlusion_from_inside_target = region; - } -}; - -typedef TestOcclusionTrackerBase<Layer, RenderSurface> TestOcclusionTracker; -typedef TestOcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> - TestOcclusionTrackerImpl; - -} // namespace cc - -#endif // CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_ diff --git a/cc/test/test_occlusion_tracker.h b/cc/test/test_occlusion_tracker.h new file mode 100644 index 0000000..6eec732 --- /dev/null +++ b/cc/test/test_occlusion_tracker.h @@ -0,0 +1,44 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_TEST_TEST_OCCLUSION_TRACKER_H_ +#define CC_TEST_TEST_OCCLUSION_TRACKER_H_ + +#include "cc/layers/render_surface.h" +#include "cc/layers/render_surface_impl.h" +#include "cc/trees/occlusion_tracker.h" + +namespace cc { + +// A subclass to expose the total current occlusion. +template <typename LayerType> +class TestOcclusionTracker : public OcclusionTracker<LayerType> { + public: + TestOcclusionTracker(const gfx::Rect& screen_scissor_rect, + bool record_metrics_for_frame) + : OcclusionTracker<LayerType>(screen_scissor_rect, + record_metrics_for_frame) {} + + Region occlusion_from_inside_target() const { + return OcclusionTracker<LayerType>::stack_.back() + .occlusion_from_inside_target; + } + Region occlusion_from_outside_target() const { + return OcclusionTracker<LayerType>::stack_.back() + .occlusion_from_outside_target; + } + + void set_occlusion_from_outside_target(const Region& region) { + OcclusionTracker<LayerType>::stack_.back().occlusion_from_outside_target = + region; + } + void set_occlusion_from_inside_target(const Region& region) { + OcclusionTracker<LayerType>::stack_.back().occlusion_from_inside_target = + region; + } +}; + +} // namespace cc + +#endif // CC_TEST_TEST_OCCLUSION_TRACKER_H_ diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 097ad5da..2a8248e 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -989,7 +989,7 @@ void LayerTreeHost::PaintLayerContents( settings_.show_overdraw_in_tracing && base::debug::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); - OcclusionTracker occlusion_tracker( + OcclusionTracker<Layer> occlusion_tracker( root_layer_->render_surface()->content_rect(), record_metrics_for_frame); occlusion_tracker.set_minimum_tracking_size( settings_.minimum_occlusion_tracking_size); diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 1a2a65b..7dcf3e6 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -26,6 +26,7 @@ #include "cc/base/swap_promise_monitor.h" #include "cc/debug/micro_benchmark.h" #include "cc/debug/micro_benchmark_controller.h" +#include "cc/debug/overdraw_metrics.h" #include "cc/input/input_handler.h" #include "cc/input/scrollbar.h" #include "cc/input/top_controls_state.h" @@ -36,7 +37,6 @@ #include "cc/trees/layer_tree_host_client.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_settings.h" -#include "cc/trees/occlusion_tracker.h" #include "cc/trees/proxy.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/rect.h" diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 50a6c41..a7f251b 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -54,6 +54,7 @@ #include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/layer_tree_impl.h" +#include "cc/trees/occlusion_tracker.h" #include "cc/trees/quad_culler.h" #include "cc/trees/single_thread_proxy.h" #include "cc/trees/tree_synchronizer.h" @@ -560,10 +561,11 @@ static DrawMode GetDrawMode(OutputSurface* output_surface) { } } -static void AppendQuadsForLayer(RenderPass* target_render_pass, - LayerImpl* layer, - const OcclusionTrackerImpl& occlusion_tracker, - AppendQuadsData* append_quads_data) { +static void AppendQuadsForLayer( + RenderPass* target_render_pass, + LayerImpl* layer, + const OcclusionTracker<LayerImpl>& occlusion_tracker, + AppendQuadsData* append_quads_data) { bool for_surface = false; QuadCuller quad_culler(&target_render_pass->quad_list, &target_render_pass->shared_quad_state_list, @@ -578,7 +580,7 @@ static void AppendQuadsForRenderSurfaceLayer( RenderPass* target_render_pass, LayerImpl* layer, const RenderPass* contributing_render_pass, - const OcclusionTrackerImpl& occlusion_tracker, + const OcclusionTracker<LayerImpl>& occlusion_tracker, AppendQuadsData* append_quads_data) { bool for_surface = true; QuadCuller quad_culler(&target_render_pass->quad_list, @@ -611,7 +613,7 @@ static void AppendQuadsToFillScreen( RenderPass* target_render_pass, LayerImpl* root_layer, SkColor screen_background_color, - const OcclusionTrackerImpl& occlusion_tracker) { + const OcclusionTracker<LayerImpl>& occlusion_tracker) { if (!root_layer || !SkColorGetA(screen_background_color)) return; @@ -747,7 +749,7 @@ DrawSwapReadbackResult::DrawResult LayerTreeHostImpl::CalculateRenderPasses( settings_.show_overdraw_in_tracing && base::debug::TraceLog::GetInstance() && base::debug::TraceLog::GetInstance()->IsEnabled(); - OcclusionTrackerImpl occlusion_tracker( + OcclusionTracker<LayerImpl> occlusion_tracker( active_tree_->root_layer()->render_surface()->content_rect(), record_metrics_for_frame); occlusion_tracker.set_minimum_tracking_size( diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 8212993..f395398 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -40,7 +40,6 @@ #include "cc/test/fake_video_frame_provider.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_tree_test.h" -#include "cc/test/occlusion_tracker_test_common.h" #include "cc/test/test_web_graphics_context_3d.h" #include "cc/trees/layer_tree_host_impl.h" #include "cc/trees/layer_tree_impl.h" @@ -1329,7 +1328,7 @@ class ContentLayerWithUpdateTracking : public ContentLayer { void ResetPaintContentsCount() { paint_contents_count_ = 0; } virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE { + const OcclusionTracker<Layer>* occlusion) OVERRIDE { bool updated = ContentLayer::Update(queue, occlusion); paint_contents_count_++; return updated; @@ -2020,7 +2019,8 @@ class EvictionTestLayer : public Layer { return make_scoped_refptr(new EvictionTestLayer()); } - virtual bool Update(ResourceUpdateQueue*, const OcclusionTracker*) OVERRIDE; + virtual bool Update(ResourceUpdateQueue*, + const OcclusionTracker<Layer>*) OVERRIDE; virtual bool DrawsContent() const OVERRIDE { return true; } virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) @@ -2081,7 +2081,7 @@ void EvictionTestLayer::SetTexturePriorities(const PriorityCalculator&) { } bool EvictionTestLayer::Update(ResourceUpdateQueue* queue, - const OcclusionTracker*) { + const OcclusionTracker<Layer>* occlusion) { CreateTextureIfNeeded(); if (!texture_) return false; @@ -4667,7 +4667,7 @@ class LayerSetsNeedsFilterContext : public Layer { } virtual bool Update(ResourceUpdateQueue* queue, - const OcclusionTracker* occlusion) OVERRIDE { + const OcclusionTracker<Layer>* occlusion) OVERRIDE { bool updated = Layer::Update(queue, occlusion); if (needs_context_) { layer_tree_host()->set_needs_filter_context(); diff --git a/cc/trees/layer_tree_host_unittest_occlusion.cc b/cc/trees/layer_tree_host_unittest_occlusion.cc index 491b42f1..352b5cf 100644 --- a/cc/trees/layer_tree_host_unittest_occlusion.cc +++ b/cc/trees/layer_tree_host_unittest_occlusion.cc @@ -8,7 +8,7 @@ #include "cc/output/copy_output_request.h" #include "cc/output/copy_output_result.h" #include "cc/test/layer_tree_test.h" -#include "cc/test/occlusion_tracker_test_common.h" +#include "cc/test/test_occlusion_tracker.h" namespace cc { namespace { @@ -19,15 +19,14 @@ class TestLayer : public Layer { return make_scoped_refptr(new TestLayer()); } - virtual bool Update( - ResourceUpdateQueue* update_queue, - const OcclusionTracker* occlusion) OVERRIDE { + virtual bool Update(ResourceUpdateQueue* update_queue, + const OcclusionTracker<Layer>* occlusion) OVERRIDE { if (!occlusion) return false; // Gain access to internals of the OcclusionTracker. - const TestOcclusionTracker* test_occlusion = - static_cast<const TestOcclusionTracker*>(occlusion); + const TestOcclusionTracker<Layer>* test_occlusion = + static_cast<const TestOcclusionTracker<Layer>*>(occlusion); occlusion_ = UnionRegions( test_occlusion->occlusion_from_inside_target(), test_occlusion->occlusion_from_outside_target()); diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 8fe1f88..1142a6e 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -12,6 +12,7 @@ #include "cc/debug/traced_value.h" #include "cc/layers/heads_up_display_layer_impl.h" #include "cc/layers/layer.h" +#include "cc/layers/layer_iterator.h" #include "cc/layers/render_surface_impl.h" #include "cc/layers/scrollbar_layer_impl_base.h" #include "cc/resources/ui_resource_request.h" diff --git a/cc/trees/occlusion_tracker.cc b/cc/trees/occlusion_tracker.cc index 11982a8..6d6f320 100644 --- a/cc/trees/occlusion_tracker.cc +++ b/cc/trees/occlusion_tracker.cc @@ -17,19 +17,20 @@ namespace cc { -template <typename LayerType, typename RenderSurfaceType> -OcclusionTrackerBase<LayerType, RenderSurfaceType>::OcclusionTrackerBase( - const gfx::Rect& screen_space_clip_rect, bool record_metrics_for_frame) +template <typename LayerType> +OcclusionTracker<LayerType>::OcclusionTracker( + const gfx::Rect& screen_space_clip_rect, + bool record_metrics_for_frame) : screen_space_clip_rect_(screen_space_clip_rect), overdraw_metrics_(OverdrawMetrics::Create(record_metrics_for_frame)), occluding_screen_space_rects_(NULL), non_occluding_screen_space_rects_(NULL) {} -template <typename LayerType, typename RenderSurfaceType> -OcclusionTrackerBase<LayerType, RenderSurfaceType>::~OcclusionTrackerBase() {} +template <typename LayerType> +OcclusionTracker<LayerType>::~OcclusionTracker() {} -template <typename LayerType, typename RenderSurfaceType> -void OcclusionTrackerBase<LayerType, RenderSurfaceType>::EnterLayer( +template <typename LayerType> +void OcclusionTracker<LayerType>::EnterLayer( const LayerIteratorPosition<LayerType>& layer_iterator) { LayerType* render_target = layer_iterator.target_render_surface_layer; @@ -39,8 +40,8 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::EnterLayer( FinishedRenderTarget(render_target); } -template <typename LayerType, typename RenderSurfaceType> -void OcclusionTrackerBase<LayerType, RenderSurfaceType>::LeaveLayer( +template <typename LayerType> +void OcclusionTracker<LayerType>::LeaveLayer( const LayerIteratorPosition<LayerType>& layer_iterator) { LayerType* render_target = layer_iterator.target_render_surface_layer; @@ -145,20 +146,21 @@ static inline bool LayerIsHidden(const LayerType* layer) { (layer->parent() && LayerIsHidden(layer->parent())); } -template <typename LayerType, typename RenderSurfaceType> -void OcclusionTrackerBase<LayerType, RenderSurfaceType>::EnterRenderTarget( +template <typename LayerType> +void OcclusionTracker<LayerType>::EnterRenderTarget( const LayerType* new_target) { if (!stack_.empty() && stack_.back().target == new_target) return; const LayerType* old_target = NULL; - const RenderSurfaceType* old_occlusion_immune_ancestor = NULL; + const typename LayerType::RenderSurfaceType* old_occlusion_immune_ancestor = + NULL; if (!stack_.empty()) { old_target = stack_.back().target; old_occlusion_immune_ancestor = old_target->render_surface()->nearest_occlusion_immune_ancestor(); } - const RenderSurfaceType* new_occlusion_immune_ancestor = + const typename LayerType::RenderSurfaceType* new_occlusion_immune_ancestor = new_target->render_surface()->nearest_occlusion_immune_ancestor(); stack_.push_back(StackObject(new_target)); @@ -198,26 +200,27 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::EnterRenderTarget( inverse_new_target_screen_space_transform, old_target->render_surface()->screen_space_transform()); stack_[last_index].occlusion_from_outside_target = - TransformSurfaceOpaqueRegion<RenderSurfaceType>( + TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( stack_[last_index - 1].occlusion_from_outside_target, false, gfx::Rect(), old_target_to_new_target_transform); stack_[last_index].occlusion_from_outside_target.Union( - TransformSurfaceOpaqueRegion<RenderSurfaceType>( + TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( stack_[last_index - 1].occlusion_from_inside_target, false, gfx::Rect(), old_target_to_new_target_transform)); } -template <typename LayerType, typename RenderSurfaceType> -void OcclusionTrackerBase<LayerType, RenderSurfaceType>::FinishedRenderTarget( +template <typename LayerType> +void OcclusionTracker<LayerType>::FinishedRenderTarget( const LayerType* finished_target) { // Make sure we know about the target surface. EnterRenderTarget(finished_target); - RenderSurfaceType* surface = finished_target->render_surface(); + typename LayerType::RenderSurfaceType* surface = + finished_target->render_surface(); // Readbacks always happen on render targets so we only need to check // for readbacks here. @@ -294,8 +297,8 @@ static void ReduceOcclusionBelowSurface(LayerType* contributing_layer, } } -template <typename LayerType, typename RenderSurfaceType> -void OcclusionTrackerBase<LayerType, RenderSurfaceType>::LeaveToRenderTarget( +template <typename LayerType> +void OcclusionTracker<LayerType>::LeaveToRenderTarget( const LayerType* new_target) { int last_index = stack_.size() - 1; bool surface_will_be_at_top_after_pop = @@ -306,17 +309,18 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::LeaveToRenderTarget( // merged out as well but needs to be transformed to the new target. const LayerType* old_target = stack_[last_index].target; - const RenderSurfaceType* old_surface = old_target->render_surface(); + const typename LayerType::RenderSurfaceType* old_surface = + old_target->render_surface(); Region old_occlusion_from_inside_target_in_new_target = - TransformSurfaceOpaqueRegion<RenderSurfaceType>( + TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( stack_[last_index].occlusion_from_inside_target, old_surface->is_clipped(), old_surface->clip_rect(), old_surface->draw_transform()); if (old_target->has_replica() && !old_target->replica_has_mask()) { old_occlusion_from_inside_target_in_new_target.Union( - TransformSurfaceOpaqueRegion<RenderSurfaceType>( + TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( stack_[last_index].occlusion_from_inside_target, old_surface->is_clipped(), old_surface->clip_rect(), @@ -324,7 +328,7 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::LeaveToRenderTarget( } Region old_occlusion_from_outside_target_in_new_target = - TransformSurfaceOpaqueRegion<RenderSurfaceType>( + TransformSurfaceOpaqueRegion<typename LayerType::RenderSurfaceType>( stack_[last_index].occlusion_from_outside_target, false, gfx::Rect(), @@ -393,9 +397,9 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>::LeaveToRenderTarget( &stack_.back().occlusion_from_outside_target); } -template <typename LayerType, typename RenderSurfaceType> -void OcclusionTrackerBase<LayerType, RenderSurfaceType>:: - MarkOccludedBehindLayer(const LayerType* layer) { +template <typename LayerType> +void OcclusionTracker<LayerType>::MarkOccludedBehindLayer( + const LayerType* layer) { DCHECK(!stack_.empty()); DCHECK_EQ(layer->render_target(), stack_.back().target); if (stack_.empty()) @@ -496,8 +500,8 @@ void OcclusionTrackerBase<LayerType, RenderSurfaceType>:: } } -template <typename LayerType, typename RenderSurfaceType> -bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::Occluded( +template <typename LayerType> +bool OcclusionTracker<LayerType>::Occluded( const LayerType* render_target, const gfx::Rect& content_rect, const gfx::Transform& draw_transform, @@ -544,13 +548,12 @@ bool OcclusionTrackerBase<LayerType, RenderSurfaceType>::Occluded( return unoccluded_rect_in_target_surface.IsEmpty(); } -template <typename LayerType, typename RenderSurfaceType> -gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>:: - UnoccludedContentRect( - const LayerType* render_target, - const gfx::Rect& content_rect, - const gfx::Transform& draw_transform, - bool impl_draw_transform_is_unknown) const { +template <typename LayerType> +gfx::Rect OcclusionTracker<LayerType>::UnoccludedContentRect( + const LayerType* render_target, + const gfx::Rect& content_rect, + const gfx::Transform& draw_transform, + bool impl_draw_transform_is_unknown) const { DCHECK(!stack_.empty()); if (stack_.empty()) return content_rect; @@ -594,12 +597,11 @@ gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>:: return unoccluded_rect; } -template <typename LayerType, typename RenderSurfaceType> -gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>:: - UnoccludedContributingSurfaceContentRect( - const LayerType* layer, - bool for_replica, - const gfx::Rect& content_rect) const { +template <typename LayerType> +gfx::Rect OcclusionTracker<LayerType>::UnoccludedContributingSurfaceContentRect( + const LayerType* layer, + bool for_replica, + const gfx::Rect& content_rect) const { DCHECK(!stack_.empty()); // The layer is a contributing render_target so it should have a surface. DCHECK(layer->render_surface()); @@ -614,7 +616,8 @@ gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>:: if (content_rect.IsEmpty()) return content_rect; - const RenderSurfaceType* surface = layer->render_surface(); + const typename LayerType::RenderSurfaceType* surface = + layer->render_surface(); const LayerType* contributing_surface_render_target = layer->parent()->render_target(); @@ -666,7 +669,7 @@ gfx::Rect OcclusionTrackerBase<LayerType, RenderSurfaceType>:: } // Instantiate (and export) templates here for the linker. -template class OcclusionTrackerBase<Layer, RenderSurface>; -template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; +template class OcclusionTracker<Layer>; +template class OcclusionTracker<LayerImpl>; } // namespace cc diff --git a/cc/trees/occlusion_tracker.h b/cc/trees/occlusion_tracker.h index 2fe54d0..39cd026 100644 --- a/cc/trees/occlusion_tracker.h +++ b/cc/trees/occlusion_tracker.h @@ -29,12 +29,12 @@ class RenderSurface; // be queried via surfaceOccluded() and surfaceUnoccludedContentRect(). Finally, // once finished with the layer, occlusion behind the layer should be marked by // calling MarkOccludedBehindLayer(). -template <typename LayerType, typename RenderSurfaceType> -class CC_EXPORT OcclusionTrackerBase { +template <typename LayerType> +class CC_EXPORT OcclusionTracker { public: - OcclusionTrackerBase(const gfx::Rect& screen_space_clip_rect, - bool record_metrics_for_frame); - ~OcclusionTrackerBase(); + OcclusionTracker(const gfx::Rect& screen_space_clip_rect, + bool record_metrics_for_frame); + ~OcclusionTracker(); // Called at the beginning of each step in the LayerIterator's front-to-back // traversal. @@ -149,14 +149,12 @@ class CC_EXPORT OcclusionTrackerBase { std::vector<gfx::Rect>* occluding_screen_space_rects_; std::vector<gfx::Rect>* non_occluding_screen_space_rects_; - DISALLOW_COPY_AND_ASSIGN(OcclusionTrackerBase); + DISALLOW_COPY_AND_ASSIGN(OcclusionTracker); }; -typedef OcclusionTrackerBase<Layer, RenderSurface> OcclusionTracker; -typedef OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> OcclusionTrackerImpl; #if !defined(COMPILER_MSVC) -extern template class OcclusionTrackerBase<Layer, RenderSurface>; -extern template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; +extern template class OcclusionTracker<Layer>; +extern template class OcclusionTracker<LayerImpl>; #endif } // namespace cc diff --git a/cc/trees/occlusion_tracker_perftest.cc b/cc/trees/occlusion_tracker_perftest.cc index f4a2faf..344e48c 100644 --- a/cc/trees/occlusion_tracker_perftest.cc +++ b/cc/trees/occlusion_tracker_perftest.cc @@ -71,8 +71,7 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_FullyOccluded) { SetTestName("unoccluded_content_rect_fully_occluded"); gfx::Rect viewport_rect(768, 1038); - OcclusionTrackerBase<LayerImpl, LayerImpl::RenderSurfaceType> tracker( - viewport_rect, false); + OcclusionTracker<LayerImpl> tracker(viewport_rect, false); CreateHost(); host_impl_->SetViewportSize(viewport_rect.size()); @@ -140,8 +139,7 @@ TEST_F(OcclusionTrackerPerfTest, UnoccludedContentRect_10OpaqueLayers) { SetTestName("unoccluded_content_rect_10_opaque_layers"); gfx::Rect viewport_rect(768, 1038); - OcclusionTrackerBase<LayerImpl, LayerImpl::RenderSurfaceType> tracker( - viewport_rect, false); + OcclusionTracker<LayerImpl> tracker(viewport_rect, false); CreateHost(); host_impl_->SetViewportSize(viewport_rect.size()); diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc index 3e4ff5b..b61ed70 100644 --- a/cc/trees/occlusion_tracker_unittest.cc +++ b/cc/trees/occlusion_tracker_unittest.cc @@ -18,7 +18,7 @@ #include "cc/test/fake_layer_tree_host.h" #include "cc/test/fake_layer_tree_host_impl.h" #include "cc/test/geometry_test_utils.h" -#include "cc/test/occlusion_tracker_test_common.h" +#include "cc/test/test_occlusion_tracker.h" #include "cc/trees/layer_tree_host_common.h" #include "cc/trees/single_thread_proxy.h" #include "testing/gmock/include/gmock/gmock.h" @@ -80,18 +80,15 @@ static inline bool LayerImplDrawTransformIsUnknown(const LayerImpl* layer) { return false; } -template <typename LayerType, typename RenderSurfaceType> -class TestOcclusionTrackerWithClip - : public TestOcclusionTrackerBase<LayerType, RenderSurfaceType> { +template <typename LayerType> +class TestOcclusionTrackerWithClip : public TestOcclusionTracker<LayerType> { public: TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect, bool record_metrics_for_frame) - : TestOcclusionTrackerBase<LayerType, RenderSurfaceType>( - viewport_rect, - record_metrics_for_frame) {} + : TestOcclusionTracker<LayerType>(viewport_rect, + record_metrics_for_frame) {} explicit TestOcclusionTrackerWithClip(const gfx::Rect& viewport_rect) - : TestOcclusionTrackerBase<LayerType, RenderSurfaceType>(viewport_rect, - false) {} + : TestOcclusionTracker<LayerType>(viewport_rect, false) {} bool OccludedLayer(const LayerType* layer, const gfx::Rect& content_rect) const { @@ -123,7 +120,7 @@ struct OcclusionTrackerTestMainThreadTypes { typedef scoped_refptr<Layer> LayerPtrType; typedef scoped_refptr<ContentLayerType> ContentLayerPtrType; typedef LayerIterator<Layer> TestLayerIterator; - typedef OcclusionTracker OcclusionTrackerType; + typedef OcclusionTracker<Layer> OcclusionTrackerType; static LayerPtrType CreateLayer(HostType* host) { return Layer::Create(); } static ContentLayerPtrType CreateContentLayer(HostType* host) { @@ -153,7 +150,7 @@ struct OcclusionTrackerTestImplThreadTypes { typedef scoped_ptr<LayerImpl> LayerPtrType; typedef scoped_ptr<ContentLayerType> ContentLayerPtrType; typedef LayerIterator<LayerImpl> TestLayerIterator; - typedef OcclusionTrackerImpl OcclusionTrackerType; + typedef OcclusionTracker<LayerImpl> OcclusionTrackerType; static LayerPtrType CreateLayer(HostType* host) { return LayerImpl::Create(host, next_layer_impl_id++); @@ -545,8 +542,7 @@ class OcclusionTrackerTestIdentityTransforms parent->SetMasksToBounds(true); this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000), false); this->VisitLayer(layer, &occlusion); @@ -612,8 +608,7 @@ class OcclusionTrackerTestQuadsMismatchLayer layer1, layer_transform, gfx::PointF(), gfx::Size(50, 50), true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(layer2, &occlusion); @@ -679,8 +674,7 @@ class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> { parent->SetMasksToBounds(true); this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(layer, &occlusion); @@ -750,8 +744,7 @@ class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> { parent->SetMasksToBounds(true); this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(layer, &occlusion); @@ -822,8 +815,7 @@ class OcclusionTrackerTestChildInRotatedChild true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(layer, &occlusion); @@ -929,8 +921,7 @@ class OcclusionTrackerTestScaledRenderSurface true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(occluder, &occlusion); @@ -994,8 +985,7 @@ class OcclusionTrackerTestVisitTargetTwoTimes true); this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(child2, &occlusion); @@ -1161,8 +1151,7 @@ class OcclusionTrackerTestSurfaceRotatedOffAxis child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true); this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); gfx::Rect clipped_layer_in_child = MathUtil::MapEnclosingClippedRect( @@ -1231,8 +1220,7 @@ class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren true); this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(layer2, &occlusion); @@ -1351,8 +1339,7 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(layer2, &occlusion); @@ -1472,8 +1459,7 @@ class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(layer2, &occlusion); @@ -1596,8 +1582,7 @@ class OcclusionTrackerTestFilters : public OcclusionTrackerTest<Types> { this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // Opacity layer won't contribute to occlusion. @@ -1668,8 +1653,7 @@ class OcclusionTrackerTestReplicaDoesOcclude surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(surface, &occlusion); @@ -1710,8 +1694,7 @@ class OcclusionTrackerTestReplicaWithClipping surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(surface, &occlusion); @@ -1751,8 +1734,7 @@ class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> { this->CreateMaskLayer(replica, gfx::Size(10, 10)); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(surface, &occlusion); @@ -1789,8 +1771,7 @@ class OcclusionTrackerTestOpaqueContentsRegionEmpty false); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->EnterLayer(layer, &occlusion); @@ -1826,8 +1807,7 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty false); this->CalcDrawEtc(parent); { - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); @@ -1846,8 +1826,7 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); } { - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); @@ -1866,8 +1845,7 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); } { - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); @@ -1911,8 +1889,7 @@ class OcclusionTrackerTest3dTransform : public OcclusionTrackerTest<Types> { true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->EnterLayer(layer, &occlusion); @@ -1962,8 +1939,7 @@ class OcclusionTrackerTestUnsorted3dLayers this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(child2, &occlusion); EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); @@ -2009,8 +1985,7 @@ class OcclusionTrackerTestPerspectiveTransform this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->EnterLayer(layer, &occlusion); @@ -2054,8 +2029,7 @@ class OcclusionTrackerTestPerspectiveTransformBehindCamera layer->SetIs3dSorted(true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->EnterLayer(layer, &occlusion); @@ -2098,8 +2072,7 @@ class OcclusionTrackerTestLayerBehindCameraDoesNotOcclude layer->SetIs3dSorted(true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // The |layer| is entirely behind the camera and should not occlude. @@ -2140,8 +2113,7 @@ class OcclusionTrackerTestLargePixelsOccludeInsideClipRect layer->SetIs3dSorted(true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // This is very close to the camera, so pixels in its visible_content_rect() @@ -2225,8 +2197,7 @@ class OcclusionTrackerTestAnimationOpacity1OnMainThread EXPECT_FALSE(surface->draw_opacity_is_animating()); EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(topmost, &occlusion); @@ -2346,8 +2317,7 @@ class OcclusionTrackerTestAnimationOpacity0OnMainThread EXPECT_FALSE(surface->draw_opacity_is_animating()); EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(topmost, &occlusion); @@ -2468,8 +2438,7 @@ class OcclusionTrackerTestAnimationTranslateOnMainThread EXPECT_TRUE(surface_child->draw_transform_is_animating()); EXPECT_TRUE(surface_child->screen_space_transform_is_animating()); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(surface2, &occlusion); @@ -2590,8 +2559,7 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent surface2->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(surface2, &occlusion); @@ -2639,8 +2607,7 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 400, 200)); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(surface, &occlusion); @@ -2682,8 +2649,7 @@ class OcclusionTrackerTestReplicaOccluded : public OcclusionTrackerTest<Types> { true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // |topmost| occludes the replica, but not the surface itself. @@ -2740,8 +2706,7 @@ class OcclusionTrackerTestSurfaceWithReplicaUnoccluded true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // |topmost| occludes the surface, but not the entire surface's replica. @@ -2804,8 +2769,7 @@ class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // These occlude the surface and replica differently, so we can test each @@ -2870,8 +2834,7 @@ class OcclusionTrackerTestSurfaceChildOfSurface parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(-100, -100, 1000, 1000)); // |topmost| occludes everything partially so we know occlusion is happening @@ -2948,8 +2911,7 @@ class OcclusionTrackerTestTopmostSurfaceIsClippedToViewport this->CalcDrawEtc(parent); { // Make a viewport rect that is larger than the root layer. - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(surface, &occlusion); @@ -2966,8 +2928,7 @@ class OcclusionTrackerTestTopmostSurfaceIsClippedToViewport this->ResetLayerIterator(); { // Make a viewport rect that is smaller than the root layer. - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 100, 100)); this->VisitLayer(surface, &occlusion); @@ -3016,8 +2977,7 @@ class OcclusionTrackerTestSurfaceChildOfClippingSurface parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // |topmost| occludes everything partially so we know occlusion is happening @@ -3120,8 +3080,7 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // These layers occlude pixels directly beside the filtered_surface. Because @@ -3264,8 +3223,7 @@ class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(occluding_layer_above, &occlusion); @@ -3345,8 +3303,7 @@ class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); // The surface has a background blur, so it blurs non-opaque pixels below @@ -3413,8 +3370,7 @@ class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(occluding_layer, &occlusion); @@ -3515,8 +3471,7 @@ class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(beside_replica_layer, &occlusion); @@ -3589,8 +3544,7 @@ class OcclusionTrackerTestMinimumTrackingSize true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); occlusion.set_minimum_tracking_size(tracking_size); @@ -3637,8 +3591,7 @@ class OcclusionTrackerTestScaledLayerIsClipped scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(scaled, &occlusion); @@ -3677,8 +3630,7 @@ class OcclusionTrackerTestScaledLayerInSurfaceIsClipped scale, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500), true); this->CalcDrawEtc(parent); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(scaled, &occlusion); @@ -3718,8 +3670,7 @@ class OcclusionTrackerTestCopyRequestDoesOcclude true); this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(copy_child, &occlusion); @@ -3767,8 +3718,7 @@ class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000)); this->VisitLayer(copy_child, &occlusion); @@ -3807,8 +3757,7 @@ class OcclusionTrackerTestEmptyEventLayerDoesNotOcclude this->CalcDrawEtc(root); - TestOcclusionTrackerWithClip<typename Types::LayerType, - typename Types::RenderSurfaceType> occlusion( + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( gfx::Rect(0, 0, 1000, 1000), false); this->VisitLayer(empty_layer, &occlusion); diff --git a/cc/trees/quad_culler.cc b/cc/trees/quad_culler.cc index 1b6404c..9ff2dcc 100644 --- a/cc/trees/quad_culler.cc +++ b/cc/trees/quad_culler.cc @@ -19,7 +19,7 @@ namespace cc { QuadCuller::QuadCuller(QuadList* quad_list, SharedQuadStateList* shared_quad_state_list, const LayerImpl* layer, - const OcclusionTrackerImpl& occlusion_tracker, + const OcclusionTracker<LayerImpl>& occlusion_tracker, bool show_culling_with_debug_border_quads, bool for_surface) : quad_list_(quad_list), @@ -44,7 +44,7 @@ static inline bool AppendQuadInternal( scoped_ptr<DrawQuad> draw_quad, const gfx::Rect& culled_rect, QuadList* quad_list, - const OcclusionTrackerImpl& occlusion_tracker, + const OcclusionTracker<LayerImpl>& occlusion_tracker, const LayerImpl* layer, bool create_debug_border_quads) { bool keep_quad = !culled_rect.IsEmpty(); diff --git a/cc/trees/quad_culler.h b/cc/trees/quad_culler.h index be0095f..3d71543 100644 --- a/cc/trees/quad_culler.h +++ b/cc/trees/quad_culler.h @@ -12,15 +12,15 @@ namespace cc { class LayerImpl; class RenderSurfaceImpl; -template <typename LayerType, typename SurfaceType> class OcclusionTrackerBase; +template <typename LayerType> +class OcclusionTracker; class CC_EXPORT QuadCuller : public QuadSink { public: QuadCuller(QuadList* quad_list, SharedQuadStateList* shared_quad_state_list, const LayerImpl* layer, - const OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>& - occlusion_tracker, + const OcclusionTracker<LayerImpl>& occlusion_tracker, bool show_culling_with_debug_border_quads, bool for_surface); virtual ~QuadCuller() {} @@ -35,7 +35,7 @@ class CC_EXPORT QuadCuller : public QuadSink { QuadList* quad_list_; SharedQuadStateList* shared_quad_state_list_; const LayerImpl* layer_; - const OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>& occlusion_tracker_; + const OcclusionTracker<LayerImpl>& occlusion_tracker_; SharedQuadState* current_shared_quad_state_; bool show_culling_with_debug_border_quads_; diff --git a/cc/trees/quad_culler_unittest.cc b/cc/trees/quad_culler_unittest.cc index ee97319..27e3de5 100644 --- a/cc/trees/quad_culler_unittest.cc +++ b/cc/trees/quad_culler_unittest.cc @@ -17,7 +17,7 @@ #include "cc/resources/layer_tiling_data.h" #include "cc/test/fake_impl_proxy.h" #include "cc/test/fake_layer_tree_host_impl.h" -#include "cc/test/occlusion_tracker_test_common.h" +#include "cc/test/test_occlusion_tracker.h" #include "cc/trees/occlusion_tracker.h" #include "cc/trees/single_thread_proxy.h" #include "testing/gmock/include/gmock/gmock.h" @@ -27,18 +27,6 @@ namespace cc { namespace { -class TestOcclusionTrackerImpl - : public TestOcclusionTrackerBase<LayerImpl, RenderSurfaceImpl> { - public: - TestOcclusionTrackerImpl(const gfx::Rect& scissor_rect_in_screen, - bool record_metrics_for_frame = true) - : TestOcclusionTrackerBase(scissor_rect_in_screen, - record_metrics_for_frame) {} - - private: - DISALLOW_COPY_AND_ASSIGN(TestOcclusionTrackerImpl); -}; - typedef LayerIterator<LayerImpl> LayerIteratorType; class QuadCullerTest : public testing::Test { @@ -104,7 +92,7 @@ class QuadCullerTest : public testing::Test { SharedQuadStateList* shared_state_list, TiledLayerImpl* layer, LayerIteratorType* it, - OcclusionTrackerImpl* occlusion_tracker) { + OcclusionTracker<LayerImpl>* occlusion_tracker) { occlusion_tracker->EnterLayer(*it); QuadCuller quad_culler( quad_list, shared_state_list, layer, *occlusion_tracker, false, false); @@ -150,7 +138,9 @@ TEST_F(QuadCullerTest, NoCulling) { false, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -190,7 +180,9 @@ TEST_F(QuadCullerTest, CullChildLinesUpTopLeft) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -230,7 +222,9 @@ TEST_F(QuadCullerTest, CullWhenChildOpacityNotOne) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -270,7 +264,9 @@ TEST_F(QuadCullerTest, CullWhenChildOpaqueFlagFalse) { false, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -311,7 +307,9 @@ TEST_F(QuadCullerTest, CullCenterTileOnly) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -377,7 +375,9 @@ TEST_F(QuadCullerTest, CullCenterTileNonIntegralSize1) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -428,7 +428,9 @@ TEST_F(QuadCullerTest, CullCenterTileNonIntegralSize2) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -469,7 +471,9 @@ TEST_F(QuadCullerTest, CullChildLinesUpBottomRight) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -514,7 +518,9 @@ TEST_F(QuadCullerTest, CullSubRegion) { false, child_opaque_rect, render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -560,7 +566,9 @@ TEST_F(QuadCullerTest, CullSubRegion2) { false, child_opaque_rect, render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -606,7 +614,9 @@ TEST_F(QuadCullerTest, CullSubRegionCheckOvercull) { false, child_opaque_rect, render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -650,7 +660,9 @@ TEST_F(QuadCullerTest, NonAxisAlignedQuadsDontOcclude) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -699,7 +711,9 @@ TEST_F(QuadCullerTest, NonAxisAlignedQuadsSafelyCulled) { true, gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -739,8 +753,8 @@ TEST_F(QuadCullerTest, WithoutMetrics) { gfx::Rect(), render_surface_layer_list); bool record_metrics = false; - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(-100, -100, 1000, 1000), - record_metrics); + TestOcclusionTracker<LayerImpl> occlusion_tracker( + gfx::Rect(-100, -100, 1000, 1000), record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); AppendQuads(&quad_list, @@ -773,7 +787,9 @@ TEST_F(QuadCullerTest, PartialCullingNotDestroyed) { gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker(gfx::Rect(1000, 1000), + record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); QuadCuller culler(&quad_list, @@ -847,7 +863,9 @@ TEST_F(QuadCullerTest, PartialCullingWithOcclusionNotDestroyed) { gfx::Rect(), render_surface_layer_list); - TestOcclusionTrackerImpl occlusion_tracker(gfx::Rect(1000, 1000)); + bool record_metrics = true; + TestOcclusionTracker<LayerImpl> occlusion_tracker(gfx::Rect(1000, 1000), + record_metrics); LayerIteratorType it = LayerIteratorType::Begin(&render_surface_layer_list); QuadCuller culler(&quad_list, |