| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } | 1105 void SetTestLayer(Layer* test_layer) { test_layer_ = test_layer; } |
| 1106 | 1106 |
| 1107 void PaintContents( | 1107 void PaintContents( |
| 1108 SkCanvas* canvas, | 1108 SkCanvas* canvas, |
| 1109 const gfx::Rect& clip, | 1109 const gfx::Rect& clip, |
| 1110 ContentLayerClient::GraphicsContextStatus gc_status) override { | 1110 ContentLayerClient::GraphicsContextStatus gc_status) override { |
| 1111 // Set layer opacity to 0. | 1111 // Set layer opacity to 0. |
| 1112 if (test_layer_) | 1112 if (test_layer_) |
| 1113 test_layer_->SetOpacity(0.f); | 1113 test_layer_->SetOpacity(0.f); |
| 1114 } | 1114 } |
| 1115 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 1116 const gfx::Rect& clip, |
| 1117 GraphicsContextStatus gc_status) override { |
| 1118 NOTIMPLEMENTED(); |
| 1119 return DisplayItemList::Create(); |
| 1120 } |
| 1115 bool FillsBoundsCompletely() const override { return false; } | 1121 bool FillsBoundsCompletely() const override { return false; } |
| 1116 | 1122 |
| 1117 private: | 1123 private: |
| 1118 Layer* test_layer_; | 1124 Layer* test_layer_; |
| 1119 }; | 1125 }; |
| 1120 | 1126 |
| 1121 class ContentLayerWithUpdateTracking : public ContentLayer { | 1127 class ContentLayerWithUpdateTracking : public ContentLayer { |
| 1122 public: | 1128 public: |
| 1123 static scoped_refptr<ContentLayerWithUpdateTracking> Create( | 1129 static scoped_refptr<ContentLayerWithUpdateTracking> Create( |
| 1124 ContentLayerClient* client) { | 1130 ContentLayerClient* client) { |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2314 int paint_count() const { return paint_count_; } | 2320 int paint_count() const { return paint_count_; } |
| 2315 | 2321 |
| 2316 void PaintContents( | 2322 void PaintContents( |
| 2317 SkCanvas* canvas, | 2323 SkCanvas* canvas, |
| 2318 const gfx::Rect& clip, | 2324 const gfx::Rect& clip, |
| 2319 ContentLayerClient::GraphicsContextStatus gc_status) override { | 2325 ContentLayerClient::GraphicsContextStatus gc_status) override { |
| 2320 FakeContentLayerClient::PaintContents(canvas, clip, gc_status); | 2326 FakeContentLayerClient::PaintContents(canvas, clip, gc_status); |
| 2321 ++paint_count_; | 2327 ++paint_count_; |
| 2322 } | 2328 } |
| 2323 | 2329 |
| 2330 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 2331 const gfx::Rect& clip, |
| 2332 GraphicsContextStatus gc_status) override { |
| 2333 NOTIMPLEMENTED(); |
| 2334 return DisplayItemList::Create(); |
| 2335 } |
| 2336 |
| 2324 bool FillsBoundsCompletely() const override { return false; } | 2337 bool FillsBoundsCompletely() const override { return false; } |
| 2325 | 2338 |
| 2326 private: | 2339 private: |
| 2327 int paint_count_; | 2340 int paint_count_; |
| 2328 }; | 2341 }; |
| 2329 | 2342 |
| 2330 void SetupTree() override { | 2343 void SetupTree() override { |
| 2331 num_tiles_rastered_ = 0; | 2344 num_tiles_rastered_ = 0; |
| 2332 | 2345 |
| 2333 scoped_refptr<Layer> root_layer; | 2346 scoped_refptr<Layer> root_layer; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2584 | 2597 |
| 2585 void set_layer(Layer* layer) { layer_ = layer; } | 2598 void set_layer(Layer* layer) { layer_ = layer; } |
| 2586 | 2599 |
| 2587 void PaintContents( | 2600 void PaintContents( |
| 2588 SkCanvas* canvas, | 2601 SkCanvas* canvas, |
| 2589 const gfx::Rect& clip, | 2602 const gfx::Rect& clip, |
| 2590 ContentLayerClient::GraphicsContextStatus gc_status) override { | 2603 ContentLayerClient::GraphicsContextStatus gc_status) override { |
| 2591 layer_->SetBounds(gfx::Size(2, 2)); | 2604 layer_->SetBounds(gfx::Size(2, 2)); |
| 2592 } | 2605 } |
| 2593 | 2606 |
| 2607 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 2608 const gfx::Rect& clip, |
| 2609 GraphicsContextStatus gc_status) override { |
| 2610 NOTIMPLEMENTED(); |
| 2611 return DisplayItemList::Create(); |
| 2612 } |
| 2613 |
| 2594 bool FillsBoundsCompletely() const override { return false; } | 2614 bool FillsBoundsCompletely() const override { return false; } |
| 2595 | 2615 |
| 2596 private: | 2616 private: |
| 2597 Layer* layer_; | 2617 Layer* layer_; |
| 2598 }; | 2618 }; |
| 2599 | 2619 |
| 2600 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} | 2620 LayerTreeHostTestChangeLayerPropertiesInPaintContents() : num_commits_(0) {} |
| 2601 | 2621 |
| 2602 void SetupTree() override { | 2622 void SetupTree() override { |
| 2603 if (layer_tree_host()->settings().impl_side_painting) { | 2623 if (layer_tree_host()->settings().impl_side_painting) { |
| (...skipping 3042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5646 void InitializeSettings(LayerTreeSettings* settings) override { | 5666 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5647 settings->use_one_copy = true; | 5667 settings->use_one_copy = true; |
| 5648 } | 5668 } |
| 5649 | 5669 |
| 5650 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( | 5670 scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface( |
| 5651 bool fallback) override { | 5671 bool fallback) override { |
| 5652 scoped_ptr<TestWebGraphicsContext3D> context3d = | 5672 scoped_ptr<TestWebGraphicsContext3D> context3d = |
| 5653 TestWebGraphicsContext3D::Create(); | 5673 TestWebGraphicsContext3D::Create(); |
| 5654 context3d->set_support_image(true); | 5674 context3d->set_support_image(true); |
| 5655 context3d->set_support_sync_query(true); | 5675 context3d->set_support_sync_query(true); |
| 5676 #if defined(OS_MACOSX) |
| 5677 context3d->set_support_texture_rectangle(true); |
| 5678 #endif |
| 5656 | 5679 |
| 5657 if (delegating_renderer()) | 5680 if (delegating_renderer()) |
| 5658 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); | 5681 return FakeOutputSurface::CreateDelegating3d(context3d.Pass()); |
| 5659 else | 5682 else |
| 5660 return FakeOutputSurface::Create3d(context3d.Pass()); | 5683 return FakeOutputSurface::Create3d(context3d.Pass()); |
| 5661 } | 5684 } |
| 5662 }; | 5685 }; |
| 5663 | 5686 |
| 5664 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); | 5687 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy); |
| 5665 | 5688 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5833 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } | 5856 void AfterTest() override { EXPECT_GT(continuous_draws_, 5); } |
| 5834 | 5857 |
| 5835 FakeContentLayerClient client_; | 5858 FakeContentLayerClient client_; |
| 5836 int step_; | 5859 int step_; |
| 5837 int continuous_draws_; | 5860 int continuous_draws_; |
| 5838 base::WaitableEvent playback_allowed_event_; | 5861 base::WaitableEvent playback_allowed_event_; |
| 5839 }; | 5862 }; |
| 5840 | 5863 |
| 5841 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); | 5864 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
| 5842 | 5865 |
| 5866 class LayerTreeHostTestOneActivatePerManageTiles : public LayerTreeHostTest { |
| 5867 public: |
| 5868 LayerTreeHostTestOneActivatePerManageTiles() |
| 5869 : notify_ready_to_activate_count_(0u), scheduled_manage_tiles_count_(0) {} |
| 5870 |
| 5871 void SetupTree() override { |
| 5872 client_.set_fill_with_nonsolid_color(true); |
| 5873 scoped_refptr<FakePictureLayer> root_layer = |
| 5874 FakePictureLayer::Create(&client_); |
| 5875 root_layer->SetBounds(gfx::Size(1500, 1500)); |
| 5876 root_layer->SetIsDrawable(true); |
| 5877 |
| 5878 layer_tree_host()->SetRootLayer(root_layer); |
| 5879 LayerTreeHostTest::SetupTree(); |
| 5880 } |
| 5881 |
| 5882 void BeginTest() override { |
| 5883 layer_tree_host()->SetViewportSize(gfx::Size(16, 16)); |
| 5884 PostSetNeedsCommitToMainThread(); |
| 5885 } |
| 5886 |
| 5887 void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
| 5888 bool success) override { |
| 5889 ASSERT_TRUE(success); |
| 5890 host_impl->tile_manager()->SetScheduledRasterTaskLimitForTesting(1); |
| 5891 } |
| 5892 |
| 5893 void NotifyReadyToActivateOnThread(LayerTreeHostImpl* impl) override { |
| 5894 ++notify_ready_to_activate_count_; |
| 5895 EndTestAfterDelayMs(100); |
| 5896 } |
| 5897 |
| 5898 void ScheduledActionManageTiles() override { |
| 5899 ++scheduled_manage_tiles_count_; |
| 5900 } |
| 5901 |
| 5902 void AfterTest() override { |
| 5903 // Expect at most a notification for each scheduled manage tiles, plus one |
| 5904 // for the initial commit (which doesn't go through scheduled actions). |
| 5905 // The reason this is not an equality is because depending on timing, we |
| 5906 // might get a manage tiles but not yet get a notification that we're |
| 5907 // ready to activate. The intent of a test is to ensure that we don't |
| 5908 // get more than one notification per manage tiles, so this is OK. |
| 5909 EXPECT_LE(notify_ready_to_activate_count_, |
| 5910 1u + scheduled_manage_tiles_count_); |
| 5911 } |
| 5912 |
| 5913 protected: |
| 5914 FakeContentLayerClient client_; |
| 5915 size_t notify_ready_to_activate_count_; |
| 5916 size_t scheduled_manage_tiles_count_; |
| 5917 }; |
| 5918 |
| 5919 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostTestOneActivatePerManageTiles); |
| 5920 |
| 5843 } // namespace cc | 5921 } // namespace cc |
| OLD | NEW |