Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: cc/resources/display_item_list_unittest.cc

Issue 952893003: Update from https://crrev.com/317530 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix gn for nacl Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/quads/yuv_video_draw_quad.h ('k') | cc/resources/display_list_raster_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)));
44 canvas->translate(offset.x(), offset.y());
42 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); 45 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); 46 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
44 picture = skia::AdoptRef(recorder.endRecording()); 47 picture = skia::AdoptRef(recorder.endRecording());
45 gfx::PointF offset(8.f, 9.f); 48 list->AppendItem(DrawingDisplayItem::Create(picture));
46 list->AppendItem(DrawingDisplayItem::Create(picture, offset));
47 DrawDisplayList(pixels, layer_rect, list); 49 DrawDisplayList(pixels, layer_rect, list);
48 50
49 SkBitmap expected_bitmap; 51 SkBitmap expected_bitmap;
50 unsigned char expected_pixels[4 * 100 * 100] = {0}; 52 unsigned char expected_pixels[4 * 100 * 100] = {0};
51 SkImageInfo info = 53 SkImageInfo info =
52 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 54 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
53 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); 55 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes());
54 SkCanvas expected_canvas(expected_bitmap); 56 SkCanvas expected_canvas(expected_bitmap);
55 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); 57 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect));
56 expected_canvas.drawRectCoords(0.f + offset.x(), 0.f + offset.y(), 58 expected_canvas.drawRectCoords(0.f + offset.x(), 0.f + offset.y(),
(...skipping 11 matching lines...) Expand all
68 SkPictureRecorder recorder; 70 SkPictureRecorder recorder;
69 skia::RefPtr<SkCanvas> canvas; 71 skia::RefPtr<SkCanvas> canvas;
70 skia::RefPtr<SkPicture> picture; 72 skia::RefPtr<SkPicture> picture;
71 SkPaint blue_paint; 73 SkPaint blue_paint;
72 blue_paint.setColor(SK_ColorBLUE); 74 blue_paint.setColor(SK_ColorBLUE);
73 SkPaint red_paint; 75 SkPaint red_paint;
74 red_paint.setColor(SK_ColorRED); 76 red_paint.setColor(SK_ColorRED);
75 unsigned char pixels[4 * 100 * 100] = {0}; 77 unsigned char pixels[4 * 100 * 100] = {0};
76 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); 78 scoped_refptr<DisplayItemList> list = DisplayItemList::Create();
77 79
80 gfx::PointF first_offset(8.f, 9.f);
81 gfx::RectF first_recording_rect(first_offset, layer_rect.size());
78 canvas = skia::SharePtr( 82 canvas = skia::SharePtr(
79 recorder.beginRecording(layer_rect.width(), layer_rect.height())); 83 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)));
84 canvas->translate(first_offset.x(), first_offset.y());
80 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); 85 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
81 picture = skia::AdoptRef(recorder.endRecording()); 86 picture = skia::AdoptRef(recorder.endRecording());
82 gfx::PointF first_offset(8.f, 9.f); 87 list->AppendItem(DrawingDisplayItem::Create(picture));
83 list->AppendItem(DrawingDisplayItem::Create(picture, first_offset));
84 88
85 gfx::Rect clip_rect(60, 60, 10, 10); 89 gfx::Rect clip_rect(60, 60, 10, 10);
86 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>())); 90 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>()));
87 91
92 gfx::PointF second_offset(2.f, 3.f);
93 gfx::RectF second_recording_rect(second_offset, layer_rect.size());
88 canvas = skia::SharePtr( 94 canvas = skia::SharePtr(
89 recorder.beginRecording(layer_rect.width(), layer_rect.height())); 95 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)));
96 canvas->translate(second_offset.x(), second_offset.y());
90 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); 97 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
91 picture = skia::AdoptRef(recorder.endRecording()); 98 picture = skia::AdoptRef(recorder.endRecording());
92 gfx::PointF second_offset(2.f, 3.f); 99 list->AppendItem(DrawingDisplayItem::Create(picture));
93 list->AppendItem(DrawingDisplayItem::Create(picture, second_offset));
94 100
95 list->AppendItem(EndClipDisplayItem::Create()); 101 list->AppendItem(EndClipDisplayItem::Create());
96 102
97 DrawDisplayList(pixels, layer_rect, list); 103 DrawDisplayList(pixels, layer_rect, list);
98 104
99 SkBitmap expected_bitmap; 105 SkBitmap expected_bitmap;
100 unsigned char expected_pixels[4 * 100 * 100] = {0}; 106 unsigned char expected_pixels[4 * 100 * 100] = {0};
101 SkImageInfo info = 107 SkImageInfo info =
102 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 108 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
103 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); 109 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes());
(...skipping 15 matching lines...) Expand all
119 SkPictureRecorder recorder; 125 SkPictureRecorder recorder;
120 skia::RefPtr<SkCanvas> canvas; 126 skia::RefPtr<SkCanvas> canvas;
121 skia::RefPtr<SkPicture> picture; 127 skia::RefPtr<SkPicture> picture;
122 SkPaint blue_paint; 128 SkPaint blue_paint;
123 blue_paint.setColor(SK_ColorBLUE); 129 blue_paint.setColor(SK_ColorBLUE);
124 SkPaint red_paint; 130 SkPaint red_paint;
125 red_paint.setColor(SK_ColorRED); 131 red_paint.setColor(SK_ColorRED);
126 unsigned char pixels[4 * 100 * 100] = {0}; 132 unsigned char pixels[4 * 100 * 100] = {0};
127 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); 133 scoped_refptr<DisplayItemList> list = DisplayItemList::Create();
128 134
135 gfx::PointF first_offset(8.f, 9.f);
136 gfx::RectF first_recording_rect(first_offset, layer_rect.size());
129 canvas = skia::SharePtr( 137 canvas = skia::SharePtr(
130 recorder.beginRecording(layer_rect.width(), layer_rect.height())); 138 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)));
139 canvas->translate(first_offset.x(), first_offset.y());
131 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint); 140 canvas->drawRectCoords(0.f, 0.f, 60.f, 60.f, red_paint);
132 picture = skia::AdoptRef(recorder.endRecording()); 141 picture = skia::AdoptRef(recorder.endRecording());
133 gfx::PointF first_offset(8.f, 9.f); 142 list->AppendItem(DrawingDisplayItem::Create(picture));
134 list->AppendItem(DrawingDisplayItem::Create(picture, first_offset));
135 143
136 gfx::Transform transform; 144 gfx::Transform transform;
137 transform.Rotate(45.0); 145 transform.Rotate(45.0);
138 list->AppendItem(TransformDisplayItem::Create(transform)); 146 list->AppendItem(TransformDisplayItem::Create(transform));
139 147
148 gfx::PointF second_offset(2.f, 3.f);
149 gfx::RectF second_recording_rect(second_offset, layer_rect.size());
140 canvas = skia::SharePtr( 150 canvas = skia::SharePtr(
141 recorder.beginRecording(layer_rect.width(), layer_rect.height())); 151 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)));
152 canvas->translate(second_offset.x(), second_offset.y());
142 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint); 153 canvas->drawRectCoords(50.f, 50.f, 75.f, 75.f, blue_paint);
143 picture = skia::AdoptRef(recorder.endRecording()); 154 picture = skia::AdoptRef(recorder.endRecording());
144 gfx::PointF second_offset(2.f, 3.f); 155 list->AppendItem(DrawingDisplayItem::Create(picture));
145 list->AppendItem(DrawingDisplayItem::Create(picture, second_offset));
146 156
147 list->AppendItem(EndTransformDisplayItem::Create()); 157 list->AppendItem(EndTransformDisplayItem::Create());
148 158
149 DrawDisplayList(pixels, layer_rect, list); 159 DrawDisplayList(pixels, layer_rect, list);
150 160
151 SkBitmap expected_bitmap; 161 SkBitmap expected_bitmap;
152 unsigned char expected_pixels[4 * 100 * 100] = {0}; 162 unsigned char expected_pixels[4 * 100 * 100] = {0};
153 SkImageInfo info = 163 SkImageInfo info =
154 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 164 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
155 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); 165 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 216 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
207 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); 217 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes());
208 SkCanvas expected_canvas(expected_bitmap); 218 SkCanvas expected_canvas(expected_bitmap);
209 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint); 219 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint);
210 220
211 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); 221 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100));
212 } 222 }
213 223
214 } // namespace 224 } // namespace
215 } // namespace cc 225 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/yuv_video_draw_quad.h ('k') | cc/resources/display_list_raster_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698