| 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 "cc/layers/content_layer_client.h" | 5 #include "cc/layers/content_layer_client.h" |
| 6 #include "cc/layers/picture_layer.h" | 6 #include "cc/layers/picture_layer.h" |
| 7 #include "cc/output/copy_output_request.h" | 7 #include "cc/output/copy_output_request.h" |
| 8 #include "cc/playback/display_item_list.h" | 8 #include "cc/playback/display_item_list.h" |
| 9 #include "cc/playback/display_item_list_settings.h" | 9 #include "cc/playback/display_item_list_settings.h" |
| 10 #include "cc/playback/drawing_display_item.h" | 10 #include "cc/playback/drawing_display_item.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 RasterMode raster_mode_; | 100 RasterMode raster_mode_; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 class BlueYellowClient : public ContentLayerClient { | 103 class BlueYellowClient : public ContentLayerClient { |
| 104 public: | 104 public: |
| 105 explicit BlueYellowClient(const gfx::Size& size) | 105 explicit BlueYellowClient(const gfx::Size& size) |
| 106 : size_(size), blue_top_(true) {} | 106 : size_(size), blue_top_(true) {} |
| 107 | 107 |
| 108 gfx::Rect PaintableRegion() override { return gfx::Rect(size_); } | 108 gfx::Rect PaintableRegion() override { return gfx::Rect(size_); } |
| 109 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 109 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 110 const gfx::Rect& clip, | |
| 111 PaintingControlSetting painting_status) override { | 110 PaintingControlSetting painting_status) override { |
| 112 DisplayItemListSettings settings; | 111 DisplayItemListSettings settings; |
| 113 settings.use_cached_picture = false; | 112 settings.use_cached_picture = false; |
| 114 scoped_refptr<DisplayItemList> display_list = | 113 scoped_refptr<DisplayItemList> display_list = |
| 115 DisplayItemList::Create(clip, settings); | 114 DisplayItemList::Create(PaintableRegion(), settings); |
| 116 | 115 |
| 117 SkPictureRecorder recorder; | 116 SkPictureRecorder recorder; |
| 118 skia::RefPtr<SkCanvas> canvas = skia::SharePtr( | 117 skia::RefPtr<SkCanvas> canvas = skia::SharePtr( |
| 119 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(size_)))); | 118 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(size_)))); |
| 120 gfx::Rect top(0, 0, size_.width(), size_.height() / 2); | 119 gfx::Rect top(0, 0, size_.width(), size_.height() / 2); |
| 121 gfx::Rect bottom(0, size_.height() / 2, size_.width(), size_.height() / 2); | 120 gfx::Rect bottom(0, size_.height() / 2, size_.width(), size_.height() / 2); |
| 122 | 121 |
| 123 gfx::Rect blue_rect = blue_top_ ? top : bottom; | 122 gfx::Rect blue_rect = blue_top_ ? top : bottom; |
| 124 gfx::Rect yellow_rect = blue_top_ ? bottom : top; | 123 gfx::Rect yellow_rect = blue_top_ ? bottom : top; |
| 125 | 124 |
| 126 SkPaint paint; | 125 SkPaint paint; |
| 127 paint.setStyle(SkPaint::kFill_Style); | 126 paint.setStyle(SkPaint::kFill_Style); |
| 128 | 127 |
| 129 paint.setColor(SK_ColorBLUE); | 128 paint.setColor(SK_ColorBLUE); |
| 130 canvas->drawRect(gfx::RectToSkRect(blue_rect), paint); | 129 canvas->drawRect(gfx::RectToSkRect(blue_rect), paint); |
| 131 paint.setColor(SK_ColorYELLOW); | 130 paint.setColor(SK_ColorYELLOW); |
| 132 canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint); | 131 canvas->drawRect(gfx::RectToSkRect(yellow_rect), paint); |
| 133 | 132 |
| 134 skia::RefPtr<SkPicture> picture = | 133 skia::RefPtr<SkPicture> picture = |
| 135 skia::AdoptRef(recorder.endRecordingAsPicture()); | 134 skia::AdoptRef(recorder.endRecordingAsPicture()); |
| 136 | 135 |
| 137 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>(clip); | 136 auto* item = display_list->CreateAndAppendItem<DrawingDisplayItem>( |
| 137 PaintableRegion()); |
| 138 item->SetNew(std::move(picture)); | 138 item->SetNew(std::move(picture)); |
| 139 | 139 |
| 140 display_list->Finalize(); | 140 display_list->Finalize(); |
| 141 return display_list; | 141 return display_list; |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool FillsBoundsCompletely() const override { return true; } | 144 bool FillsBoundsCompletely() const override { return true; } |
| 145 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 145 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 146 | 146 |
| 147 void set_blue_top(bool b) { blue_top_ = b; } | 147 void set_blue_top(bool b) { blue_top_ = b; } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 FullRaster_SingleThread_GpuRaster) { | 237 FullRaster_SingleThread_GpuRaster) { |
| 238 RunRasterPixelTest( | 238 RunRasterPixelTest( |
| 239 false, FULL_GPU, picture_layer_, | 239 false, FULL_GPU, picture_layer_, |
| 240 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); | 240 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace | 243 } // namespace |
| 244 } // namespace cc | 244 } // namespace cc |
| 245 | 245 |
| 246 #endif // !defined(OS_ANDROID) | 246 #endif // !defined(OS_ANDROID) |
| OLD | NEW |