Chromium Code Reviews| 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" | 10 #include "cc/test/fake_rendering_stats_instrumentation.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
| 13 #include "ui/gfx/geometry/size_conversions.h" | 13 #include "ui/gfx/geometry/size_conversions.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class TestPicturePile : public PicturePile { | 18 class TestPicturePile : public PicturePile { |
| 19 public: | 19 public: |
| 20 ~TestPicturePile() override {} | |
| 21 | |
| 20 using PicturePile::buffer_pixels; | 22 using PicturePile::buffer_pixels; |
| 21 using PicturePile::CanRasterSlowTileCheck; | 23 using PicturePile::CanRasterSlowTileCheck; |
| 22 using PicturePile::Clear; | 24 using PicturePile::Clear; |
| 23 | 25 |
| 24 PictureMap& picture_map() { return picture_map_; } | 26 PictureMap& picture_map() { return picture_map_; } |
| 25 const gfx::Rect& recorded_viewport() const { return recorded_viewport_; } | 27 const gfx::Rect& recorded_viewport() const { return recorded_viewport_; } |
| 26 | 28 |
| 27 bool CanRasterLayerRect(const gfx::Rect& layer_rect) { | 29 bool CanRasterLayerRect(const gfx::Rect& layer_rect) { |
| 28 return CanRaster(1.f, layer_rect); | 30 return CanRaster(1.f, layer_rect); |
| 29 } | 31 } |
| 30 | 32 |
| 31 typedef PicturePile::PictureInfo PictureInfo; | 33 typedef PicturePile::PictureInfo PictureInfo; |
| 32 typedef PicturePile::PictureMapKey PictureMapKey; | 34 typedef PicturePile::PictureMapKey PictureMapKey; |
| 33 typedef PicturePile::PictureMap PictureMap; | 35 typedef PicturePile::PictureMap PictureMap; |
| 34 | |
| 35 protected: | |
| 36 ~TestPicturePile() override {} | |
| 37 }; | 36 }; |
| 38 | 37 |
| 39 class PicturePileTestBase { | 38 class PicturePileTestBase { |
| 40 public: | 39 public: |
| 41 PicturePileTestBase() | 40 PicturePileTestBase() |
| 42 : background_color_(SK_ColorBLUE), | 41 : background_color_(SK_ColorBLUE), |
| 43 min_scale_(0.125), | 42 min_scale_(0.125), |
| 44 frame_number_(0), | 43 frame_number_(0), |
| 45 contents_opaque_(false) {} | 44 contents_opaque_(false) {} |
| 46 | 45 |
| 47 void InitializeData() { | 46 void InitializeData() { |
| 48 pile_ = make_scoped_refptr(new TestPicturePile()); | 47 pile_.reset(new TestPicturePile()); |
| 49 pile_->SetTileGridSize(gfx::Size(1000, 1000)); | 48 pile_->SetTileGridSize(gfx::Size(1000, 1000)); |
| 50 pile_->SetMinContentsScale(min_scale_); | 49 pile_->SetMinContentsScale(min_scale_); |
| 51 client_ = FakeContentLayerClient(); | 50 client_ = FakeContentLayerClient(); |
| 52 SetTilingSize(pile_->tiling().max_texture_size()); | 51 SetTilingSize(pile_->tiling().max_texture_size()); |
| 53 } | 52 } |
| 54 | 53 |
| 55 void SetTilingSize(const gfx::Size& tiling_size) { | 54 void SetTilingSize(const gfx::Size& tiling_size) { |
| 56 Region invalidation; | 55 Region invalidation; |
| 57 gfx::Rect viewport_rect(tiling_size); | 56 gfx::Rect viewport_rect(tiling_size); |
| 58 UpdateAndExpandInvalidation(&invalidation, tiling_size, viewport_rect); | 57 UpdateAndExpandInvalidation(&invalidation, tiling_size, viewport_rect); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 80 bool UpdateWholePile() { | 79 bool UpdateWholePile() { |
| 81 Region invalidation = tiling_rect(); | 80 Region invalidation = tiling_rect(); |
| 82 bool result = UpdateAndExpandInvalidation( | 81 bool result = UpdateAndExpandInvalidation( |
| 83 &invalidation, tiling_size(), tiling_rect()); | 82 &invalidation, tiling_size(), tiling_rect()); |
| 84 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); | 83 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); |
| 85 return result; | 84 return result; |
| 86 } | 85 } |
| 87 | 86 |
| 88 FakeContentLayerClient client_; | 87 FakeContentLayerClient client_; |
| 89 FakeRenderingStatsInstrumentation stats_instrumentation_; | 88 FakeRenderingStatsInstrumentation stats_instrumentation_; |
| 90 scoped_refptr<TestPicturePile> pile_; | 89 scoped_ptr<TestPicturePile> pile_; |
|
enne (OOO)
2014/10/24 22:27:35
This could probably just be a member too...
vmpstr
2014/10/24 23:15:23
I did that first and then I thought "but that chan
| |
| 91 SkColor background_color_; | 90 SkColor background_color_; |
| 92 float min_scale_; | 91 float min_scale_; |
| 93 int frame_number_; | 92 int frame_number_; |
| 94 bool contents_opaque_; | 93 bool contents_opaque_; |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 class PicturePileTest : public PicturePileTestBase, public testing::Test { | 96 class PicturePileTest : public PicturePileTestBase, public testing::Test { |
| 98 public: | 97 public: |
| 99 virtual void SetUp() override { InitializeData(); } | 98 virtual void SetUp() override { InitializeData(); } |
| 100 }; | 99 }; |
| (...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1429 client_.add_draw_rect(tiling_rect(), paint); | 1428 client_.add_draw_rect(tiling_rect(), paint); |
| 1430 client_.add_draw_rect(tiling_rect(), paint); | 1429 client_.add_draw_rect(tiling_rect(), paint); |
| 1431 client_.add_draw_rect(tiling_rect(), paint); | 1430 client_.add_draw_rect(tiling_rect(), paint); |
| 1432 Region invalidation5(tiling_rect()); | 1431 Region invalidation5(tiling_rect()); |
| 1433 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); | 1432 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); |
| 1434 EXPECT_FALSE(pile_->is_solid_color()); | 1433 EXPECT_FALSE(pile_->is_solid_color()); |
| 1435 } | 1434 } |
| 1436 | 1435 |
| 1437 } // namespace | 1436 } // namespace |
| 1438 } // namespace cc | 1437 } // namespace cc |
| OLD | NEW |