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/append_quads_data.h" | 5 #include "cc/layers/append_quads_data.h" |
6 #include "cc/layers/content_layer_client.h" | 6 #include "cc/layers/content_layer_client.h" |
7 #include "cc/layers/picture_layer.h" | 7 #include "cc/layers/picture_layer.h" |
8 #include "cc/layers/picture_layer_impl.h" | 8 #include "cc/layers/picture_layer_impl.h" |
9 #include "cc/quads/draw_quad.h" | 9 #include "cc/quads/draw_quad.h" |
10 #include "cc/test/layer_tree_pixel_test.h" | 10 #include "cc/test/layer_tree_pixel_test.h" |
11 #include "cc/test/mock_occlusion_tracker.h" | 11 #include "cc/test/mock_occlusion_tracker.h" |
12 #include "cc/trees/layer_tree_impl.h" | 12 #include "cc/trees/layer_tree_impl.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
16 #include "ui/gfx/rect_f.h" | 16 #include "ui/gfx/rect_f.h" |
17 | 17 |
18 #if !defined(OS_ANDROID) | 18 #if !defined(OS_ANDROID) |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 namespace { | 21 namespace { |
22 | 22 |
23 class LayerTreeHostOnDemandRasterPixelTest : public LayerTreePixelTest { | 23 class LayerTreeHostOnDemandRasterPixelTest : public LayerTreePixelTest { |
24 public: | 24 public: |
25 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 25 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
26 settings->impl_side_painting = true; | 26 settings->impl_side_painting = true; |
27 } | 27 } |
28 | 28 |
29 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 29 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) override { |
30 // Not enough memory available. Enforce on-demand rasterization. | 30 // Not enough memory available. Enforce on-demand rasterization. |
31 impl->SetMemoryPolicy( | 31 impl->SetMemoryPolicy( |
32 ManagedMemoryPolicy(1, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 32 ManagedMemoryPolicy(1, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
33 1000)); | 33 1000)); |
34 } | 34 } |
35 | 35 |
36 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | 36 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
37 bool result) OVERRIDE { | 37 bool result) override { |
38 // Find the PictureLayerImpl ask it to append quads to check their material. | 38 // Find the PictureLayerImpl ask it to append quads to check their material. |
39 // The PictureLayerImpl is assumed to be the first child of the root layer | 39 // The PictureLayerImpl is assumed to be the first child of the root layer |
40 // in the active tree. | 40 // in the active tree. |
41 PictureLayerImpl* picture_layer = static_cast<PictureLayerImpl*>( | 41 PictureLayerImpl* picture_layer = static_cast<PictureLayerImpl*>( |
42 host_impl->active_tree()->root_layer()->child_at(0)); | 42 host_impl->active_tree()->root_layer()->child_at(0)); |
43 | 43 |
44 MockOcclusionTracker<LayerImpl> occlusion_tracker; | 44 MockOcclusionTracker<LayerImpl> occlusion_tracker; |
45 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 45 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
46 | 46 |
47 AppendQuadsData data; | 47 AppendQuadsData data; |
48 picture_layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); | 48 picture_layer->AppendQuads(render_pass.get(), occlusion_tracker, &data); |
49 | 49 |
50 for (QuadList::Iterator iter = render_pass->quad_list.begin(); | 50 for (QuadList::Iterator iter = render_pass->quad_list.begin(); |
51 iter != render_pass->quad_list.end(); | 51 iter != render_pass->quad_list.end(); |
52 ++iter) | 52 ++iter) |
53 EXPECT_EQ(iter->material, DrawQuad::PICTURE_CONTENT); | 53 EXPECT_EQ(iter->material, DrawQuad::PICTURE_CONTENT); |
54 | 54 |
55 // Triggers pixel readback and ends the test. | 55 // Triggers pixel readback and ends the test. |
56 LayerTreePixelTest::SwapBuffersOnThread(host_impl, result); | 56 LayerTreePixelTest::SwapBuffersOnThread(host_impl, result); |
57 } | 57 } |
58 | 58 |
59 void RunOnDemandRasterPixelTest(); | 59 void RunOnDemandRasterPixelTest(); |
60 }; | 60 }; |
61 | 61 |
62 class BlueYellowLayerClient : public ContentLayerClient { | 62 class BlueYellowLayerClient : public ContentLayerClient { |
63 public: | 63 public: |
64 explicit BlueYellowLayerClient(gfx::Rect layer_rect) | 64 explicit BlueYellowLayerClient(gfx::Rect layer_rect) |
65 : layer_rect_(layer_rect) {} | 65 : layer_rect_(layer_rect) {} |
66 | 66 |
67 virtual void DidChangeLayerCanUseLCDText() OVERRIDE { } | 67 virtual void DidChangeLayerCanUseLCDText() override { } |
68 | 68 |
69 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } | 69 virtual bool FillsBoundsCompletely() const override { return false; } |
70 | 70 |
71 virtual void PaintContents( | 71 virtual void PaintContents( |
72 SkCanvas* canvas, | 72 SkCanvas* canvas, |
73 const gfx::Rect& clip, | 73 const gfx::Rect& clip, |
74 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE { | 74 ContentLayerClient::GraphicsContextStatus gc_status) override { |
75 SkPaint paint; | 75 SkPaint paint; |
76 paint.setColor(SK_ColorBLUE); | 76 paint.setColor(SK_ColorBLUE); |
77 canvas->drawRect(SkRect::MakeWH(layer_rect_.width(), | 77 canvas->drawRect(SkRect::MakeWH(layer_rect_.width(), |
78 layer_rect_.height() / 2), | 78 layer_rect_.height() / 2), |
79 paint); | 79 paint); |
80 | 80 |
81 paint.setColor(SK_ColorYELLOW); | 81 paint.setColor(SK_ColorYELLOW); |
82 canvas->drawRect( | 82 canvas->drawRect( |
83 SkRect::MakeXYWH(0, | 83 SkRect::MakeXYWH(0, |
84 layer_rect_.height() / 2, | 84 layer_rect_.height() / 2, |
(...skipping 21 matching lines...) Expand all Loading... |
106 layer, | 106 layer, |
107 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); | 107 base::FilePath(FILE_PATH_LITERAL("blue_yellow.png"))); |
108 } | 108 } |
109 | 109 |
110 TEST_F(LayerTreeHostOnDemandRasterPixelTest, RasterPictureLayer) { | 110 TEST_F(LayerTreeHostOnDemandRasterPixelTest, RasterPictureLayer) { |
111 RunOnDemandRasterPixelTest(); | 111 RunOnDemandRasterPixelTest(); |
112 } | 112 } |
113 | 113 |
114 class LayerTreeHostOnDemandRasterPixelTestWithGpuRasterizationForced | 114 class LayerTreeHostOnDemandRasterPixelTestWithGpuRasterizationForced |
115 : public LayerTreeHostOnDemandRasterPixelTest { | 115 : public LayerTreeHostOnDemandRasterPixelTest { |
116 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 116 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
117 LayerTreeHostOnDemandRasterPixelTest::InitializeSettings(settings); | 117 LayerTreeHostOnDemandRasterPixelTest::InitializeSettings(settings); |
118 settings->gpu_rasterization_forced = true; | 118 settings->gpu_rasterization_forced = true; |
119 } | 119 } |
120 }; | 120 }; |
121 | 121 |
122 TEST_F(LayerTreeHostOnDemandRasterPixelTestWithGpuRasterizationForced, | 122 TEST_F(LayerTreeHostOnDemandRasterPixelTestWithGpuRasterizationForced, |
123 RasterPictureLayer) { | 123 RasterPictureLayer) { |
124 RunOnDemandRasterPixelTest(); | 124 RunOnDemandRasterPixelTest(); |
125 } | 125 } |
126 | 126 |
127 } // namespace | 127 } // namespace |
128 } // namespace cc | 128 } // namespace cc |
129 | 129 |
130 #endif // OS_ANDROID | 130 #endif // OS_ANDROID |
OLD | NEW |