OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/resources/display_item_list.h" | 5 #include "cc/resources/display_item_list.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "cc/output/filter_operation.h" | 9 #include "cc/output/filter_operation.h" |
10 #include "cc/output/filter_operations.h" | 10 #include "cc/output/filter_operations.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 TEST(DisplayItemListTest, SingleDrawingItem) { | 29 TEST(DisplayItemListTest, SingleDrawingItem) { |
30 gfx::Rect layer_rect(100, 100); | 30 gfx::Rect layer_rect(100, 100); |
31 SkPictureRecorder recorder; | 31 SkPictureRecorder recorder; |
32 skia::RefPtr<SkCanvas> canvas; | 32 skia::RefPtr<SkCanvas> canvas; |
33 skia::RefPtr<SkPicture> picture; | 33 skia::RefPtr<SkPicture> picture; |
34 SkPaint blue_paint; | 34 SkPaint blue_paint; |
35 blue_paint.setColor(SK_ColorBLUE); | 35 blue_paint.setColor(SK_ColorBLUE); |
36 SkPaint red_paint; | 36 SkPaint red_paint; |
37 red_paint.setColor(SK_ColorRED); | 37 red_paint.setColor(SK_ColorRED); |
38 unsigned char pixels[4 * 100 * 100] = {0}; | 38 unsigned char pixels[4 * 100 * 100] = {0}; |
39 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 39 const bool use_cached_picture = true; |
| 40 scoped_refptr<DisplayItemList> list = |
| 41 DisplayItemList::Create(layer_rect, use_cached_picture); |
40 | 42 |
41 gfx::PointF offset(8.f, 9.f); | 43 gfx::PointF offset(8.f, 9.f); |
42 gfx::RectF recording_rect(offset, layer_rect.size()); | 44 gfx::RectF recording_rect(offset, layer_rect.size()); |
43 canvas = skia::SharePtr( | 45 canvas = skia::SharePtr( |
44 recorder.beginRecording(gfx::RectFToSkRect(recording_rect))); | 46 recorder.beginRecording(gfx::RectFToSkRect(recording_rect))); |
45 canvas->translate(offset.x(), offset.y()); | 47 canvas->translate(offset.x(), offset.y()); |
46 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); | 48 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
47 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); | 49 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
48 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 50 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
49 list->AppendItem(DrawingDisplayItem::Create(picture)); | 51 list->AppendItem(DrawingDisplayItem::Create(picture)); |
| 52 list->CreateAndCacheSkPicture(); |
50 DrawDisplayList(pixels, layer_rect, list); | 53 DrawDisplayList(pixels, layer_rect, list); |
51 | 54 |
52 SkBitmap expected_bitmap; | 55 SkBitmap expected_bitmap; |
53 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 56 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
54 SkImageInfo info = | 57 SkImageInfo info = |
55 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 58 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
56 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 59 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
57 SkCanvas expected_canvas(expected_bitmap); | 60 SkCanvas expected_canvas(expected_bitmap); |
58 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 61 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
59 expected_canvas.drawRectCoords(0.f + offset.x(), 0.f + offset.y(), | 62 expected_canvas.drawRectCoords(0.f + offset.x(), 0.f + offset.y(), |
60 60.f + offset.x(), 60.f + offset.y(), | 63 60.f + offset.x(), 60.f + offset.y(), |
61 red_paint); | 64 red_paint); |
62 expected_canvas.drawRectCoords(50.f + offset.x(), 50.f + offset.y(), | 65 expected_canvas.drawRectCoords(50.f + offset.x(), 50.f + offset.y(), |
63 75.f + offset.x(), 75.f + offset.y(), | 66 75.f + offset.x(), 75.f + offset.y(), |
64 blue_paint); | 67 blue_paint); |
65 | 68 |
66 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); | 69 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); |
67 } | 70 } |
68 | 71 |
69 TEST(DisplayItemListTest, ClipItem) { | 72 TEST(DisplayItemListTest, ClipItem) { |
70 gfx::Rect layer_rect(100, 100); | 73 gfx::Rect layer_rect(100, 100); |
71 SkPictureRecorder recorder; | 74 SkPictureRecorder recorder; |
72 skia::RefPtr<SkCanvas> canvas; | 75 skia::RefPtr<SkCanvas> canvas; |
73 skia::RefPtr<SkPicture> picture; | 76 skia::RefPtr<SkPicture> picture; |
74 SkPaint blue_paint; | 77 SkPaint blue_paint; |
75 blue_paint.setColor(SK_ColorBLUE); | 78 blue_paint.setColor(SK_ColorBLUE); |
76 SkPaint red_paint; | 79 SkPaint red_paint; |
77 red_paint.setColor(SK_ColorRED); | 80 red_paint.setColor(SK_ColorRED); |
78 unsigned char pixels[4 * 100 * 100] = {0}; | 81 unsigned char pixels[4 * 100 * 100] = {0}; |
79 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 82 const bool use_cached_picture = true; |
| 83 scoped_refptr<DisplayItemList> list = |
| 84 DisplayItemList::Create(layer_rect, use_cached_picture); |
80 | 85 |
81 gfx::PointF first_offset(8.f, 9.f); | 86 gfx::PointF first_offset(8.f, 9.f); |
82 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); | 87 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); |
83 canvas = skia::SharePtr( | 88 canvas = skia::SharePtr( |
84 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); | 89 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); |
85 canvas->translate(first_offset.x(), first_offset.y()); | 90 canvas->translate(first_offset.x(), first_offset.y()); |
86 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); | 91 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
87 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 92 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
88 list->AppendItem(DrawingDisplayItem::Create(picture)); | 93 list->AppendItem(DrawingDisplayItem::Create(picture)); |
89 | 94 |
90 gfx::Rect clip_rect(60, 60, 10, 10); | 95 gfx::Rect clip_rect(60, 60, 10, 10); |
91 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>())); | 96 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>())); |
92 | 97 |
93 gfx::PointF second_offset(2.f, 3.f); | 98 gfx::PointF second_offset(2.f, 3.f); |
94 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); | 99 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); |
95 canvas = skia::SharePtr( | 100 canvas = skia::SharePtr( |
96 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); | 101 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); |
97 canvas->translate(second_offset.x(), second_offset.y()); | 102 canvas->translate(second_offset.x(), second_offset.y()); |
98 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); | 103 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
99 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 104 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
100 list->AppendItem(DrawingDisplayItem::Create(picture)); | 105 list->AppendItem(DrawingDisplayItem::Create(picture)); |
101 | 106 |
102 list->AppendItem(EndClipDisplayItem::Create()); | 107 list->AppendItem(EndClipDisplayItem::Create()); |
| 108 list->CreateAndCacheSkPicture(); |
103 | 109 |
104 DrawDisplayList(pixels, layer_rect, list); | 110 DrawDisplayList(pixels, layer_rect, list); |
105 | 111 |
106 SkBitmap expected_bitmap; | 112 SkBitmap expected_bitmap; |
107 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 113 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
108 SkImageInfo info = | 114 SkImageInfo info = |
109 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 115 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
110 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 116 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
111 SkCanvas expected_canvas(expected_bitmap); | 117 SkCanvas expected_canvas(expected_bitmap); |
112 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 118 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
(...skipping 11 matching lines...) Expand all Loading... |
124 TEST(DisplayItemListTest, TransformItem) { | 130 TEST(DisplayItemListTest, TransformItem) { |
125 gfx::Rect layer_rect(100, 100); | 131 gfx::Rect layer_rect(100, 100); |
126 SkPictureRecorder recorder; | 132 SkPictureRecorder recorder; |
127 skia::RefPtr<SkCanvas> canvas; | 133 skia::RefPtr<SkCanvas> canvas; |
128 skia::RefPtr<SkPicture> picture; | 134 skia::RefPtr<SkPicture> picture; |
129 SkPaint blue_paint; | 135 SkPaint blue_paint; |
130 blue_paint.setColor(SK_ColorBLUE); | 136 blue_paint.setColor(SK_ColorBLUE); |
131 SkPaint red_paint; | 137 SkPaint red_paint; |
132 red_paint.setColor(SK_ColorRED); | 138 red_paint.setColor(SK_ColorRED); |
133 unsigned char pixels[4 * 100 * 100] = {0}; | 139 unsigned char pixels[4 * 100 * 100] = {0}; |
134 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 140 const bool use_cached_picture = true; |
| 141 scoped_refptr<DisplayItemList> list = |
| 142 DisplayItemList::Create(layer_rect, use_cached_picture); |
135 | 143 |
136 gfx::PointF first_offset(8.f, 9.f); | 144 gfx::PointF first_offset(8.f, 9.f); |
137 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); | 145 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); |
138 canvas = skia::SharePtr( | 146 canvas = skia::SharePtr( |
139 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); | 147 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); |
140 canvas->translate(first_offset.x(), first_offset.y()); | 148 canvas->translate(first_offset.x(), first_offset.y()); |
141 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); | 149 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
142 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 150 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
143 list->AppendItem(DrawingDisplayItem::Create(picture)); | 151 list->AppendItem(DrawingDisplayItem::Create(picture)); |
144 | 152 |
145 gfx::Transform transform; | 153 gfx::Transform transform; |
146 transform.Rotate(45.0); | 154 transform.Rotate(45.0); |
147 list->AppendItem(TransformDisplayItem::Create(transform)); | 155 list->AppendItem(TransformDisplayItem::Create(transform)); |
148 | 156 |
149 gfx::PointF second_offset(2.f, 3.f); | 157 gfx::PointF second_offset(2.f, 3.f); |
150 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); | 158 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); |
151 canvas = skia::SharePtr( | 159 canvas = skia::SharePtr( |
152 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); | 160 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); |
153 canvas->translate(second_offset.x(), second_offset.y()); | 161 canvas->translate(second_offset.x(), second_offset.y()); |
154 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); | 162 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
155 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 163 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
156 list->AppendItem(DrawingDisplayItem::Create(picture)); | 164 list->AppendItem(DrawingDisplayItem::Create(picture)); |
157 | 165 |
158 list->AppendItem(EndTransformDisplayItem::Create()); | 166 list->AppendItem(EndTransformDisplayItem::Create()); |
| 167 list->CreateAndCacheSkPicture(); |
159 | 168 |
160 DrawDisplayList(pixels, layer_rect, list); | 169 DrawDisplayList(pixels, layer_rect, list); |
161 | 170 |
162 SkBitmap expected_bitmap; | 171 SkBitmap expected_bitmap; |
163 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 172 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
164 SkImageInfo info = | 173 SkImageInfo info = |
165 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 174 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
166 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 175 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
167 SkCanvas expected_canvas(expected_bitmap); | 176 SkCanvas expected_canvas(expected_bitmap); |
168 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 177 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
169 expected_canvas.drawRectCoords(0.f + first_offset.x(), 0.f + first_offset.y(), | 178 expected_canvas.drawRectCoords(0.f + first_offset.x(), 0.f + first_offset.y(), |
170 60.f + first_offset.x(), | 179 60.f + first_offset.x(), |
171 60.f + first_offset.y(), red_paint); | 180 60.f + first_offset.y(), red_paint); |
172 expected_canvas.setMatrix(transform.matrix()); | 181 expected_canvas.setMatrix(transform.matrix()); |
173 expected_canvas.drawRectCoords( | 182 expected_canvas.drawRectCoords( |
174 50.f + second_offset.x(), 50.f + second_offset.y(), | 183 50.f + second_offset.x(), 50.f + second_offset.y(), |
175 75.f + second_offset.x(), 75.f + second_offset.y(), blue_paint); | 184 75.f + second_offset.x(), 75.f + second_offset.y(), blue_paint); |
176 | 185 |
177 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); | 186 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); |
178 } | 187 } |
179 | 188 |
180 TEST(DisplayItemList, FilterItem) { | 189 TEST(DisplayItemListTest, FilterItem) { |
181 gfx::Rect layer_rect(100, 100); | 190 gfx::Rect layer_rect(100, 100); |
182 FilterOperations filters; | 191 FilterOperations filters; |
183 unsigned char pixels[4 * 100 * 100] = {0}; | 192 unsigned char pixels[4 * 100 * 100] = {0}; |
184 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 193 const bool use_cached_picture = true; |
| 194 scoped_refptr<DisplayItemList> list = |
| 195 DisplayItemList::Create(layer_rect, use_cached_picture); |
185 | 196 |
186 SkBitmap source_bitmap; | 197 SkBitmap source_bitmap; |
187 source_bitmap.allocN32Pixels(50, 50); | 198 source_bitmap.allocN32Pixels(50, 50); |
188 SkCanvas source_canvas(source_bitmap); | 199 SkCanvas source_canvas(source_bitmap); |
189 source_canvas.clear(SkColorSetRGB(128, 128, 128)); | 200 source_canvas.clear(SkColorSetRGB(128, 128, 128)); |
190 | 201 |
191 // For most SkImageFilters, the |dst| bounds computed by computeFastBounds are | 202 // For most SkImageFilters, the |dst| bounds computed by computeFastBounds are |
192 // dependent on the provided |src| bounds. This means, for example, that | 203 // dependent on the provided |src| bounds. This means, for example, that |
193 // translating |src| results in a corresponding translation of |dst|. But this | 204 // translating |src| results in a corresponding translation of |dst|. But this |
194 // is not the case for all SkImageFilters; for some of them (e.g. | 205 // is not the case for all SkImageFilters; for some of them (e.g. |
195 // SkBitmapSource), the computation of |dst| in computeFastBounds doesn't | 206 // SkBitmapSource), the computation of |dst| in computeFastBounds doesn't |
196 // involve |src| at all. Incorrectly assuming such a relationship (e.g. by | 207 // involve |src| at all. Incorrectly assuming such a relationship (e.g. by |
197 // translating |dst| after it is computed by computeFastBounds, rather than | 208 // translating |dst| after it is computed by computeFastBounds, rather than |
198 // translating |src| before it provided to computedFastBounds) can cause | 209 // translating |src| before it provided to computedFastBounds) can cause |
199 // incorrect clipping of filter output. To test for this, we include an | 210 // incorrect clipping of filter output. To test for this, we include an |
200 // SkBitmapSource filter in |filters|. Here, |src| is |filter_bounds|, defined | 211 // SkBitmapSource filter in |filters|. Here, |src| is |filter_bounds|, defined |
201 // below. | 212 // below. |
202 skia::RefPtr<SkImageFilter> image_filter = | 213 skia::RefPtr<SkImageFilter> image_filter = |
203 skia::AdoptRef(SkBitmapSource::Create(source_bitmap)); | 214 skia::AdoptRef(SkBitmapSource::Create(source_bitmap)); |
204 filters.Append(FilterOperation::CreateReferenceFilter(image_filter)); | 215 filters.Append(FilterOperation::CreateReferenceFilter(image_filter)); |
205 filters.Append(FilterOperation::CreateBrightnessFilter(0.5f)); | 216 filters.Append(FilterOperation::CreateBrightnessFilter(0.5f)); |
206 gfx::RectF filter_bounds(10.f, 10.f, 50.f, 50.f); | 217 gfx::RectF filter_bounds(10.f, 10.f, 50.f, 50.f); |
207 list->AppendItem(FilterDisplayItem::Create(filters, filter_bounds)); | 218 list->AppendItem(FilterDisplayItem::Create(filters, filter_bounds)); |
208 list->AppendItem(EndFilterDisplayItem::Create()); | 219 list->AppendItem(EndFilterDisplayItem::Create()); |
| 220 list->CreateAndCacheSkPicture(); |
209 | 221 |
210 DrawDisplayList(pixels, layer_rect, list); | 222 DrawDisplayList(pixels, layer_rect, list); |
211 | 223 |
212 SkBitmap expected_bitmap; | 224 SkBitmap expected_bitmap; |
213 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 225 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
214 SkPaint paint; | 226 SkPaint paint; |
215 paint.setColor(SkColorSetRGB(64, 64, 64)); | 227 paint.setColor(SkColorSetRGB(64, 64, 64)); |
216 SkImageInfo info = | 228 SkImageInfo info = |
217 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 229 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
218 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 230 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
(...skipping 10 matching lines...) Expand all Loading... |
229 skia::RefPtr<SkPicture> picture; | 241 skia::RefPtr<SkPicture> picture; |
230 SkPaint blue_paint; | 242 SkPaint blue_paint; |
231 blue_paint.setColor(SK_ColorBLUE); | 243 blue_paint.setColor(SK_ColorBLUE); |
232 SkPaint red_paint; | 244 SkPaint red_paint; |
233 red_paint.setColor(SK_ColorRED); | 245 red_paint.setColor(SK_ColorRED); |
234 unsigned char pixels[4 * 100 * 100] = {0}; | 246 unsigned char pixels[4 * 100 * 100] = {0}; |
235 | 247 |
236 gfx::PointF offset(8.f, 9.f); | 248 gfx::PointF offset(8.f, 9.f); |
237 gfx::RectF recording_rect(offset, layer_rect.size()); | 249 gfx::RectF recording_rect(offset, layer_rect.size()); |
238 | 250 |
239 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 251 bool use_cached_picture = false; |
240 list->set_layer_rect(ToEnclosingRect(recording_rect)); | 252 scoped_refptr<DisplayItemList> list_without_caching = |
| 253 DisplayItemList::Create(layer_rect, use_cached_picture); |
241 | 254 |
242 canvas = skia::SharePtr( | 255 canvas = skia::SharePtr( |
243 recorder.beginRecording(gfx::RectFToSkRect(recording_rect))); | 256 recorder.beginRecording(gfx::RectFToSkRect(recording_rect))); |
244 canvas->translate(offset.x(), offset.y()); | 257 canvas->translate(offset.x(), offset.y()); |
245 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); | 258 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
246 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); | 259 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
247 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); | 260 picture = skia::AdoptRef(recorder.endRecordingAsPicture()); |
248 list->AppendItem(DrawingDisplayItem::Create(picture)); | 261 list_without_caching->AppendItem(DrawingDisplayItem::Create(picture)); |
249 DrawDisplayList(pixels, layer_rect, list); | 262 DrawDisplayList(pixels, layer_rect, list_without_caching); |
250 | |
251 list->CreateAndCacheSkPicture(); | |
252 | 263 |
253 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 264 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
254 DrawDisplayList(expected_pixels, layer_rect, list); | 265 use_cached_picture = true; |
| 266 scoped_refptr<DisplayItemList> list_with_caching = |
| 267 DisplayItemList::Create(layer_rect, use_cached_picture); |
| 268 list_with_caching->AppendItem(DrawingDisplayItem::Create(picture)); |
| 269 list_with_caching->CreateAndCacheSkPicture(); |
| 270 DrawDisplayList(expected_pixels, layer_rect, list_with_caching); |
255 | 271 |
256 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); | 272 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); |
257 } | 273 } |
258 | 274 |
259 } // namespace | 275 } // namespace |
260 } // namespace cc | 276 } // namespace cc |
OLD | NEW |