OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/picture_layer.h" | 8 #include "cc/layers/picture_layer.h" |
9 #include "cc/output/copy_output_request.h" | 9 #include "cc/output/copy_output_request.h" |
| 10 #include "cc/paint/paint_canvas.h" |
| 11 #include "cc/paint/paint_flags.h" |
| 12 #include "cc/paint/paint_recorder.h" |
10 #include "cc/playback/display_item_list.h" | 13 #include "cc/playback/display_item_list.h" |
11 #include "cc/playback/display_item_list_settings.h" | 14 #include "cc/playback/display_item_list_settings.h" |
12 #include "cc/playback/drawing_display_item.h" | 15 #include "cc/playback/drawing_display_item.h" |
13 #include "cc/test/layer_tree_pixel_test.h" | 16 #include "cc/test/layer_tree_pixel_test.h" |
14 #include "cc/test/test_compositor_frame_sink.h" | 17 #include "cc/test/test_compositor_frame_sink.h" |
15 #include "gpu/command_buffer/client/gles2_interface.h" | 18 #include "gpu/command_buffer/client/gles2_interface.h" |
16 #include "third_party/skia/include/core/SkCanvas.h" | |
17 #include "third_party/skia/include/core/SkPictureRecorder.h" | |
18 | 19 |
19 #if !defined(OS_ANDROID) | 20 #if !defined(OS_ANDROID) |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
22 namespace { | 23 namespace { |
23 | 24 |
24 enum RasterMode { | 25 enum RasterMode { |
25 PARTIAL_ONE_COPY, | 26 PARTIAL_ONE_COPY, |
26 FULL_ONE_COPY, | 27 FULL_ONE_COPY, |
27 PARTIAL_GPU, | 28 PARTIAL_GPU, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 : size_(size), blue_top_(true) {} | 110 : size_(size), blue_top_(true) {} |
110 | 111 |
111 gfx::Rect PaintableRegion() override { return gfx::Rect(size_); } | 112 gfx::Rect PaintableRegion() override { return gfx::Rect(size_); } |
112 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 113 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
113 PaintingControlSetting painting_status) override { | 114 PaintingControlSetting painting_status) override { |
114 DisplayItemListSettings settings; | 115 DisplayItemListSettings settings; |
115 settings.use_cached_picture = false; | 116 settings.use_cached_picture = false; |
116 scoped_refptr<DisplayItemList> display_list = | 117 scoped_refptr<DisplayItemList> display_list = |
117 DisplayItemList::Create(settings); | 118 DisplayItemList::Create(settings); |
118 | 119 |
119 SkPictureRecorder recorder; | 120 PaintRecorder recorder; |
120 SkCanvas* canvas = | 121 PaintCanvas* canvas = |
121 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(size_))); | 122 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(size_))); |
122 gfx::Rect top(0, 0, size_.width(), size_.height() / 2); | 123 gfx::Rect top(0, 0, size_.width(), size_.height() / 2); |
123 gfx::Rect bottom(0, size_.height() / 2, size_.width(), size_.height() / 2); | 124 gfx::Rect bottom(0, size_.height() / 2, size_.width(), size_.height() / 2); |
124 | 125 |
125 gfx::Rect blue_rect = blue_top_ ? top : bottom; | 126 gfx::Rect blue_rect = blue_top_ ? top : bottom; |
126 gfx::Rect yellow_rect = blue_top_ ? bottom : top; | 127 gfx::Rect yellow_rect = blue_top_ ? bottom : top; |
127 | 128 |
128 SkPaint paint; | 129 PaintFlags paint; |
129 paint.setStyle(SkPaint::kFill_Style); | 130 paint.setStyle(PaintFlags::kFill_Style); |
130 | 131 |
131 paint.setColor(SK_ColorBLUE); | 132 paint.setColor(SK_ColorBLUE); |
132 canvas->drawRect(gfx::RectToSkRect(blue_rect), paint); | 133 canvas->drawRect(gfx::RectToSkRect(blue_rect), paint); |
133 paint.setColor(SK_ColorYELLOW); | 134 paint.setColor(SK_ColorYELLOW); |
134 canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint); | 135 canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint); |
135 | 136 |
136 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 137 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
137 PaintableRegion(), recorder.finishRecordingAsPicture()); | 138 PaintableRegion(), recorder.finishRecordingAsPicture()); |
138 display_list->Finalize(); | 139 display_list->Finalize(); |
139 return display_list; | 140 return display_list; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 FullRaster_SingleThread_GpuRaster) { | 248 FullRaster_SingleThread_GpuRaster) { |
248 RunRasterPixelTest( | 249 RunRasterPixelTest( |
249 false, FULL_GPU, picture_layer_, | 250 false, FULL_GPU, picture_layer_, |
250 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); | 251 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); |
251 } | 252 } |
252 | 253 |
253 } // namespace | 254 } // namespace |
254 } // namespace cc | 255 } // namespace cc |
255 | 256 |
256 #endif // !defined(OS_ANDROID) | 257 #endif // !defined(OS_ANDROID) |
OLD | NEW |