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

Side by Side Diff: tests/PaintTest.cpp

Issue 595583003: Make a flipped fDirtyBit always mean "this field is not the default". (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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // test that the rect was reset 311 // test that the rect was reset
312 paint.measureText("", 0, &r); 312 paint.measureText("", 0, &r);
313 REPORTER_ASSERT(reporter, r.isEmpty()); 313 REPORTER_ASSERT(reporter, r.isEmpty());
314 } 314 }
315 315
316 #define ASSERT(expr) REPORTER_ASSERT(r, expr) 316 #define ASSERT(expr) REPORTER_ASSERT(r, expr)
317 317
318 DEF_TEST(Paint_FlatteningTraits, r) { 318 DEF_TEST(Paint_FlatteningTraits, r) {
319 SkPaint paint; 319 SkPaint paint;
320 paint.setColor(0x00AABBCC); 320 paint.setColor(0x00AABBCC);
321 paint.setTextScaleX(1.0f); // Encoded despite being the default value. 321 paint.setTextScaleX(1.0f); // Default value, ignored.
322 paint.setTextSize(19); 322 paint.setTextSize(19);
323 paint.setXfermode(SkXfermode::Create(SkXfermode::kModulate_Mode))->unref(); 323 paint.setXfermode(SkXfermode::Create(SkXfermode::kModulate_Mode))->unref();
324 paint.setLooper(NULL); // Ignored. 324 paint.setLooper(NULL); // Default value, ignored.
325 325
326 SkWriteBuffer writer; 326 SkWriteBuffer writer;
327 SkPaint::FlatteningTraits::Flatten(writer, paint); 327 SkPaint::FlatteningTraits::Flatten(writer, paint);
328 const size_t expectedBytesWritten = sizeof(void*) == 8 ? 36 : 32;
329 ASSERT(expectedBytesWritten == writer.bytesWritten());
330 328
331 const uint32_t* written = writer.getWriter32()->contiguousArray(); 329 // BEGIN white box asserts: if the impl changes, these asserts may change
332 SkASSERT(written != NULL); 330 const size_t expectedBytesWritten = sizeof(void*) == 8 ? 32 : 28;
333 ASSERT(*written == ((1<<0) | (1<<1) | (1<<2) | (1<<8))); // Dirty bits for our 4. 331 ASSERT(expectedBytesWritten == writer.bytesWritten());
332
333 const uint32_t* written = writer.getWriter32()->contiguousArray();
334 SkASSERT(written != NULL);
335 ASSERT(*written == ((1<<0) | (1<<1) | (1<<8))); // Dirty bits for our 3 .
336 // END white box asserts
334 337
335 SkReadBuffer reader(written, writer.bytesWritten()); 338 SkReadBuffer reader(written, writer.bytesWritten());
336 SkPaint other; 339 SkPaint other;
337 SkPaint::FlatteningTraits::Unflatten(reader, &other); 340 SkPaint::FlatteningTraits::Unflatten(reader, &other);
338 ASSERT(reader.offset() == writer.bytesWritten()); 341 ASSERT(reader.offset() == writer.bytesWritten());
339 342
340 // No matter the encoding, these must always hold. 343 // No matter the encoding, these must always hold.
341 ASSERT(other.getColor() == paint.getColor()); 344 ASSERT(other.getColor() == paint.getColor());
342 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); 345 ASSERT(other.getTextScaleX() == paint.getTextScaleX());
343 ASSERT(other.getTextSize() == paint.getTextSize()); 346 ASSERT(other.getTextSize() == paint.getTextSize());
344 ASSERT(other.getLooper() == paint.getLooper()); 347 ASSERT(other.getLooper() == paint.getLooper());
345 348
346 // We have to be a little looser and compare just the modes. Pointers might not be the same. 349 // We have to be a little looser and compare just the modes. Pointers might not be the same.
347 SkXfermode::Mode otherMode, paintMode; 350 SkXfermode::Mode otherMode, paintMode;
348 ASSERT(other.getXfermode()->asMode(&otherMode)); 351 ASSERT(other.getXfermode()->asMode(&otherMode));
349 ASSERT(paint.getXfermode()->asMode(&paintMode)); 352 ASSERT(paint.getXfermode()->asMode(&paintMode));
350 ASSERT(otherMode == paintMode); 353 ASSERT(otherMode == paintMode);
351 } 354 }
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