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

Side by Side Diff: tests/PaintTest.cpp

Issue 677453002: Remove android specific genID from SkPaint. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « src/core/SkPaint.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurMask.h" 8 #include "SkBlurMask.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkLayerDrawLooper.h" 10 #include "SkLayerDrawLooper.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 SkLayerDrawLooper* looper = looperBuilder.detachLooper(); 151 SkLayerDrawLooper* looper = looperBuilder.detachLooper();
152 paint.setLooper(looper)->unref(); 152 paint.setLooper(looper)->unref();
153 SkMaskFilter* mask = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 153 SkMaskFilter* mask = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
154 SkBlurMask::ConvertRadiusToSigma(SkIntToSc alar(1))); 154 SkBlurMask::ConvertRadiusToSigma(SkIntToSc alar(1)));
155 paint.setMaskFilter(mask)->unref(); 155 paint.setMaskFilter(mask)->unref();
156 156
157 // copy the paint using the copy constructor and check they are the same 157 // copy the paint using the copy constructor and check they are the same
158 SkPaint copiedPaint = paint; 158 SkPaint copiedPaint = paint;
159 REPORTER_ASSERT(reporter, paint == copiedPaint); 159 REPORTER_ASSERT(reporter, paint == copiedPaint);
160 160
161 #ifdef SK_BUILD_FOR_ANDROID
162 // the copy constructor should preserve the Generation ID
163 uint32_t paintGenID = paint.getGenerationID();
164 uint32_t copiedPaintGenID = copiedPaint.getGenerationID();
165 REPORTER_ASSERT(reporter, paintGenID == copiedPaintGenID);
166 REPORTER_ASSERT(reporter, paint == copiedPaint);
167 #endif
168
169 // copy the paint using the equal operator and check they are the same 161 // copy the paint using the equal operator and check they are the same
170 copiedPaint = paint; 162 copiedPaint = paint;
171 REPORTER_ASSERT(reporter, paint == copiedPaint); 163 REPORTER_ASSERT(reporter, paint == copiedPaint);
172 164
173 #ifdef SK_BUILD_FOR_ANDROID
174 // the equals operator should increment the Generation ID
175 REPORTER_ASSERT(reporter, paint.getGenerationID() == paintGenID);
176 REPORTER_ASSERT(reporter, copiedPaint.getGenerationID() != copiedPaintGenID) ;
177 copiedPaintGenID = copiedPaint.getGenerationID(); // reset to the new value
178 REPORTER_ASSERT(reporter, paint == copiedPaint); // operator== ignores fGen erationID
179 #endif
180
181 // clean the paint and check they are back to their initial states 165 // clean the paint and check they are back to their initial states
182 SkPaint cleanPaint; 166 SkPaint cleanPaint;
183 paint.reset(); 167 paint.reset();
184 copiedPaint.reset(); 168 copiedPaint.reset();
185 REPORTER_ASSERT(reporter, cleanPaint == paint); 169 REPORTER_ASSERT(reporter, cleanPaint == paint);
186 REPORTER_ASSERT(reporter, cleanPaint == copiedPaint); 170 REPORTER_ASSERT(reporter, cleanPaint == copiedPaint);
187
188 #ifdef SK_BUILD_FOR_ANDROID
189 // the reset function should increment the Generation ID
190 REPORTER_ASSERT(reporter, paint.getGenerationID() != paintGenID);
191 REPORTER_ASSERT(reporter, copiedPaint.getGenerationID() != copiedPaintGenID) ;
192 // operator== ignores fGenerationID
193 REPORTER_ASSERT(reporter, cleanPaint == paint);
194 REPORTER_ASSERT(reporter, cleanPaint == copiedPaint);
195 #endif
196 } 171 }
197 172
198 // found and fixed for webkit: mishandling when we hit recursion limit on 173 // found and fixed for webkit: mishandling when we hit recursion limit on
199 // mostly degenerate cubic flatness test 174 // mostly degenerate cubic flatness test
200 DEF_TEST(Paint_regression_cubic, reporter) { 175 DEF_TEST(Paint_regression_cubic, reporter) {
201 SkPath path, stroke; 176 SkPath path, stroke;
202 SkPaint paint; 177 SkPaint paint;
203 178
204 path.moveTo(460.2881309415525f, 179 path.moveTo(460.2881309415525f,
205 303.250847066498f); 180 303.250847066498f);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 337 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
363 paint.setTypeface(NULL); 338 paint.setTypeface(NULL);
364 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 339 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
365 340
366 // This is part of fBitfields, the last field we hash. 341 // This is part of fBitfields, the last field we hash.
367 paint.setHinting(SkPaint::kSlight_Hinting); 342 paint.setHinting(SkPaint::kSlight_Hinting);
368 REPORTER_ASSERT(r, paint.getHash() != defaultHash); 343 REPORTER_ASSERT(r, paint.getHash() != defaultHash);
369 paint.setHinting(SkPaint::kNormal_Hinting); 344 paint.setHinting(SkPaint::kNormal_Hinting);
370 REPORTER_ASSERT(r, paint.getHash() == defaultHash); 345 REPORTER_ASSERT(r, paint.getHash() == defaultHash);
371 } 346 }
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698