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