| 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 19 matching lines...) Expand all Loading... |
| 30 SkPictureRecorder recorder; | 30 SkPictureRecorder recorder; |
| 31 skia::RefPtr<SkCanvas> canvas; | 31 skia::RefPtr<SkCanvas> canvas; |
| 32 skia::RefPtr<SkPicture> picture; | 32 skia::RefPtr<SkPicture> picture; |
| 33 SkPaint blue_paint; | 33 SkPaint blue_paint; |
| 34 blue_paint.setColor(SK_ColorBLUE); | 34 blue_paint.setColor(SK_ColorBLUE); |
| 35 SkPaint red_paint; | 35 SkPaint red_paint; |
| 36 red_paint.setColor(SK_ColorRED); | 36 red_paint.setColor(SK_ColorRED); |
| 37 unsigned char pixels[4 * 100 * 100] = {0}; | 37 unsigned char pixels[4 * 100 * 100] = {0}; |
| 38 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 38 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); |
| 39 | 39 |
| 40 gfx::PointF offset(8.f, 9.f); |
| 41 gfx::RectF recording_rect(offset, layer_rect.size()); |
| 40 canvas = skia::SharePtr( | 42 canvas = skia::SharePtr( |
| 41 recorder.beginRecording(layer_rect.width(), layer_rect.height())); | 43 recorder.beginRecording(gfx::RectFToSkRect(recording_rect))); |
| 42 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); | 44 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
| 43 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); | 45 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
| 44 picture = skia::AdoptRef(recorder.endRecording()); | 46 picture = skia::AdoptRef(recorder.endRecording()); |
| 45 gfx::PointF offset(8.f, 9.f); | 47 list->AppendItem(DrawingDisplayItem::Create(picture)); |
| 46 list->AppendItem(DrawingDisplayItem::Create(picture, offset)); | |
| 47 DrawDisplayList(pixels, layer_rect, list); | 48 DrawDisplayList(pixels, layer_rect, list); |
| 48 | 49 |
| 49 SkBitmap expected_bitmap; | 50 SkBitmap expected_bitmap; |
| 50 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 51 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| 51 SkImageInfo info = | 52 SkImageInfo info = |
| 52 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 53 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 53 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 54 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| 54 SkCanvas expected_canvas(expected_bitmap); | 55 SkCanvas expected_canvas(expected_bitmap); |
| 55 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); | 56 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); |
| 56 expected_canvas.drawRectCoords(0.f + offset.x(), 0.f + offset.y(), | 57 expected_canvas.drawRectCoords(0.f + offset.x(), 0.f + offset.y(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 68 SkPictureRecorder recorder; | 69 SkPictureRecorder recorder; |
| 69 skia::RefPtr<SkCanvas> canvas; | 70 skia::RefPtr<SkCanvas> canvas; |
| 70 skia::RefPtr<SkPicture> picture; | 71 skia::RefPtr<SkPicture> picture; |
| 71 SkPaint blue_paint; | 72 SkPaint blue_paint; |
| 72 blue_paint.setColor(SK_ColorBLUE); | 73 blue_paint.setColor(SK_ColorBLUE); |
| 73 SkPaint red_paint; | 74 SkPaint red_paint; |
| 74 red_paint.setColor(SK_ColorRED); | 75 red_paint.setColor(SK_ColorRED); |
| 75 unsigned char pixels[4 * 100 * 100] = {0}; | 76 unsigned char pixels[4 * 100 * 100] = {0}; |
| 76 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 77 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); |
| 77 | 78 |
| 79 gfx::PointF first_offset(8.f, 9.f); |
| 80 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); |
| 78 canvas = skia::SharePtr( | 81 canvas = skia::SharePtr( |
| 79 recorder.beginRecording(layer_rect.width(), layer_rect.height())); | 82 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); |
| 80 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); | 83 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
| 81 picture = skia::AdoptRef(recorder.endRecording()); | 84 picture = skia::AdoptRef(recorder.endRecording()); |
| 82 gfx::PointF first_offset(8.f, 9.f); | 85 list->AppendItem(DrawingDisplayItem::Create(picture)); |
| 83 list->AppendItem(DrawingDisplayItem::Create(picture, first_offset)); | |
| 84 | 86 |
| 85 gfx::Rect clip_rect(60, 60, 10, 10); | 87 gfx::Rect clip_rect(60, 60, 10, 10); |
| 86 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>())); | 88 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>())); |
| 87 | 89 |
| 90 gfx::PointF second_offset(2.f, 3.f); |
| 91 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); |
| 88 canvas = skia::SharePtr( | 92 canvas = skia::SharePtr( |
| 89 recorder.beginRecording(layer_rect.width(), layer_rect.height())); | 93 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); |
| 90 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); | 94 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
| 91 picture = skia::AdoptRef(recorder.endRecording()); | 95 picture = skia::AdoptRef(recorder.endRecording()); |
| 92 gfx::PointF second_offset(2.f, 3.f); | 96 list->AppendItem(DrawingDisplayItem::Create(picture)); |
| 93 list->AppendItem(DrawingDisplayItem::Create(picture, second_offset)); | |
| 94 | 97 |
| 95 list->AppendItem(EndClipDisplayItem::Create()); | 98 list->AppendItem(EndClipDisplayItem::Create()); |
| 96 | 99 |
| 97 DrawDisplayList(pixels, layer_rect, list); | 100 DrawDisplayList(pixels, layer_rect, list); |
| 98 | 101 |
| 99 SkBitmap expected_bitmap; | 102 SkBitmap expected_bitmap; |
| 100 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 103 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| 101 SkImageInfo info = | 104 SkImageInfo info = |
| 102 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 105 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 103 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 106 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 119 SkPictureRecorder recorder; | 122 SkPictureRecorder recorder; |
| 120 skia::RefPtr<SkCanvas> canvas; | 123 skia::RefPtr<SkCanvas> canvas; |
| 121 skia::RefPtr<SkPicture> picture; | 124 skia::RefPtr<SkPicture> picture; |
| 122 SkPaint blue_paint; | 125 SkPaint blue_paint; |
| 123 blue_paint.setColor(SK_ColorBLUE); | 126 blue_paint.setColor(SK_ColorBLUE); |
| 124 SkPaint red_paint; | 127 SkPaint red_paint; |
| 125 red_paint.setColor(SK_ColorRED); | 128 red_paint.setColor(SK_ColorRED); |
| 126 unsigned char pixels[4 * 100 * 100] = {0}; | 129 unsigned char pixels[4 * 100 * 100] = {0}; |
| 127 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); | 130 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); |
| 128 | 131 |
| 132 gfx::PointF first_offset(8.f, 9.f); |
| 133 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); |
| 129 canvas = skia::SharePtr( | 134 canvas = skia::SharePtr( |
| 130 recorder.beginRecording(layer_rect.width(), layer_rect.height())); | 135 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); |
| 131 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); | 136 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); |
| 132 picture = skia::AdoptRef(recorder.endRecording()); | 137 picture = skia::AdoptRef(recorder.endRecording()); |
| 133 gfx::PointF first_offset(8.f, 9.f); | 138 list->AppendItem(DrawingDisplayItem::Create(picture)); |
| 134 list->AppendItem(DrawingDisplayItem::Create(picture, first_offset)); | |
| 135 | 139 |
| 136 gfx::Transform transform; | 140 gfx::Transform transform; |
| 137 transform.Rotate(45.0); | 141 transform.Rotate(45.0); |
| 138 list->AppendItem(TransformDisplayItem::Create(transform)); | 142 list->AppendItem(TransformDisplayItem::Create(transform)); |
| 139 | 143 |
| 144 gfx::PointF second_offset(2.f, 3.f); |
| 145 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); |
| 140 canvas = skia::SharePtr( | 146 canvas = skia::SharePtr( |
| 141 recorder.beginRecording(layer_rect.width(), layer_rect.height())); | 147 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); |
| 142 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); | 148 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); |
| 143 picture = skia::AdoptRef(recorder.endRecording()); | 149 picture = skia::AdoptRef(recorder.endRecording()); |
| 144 gfx::PointF second_offset(2.f, 3.f); | 150 list->AppendItem(DrawingDisplayItem::Create(picture)); |
| 145 list->AppendItem(DrawingDisplayItem::Create(picture, second_offset)); | |
| 146 | 151 |
| 147 list->AppendItem(EndTransformDisplayItem::Create()); | 152 list->AppendItem(EndTransformDisplayItem::Create()); |
| 148 | 153 |
| 149 DrawDisplayList(pixels, layer_rect, list); | 154 DrawDisplayList(pixels, layer_rect, list); |
| 150 | 155 |
| 151 SkBitmap expected_bitmap; | 156 SkBitmap expected_bitmap; |
| 152 unsigned char expected_pixels[4 * 100 * 100] = {0}; | 157 unsigned char expected_pixels[4 * 100 * 100] = {0}; |
| 153 SkImageInfo info = | 158 SkImageInfo info = |
| 154 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 159 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 155 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 160 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); | 211 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); |
| 207 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); | 212 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); |
| 208 SkCanvas expected_canvas(expected_bitmap); | 213 SkCanvas expected_canvas(expected_bitmap); |
| 209 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint); | 214 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint); |
| 210 | 215 |
| 211 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); | 216 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); |
| 212 } | 217 } |
| 213 | 218 |
| 214 } // namespace | 219 } // namespace |
| 215 } // namespace cc | 220 } // namespace cc |
| OLD | NEW |