| 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 25 matching lines...) Expand all Loading... |
| 36 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 36 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 37 | 37 |
| 38 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } | 38 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } |
| 39 | 39 |
| 40 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 40 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 41 PaintingControlSetting picture_control) override { | 41 PaintingControlSetting picture_control) override { |
| 42 PaintRecorder recorder; | 42 PaintRecorder recorder; |
| 43 PaintCanvas* canvas = | 43 PaintCanvas* canvas = |
| 44 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); | 44 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); |
| 45 | 45 |
| 46 PaintFlags paint; | 46 PaintFlags flags; |
| 47 paint.setStyle(PaintFlags::kStroke_Style); | 47 flags.setStyle(PaintFlags::kStroke_Style); |
| 48 paint.setStrokeWidth(SkIntToScalar(2)); | 48 flags.setStrokeWidth(SkIntToScalar(2)); |
| 49 paint.setColor(SK_ColorWHITE); | 49 flags.setColor(SK_ColorWHITE); |
| 50 | 50 |
| 51 canvas->clear(SK_ColorTRANSPARENT); | 51 canvas->clear(SK_ColorTRANSPARENT); |
| 52 gfx::Rect inset_rect(bounds_); | 52 gfx::Rect inset_rect(bounds_); |
| 53 while (!inset_rect.IsEmpty()) { | 53 while (!inset_rect.IsEmpty()) { |
| 54 inset_rect.Inset(3, 3, 2, 2); | 54 inset_rect.Inset(3, 3, 2, 2); |
| 55 canvas->drawRect( | 55 canvas->drawRect( |
| 56 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), | 56 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), inset_rect.width(), |
| 57 inset_rect.width(), inset_rect.height()), | 57 inset_rect.height()), |
| 58 paint); | 58 flags); |
| 59 inset_rect.Inset(3, 3, 2, 2); | 59 inset_rect.Inset(3, 3, 2, 2); |
| 60 } | 60 } |
| 61 | 61 |
| 62 auto display_list = make_scoped_refptr(new DisplayItemList); | 62 auto display_list = make_scoped_refptr(new DisplayItemList); |
| 63 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 63 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 64 PaintableRegion(), recorder.finishRecordingAsPicture()); | 64 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 65 | 65 |
| 66 display_list->Finalize(); | 66 display_list->Finalize(); |
| 67 return display_list; | 67 return display_list; |
| 68 } | 68 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 ~CheckerContentLayerClient() override {} | 158 ~CheckerContentLayerClient() override {} |
| 159 bool FillsBoundsCompletely() const override { return false; } | 159 bool FillsBoundsCompletely() const override { return false; } |
| 160 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 160 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 161 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } | 161 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } |
| 162 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 162 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 163 PaintingControlSetting picture_control) override { | 163 PaintingControlSetting picture_control) override { |
| 164 PaintRecorder recorder; | 164 PaintRecorder recorder; |
| 165 PaintCanvas* canvas = | 165 PaintCanvas* canvas = |
| 166 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); | 166 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); |
| 167 | 167 |
| 168 PaintFlags paint; | 168 PaintFlags flags; |
| 169 paint.setStyle(PaintFlags::kStroke_Style); | 169 flags.setStyle(PaintFlags::kStroke_Style); |
| 170 paint.setStrokeWidth(SkIntToScalar(4)); | 170 flags.setStrokeWidth(SkIntToScalar(4)); |
| 171 paint.setColor(color_); | 171 flags.setColor(color_); |
| 172 canvas->clear(SK_ColorTRANSPARENT); | 172 canvas->clear(SK_ColorTRANSPARENT); |
| 173 if (vertical_) { | 173 if (vertical_) { |
| 174 for (int i = 4; i < bounds_.width(); i += 16) { | 174 for (int i = 4; i < bounds_.width(); i += 16) { |
| 175 canvas->drawLine(i, 0, i, bounds_.height(), paint); | 175 canvas->drawLine(i, 0, i, bounds_.height(), flags); |
| 176 } | 176 } |
| 177 } else { | 177 } else { |
| 178 for (int i = 4; i < bounds_.height(); i += 16) { | 178 for (int i = 4; i < bounds_.height(); i += 16) { |
| 179 canvas->drawLine(0, i, bounds_.width(), i, paint); | 179 canvas->drawLine(0, i, bounds_.width(), i, flags); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 auto display_list = make_scoped_refptr(new DisplayItemList); | 183 auto display_list = make_scoped_refptr(new DisplayItemList); |
| 184 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 184 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 185 PaintableRegion(), recorder.finishRecordingAsPicture()); | 185 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 186 | 186 |
| 187 display_list->Finalize(); | 187 display_list->Finalize(); |
| 188 return display_list; | 188 return display_list; |
| 189 } | 189 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 201 ~CircleContentLayerClient() override {} | 201 ~CircleContentLayerClient() override {} |
| 202 bool FillsBoundsCompletely() const override { return false; } | 202 bool FillsBoundsCompletely() const override { return false; } |
| 203 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } | 203 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } |
| 204 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } | 204 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } |
| 205 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( | 205 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 206 PaintingControlSetting picture_control) override { | 206 PaintingControlSetting picture_control) override { |
| 207 PaintRecorder recorder; | 207 PaintRecorder recorder; |
| 208 PaintCanvas* canvas = | 208 PaintCanvas* canvas = |
| 209 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); | 209 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); |
| 210 | 210 |
| 211 PaintFlags paint; | 211 PaintFlags flags; |
| 212 paint.setStyle(PaintFlags::kFill_Style); | 212 flags.setStyle(PaintFlags::kFill_Style); |
| 213 paint.setColor(SK_ColorWHITE); | 213 flags.setColor(SK_ColorWHITE); |
| 214 canvas->clear(SK_ColorTRANSPARENT); | 214 canvas->clear(SK_ColorTRANSPARENT); |
| 215 canvas->drawCircle(bounds_.width() / 2, | 215 canvas->drawCircle(bounds_.width() / 2, bounds_.height() / 2, |
| 216 bounds_.height() / 2, | 216 bounds_.width() / 4, flags); |
| 217 bounds_.width() / 4, | |
| 218 paint); | |
| 219 | 217 |
| 220 auto display_list = make_scoped_refptr(new DisplayItemList); | 218 auto display_list = make_scoped_refptr(new DisplayItemList); |
| 221 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( | 219 display_list->CreateAndAppendDrawingItem<DrawingDisplayItem>( |
| 222 PaintableRegion(), recorder.finishRecordingAsPicture()); | 220 PaintableRegion(), recorder.finishRecordingAsPicture()); |
| 223 | 221 |
| 224 display_list->Finalize(); | 222 display_list->Finalize(); |
| 225 return display_list; | 223 return display_list; |
| 226 } | 224 } |
| 227 | 225 |
| 228 private: | 226 private: |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 335 |
| 338 RunPixelResourceTest(background, | 336 RunPixelResourceTest(background, |
| 339 base::FilePath( | 337 base::FilePath( |
| 340 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 338 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
| 341 } | 339 } |
| 342 | 340 |
| 343 } // namespace | 341 } // namespace |
| 344 } // namespace cc | 342 } // namespace cc |
| 345 | 343 |
| 346 #endif // !defined(OS_ANDROID) | 344 #endif // !defined(OS_ANDROID) |
| OLD | NEW |