OLD | NEW |
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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); // Encoded despite being the default value. |
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); // 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 ? 48 : 40; | 328 const size_t expectedBytesWritten = sizeof(void*) == 8 ? 40 : 32; |
329 ASSERT(expectedBytesWritten == writer.bytesWritten()); | 329 ASSERT(expectedBytesWritten == writer.bytesWritten()); |
330 | 330 |
331 const uint32_t* written = writer.getWriter32()->contiguousArray(); | 331 const uint32_t* written = writer.getWriter32()->contiguousArray(); |
332 SkASSERT(written != NULL); | 332 SkASSERT(written != NULL); |
333 ASSERT(*written == ((1<<0) | (1<<2) | (1<<3) | (1<<9))); // Dirty bits for
our 4. | 333 ASSERT(*written == ((1<<0) | (1<<2) | (1<<3) | (1<<9))); // Dirty bits for
our 4. |
334 | 334 |
335 SkReadBuffer reader(written, writer.bytesWritten()); | 335 SkReadBuffer reader(written, writer.bytesWritten()); |
336 SkPaint other; | 336 SkPaint other; |
337 SkPaint::FlatteningTraits::Unflatten(reader, &other); | 337 SkPaint::FlatteningTraits::Unflatten(reader, &other); |
338 ASSERT(reader.offset() == writer.bytesWritten()); | 338 ASSERT(reader.offset() == writer.bytesWritten()); |
339 | 339 |
340 // No matter the encoding, these must always hold. | 340 // No matter the encoding, these must always hold. |
341 ASSERT(other.getColor() == paint.getColor()); | 341 ASSERT(other.getColor() == paint.getColor()); |
342 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); | 342 ASSERT(other.getTextScaleX() == paint.getTextScaleX()); |
343 ASSERT(other.getTextSize() == paint.getTextSize()); | 343 ASSERT(other.getTextSize() == paint.getTextSize()); |
344 ASSERT(other.getLooper() == paint.getLooper()); | 344 ASSERT(other.getLooper() == paint.getLooper()); |
345 | 345 |
346 // We have to be a little looser and compare just the modes. Pointers might
not be the same. | 346 // We have to be a little looser and compare just the modes. Pointers might
not be the same. |
347 SkXfermode::Mode otherMode, paintMode; | 347 SkXfermode::Mode otherMode, paintMode; |
348 ASSERT(other.getXfermode()->asMode(&otherMode)); | 348 ASSERT(other.getXfermode()->asMode(&otherMode)); |
349 ASSERT(paint.getXfermode()->asMode(&paintMode)); | 349 ASSERT(paint.getXfermode()->asMode(&paintMode)); |
350 ASSERT(otherMode == paintMode); | 350 ASSERT(otherMode == paintMode); |
351 } | 351 } |
OLD | NEW |