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

Side by Side Diff: tests/RecorderTest.cpp

Issue 610003002: Override SkCanvas::drawImage() in SkRecorder. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase master Created 6 years, 2 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
« tests/RecordDrawTest.cpp ('K') | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 9
10 #include "SkPictureRecorder.h" 10 #include "SkPictureRecorder.h"
11 #include "SkRecord.h" 11 #include "SkRecord.h"
12 #include "SkRecorder.h" 12 #include "SkRecorder.h"
13 #include "SkRecords.h" 13 #include "SkRecords.h"
14 #include "SkShader.h" 14 #include "SkShader.h"
15 #include "SkSurface.h"
15 16
16 #define COUNT(T) + 1 17 #define COUNT(T) + 1
17 static const int kRecordTypes = SK_RECORD_TYPES(COUNT); 18 static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
18 #undef COUNT 19 #undef COUNT
19 20
20 // Tallies the types of commands it sees into a histogram. 21 // Tallies the types of commands it sees into a histogram.
21 class Tally { 22 class Tally {
22 public: 23 public:
23 Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); } 24 Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); }
24 25
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 recorder.restore(); 144 recorder.restore();
144 REPORTER_ASSERT(r, recorder.isDrawingToLayer()); 145 REPORTER_ASSERT(r, recorder.isDrawingToLayer());
145 recorder.restore(); 146 recorder.restore();
146 REPORTER_ASSERT(r, recorder.isDrawingToLayer()); 147 REPORTER_ASSERT(r, recorder.isDrawingToLayer());
147 recorder.restore(); 148 recorder.restore();
148 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); 149 REPORTER_ASSERT(r, !recorder.isDrawingToLayer());
149 recorder.restore(); 150 recorder.restore();
150 REPORTER_ASSERT(r, !recorder.isDrawingToLayer()); 151 REPORTER_ASSERT(r, !recorder.isDrawingToLayer());
151 } 152 }
152 153
154 DEF_TEST(Recorder_drawImage_takeReference, reporter) {
155
156 SkAutoTUnref<SkImage> image;
157 {
158 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(100, 100));
159 surface->getCanvas()->clear(SK_ColorGREEN);
160 image.reset(surface->newImageSnapshot());
161 }
162 {
163 SkRecord record;
164 SkRecorder recorder(&record, 100, 100);
165
166 // DrawImage is supposed to take a reference
167 recorder.drawImage(image.get(), 0, 0);
168 REPORTER_ASSERT(reporter, !image->unique());
169
170 Tally tally;
171 tally.apply(record);
172
173 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImage>());
174 }
175 REPORTER_ASSERT(reporter, image->unique());
176
177 {
178 SkRecord record;
179 SkRecorder recorder(&record, 100, 100);
180
181 // DrawImageRect is supposed to take a reference
182 recorder.drawImageRect(image.get(), 0, SkRect::MakeWH(100, 100));
183 REPORTER_ASSERT(reporter, !image->unique());
184
185 Tally tally;
186 tally.apply(record);
187
188 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>());
189 }
190 REPORTER_ASSERT(reporter, image->unique());
191 }
OLDNEW
« tests/RecordDrawTest.cpp ('K') | « tests/RecordReplaceDrawTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698