| 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/playback/display_item_list.h" | 10 #include "cc/playback/display_item_list.h" |
| 11 #include "cc/playback/display_item_list_settings.h" | 11 #include "cc/playback/display_item_list_settings.h" |
| 12 #include "cc/playback/drawing_display_item.h" | 12 #include "cc/playback/drawing_display_item.h" |
| 13 #include "cc/test/layer_tree_pixel_test.h" | 13 #include "cc/test/layer_tree_pixel_test.h" |
| 14 #include "skia/ext/cdl_paint.h" |
| 15 #include "skia/ext/cdl_picture_recorder.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "third_party/skia/include/core/SkPictureRecorder.h" | |
| 16 | 17 |
| 17 #if !defined(OS_ANDROID) | 18 #if !defined(OS_ANDROID) |
| 18 | 19 |
| 19 namespace cc { | 20 namespace cc { |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 enum RasterMode { | 23 enum RasterMode { |
| 23 PARTIAL_ONE_COPY, | 24 PARTIAL_ONE_COPY, |
| 24 FULL_ONE_COPY, | 25 FULL_ONE_COPY, |
| 25 PARTIAL_GPU, | 26 PARTIAL_GPU, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 : size_(size), blue_top_(true) {} | 108 : size_(size), blue_top_(true) {} |
| 108 | 109 |
| 109 gfx::Rect PaintableRegion() override { return gfx::Rect(size_); } | 110 gfx::Rect PaintableRegion() override { return gfx::Rect(size_); } |
| 110 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 111 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 111 PaintingControlSetting painting_status) override { | 112 PaintingControlSetting painting_status) override { |
| 112 DisplayItemListSettings settings; | 113 DisplayItemListSettings settings; |
| 113 settings.use_cached_picture = false; | 114 settings.use_cached_picture = false; |
| 114 scoped_refptr<DisplayItemList> display_list = | 115 scoped_refptr<DisplayItemList> display_list = |
| 115 DisplayItemList::Create(settings); | 116 DisplayItemList::Create(settings); |
| 116 | 117 |
| 117 SkPictureRecorder recorder; | 118 CdlPictureRecorder recorder; |
| 118 SkCanvas* canvas = | 119 CdlCanvas* canvas = |
| 119 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(size_))); | 120 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(size_))); |
| 120 gfx::Rect top(0, 0, size_.width(), size_.height() / 2); | 121 gfx::Rect top(0, 0, size_.width(), size_.height() / 2); |
| 121 gfx::Rect bottom(0, size_.height() / 2, size_.width(), size_.height() / 2); | 122 gfx::Rect bottom(0, size_.height() / 2, size_.width(), size_.height() / 2); |
| 122 | 123 |
| 123 gfx::Rect blue_rect = blue_top_ ? top : bottom; | 124 gfx::Rect blue_rect = blue_top_ ? top : bottom; |
| 124 gfx::Rect yellow_rect = blue_top_ ? bottom : top; | 125 gfx::Rect yellow_rect = blue_top_ ? bottom : top; |
| 125 | 126 |
| 126 SkPaint paint; | 127 CdlPaint paint; |
| 127 paint.setStyle(SkPaint::kFill_Style); | 128 paint.setStyle(CdlPaint::kFill_Style); |
| 128 | 129 |
| 129 paint.setColor(SK_ColorBLUE); | 130 paint.setColor(SK_ColorBLUE); |
| 130 canvas->drawRect(gfx::RectToSkRect(blue_rect), paint); | 131 canvas->drawRect(gfx::RectToSkRect(blue_rect), paint); |
| 131 paint.setColor(SK_ColorYELLOW); | 132 paint.setColor(SK_ColorYELLOW); |
| 132 canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint); | 133 canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint); |
| 133 | 134 |
| 134 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 135 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 135 PaintableRegion(), recorder.finishRecordingAsPicture()); | 136 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 136 display_list->Finalize(); | 137 display_list->Finalize(); |
| 137 return display_list; | 138 return display_list; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 FullRaster_SingleThread_GpuRaster) { | 234 FullRaster_SingleThread_GpuRaster) { |
| 234 RunRasterPixelTest( | 235 RunRasterPixelTest( |
| 235 false, FULL_GPU, picture_layer_, | 236 false, FULL_GPU, picture_layer_, |
| 236 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); | 237 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); |
| 237 } | 238 } |
| 238 | 239 |
| 239 } // namespace | 240 } // namespace |
| 240 } // namespace cc | 241 } // namespace cc |
| 241 | 242 |
| 242 #endif // !defined(OS_ANDROID) | 243 #endif // !defined(OS_ANDROID) |
| OLD | NEW |