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

Side by Side Diff: tests/PaintTest.cpp

Issue 2396953002: Revert[8] "replace SkXfermode obj with SkBlendMode enum in paints" (Closed)
Patch Set: add tmp virtual to unroll legacy arithmodes Created 4 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 | « tests/PDFOpaqueSrcModeToSrcOverTest.cpp ('k') | tests/ReadPixelsTest.cpp » ('j') | 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 REPORTER_ASSERT(reporter, r.isEmpty()); 285 REPORTER_ASSERT(reporter, r.isEmpty());
286 } 286 }
287 287
288 #define ASSERT(expr) REPORTER_ASSERT(r, expr) 288 #define ASSERT(expr) REPORTER_ASSERT(r, expr)
289 289
290 DEF_TEST(Paint_MoreFlattening, r) { 290 DEF_TEST(Paint_MoreFlattening, r) {
291 SkPaint paint; 291 SkPaint paint;
292 paint.setColor(0x00AABBCC); 292 paint.setColor(0x00AABBCC);
293 paint.setTextScaleX(1.0f); // Default value, ignored. 293 paint.setTextScaleX(1.0f); // Default value, ignored.
294 paint.setTextSize(19); 294 paint.setTextSize(19);
295 paint.setXfermode(SkXfermode::Make(SkXfermode::kModulate_Mode)); 295 paint.setBlendMode(SkBlendMode::kModulate);
296 paint.setLooper(nullptr); // Default value, ignored. 296 paint.setLooper(nullptr); // Default value, ignored.
297 297
298 SkBinaryWriteBuffer writer; 298 SkBinaryWriteBuffer writer;
299 paint.flatten(writer); 299 paint.flatten(writer);
300 300
301 SkAutoMalloc buf(writer.bytesWritten()); 301 SkAutoMalloc buf(writer.bytesWritten());
302 writer.writeToMemory(buf.get()); 302 writer.writeToMemory(buf.get());
303 SkReadBuffer reader(buf.get(), writer.bytesWritten()); 303 SkReadBuffer reader(buf.get(), writer.bytesWritten());
304 304
305 SkPaint other; 305 SkPaint other;
306 other.unflatten(reader); 306 other.unflatten(reader);
307 ASSERT(reader.offset() == writer.bytesWritten()); 307 ASSERT(reader.offset() == writer.bytesWritten());
308 308
309 // No matter the encoding, these must always hold. 309 // No matter the encoding, these must always hold.
310 ASSERT(other.getColor() == paint.getColor()); 310 ASSERT(other.getColor() == paint.getColor());
311 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); 311 ASSERT(other.getTextScaleX() == paint.getTextScaleX());
312 ASSERT(other.getTextSize() == paint.getTextSize()); 312 ASSERT(other.getTextSize() == paint.getTextSize());
313 ASSERT(other.getLooper() == paint.getLooper()); 313 ASSERT(other.getLooper() == paint.getLooper());
314 ASSERT(other.getBlendMode() == paint.getBlendMode());
314 315
315 // We have to be a little looser and compare just the modes. Pointers might not be the same. 316 #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
316 SkXfermode::Mode otherMode, paintMode; 317 other.setXfermode(nullptr);
317 ASSERT(other.getXfermode()->asMode(&otherMode)); 318 #endif
318 ASSERT(paint.getXfermode()->asMode(&paintMode));
319 ASSERT(otherMode == paintMode);
320 } 319 }
321 320
322 DEF_TEST(Paint_getHash, r) { 321 DEF_TEST(Paint_getHash, r) {
323 // Try not to inspect the actual hash values in here. 322 // Try not to inspect the actual hash values in here.
324 // We might want to change the hash function. 323 // We might want to change the hash function.
325 324
326 SkPaint paint; 325 SkPaint paint;
327 const uint32_t defaultHash = paint.getHash(); 326 const uint32_t defaultHash = paint.getHash();
328 327
329 // Check that some arbitrary field affects the hash. 328 // Check that some arbitrary field affects the hash.
(...skipping 18 matching lines...) Expand all
348 #include "SkColorMatrixFilter.h" 347 #include "SkColorMatrixFilter.h"
349 348
350 DEF_TEST(Paint_nothingToDraw, r) { 349 DEF_TEST(Paint_nothingToDraw, r) {
351 SkPaint paint; 350 SkPaint paint;
352 351
353 REPORTER_ASSERT(r, !paint.nothingToDraw()); 352 REPORTER_ASSERT(r, !paint.nothingToDraw());
354 paint.setAlpha(0); 353 paint.setAlpha(0);
355 REPORTER_ASSERT(r, paint.nothingToDraw()); 354 REPORTER_ASSERT(r, paint.nothingToDraw());
356 355
357 paint.setAlpha(0xFF); 356 paint.setAlpha(0xFF);
358 paint.setXfermodeMode(SkXfermode::kDst_Mode); 357 paint.setBlendMode(SkBlendMode::kDst);
359 REPORTER_ASSERT(r, paint.nothingToDraw()); 358 REPORTER_ASSERT(r, paint.nothingToDraw());
360 359
361 paint.setAlpha(0); 360 paint.setAlpha(0);
362 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 361 paint.setBlendMode(SkBlendMode::kSrcOver);
363 362
364 SkColorMatrix cm; 363 SkColorMatrix cm;
365 cm.setIdentity(); // does not change alpha 364 cm.setIdentity(); // does not change alpha
366 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 365 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
367 REPORTER_ASSERT(r, paint.nothingToDraw()); 366 REPORTER_ASSERT(r, paint.nothingToDraw());
368 367
369 cm.postTranslate(0, 0, 0, 1); // wacks alpha 368 cm.postTranslate(0, 0, 0, 1); // wacks alpha
370 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat)); 369 paint.setColorFilter(SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat));
371 REPORTER_ASSERT(r, !paint.nothingToDraw()); 370 REPORTER_ASSERT(r, !paint.nothingToDraw());
372 } 371 }
OLDNEW
« no previous file with comments | « tests/PDFOpaqueSrcModeToSrcOverTest.cpp ('k') | tests/ReadPixelsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698