From: vandebo@chromium.org Date: Mon, 9 May 2011 17:34:19 +0000 (+0000) Subject: [PDF] Fix bug in graphic state comparison. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~18528 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69d4ca32ec0d6e61061f7d3c321f1b9ced6dd3ea;p=platform%2Fupstream%2FlibSkiaSharp.git [PDF] Fix bug in graphic state comparison. SkPDFGraphicState::GSCanonicalEntry::operator== was out of sync with SkPDFGraphicState::populateDict leading to graphic state objects with the same value. Review URL: http://codereview.appspot.com/4516043 git-svn-id: http://skia.googlecode.com/svn/trunk@1278 2bbb7eff-a529-9590-31e7-b0007b416f81 --- diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp index 730dc29..e5badae 100644 --- a/src/pdf/SkPDFGraphicState.cpp +++ b/src/pdf/SkPDFGraphicState.cpp @@ -179,20 +179,29 @@ bool SkPDFGraphicState::GSCanonicalEntry::operator==( return false; } - SkXfermode* aXfermode = a->getXfermode(); SkXfermode::Mode aXfermodeName = SkXfermode::kSrcOver_Mode; - bool aXfermodeKnown = true; - if (aXfermode) - aXfermodeKnown = aXfermode->asMode(&aXfermodeName); - SkXfermode* bXfermode = b->getXfermode(); + SkXfermode* aXfermode = a->getXfermode(); + if (aXfermode) { + aXfermode->asMode(&aXfermodeName); + } + if (aXfermodeName < 0 || aXfermodeName > SkXfermode::kLastMode || + blendModeFromXfermode(aXfermodeName) == NULL) { + aXfermodeName = SkXfermode::kSrcOver_Mode; + } + const char* aXfermodeString = blendModeFromXfermode(aXfermodeName); + SkASSERT(aXfermodeString != NULL); + SkXfermode::Mode bXfermodeName = SkXfermode::kSrcOver_Mode; - bool bXfermodeKnown = true; - if (bXfermode) - bXfermodeKnown = bXfermode->asMode(&bXfermodeName); + SkXfermode* bXfermode = b->getXfermode(); + if (bXfermode) { + bXfermode->asMode(&bXfermodeName); + } + if (bXfermodeName < 0 || bXfermodeName > SkXfermode::kLastMode || + blendModeFromXfermode(bXfermodeName) == NULL) { + bXfermodeName = SkXfermode::kSrcOver_Mode; + } + const char* bXfermodeString = blendModeFromXfermode(bXfermodeName); + SkASSERT(bXfermodeString != NULL); - if (aXfermodeKnown != bXfermodeKnown) - return false; - if (!aXfermodeKnown) - return aXfermode == bXfermode; - return aXfermodeName == bXfermodeName; + return strcmp(aXfermodeString, bXfermodeString) == 0; }