| 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 <map> | 5 #include <map> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "cc/resources/picture_pile.h" | 8 #include "cc/resources/picture_pile.h" |
| 9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
| 10 #include "cc/test/fake_rendering_stats_instrumentation.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/gfx/geometry/rect_conversions.h" | 11 #include "ui/gfx/geometry/rect_conversions.h" |
| 13 #include "ui/gfx/geometry/size_conversions.h" | 12 #include "ui/gfx/geometry/size_conversions.h" |
| 14 | 13 |
| 15 namespace cc { | 14 namespace cc { |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| 18 class TestPicturePile : public PicturePile { | 17 class TestPicturePile : public PicturePile { |
| 19 public: | 18 public: |
| 20 ~TestPicturePile() override {} | 19 ~TestPicturePile() override {} |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 UpdateAndExpandInvalidation(&invalidation, tiling_size, viewport_rect); | 60 UpdateAndExpandInvalidation(&invalidation, tiling_size, viewport_rect); |
| 62 } | 61 } |
| 63 | 62 |
| 64 gfx::Size tiling_size() const { return pile_.tiling_size(); } | 63 gfx::Size tiling_size() const { return pile_.tiling_size(); } |
| 65 gfx::Rect tiling_rect() const { return gfx::Rect(pile_.tiling_size()); } | 64 gfx::Rect tiling_rect() const { return gfx::Rect(pile_.tiling_size()); } |
| 66 | 65 |
| 67 bool UpdateAndExpandInvalidation(Region* invalidation, | 66 bool UpdateAndExpandInvalidation(Region* invalidation, |
| 68 const gfx::Size& layer_size, | 67 const gfx::Size& layer_size, |
| 69 const gfx::Rect& visible_layer_rect) { | 68 const gfx::Rect& visible_layer_rect) { |
| 70 frame_number_++; | 69 frame_number_++; |
| 71 return pile_.UpdateAndExpandInvalidation(&client_, | 70 return pile_.UpdateAndExpandInvalidation( |
| 72 invalidation, | 71 &client_, invalidation, background_color_, contents_opaque_, false, |
| 73 background_color_, | 72 layer_size, visible_layer_rect, frame_number_, |
| 74 contents_opaque_, | 73 Picture::RECORD_NORMALLY); |
| 75 false, | |
| 76 layer_size, | |
| 77 visible_layer_rect, | |
| 78 frame_number_, | |
| 79 Picture::RECORD_NORMALLY, | |
| 80 &stats_instrumentation_); | |
| 81 } | 74 } |
| 82 | 75 |
| 83 bool UpdateWholePile() { | 76 bool UpdateWholePile() { |
| 84 Region invalidation = tiling_rect(); | 77 Region invalidation = tiling_rect(); |
| 85 bool result = UpdateAndExpandInvalidation( | 78 bool result = UpdateAndExpandInvalidation( |
| 86 &invalidation, tiling_size(), tiling_rect()); | 79 &invalidation, tiling_size(), tiling_rect()); |
| 87 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); | 80 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); |
| 88 return result; | 81 return result; |
| 89 } | 82 } |
| 90 | 83 |
| 91 FakeContentLayerClient client_; | 84 FakeContentLayerClient client_; |
| 92 FakeRenderingStatsInstrumentation stats_instrumentation_; | |
| 93 TestPicturePile pile_; | 85 TestPicturePile pile_; |
| 94 SkColor background_color_; | 86 SkColor background_color_; |
| 95 float min_scale_; | 87 float min_scale_; |
| 96 int frame_number_; | 88 int frame_number_; |
| 97 bool contents_opaque_; | 89 bool contents_opaque_; |
| 98 }; | 90 }; |
| 99 | 91 |
| 100 class PicturePileTest : public PicturePileTestBase, public testing::Test { | 92 class PicturePileTest : public PicturePileTestBase, public testing::Test { |
| 101 public: | 93 public: |
| 102 virtual void SetUp() override { InitializeData(); } | 94 virtual void SetUp() override { InitializeData(); } |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 EXPECT_TRUE(pile_.HasRecordings()); | 1460 EXPECT_TRUE(pile_.HasRecordings()); |
| 1469 pile_.SetEmptyBounds(); | 1461 pile_.SetEmptyBounds(); |
| 1470 EXPECT_FALSE(pile_.is_solid_color()); | 1462 EXPECT_FALSE(pile_.is_solid_color()); |
| 1471 EXPECT_TRUE(pile_.tiling_size().IsEmpty()); | 1463 EXPECT_TRUE(pile_.tiling_size().IsEmpty()); |
| 1472 EXPECT_TRUE(pile_.picture_map().empty()); | 1464 EXPECT_TRUE(pile_.picture_map().empty()); |
| 1473 EXPECT_FALSE(pile_.HasRecordings()); | 1465 EXPECT_FALSE(pile_.HasRecordings()); |
| 1474 } | 1466 } |
| 1475 | 1467 |
| 1476 } // namespace | 1468 } // namespace |
| 1477 } // namespace cc | 1469 } // namespace cc |
| OLD | NEW |