diff options
author | senorblanco <senorblanco@chromium.org> | 2014-09-24 11:09:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-24 11:09:38 -0700 |
commit | 0f7197bc0ddbe6c61732d6fe69df86bdba00a060 (patch) | |
tree | 2fcfa8beeea58fc437d337425510ed97db609721 | |
parent | 7b09aab7130c174c6a2dd4becedbddaa6cf7945d (diff) |
Fix SkXfermode deserialization.
Validation was failing due to an inverted test condition.
BUG=417266
R=reed@google.com
Author: senorblanco@chromium.org
Review URL: https://codereview.chromium.org/596333002
-rw-r--r-- | src/core/SkXfermode.cpp | 2 | ||||
-rw-r--r-- | tests/SerializationTest.cpp | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index 443aa19405..8a3218fcbd 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -1258,7 +1258,7 @@ SkProcCoeffXfermode::SkProcCoeffXfermode(SkReadBuffer& buffer) : INHERITED(buffe SkFlattenable* SkProcCoeffXfermode::CreateProc(SkReadBuffer& buffer) { uint32_t mode32 = buffer.read32(); - if (!buffer.validate(mode32 >= SK_ARRAY_COUNT(gProcCoeffs))) { + if (!buffer.validate(mode32 < SK_ARRAY_COUNT(gProcCoeffs))) { return NULL; } return SkXfermode::Create((SkXfermode::Mode)mode32); diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index b6ee978869..af146006e7 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -261,6 +261,19 @@ static void TestBitmapSerialization(const SkBitmap& validBitmap, } } +static void TestXfermodeSerialization(skiatest::Reporter* reporter) { + for (size_t i = 0; i <= SkXfermode::kLastMode; ++i) { + if (i == SkXfermode::kSrcOver_Mode) { + // skip SrcOver, as it is allowed to return NULL from Create() + continue; + } + SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(static_cast<SkXfermode::Mode>(i))); + REPORTER_ASSERT(reporter, mode.get()); + SkAutoTUnref<SkXfermode> copy( + TestFlattenableSerialization<SkXfermode>(mode.get(), true, reporter)); + } +} + static SkBitmap draw_picture(SkPicture& picture) { SkBitmap bitmap; bitmap.allocN32Pixels(SkScalarCeilToInt(picture.cullRect().width()), @@ -406,6 +419,11 @@ DEF_TEST(Serialization, reporter) { TestObjectSerialization(®ion, reporter); } + // Test xfermode serialization + { + TestXfermodeSerialization(reporter); + } + // Test string serialization { SkString string("string"); |