| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "cc/layers/content_layer_client.h" | 8 #include "cc/layers/content_layer_client.h" |
| 9 #include "cc/layers/picture_image_layer.h" | 9 #include "cc/layers/picture_image_layer.h" |
| 10 #include "cc/layers/picture_layer.h" | 10 #include "cc/layers/picture_layer.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 bool FillsBoundsCompletely() const override { return false; } | 36 bool FillsBoundsCompletely() const override { return false; } |
| 37 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 37 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 38 | 38 |
| 39 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } | 39 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } |
| 40 | 40 |
| 41 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 41 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 42 PaintingControlSetting picture_control) override { | 42 PaintingControlSetting picture_control) override { |
| 43 PaintRecorder recorder; | 43 PaintRecorder recorder; |
| 44 PaintCanvas* canvas = | 44 PaintCanvas* canvas = |
| 45 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); | 45 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); |
| 46 | 46 |
| 47 PaintFlags flags; | 47 PaintFlags flags; |
| 48 flags.setStyle(PaintFlags::kStroke_Style); | 48 flags.setStyle(PaintFlags::kStroke_Style); |
| 49 flags.setStrokeWidth(SkIntToScalar(2)); | 49 flags.setStrokeWidth(SkIntToScalar(2)); |
| 50 flags.setColor(SK_ColorWHITE); | 50 flags.setColor(SK_ColorWHITE); |
| 51 | 51 |
| 52 canvas->clear(SK_ColorTRANSPARENT); | 52 canvas->clear(SK_ColorTRANSPARENT); |
| 53 gfx::Rect inset_rect(bounds_); | 53 gfx::Rect inset_rect(bounds_); |
| 54 while (!inset_rect.IsEmpty()) { | 54 while (!inset_rect.IsEmpty()) { |
| 55 inset_rect.Inset(3, 3, 2, 2); | 55 inset_rect.Inset(3, 3, 2, 2); |
| 56 canvas->drawRect( | 56 canvas->drawRect( |
| 57 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), inset_rect.width(), | 57 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), inset_rect.width(), |
| 58 inset_rect.height()), | 58 inset_rect.height()), |
| 59 flags); | 59 flags); |
| 60 inset_rect.Inset(3, 3, 2, 2); | 60 inset_rect.Inset(3, 3, 2, 2); |
| 61 } | 61 } |
| 62 | 62 |
| 63 auto display_list = make_scoped_refptr(new DisplayItemList); | 63 auto display_list = make_scoped_refptr(new DisplayItemList); |
| 64 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 64 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 65 PaintableRegion(), recorder.finishRecordingAsPicture(), | 65 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 66 gfx::RectToSkRect(PaintableRegion())); | |
| 67 | 66 |
| 68 display_list->Finalize(); | 67 display_list->Finalize(); |
| 69 return display_list; | 68 return display_list; |
| 70 } | 69 } |
| 71 | 70 |
| 72 private: | 71 private: |
| 73 gfx::Size bounds_; | 72 gfx::Size bounds_; |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { | 75 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 bool vertical) | 215 bool vertical) |
| 217 : bounds_(bounds), color_(color), vertical_(vertical) {} | 216 : bounds_(bounds), color_(color), vertical_(vertical) {} |
| 218 ~CheckerContentLayerClient() override {} | 217 ~CheckerContentLayerClient() override {} |
| 219 bool FillsBoundsCompletely() const override { return false; } | 218 bool FillsBoundsCompletely() const override { return false; } |
| 220 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 219 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 221 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } | 220 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } |
| 222 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 221 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 223 PaintingControlSetting picture_control) override { | 222 PaintingControlSetting picture_control) override { |
| 224 PaintRecorder recorder; | 223 PaintRecorder recorder; |
| 225 PaintCanvas* canvas = | 224 PaintCanvas* canvas = |
| 226 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); | 225 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); |
| 227 | 226 |
| 228 PaintFlags flags; | 227 PaintFlags flags; |
| 229 flags.setStyle(PaintFlags::kStroke_Style); | 228 flags.setStyle(PaintFlags::kStroke_Style); |
| 230 flags.setStrokeWidth(SkIntToScalar(4)); | 229 flags.setStrokeWidth(SkIntToScalar(4)); |
| 231 flags.setColor(color_); | 230 flags.setColor(color_); |
| 232 canvas->clear(SK_ColorTRANSPARENT); | 231 canvas->clear(SK_ColorTRANSPARENT); |
| 233 if (vertical_) { | 232 if (vertical_) { |
| 234 for (int i = 4; i < bounds_.width(); i += 16) { | 233 for (int i = 4; i < bounds_.width(); i += 16) { |
| 235 canvas->drawLine(i, 0, i, bounds_.height(), flags); | 234 canvas->drawLine(i, 0, i, bounds_.height(), flags); |
| 236 } | 235 } |
| 237 } else { | 236 } else { |
| 238 for (int i = 4; i < bounds_.height(); i += 16) { | 237 for (int i = 4; i < bounds_.height(); i += 16) { |
| 239 canvas->drawLine(0, i, bounds_.width(), i, flags); | 238 canvas->drawLine(0, i, bounds_.width(), i, flags); |
| 240 } | 239 } |
| 241 } | 240 } |
| 242 | 241 |
| 243 auto display_list = make_scoped_refptr(new DisplayItemList); | 242 auto display_list = make_scoped_refptr(new DisplayItemList); |
| 244 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 243 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 245 PaintableRegion(), recorder.finishRecordingAsPicture(), | 244 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 246 gfx::RectToSkRect(PaintableRegion())); | |
| 247 | 245 |
| 248 display_list->Finalize(); | 246 display_list->Finalize(); |
| 249 return display_list; | 247 return display_list; |
| 250 } | 248 } |
| 251 | 249 |
| 252 private: | 250 private: |
| 253 gfx::Size bounds_; | 251 gfx::Size bounds_; |
| 254 SkColor color_; | 252 SkColor color_; |
| 255 bool vertical_; | 253 bool vertical_; |
| 256 }; | 254 }; |
| 257 | 255 |
| 258 class CircleContentLayerClient : public ContentLayerClient { | 256 class CircleContentLayerClient : public ContentLayerClient { |
| 259 public: | 257 public: |
| 260 explicit CircleContentLayerClient(const gfx::Size& bounds) | 258 explicit CircleContentLayerClient(const gfx::Size& bounds) |
| 261 : bounds_(bounds) {} | 259 : bounds_(bounds) {} |
| 262 ~CircleContentLayerClient() override {} | 260 ~CircleContentLayerClient() override {} |
| 263 bool FillsBoundsCompletely() const override { return false; } | 261 bool FillsBoundsCompletely() const override { return false; } |
| 264 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 262 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 265 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } | 263 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } |
| 266 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 264 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 267 PaintingControlSetting picture_control) override { | 265 PaintingControlSetting picture_control) override { |
| 268 PaintRecorder recorder; | 266 PaintRecorder recorder; |
| 269 PaintCanvas* canvas = | 267 PaintCanvas* canvas = |
| 270 recorder.beginRecording(gfx::RectToSkRect(PaintableRegion())); | 268 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); |
| 271 | 269 |
| 272 PaintFlags flags; | 270 PaintFlags flags; |
| 273 flags.setStyle(PaintFlags::kFill_Style); | 271 flags.setStyle(PaintFlags::kFill_Style); |
| 274 flags.setColor(SK_ColorWHITE); | 272 flags.setColor(SK_ColorWHITE); |
| 275 canvas->clear(SK_ColorTRANSPARENT); | 273 canvas->clear(SK_ColorTRANSPARENT); |
| 276 canvas->drawCircle(bounds_.width() / 2, bounds_.height() / 2, | 274 canvas->drawCircle(bounds_.width() / 2, bounds_.height() / 2, |
| 277 bounds_.width() / 4, flags); | 275 bounds_.width() / 4, flags); |
| 278 | 276 |
| 279 auto display_list = make_scoped_refptr(new DisplayItemList); | 277 auto display_list = make_scoped_refptr(new DisplayItemList); |
| 280 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 278 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 281 PaintableRegion(), recorder.finishRecordingAsPicture(), | 279 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 282 gfx::RectToSkRect(PaintableRegion())); | |
| 283 | 280 |
| 284 display_list->Finalize(); | 281 display_list->Finalize(); |
| 285 return display_list; | 282 return display_list; |
| 286 } | 283 } |
| 287 | 284 |
| 288 private: | 285 private: |
| 289 gfx::Size bounds_; | 286 gfx::Size bounds_; |
| 290 }; | 287 }; |
| 291 | 288 |
| 292 using LayerTreeHostMasksForBackgroundFiltersPixelTest = | 289 using LayerTreeHostMasksForBackgroundFiltersPixelTest = |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 398 |
| 402 RunPixelResourceTest(background, | 399 RunPixelResourceTest(background, |
| 403 base::FilePath( | 400 base::FilePath( |
| 404 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 401 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
| 405 } | 402 } |
| 406 | 403 |
| 407 } // namespace | 404 } // namespace |
| 408 } // namespace cc | 405 } // namespace cc |
| 409 | 406 |
| 410 #endif // !defined(OS_ANDROID) | 407 #endif // !defined(OS_ANDROID) |
| OLD | NEW |