[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
This commit is contained in:
vandebo@chromium.org 2011-05-09 17:34:19 +00:00
parent 20efde71b4
commit 69d4ca32ec

View File

@ -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::Mode bXfermodeName = SkXfermode::kSrcOver_Mode;
bool bXfermodeKnown = true;
if (bXfermode)
bXfermodeKnown = bXfermode->asMode(&bXfermodeName);
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);
if (aXfermodeKnown != bXfermodeKnown)
return false;
if (!aXfermodeKnown)
return aXfermode == bXfermode;
return aXfermodeName == bXfermodeName;
SkXfermode::Mode bXfermodeName = SkXfermode::kSrcOver_Mode;
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);
return strcmp(aXfermodeString, bXfermodeString) == 0;
}