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