OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/fake_content_layer_client.h" | 5 #include "cc/test/fake_content_layer_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/playback/clip_display_item.h" | 9 #include "cc/playback/clip_display_item.h" |
10 #include "cc/playback/display_item_list_settings.h" | 10 #include "cc/playback/display_item_list_settings.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 : image(skia::SharePtr(img)), transform(transform), paint(paint) {} | 28 : image(skia::SharePtr(img)), transform(transform), paint(paint) {} |
29 | 29 |
30 FakeContentLayerClient::ImageData::~ImageData() {} | 30 FakeContentLayerClient::ImageData::~ImageData() {} |
31 | 31 |
32 FakeContentLayerClient::FakeContentLayerClient() | 32 FakeContentLayerClient::FakeContentLayerClient() |
33 : display_list_use_cached_picture_(true), | 33 : display_list_use_cached_picture_(true), |
34 fill_with_nonsolid_color_(false), | 34 fill_with_nonsolid_color_(false), |
35 last_canvas_(nullptr), | 35 last_canvas_(nullptr), |
36 last_painting_control_(PAINTING_BEHAVIOR_NORMAL), | 36 last_painting_control_(PAINTING_BEHAVIOR_NORMAL), |
37 reported_memory_usage_(0), | 37 reported_memory_usage_(0), |
38 bounds_set_(false) {} | 38 bounds_set_(false), |
| 39 delegate_(nullptr) {} |
39 | 40 |
40 FakeContentLayerClient::~FakeContentLayerClient() { | 41 FakeContentLayerClient::~FakeContentLayerClient() { |
41 } | 42 } |
42 | 43 |
43 gfx::Rect FakeContentLayerClient::PaintableRegion() { | 44 gfx::Rect FakeContentLayerClient::PaintableRegion() { |
44 CHECK(bounds_set_); | 45 CHECK(bounds_set_); |
45 return gfx::Rect(bounds_); | 46 return gfx::Rect(bounds_); |
46 } | 47 } |
47 | 48 |
48 scoped_refptr<DisplayItemList> | 49 scoped_refptr<DisplayItemList> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); | 96 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE); |
96 canvas = | 97 canvas = |
97 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); | 98 skia::SharePtr(recorder.beginRecording(gfx::RectToSkRect(draw_rect))); |
98 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); | 99 canvas->drawIRect(gfx::RectToSkIRect(draw_rect), paint); |
99 display_list->CreateAndAppendItem<DrawingDisplayItem>( | 100 display_list->CreateAndAppendItem<DrawingDisplayItem>( |
100 draw_rect, skia::AdoptRef(recorder.endRecordingAsPicture())); | 101 draw_rect, skia::AdoptRef(recorder.endRecordingAsPicture())); |
101 draw_rect.Inset(1, 1); | 102 draw_rect.Inset(1, 1); |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
| 106 if (delegate_) { |
| 107 canvas = |
| 108 skia::SharePtr(recorder.beginRecording( |
| 109 gfx::RectToSkRect(PaintableRegion()))); |
| 110 delegate_->OnPaint(canvas.get(), PaintableRegion()); |
| 111 display_list->CreateAndAppendItem<DrawingDisplayItem>( |
| 112 PaintableRegion(), skia::AdoptRef(recorder.endRecordingAsPicture())); |
| 113 } |
105 | 114 |
106 display_list->Finalize(); | 115 display_list->Finalize(); |
107 return display_list; | 116 return display_list; |
108 } | 117 } |
109 | 118 |
110 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 119 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
111 | 120 |
112 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { | 121 size_t FakeContentLayerClient::GetApproximateUnsharedMemoryUsage() const { |
113 return reported_memory_usage_; | 122 return reported_memory_usage_; |
114 } | 123 } |
115 | 124 |
116 } // namespace cc | 125 } // namespace cc |
OLD | NEW |