| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "ui/gfx/rect_conversions.h" | 31 #include "ui/gfx/rect_conversions.h" |
| 32 #include "ui/gfx/size_conversions.h" | 32 #include "ui/gfx/size_conversions.h" |
| 33 | 33 |
| 34 namespace cc { | 34 namespace cc { |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 class MockCanvas : public SkCanvas { | 37 class MockCanvas : public SkCanvas { |
| 38 public: | 38 public: |
| 39 explicit MockCanvas(int w, int h) : SkCanvas(w, h) {} | 39 explicit MockCanvas(int w, int h) : SkCanvas(w, h) {} |
| 40 | 40 |
| 41 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE { | 41 virtual void drawRect(const SkRect& rect, const SkPaint& paint) override { |
| 42 // Capture calls before SkCanvas quickReject() kicks in. | 42 // Capture calls before SkCanvas quickReject() kicks in. |
| 43 rects_.push_back(rect); | 43 rects_.push_back(rect); |
| 44 } | 44 } |
| 45 | 45 |
| 46 std::vector<SkRect> rects_; | 46 std::vector<SkRect> rects_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 class NoLowResTilingsSettings : public ImplSidePaintingSettings {}; | 49 class NoLowResTilingsSettings : public ImplSidePaintingSettings {}; |
| 50 | 50 |
| 51 class LowResTilingsSettings : public ImplSidePaintingSettings { | 51 class LowResTilingsSettings : public ImplSidePaintingSettings { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 active_layer_(NULL) {} | 64 active_layer_(NULL) {} |
| 65 | 65 |
| 66 explicit PictureLayerImplTest(const LayerTreeSettings& settings) | 66 explicit PictureLayerImplTest(const LayerTreeSettings& settings) |
| 67 : proxy_(base::MessageLoopProxy::current()), | 67 : proxy_(base::MessageLoopProxy::current()), |
| 68 host_impl_(settings, &proxy_, &shared_bitmap_manager_), | 68 host_impl_(settings, &proxy_, &shared_bitmap_manager_), |
| 69 id_(7) {} | 69 id_(7) {} |
| 70 | 70 |
| 71 virtual ~PictureLayerImplTest() { | 71 virtual ~PictureLayerImplTest() { |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void SetUp() OVERRIDE { | 74 virtual void SetUp() override { |
| 75 InitializeRenderer(); | 75 InitializeRenderer(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 virtual void InitializeRenderer() { | 78 virtual void InitializeRenderer() { |
| 79 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 79 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void SetupDefaultTrees(const gfx::Size& layer_bounds) { | 82 void SetupDefaultTrees(const gfx::Size& layer_bounds) { |
| 83 gfx::Size tile_size(100, 100); | 83 gfx::Size tile_size(100, 100); |
| 84 | 84 |
| (...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 pending_layer_->MinimumContentsScale()); | 2230 pending_layer_->MinimumContentsScale()); |
| 2231 | 2231 |
| 2232 SetContentsScaleOnBothLayers(contents_scale, 1.f, page_scale, 1.f, false); | 2232 SetContentsScaleOnBothLayers(contents_scale, 1.f, page_scale, 1.f, false); |
| 2233 ASSERT_GE(pending_layer_->num_tilings(), 0u); | 2233 ASSERT_GE(pending_layer_->num_tilings(), 0u); |
| 2234 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), | 2234 EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
| 2235 pending_layer_->HighResTiling()->contents_scale()); | 2235 pending_layer_->HighResTiling()->contents_scale()); |
| 2236 } | 2236 } |
| 2237 | 2237 |
| 2238 class DeferredInitPictureLayerImplTest : public PictureLayerImplTest { | 2238 class DeferredInitPictureLayerImplTest : public PictureLayerImplTest { |
| 2239 public: | 2239 public: |
| 2240 virtual void InitializeRenderer() OVERRIDE { | 2240 virtual void InitializeRenderer() override { |
| 2241 bool delegated_rendering = false; | 2241 bool delegated_rendering = false; |
| 2242 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDeferredGL( | 2242 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDeferredGL( |
| 2243 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), | 2243 scoped_ptr<SoftwareOutputDevice>(new SoftwareOutputDevice), |
| 2244 delegated_rendering)); | 2244 delegated_rendering)); |
| 2245 } | 2245 } |
| 2246 | 2246 |
| 2247 virtual void SetUp() OVERRIDE { | 2247 virtual void SetUp() override { |
| 2248 PictureLayerImplTest::SetUp(); | 2248 PictureLayerImplTest::SetUp(); |
| 2249 | 2249 |
| 2250 // Create some default active and pending trees. | 2250 // Create some default active and pending trees. |
| 2251 gfx::Size tile_size(100, 100); | 2251 gfx::Size tile_size(100, 100); |
| 2252 gfx::Size layer_bounds(400, 400); | 2252 gfx::Size layer_bounds(400, 400); |
| 2253 | 2253 |
| 2254 scoped_refptr<FakePicturePileImpl> pending_pile = | 2254 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2255 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2255 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2256 scoped_refptr<FakePicturePileImpl> active_pile = | 2256 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2257 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2257 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3557 | 3557 |
| 3558 EXPECT_FALSE(pending_mask_content->tilings()); | 3558 EXPECT_FALSE(pending_mask_content->tilings()); |
| 3559 host_impl_.pending_tree()->UpdateDrawProperties(); | 3559 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 3560 EXPECT_NE(0u, pending_mask_content->num_tilings()); | 3560 EXPECT_NE(0u, pending_mask_content->num_tilings()); |
| 3561 } | 3561 } |
| 3562 | 3562 |
| 3563 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { | 3563 class PictureLayerImplTestWithDelegatingRenderer : public PictureLayerImplTest { |
| 3564 public: | 3564 public: |
| 3565 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} | 3565 PictureLayerImplTestWithDelegatingRenderer() : PictureLayerImplTest() {} |
| 3566 | 3566 |
| 3567 virtual void InitializeRenderer() OVERRIDE { | 3567 virtual void InitializeRenderer() override { |
| 3568 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDelegating3d()); | 3568 host_impl_.InitializeRenderer(FakeOutputSurface::CreateDelegating3d()); |
| 3569 } | 3569 } |
| 3570 }; | 3570 }; |
| 3571 | 3571 |
| 3572 TEST_F(PictureLayerImplTestWithDelegatingRenderer, | 3572 TEST_F(PictureLayerImplTestWithDelegatingRenderer, |
| 3573 DelegatingRendererWithTileOOM) { | 3573 DelegatingRendererWithTileOOM) { |
| 3574 // This test is added for crbug.com/402321, where quad should be produced when | 3574 // This test is added for crbug.com/402321, where quad should be produced when |
| 3575 // raster on demand is not allowed and tile is OOM. | 3575 // raster on demand is not allowed and tile is OOM. |
| 3576 gfx::Size tile_size = host_impl_.settings().default_tile_size; | 3576 gfx::Size tile_size = host_impl_.settings().default_tile_size; |
| 3577 gfx::Size layer_bounds(1000, 1000); | 3577 gfx::Size layer_bounds(1000, 1000); |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4402 SetupPendingTree(pending_pile2); | 4402 SetupPendingTree(pending_pile2); |
| 4403 ActivateTree(); | 4403 ActivateTree(); |
| 4404 | 4404 |
| 4405 // We've switched to a solid color, so we should end up with no tilings. | 4405 // We've switched to a solid color, so we should end up with no tilings. |
| 4406 ASSERT_TRUE(active_layer_->tilings()); | 4406 ASSERT_TRUE(active_layer_->tilings()); |
| 4407 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); | 4407 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 4408 } | 4408 } |
| 4409 | 4409 |
| 4410 } // namespace | 4410 } // namespace |
| 4411 } // namespace cc | 4411 } // namespace cc |
| OLD | NEW |