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.h" | 5 #include "cc/layers/picture_layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
11 #include "cc/layers/append_quads_data.h" | 11 #include "cc/layers/append_quads_data.h" |
12 #include "cc/layers/content_layer_client.h" | 12 #include "cc/layers/content_layer_client.h" |
13 #include "cc/layers/empty_content_layer_client.h" | 13 #include "cc/layers/empty_content_layer_client.h" |
14 #include "cc/layers/picture_layer_impl.h" | 14 #include "cc/layers/picture_layer_impl.h" |
15 #include "cc/playback/display_item_list_settings.h" | 15 #include "cc/playback/display_item_list_settings.h" |
16 #include "cc/proto/layer.pb.h" | 16 #include "cc/proto/layer.pb.h" |
17 #include "cc/test/fake_image_serialization_processor.h" | 17 #include "cc/test/fake_image_serialization_processor.h" |
18 #include "cc/test/fake_layer_tree_host.h" | 18 #include "cc/test/fake_layer_tree_host.h" |
19 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
20 #include "cc/test/fake_picture_layer.h" | 20 #include "cc/test/fake_picture_layer.h" |
21 #include "cc/test/fake_picture_layer_impl.h" | 21 #include "cc/test/fake_picture_layer_impl.h" |
22 #include "cc/test/fake_proxy.h" | 22 #include "cc/test/fake_proxy.h" |
23 #include "cc/test/fake_recording_source.h" | 23 #include "cc/test/fake_recording_source.h" |
24 #include "cc/test/skia_common.h" | 24 #include "cc/test/skia_common.h" |
25 #include "cc/test/test_shared_bitmap_manager.h" | 25 #include "cc/test/test_shared_bitmap_manager.h" |
26 #include "cc/test/test_task_graph_runner.h" | 26 #include "cc/test/test_task_graph_runner.h" |
27 #include "cc/trees/single_thread_proxy.h" | 27 #include "cc/trees/single_thread_proxy.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "third_party/skia/include/core/SkRefCnt.h" |
29 | 30 |
30 namespace cc { | 31 namespace cc { |
31 | 32 |
32 class TestSerializationPictureLayer : public PictureLayer { | 33 class TestSerializationPictureLayer : public PictureLayer { |
33 public: | 34 public: |
34 static scoped_refptr<TestSerializationPictureLayer> Create( | 35 static scoped_refptr<TestSerializationPictureLayer> Create( |
35 const gfx::Size& recording_source_viewport) { | 36 const gfx::Size& recording_source_viewport) { |
36 return make_scoped_refptr(new TestSerializationPictureLayer( | 37 return make_scoped_refptr(new TestSerializationPictureLayer( |
37 EmptyContentLayerClient::GetInstance(), | 38 EmptyContentLayerClient::GetInstance(), |
38 FakeRecordingSource::CreateFilledRecordingSource( | 39 FakeRecordingSource::CreateFilledRecordingSource( |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 host_impl.pending_tree()->root_layer()); | 295 host_impl.pending_tree()->root_layer()); |
295 layer->PushPropertiesTo(layer_impl); | 296 layer->PushPropertiesTo(layer_impl); |
296 | 297 |
297 EXPECT_EQ(gfx::Rect(), layer_impl->GetPendingInvalidation()->bounds()); | 298 EXPECT_EQ(gfx::Rect(), layer_impl->GetPendingInvalidation()->bounds()); |
298 } | 299 } |
299 | 300 |
300 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { | 301 TEST(PictureLayerTest, ClearVisibleRectWhenNoTiling) { |
301 gfx::Size layer_size(50, 50); | 302 gfx::Size layer_size(50, 50); |
302 FakeContentLayerClient client; | 303 FakeContentLayerClient client; |
303 client.set_bounds(layer_size); | 304 client.set_bounds(layer_size); |
304 skia::RefPtr<SkImage> image = CreateDiscardableImage(layer_size); | 305 client.add_draw_image(CreateDiscardableImage(layer_size), gfx::Point(), |
305 client.add_draw_image(image.get(), gfx::Point(), SkPaint()); | 306 SkPaint()); |
306 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); | 307 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
307 layer->SetBounds(gfx::Size(10, 10)); | 308 layer->SetBounds(gfx::Size(10, 10)); |
308 | 309 |
309 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); | 310 FakeLayerTreeHostClient host_client(FakeLayerTreeHostClient::DIRECT_3D); |
310 TestTaskGraphRunner task_graph_runner; | 311 TestTaskGraphRunner task_graph_runner; |
311 std::unique_ptr<FakeLayerTreeHost> host = | 312 std::unique_ptr<FakeLayerTreeHost> host = |
312 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); | 313 FakeLayerTreeHost::Create(&host_client, &task_graph_runner); |
313 host->SetRootLayer(layer); | 314 host->SetRootLayer(layer); |
314 layer->SetIsDrawable(true); | 315 layer->SetIsDrawable(true); |
315 layer->SavePaintProperties(); | 316 layer->SavePaintProperties(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 // Do a main frame, record the picture layers. The frame number has changed | 465 // Do a main frame, record the picture layers. The frame number has changed |
465 // non-monotonically. | 466 // non-monotonically. |
466 layer->SetNeedsDisplay(); | 467 layer->SetNeedsDisplay(); |
467 host2->Composite(base::TimeTicks::Now()); | 468 host2->Composite(base::TimeTicks::Now()); |
468 EXPECT_EQ(3, layer->update_count()); | 469 EXPECT_EQ(3, layer->update_count()); |
469 EXPECT_EQ(1, host2->source_frame_number()); | 470 EXPECT_EQ(1, host2->source_frame_number()); |
470 } | 471 } |
471 | 472 |
472 } // namespace | 473 } // namespace |
473 } // namespace cc | 474 } // namespace cc |
OLD | NEW |