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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/debug/test_web_graphics_context_3d.h" | 9 #include "cc/debug/test_web_graphics_context_3d.h" |
10 #include "cc/layers/append_quads_data.h" | 10 #include "cc/layers/append_quads_data.h" |
11 #include "cc/layers/picture_layer.h" | 11 #include "cc/layers/picture_layer.h" |
12 #include "cc/test/fake_content_layer_client.h" | 12 #include "cc/test/fake_content_layer_client.h" |
13 #include "cc/test/fake_impl_proxy.h" | 13 #include "cc/test/fake_impl_proxy.h" |
14 #include "cc/test/fake_layer_tree_host_impl.h" | 14 #include "cc/test/fake_layer_tree_host_impl.h" |
15 #include "cc/test/fake_output_surface.h" | 15 #include "cc/test/fake_output_surface.h" |
16 #include "cc/test/fake_picture_layer_impl.h" | 16 #include "cc/test/fake_picture_layer_impl.h" |
17 #include "cc/test/fake_picture_pile_impl.h" | 17 #include "cc/test/fake_picture_pile_impl.h" |
18 #include "cc/test/geometry_test_utils.h" | 18 #include "cc/test/geometry_test_utils.h" |
19 #include "cc/test/impl_side_painting_settings.h" | 19 #include "cc/test/impl_side_painting_settings.h" |
20 #include "cc/test/mock_quad_culler.h" | 20 #include "cc/test/mock_quad_culler.h" |
21 #include "cc/trees/layer_tree_impl.h" | 21 #include "cc/trees/layer_tree_impl.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "third_party/skia/include/core/SkDevice.h" | 23 #include "third_party/skia/include/core/SkBitmapDevice.h" |
24 #include "ui/gfx/rect_conversions.h" | 24 #include "ui/gfx/rect_conversions.h" |
25 | 25 |
26 namespace cc { | 26 namespace cc { |
27 namespace { | 27 namespace { |
28 | 28 |
29 class MockCanvas : public SkCanvas { | 29 class MockCanvas : public SkCanvas { |
30 public: | 30 public: |
31 explicit MockCanvas(SkDevice* device) : SkCanvas(device) {} | 31 explicit MockCanvas(SkBaseDevice* device) : SkCanvas(device) {} |
32 | 32 |
33 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE { | 33 virtual void drawRect(const SkRect& rect, const SkPaint& paint) OVERRIDE { |
34 // Capture calls before SkCanvas quickReject() kicks in. | 34 // Capture calls before SkCanvas quickReject() kicks in. |
35 rects_.push_back(rect); | 35 rects_.push_back(rect); |
36 } | 36 } |
37 | 37 |
38 std::vector<SkRect> rects_; | 38 std::vector<SkRect> rects_; |
39 }; | 39 }; |
40 | 40 |
41 class PictureLayerImplTest : public testing::Test { | 41 class PictureLayerImplTest : public testing::Test { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); | 173 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); |
174 active_pile->add_draw_rect(rect); | 174 active_pile->add_draw_rect(rect); |
175 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); | 175 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); |
176 } | 176 } |
177 // Force re-record with newly injected content | 177 // Force re-record with newly injected content |
178 active_pile->RemoveRecordingAt(0, 0); | 178 active_pile->RemoveRecordingAt(0, 0); |
179 active_pile->AddRecordingAt(0, 0); | 179 active_pile->AddRecordingAt(0, 0); |
180 | 180 |
181 SkBitmap store; | 181 SkBitmap store; |
182 store.setConfig(SkBitmap::kNo_Config, 1000, 1000); | 182 store.setConfig(SkBitmap::kNo_Config, 1000, 1000); |
183 SkDevice device(store); | 183 SkBitmapDevice device(store); |
184 | 184 |
185 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); | 185 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); |
186 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 186 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
187 MockCanvas mock_canvas(&device); | 187 MockCanvas mock_canvas(&device); |
188 active_pile->RasterDirect( | 188 active_pile->RasterDirect( |
189 &mock_canvas, (*tile_iter)->content_rect(), 1.0f, NULL); | 189 &mock_canvas, (*tile_iter)->content_rect(), 1.0f, NULL); |
190 | 190 |
191 // This test verifies that when drawing the contents of a specific tile | 191 // This test verifies that when drawing the contents of a specific tile |
192 // at content scale 1.0, the playback canvas never receives content from | 192 // at content scale 1.0, the playback canvas never receives content from |
193 // neighboring tiles which indicates that the tile grid embedded in | 193 // neighboring tiles which indicates that the tile grid embedded in |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 active_layer_ = static_cast<FakePictureLayerImpl*>( | 1037 active_layer_ = static_cast<FakePictureLayerImpl*>( |
1038 host_impl_.active_tree()->LayerById(id_)); | 1038 host_impl_.active_tree()->LayerById(id_)); |
1039 | 1039 |
1040 EXPECT_EQ(0u, active_layer_->num_tilings()); | 1040 EXPECT_EQ(0u, active_layer_->num_tilings()); |
1041 EXPECT_EQ(!default_lcd_text_setting, active_layer_->is_using_lcd_text()); | 1041 EXPECT_EQ(!default_lcd_text_setting, active_layer_->is_using_lcd_text()); |
1042 EXPECT_FALSE(active_layer_->needs_post_commit_initialization()); | 1042 EXPECT_FALSE(active_layer_->needs_post_commit_initialization()); |
1043 } | 1043 } |
1044 | 1044 |
1045 } // namespace | 1045 } // namespace |
1046 } // namespace cc | 1046 } // namespace cc |
OLD | NEW |