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

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

Issue 1066273002: Use SkPictureRecorder::endRecordingAsPicture() instead of endRecording() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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/resources/display_item_list.cc ('k') | cc/resources/display_list_raster_source.cc » ('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 26 matching lines...) Expand all
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); 40 gfx::PointF offset(8.f, 9.f);
41 gfx::RectF recording_rect(offset, layer_rect.size()); 41 gfx::RectF recording_rect(offset, layer_rect.size());
42 canvas = skia::SharePtr( 42 canvas = skia::SharePtr(
43 recorder.beginRecording(gfx::RectFToSkRect(recording_rect))); 43 recorder.beginRecording(gfx::RectFToSkRect(recording_rect)));
44 canvas->translate(offset.x(), offset.y()); 44 canvas->translate(offset.x(), offset.y());
45 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);
46 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);
47 picture = skia::AdoptRef(recorder.endRecording()); 47 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
48 list->AppendItem(DrawingDisplayItem::Create(picture)); 48 list->AppendItem(DrawingDisplayItem::Create(picture));
49 DrawDisplayList(pixels, layer_rect, list); 49 DrawDisplayList(pixels, layer_rect, list);
50 50
51 SkBitmap expected_bitmap; 51 SkBitmap expected_bitmap;
52 unsigned char expected_pixels[4 * 100 * 100] = {0}; 52 unsigned char expected_pixels[4 * 100 * 100] = {0};
53 SkImageInfo info = 53 SkImageInfo info =
54 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 54 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
55 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); 55 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes());
56 SkCanvas expected_canvas(expected_bitmap); 56 SkCanvas expected_canvas(expected_bitmap);
57 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect)); 57 expected_canvas.clipRect(gfx::RectToSkRect(layer_rect));
(...skipping 18 matching lines...) Expand all
76 red_paint.setColor(SK_ColorRED); 76 red_paint.setColor(SK_ColorRED);
77 unsigned char pixels[4 * 100 * 100] = {0}; 77 unsigned char pixels[4 * 100 * 100] = {0};
78 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); 78 scoped_refptr<DisplayItemList> list = DisplayItemList::Create();
79 79
80 gfx::PointF first_offset(8.f, 9.f); 80 gfx::PointF first_offset(8.f, 9.f);
81 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); 81 gfx::RectF first_recording_rect(first_offset, layer_rect.size());
82 canvas = skia::SharePtr( 82 canvas = skia::SharePtr(
83 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); 83 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)));
84 canvas->translate(first_offset.x(), first_offset.y()); 84 canvas->translate(first_offset.x(), first_offset.y());
85 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);
86 picture = skia::AdoptRef(recorder.endRecording()); 86 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
87 list->AppendItem(DrawingDisplayItem::Create(picture)); 87 list->AppendItem(DrawingDisplayItem::Create(picture));
88 88
89 gfx::Rect clip_rect(60, 60, 10, 10); 89 gfx::Rect clip_rect(60, 60, 10, 10);
90 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>())); 90 list->AppendItem(ClipDisplayItem::Create(clip_rect, std::vector<SkRRect>()));
91 91
92 gfx::PointF second_offset(2.f, 3.f); 92 gfx::PointF second_offset(2.f, 3.f);
93 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); 93 gfx::RectF second_recording_rect(second_offset, layer_rect.size());
94 canvas = skia::SharePtr( 94 canvas = skia::SharePtr(
95 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); 95 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)));
96 canvas->translate(second_offset.x(), second_offset.y()); 96 canvas->translate(second_offset.x(), second_offset.y());
97 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);
98 picture = skia::AdoptRef(recorder.endRecording()); 98 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
99 list->AppendItem(DrawingDisplayItem::Create(picture)); 99 list->AppendItem(DrawingDisplayItem::Create(picture));
100 100
101 list->AppendItem(EndClipDisplayItem::Create()); 101 list->AppendItem(EndClipDisplayItem::Create());
102 102
103 DrawDisplayList(pixels, layer_rect, list); 103 DrawDisplayList(pixels, layer_rect, list);
104 104
105 SkBitmap expected_bitmap; 105 SkBitmap expected_bitmap;
106 unsigned char expected_pixels[4 * 100 * 100] = {0}; 106 unsigned char expected_pixels[4 * 100 * 100] = {0};
107 SkImageInfo info = 107 SkImageInfo info =
108 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 108 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
(...skipping 22 matching lines...) Expand all
131 red_paint.setColor(SK_ColorRED); 131 red_paint.setColor(SK_ColorRED);
132 unsigned char pixels[4 * 100 * 100] = {0}; 132 unsigned char pixels[4 * 100 * 100] = {0};
133 scoped_refptr<DisplayItemList> list = DisplayItemList::Create(); 133 scoped_refptr<DisplayItemList> list = DisplayItemList::Create();
134 134
135 gfx::PointF first_offset(8.f, 9.f); 135 gfx::PointF first_offset(8.f, 9.f);
136 gfx::RectF first_recording_rect(first_offset, layer_rect.size()); 136 gfx::RectF first_recording_rect(first_offset, layer_rect.size());
137 canvas = skia::SharePtr( 137 canvas = skia::SharePtr(
138 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect))); 138 recorder.beginRecording(gfx::RectFToSkRect(first_recording_rect)));
139 canvas->translate(first_offset.x(), first_offset.y()); 139 canvas->translate(first_offset.x(), first_offset.y());
140 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);
141 picture = skia::AdoptRef(recorder.endRecording()); 141 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
142 list->AppendItem(DrawingDisplayItem::Create(picture)); 142 list->AppendItem(DrawingDisplayItem::Create(picture));
143 143
144 gfx::Transform transform; 144 gfx::Transform transform;
145 transform.Rotate(45.0); 145 transform.Rotate(45.0);
146 list->AppendItem(TransformDisplayItem::Create(transform)); 146 list->AppendItem(TransformDisplayItem::Create(transform));
147 147
148 gfx::PointF second_offset(2.f, 3.f); 148 gfx::PointF second_offset(2.f, 3.f);
149 gfx::RectF second_recording_rect(second_offset, layer_rect.size()); 149 gfx::RectF second_recording_rect(second_offset, layer_rect.size());
150 canvas = skia::SharePtr( 150 canvas = skia::SharePtr(
151 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect))); 151 recorder.beginRecording(gfx::RectFToSkRect(second_recording_rect)));
152 canvas->translate(second_offset.x(), second_offset.y()); 152 canvas->translate(second_offset.x(), second_offset.y());
153 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);
154 picture = skia::AdoptRef(recorder.endRecording()); 154 picture = skia::AdoptRef(recorder.endRecordingAsPicture());
155 list->AppendItem(DrawingDisplayItem::Create(picture)); 155 list->AppendItem(DrawingDisplayItem::Create(picture));
156 156
157 list->AppendItem(EndTransformDisplayItem::Create()); 157 list->AppendItem(EndTransformDisplayItem::Create());
158 158
159 DrawDisplayList(pixels, layer_rect, list); 159 DrawDisplayList(pixels, layer_rect, list);
160 160
161 SkBitmap expected_bitmap; 161 SkBitmap expected_bitmap;
162 unsigned char expected_pixels[4 * 100 * 100] = {0}; 162 unsigned char expected_pixels[4 * 100 * 100] = {0};
163 SkImageInfo info = 163 SkImageInfo info =
164 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 164 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 216 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
217 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes()); 217 expected_bitmap.installPixels(info, expected_pixels, info.minRowBytes());
218 SkCanvas expected_canvas(expected_bitmap); 218 SkCanvas expected_canvas(expected_bitmap);
219 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint); 219 expected_canvas.drawRect(RectFToSkRect(filter_bounds), paint);
220 220
221 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100)); 221 EXPECT_EQ(0, memcmp(pixels, expected_pixels, 4 * 100 * 100));
222 } 222 }
223 223
224 } // namespace 224 } // namespace
225 } // namespace cc 225 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/display_item_list.cc ('k') | cc/resources/display_list_raster_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698