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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 116423004: [PDF] Fix clipping in xfermode improvement. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« gm/xfermodes.cpp ('K') | « gm/xfermodes.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index cdfec330f0888330d7ae6ff1e055019fa597e851..6625a8e701c10c7db14558d4b2a2bee321f0e40f 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1912,8 +1912,10 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
ContentEntry* contentEntries = getContentEntries()->get();
SkASSERT(dst);
SkASSERT(!contentEntries->fNext.get());
- // We have to make a copy of these here because changing the current
- // content into a form-xobject will destroy them.
+ // Changing the current content into a form-xobject will destroy the clip
+ // objects which is fine since the xobject will already be clipped. However
+ // if source has shape, we need to clip it too, so a copy of the clip is
+ // saved.
SkClipStack clipStack = contentEntries->fState.fClipStack;
SkRegion clipRegion = contentEntries->fState.fClipRegion;
@@ -1930,7 +1932,8 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
// reduces to Dst.
if (shape == NULL || xfermode == SkXfermode::kDstOut_Mode ||
xfermode == SkXfermode::kSrcATop_Mode) {
- ScopedContentEntry content(this, &clipStack, clipRegion, identity,
+ ScopedContentEntry content(this, &fExistingClipStack,
+ fExistingClipRegion, identity,
stockPaint);
SkPDFUtils::DrawFormXObject(this->addXObjectResource(dst),
&content.entry()->fContent);
@@ -1951,7 +1954,7 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
// the non-transparent parts of the device and the outlines (shape) of
// all images and devices drawn.
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()), dst,
- &clipStack, clipRegion,
+ &fExistingClipStack, fExistingClipRegion,
SkXfermode::kSrcOver_Mode, true);
} else {
SkAutoTUnref<SkPDFFormXObject> dstMaskStorage;
@@ -1970,16 +1973,17 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
dstMaskStorage.reset(createFormXObjectFromDevice());
dstMask = dstMaskStorage.get();
}
- drawFormXObjectWithMask(addXObjectResource(dst), dstMask, &clipStack,
- clipRegion, SkXfermode::kSrcOver_Mode, true);
+ drawFormXObjectWithMask(addXObjectResource(dst), dstMask,
+ &fExistingClipStack, fExistingClipRegion,
+ SkXfermode::kSrcOver_Mode, true);
}
if (xfermode == SkXfermode::kClear_Mode) {
return;
} else if (xfermode == SkXfermode::kSrc_Mode ||
xfermode == SkXfermode::kDstATop_Mode) {
- ScopedContentEntry content(this, &clipStack, clipRegion, identity,
- stockPaint);
+ ScopedContentEntry content(this, &fExistingClipStack,
+ fExistingClipRegion, identity, stockPaint);
if (content.entry()) {
SkPDFUtils::DrawFormXObject(
this->addXObjectResource(srcFormXObject.get()),
@@ -1989,8 +1993,8 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
return;
}
} else if (xfermode == SkXfermode::kSrcATop_Mode) {
- ScopedContentEntry content(this, &clipStack, clipRegion, identity,
- stockPaint);
+ ScopedContentEntry content(this, &fExistingClipStack,
+ fExistingClipRegion, identity, stockPaint);
if (content.entry()) {
SkPDFUtils::DrawFormXObject(this->addXObjectResource(dst),
&content.entry()->fContent);
@@ -2005,30 +2009,24 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
xfermode == SkXfermode::kDstATop_Mode ||
xfermode == SkXfermode::kModulate_Mode);
- ScopedContentEntry inShapeContentEntry(this, &fExistingClipStack,
vandebo (ex-Chrome) 2013/12/17 23:11:03 This was dead code - inShapeContentEntry is not us
- fExistingClipRegion, identity,
- stockPaint);
- if (!inShapeContentEntry.entry()) {
vandebo (ex-Chrome) 2013/12/17 23:11:03 This can't be true because fExistingClipRegion is
- return;
- }
-
if (xfermode == SkXfermode::kSrcIn_Mode ||
xfermode == SkXfermode::kSrcOut_Mode ||
xfermode == SkXfermode::kSrcATop_Mode) {
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()), dst,
- &clipStack, clipRegion,
+ &fExistingClipStack, fExistingClipRegion,
SkXfermode::kSrcOver_Mode,
xfermode == SkXfermode::kSrcOut_Mode);
} else {
SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode;
if (xfermode == SkXfermode::kModulate_Mode) {
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()),
- dst, &clipStack, clipRegion,
+ dst, &fExistingClipStack,
+ fExistingClipRegion,
SkXfermode::kSrcOver_Mode, false);
mode = SkXfermode::kMultiply_Mode;
}
drawFormXObjectWithMask(addXObjectResource(dst), srcFormXObject.get(),
- &clipStack, clipRegion, mode,
+ &fExistingClipStack, fExistingClipRegion, mode,
xfermode == SkXfermode::kDstOut_Mode);
}
}
« gm/xfermodes.cpp ('K') | « gm/xfermodes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698