aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2016-10-03 21:34:16 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-03 21:34:36 +0000
commit2cbcd12281ee807214df094964c584c78932e10b (patch)
tree456f2c92158b18a8b010cc6e5bb594b73fbb998e /src/pdf
parent418374c0d27280f3a1161601ae5fab28a76a0d3c (diff)
Revert "Revert "Revert "replace SkXfermode obj with SkBlendMode enum in paints"""
This reverts commit I86875511a13497112827cbaed1dbd7639e9e3d10. legacy (100K) skp failure Original change's description: > Revert "Revert "replace SkXfermode obj with SkBlendMode enum in paints"" > > This reverts commit ce02e7175872abde3721df9e5d3ec0ab8384cd8e. > > BUG=skia: > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2878 > > Change-Id: I86875511a13497112827cbaed1dbd7639e9e3d10 > Reviewed-on: https://skia-review.googlesource.com/2878 > Reviewed-by: Matt Sarett <msarett@google.com> > Commit-Queue: Mike Reed <reed@google.com> > TBR=msarett@google.com,reed@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ife6f0cf3a22b3e8cf885a188f7f44e1ff62e06a5 Reviewed-on: https://skia-review.googlesource.com/2881 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/pdf')
-rw-r--r--src/pdf/SkPDFDevice.cpp164
-rw-r--r--src/pdf/SkPDFDevice.h6
-rw-r--r--src/pdf/SkPDFGraphicState.cpp105
-rw-r--r--src/pdf/SkPDFGraphicState.h2
4 files changed, 145 insertions, 132 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 217dd3f2b6..f13b4bc1f6 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -47,11 +47,12 @@
// Utility functions
-// If the paint will definitely draw opaquely, replace kSrc with
-// kSrcOver. http://crbug.com/473572
+// If the paint will definitely draw opaquely, replace kSrc_Mode with
+// kSrcOver_Mode. http://crbug.com/473572
static void replace_srcmode_on_opaque_paint(SkPaint* paint) {
- if (kSrcOver_SkXfermodeInterpretation == SkInterpretXfermode(*paint, false)) {
- paint->setBlendMode(SkBlendMode::kSrcOver);
+ if (kSrcOver_SkXfermodeInterpretation
+ == SkInterpretXfermode(*paint, false)) {
+ paint->setXfermode(nullptr);
}
}
@@ -391,7 +392,7 @@ public:
const SkPaint& paint, bool hasText = false)
: fDevice(device),
fContentEntry(nullptr),
- fBlendMode(SkBlendMode::kSrcOver),
+ fXfermode(SkXfermode::kSrcOver_Mode),
fDstFormXObject(nullptr) {
init(draw.fClipStack, draw.fRC->bwRgn(), *draw.fMatrix, paint, hasText);
}
@@ -400,7 +401,7 @@ public:
const SkPaint& paint, bool hasText = false)
: fDevice(device),
fContentEntry(nullptr),
- fBlendMode(SkBlendMode::kSrcOver),
+ fXfermode(SkXfermode::kSrcOver_Mode),
fDstFormXObject(nullptr) {
init(clipStack, clipRegion, matrix, paint, hasText);
}
@@ -411,7 +412,7 @@ public:
if (shape->isEmpty()) {
shape = nullptr;
}
- fDevice->finishContentEntry(fBlendMode, std::move(fDstFormXObject), shape);
+ fDevice->finishContentEntry(fXfermode, std::move(fDstFormXObject), shape);
}
}
@@ -419,16 +420,16 @@ public:
/* Returns true when we explicitly need the shape of the drawing. */
bool needShape() {
- switch (fBlendMode) {
- case SkBlendMode::kClear:
- case SkBlendMode::kSrc:
- case SkBlendMode::kSrcIn:
- case SkBlendMode::kSrcOut:
- case SkBlendMode::kDstIn:
- case SkBlendMode::kDstOut:
- case SkBlendMode::kSrcATop:
- case SkBlendMode::kDstATop:
- case SkBlendMode::kModulate:
+ switch (fXfermode) {
+ case SkXfermode::kClear_Mode:
+ case SkXfermode::kSrc_Mode:
+ case SkXfermode::kSrcIn_Mode:
+ case SkXfermode::kSrcOut_Mode:
+ case SkXfermode::kDstIn_Mode:
+ case SkXfermode::kDstOut_Mode:
+ case SkXfermode::kSrcATop_Mode:
+ case SkXfermode::kDstATop_Mode:
+ case SkXfermode::kModulate_Mode:
return true;
default:
return false;
@@ -437,7 +438,7 @@ public:
/* Returns true unless we only need the shape of the drawing. */
bool needSource() {
- if (fBlendMode == SkBlendMode::kClear) {
+ if (fXfermode == SkXfermode::kClear_Mode) {
return false;
}
return true;
@@ -454,7 +455,7 @@ public:
private:
SkPDFDevice* fDevice;
SkPDFDevice::ContentEntry* fContentEntry;
- SkBlendMode fBlendMode;
+ SkXfermode::Mode fXfermode;
sk_sp<SkPDFObject> fDstFormXObject;
SkPath fShape;
@@ -465,7 +466,9 @@ private:
NOT_IMPLEMENTED(!matrix.hasPerspective(), false);
return;
}
- fBlendMode = paint.getBlendMode();
+ if (paint.getXfermode()) {
+ paint.getXfermode()->asMode(&fXfermode);
+ }
fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion,
matrix, paint, hasText,
&fDstFormXObject);
@@ -1704,7 +1707,7 @@ void SkPDFDevice::drawFormXObjectWithMask(int xObjectIndex,
sk_sp<SkPDFObject> mask,
const SkClipStack* clipStack,
const SkRegion& clipRegion,
- SkBlendMode mode,
+ SkXfermode::Mode mode,
bool invertClip) {
if (clipRegion.isEmpty() && !invertClip) {
return;
@@ -1717,7 +1720,7 @@ void SkPDFDevice::drawFormXObjectWithMask(int xObjectIndex,
SkMatrix identity;
identity.reset();
SkPaint paint;
- paint.setBlendMode(mode);
+ paint.setXfermodeMode(mode);
ScopedContentEntry content(this, clipStack, clipRegion, identity, paint);
if (!content.entry()) {
return;
@@ -1762,24 +1765,27 @@ SkPDFDevice::ContentEntry* SkPDFDevice::setUpContentEntry(const SkClipStack* cli
}
}
- SkBlendMode blendMode = paint.getBlendMode();
+ SkXfermode::Mode xfermode = SkXfermode::kSrcOver_Mode;
+ if (paint.getXfermode()) {
+ paint.getXfermode()->asMode(&xfermode);
+ }
// For the following modes, we want to handle source and destination
// separately, so make an object of what's already there.
- if (blendMode == SkBlendMode::kClear ||
- blendMode == SkBlendMode::kSrc ||
- blendMode == SkBlendMode::kSrcIn ||
- blendMode == SkBlendMode::kDstIn ||
- blendMode == SkBlendMode::kSrcOut ||
- blendMode == SkBlendMode::kDstOut ||
- blendMode == SkBlendMode::kSrcATop ||
- blendMode == SkBlendMode::kDstATop ||
- blendMode == SkBlendMode::kModulate) {
+ if (xfermode == SkXfermode::kClear_Mode ||
+ xfermode == SkXfermode::kSrc_Mode ||
+ xfermode == SkXfermode::kSrcIn_Mode ||
+ xfermode == SkXfermode::kDstIn_Mode ||
+ xfermode == SkXfermode::kSrcOut_Mode ||
+ xfermode == SkXfermode::kDstOut_Mode ||
+ xfermode == SkXfermode::kSrcATop_Mode ||
+ xfermode == SkXfermode::kDstATop_Mode ||
+ xfermode == SkXfermode::kModulate_Mode) {
if (!isContentEmpty()) {
*dst = this->makeFormXObjectFromDevice();
SkASSERT(isContentEmpty());
- } else if (blendMode != SkBlendMode::kSrc &&
- blendMode != SkBlendMode::kSrcOut) {
+ } else if (xfermode != SkXfermode::kSrc_Mode &&
+ xfermode != SkXfermode::kSrcOut_Mode) {
// Except for Src and SrcOut, if there isn't anything already there,
// then we're done.
return nullptr;
@@ -1789,14 +1795,14 @@ SkPDFDevice::ContentEntry* SkPDFDevice::setUpContentEntry(const SkClipStack* cli
// Xor, Plus.
// Dst xfer mode doesn't draw source at all.
- if (blendMode == SkBlendMode::kDst) {
+ if (xfermode == SkXfermode::kDst_Mode) {
return nullptr;
}
SkPDFDevice::ContentEntry* entry;
if (fContentEntries.back() && fContentEntries.back()->fContent.getOffset() == 0) {
entry = fContentEntries.back();
- } else if (blendMode != SkBlendMode::kDstOver) {
+ } else if (xfermode != SkXfermode::kDstOver_Mode) {
entry = fContentEntries.emplace_back();
} else {
entry = fContentEntries.emplace_front();
@@ -1806,23 +1812,23 @@ SkPDFDevice::ContentEntry* SkPDFDevice::setUpContentEntry(const SkClipStack* cli
return entry;
}
-void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
+void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
sk_sp<SkPDFObject> dst,
SkPath* shape) {
- if (blendMode != SkBlendMode::kClear &&
- blendMode != SkBlendMode::kSrc &&
- blendMode != SkBlendMode::kDstOver &&
- blendMode != SkBlendMode::kSrcIn &&
- blendMode != SkBlendMode::kDstIn &&
- blendMode != SkBlendMode::kSrcOut &&
- blendMode != SkBlendMode::kDstOut &&
- blendMode != SkBlendMode::kSrcATop &&
- blendMode != SkBlendMode::kDstATop &&
- blendMode != SkBlendMode::kModulate) {
+ if (xfermode != SkXfermode::kClear_Mode &&
+ xfermode != SkXfermode::kSrc_Mode &&
+ xfermode != SkXfermode::kDstOver_Mode &&
+ xfermode != SkXfermode::kSrcIn_Mode &&
+ xfermode != SkXfermode::kDstIn_Mode &&
+ xfermode != SkXfermode::kSrcOut_Mode &&
+ xfermode != SkXfermode::kDstOut_Mode &&
+ xfermode != SkXfermode::kSrcATop_Mode &&
+ xfermode != SkXfermode::kDstATop_Mode &&
+ xfermode != SkXfermode::kModulate_Mode) {
SkASSERT(!dst);
return;
}
- if (blendMode == SkBlendMode::kDstOver) {
+ if (xfermode == SkXfermode::kDstOver_Mode) {
SkASSERT(!dst);
if (fContentEntries.front()->fContent.getOffset() == 0) {
// For DstOver, an empty content entry was inserted before the rest
@@ -1833,8 +1839,8 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
return;
}
if (!dst) {
- SkASSERT(blendMode == SkBlendMode::kSrc ||
- blendMode == SkBlendMode::kSrcOut);
+ SkASSERT(xfermode == SkXfermode::kSrc_Mode ||
+ xfermode == SkXfermode::kSrcOut_Mode);
return;
}
@@ -1859,8 +1865,8 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
// If there is shape, then an empty source with Src, SrcIn, SrcOut,
// DstIn, DstAtop or Modulate reduces to Clear and DstOut or SrcAtop
// reduces to Dst.
- if (shape == nullptr || blendMode == SkBlendMode::kDstOut ||
- blendMode == SkBlendMode::kSrcATop) {
+ if (shape == nullptr || xfermode == SkXfermode::kDstOut_Mode ||
+ xfermode == SkXfermode::kSrcATop_Mode) {
ScopedContentEntry content(this, &fExistingClipStack,
fExistingClipRegion, identity,
stockPaint);
@@ -1869,7 +1875,7 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
&content.entry()->fContent);
return;
} else {
- blendMode = SkBlendMode::kClear;
+ xfermode = SkXfermode::kClear_Mode;
}
} else {
SkASSERT(fContentEntries.count() == 1);
@@ -1878,14 +1884,14 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
// TODO(vandebo) srcFormXObject may contain alpha, but here we want it
// without alpha.
- if (blendMode == SkBlendMode::kSrcATop) {
+ if (xfermode == SkXfermode::kSrcATop_Mode) {
// TODO(vandebo): In order to properly support SrcATop we have to track
// the shape of what's been drawn at all times. It's the intersection of
// the non-transparent parts of the device and the outlines (shape) of
// all images and devices drawn.
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()), dst,
&fExistingClipStack, fExistingClipRegion,
- SkBlendMode::kSrcOver, true);
+ SkXfermode::kSrcOver_Mode, true);
} else {
if (shape != nullptr) {
// Draw shape into a form-xobject.
@@ -1901,19 +1907,19 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
drawFormXObjectWithMask(addXObjectResource(dst.get()),
this->makeFormXObjectFromDevice(),
&fExistingClipStack, fExistingClipRegion,
- SkBlendMode::kSrcOver, true);
+ SkXfermode::kSrcOver_Mode, true);
} else {
drawFormXObjectWithMask(addXObjectResource(dst.get()), srcFormXObject,
&fExistingClipStack, fExistingClipRegion,
- SkBlendMode::kSrcOver, true);
+ SkXfermode::kSrcOver_Mode, true);
}
}
- if (blendMode == SkBlendMode::kClear) {
+ if (xfermode == SkXfermode::kClear_Mode) {
return;
- } else if (blendMode == SkBlendMode::kSrc ||
- blendMode == SkBlendMode::kDstATop) {
+ } else if (xfermode == SkXfermode::kSrc_Mode ||
+ xfermode == SkXfermode::kDstATop_Mode) {
ScopedContentEntry content(this, &fExistingClipStack,
fExistingClipRegion, identity, stockPaint);
if (content.entry()) {
@@ -1921,10 +1927,10 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
this->addXObjectResource(srcFormXObject.get()),
&content.entry()->fContent);
}
- if (blendMode == SkBlendMode::kSrc) {
+ if (xfermode == SkXfermode::kSrc_Mode) {
return;
}
- } else if (blendMode == SkBlendMode::kSrcATop) {
+ } else if (xfermode == SkXfermode::kSrcATop_Mode) {
ScopedContentEntry content(this, &fExistingClipStack,
fExistingClipRegion, identity, stockPaint);
if (content.entry()) {
@@ -1933,36 +1939,36 @@ void SkPDFDevice::finishContentEntry(SkBlendMode blendMode,
}
}
- SkASSERT(blendMode == SkBlendMode::kSrcIn ||
- blendMode == SkBlendMode::kDstIn ||
- blendMode == SkBlendMode::kSrcOut ||
- blendMode == SkBlendMode::kDstOut ||
- blendMode == SkBlendMode::kSrcATop ||
- blendMode == SkBlendMode::kDstATop ||
- blendMode == SkBlendMode::kModulate);
+ SkASSERT(xfermode == SkXfermode::kSrcIn_Mode ||
+ xfermode == SkXfermode::kDstIn_Mode ||
+ xfermode == SkXfermode::kSrcOut_Mode ||
+ xfermode == SkXfermode::kDstOut_Mode ||
+ xfermode == SkXfermode::kSrcATop_Mode ||
+ xfermode == SkXfermode::kDstATop_Mode ||
+ xfermode == SkXfermode::kModulate_Mode);
- if (blendMode == SkBlendMode::kSrcIn ||
- blendMode == SkBlendMode::kSrcOut ||
- blendMode == SkBlendMode::kSrcATop) {
+ if (xfermode == SkXfermode::kSrcIn_Mode ||
+ xfermode == SkXfermode::kSrcOut_Mode ||
+ xfermode == SkXfermode::kSrcATop_Mode) {
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()),
std::move(dst),
&fExistingClipStack, fExistingClipRegion,
- SkBlendMode::kSrcOver,
- blendMode == SkBlendMode::kSrcOut);
+ SkXfermode::kSrcOver_Mode,
+ xfermode == SkXfermode::kSrcOut_Mode);
return;
} else {
- SkBlendMode mode = SkBlendMode::kSrcOver;
+ SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode;
int resourceID = addXObjectResource(dst.get());
- if (blendMode == SkBlendMode::kModulate) {
+ if (xfermode == SkXfermode::kModulate_Mode) {
drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()),
std::move(dst), &fExistingClipStack,
fExistingClipRegion,
- SkBlendMode::kSrcOver, false);
- mode = SkBlendMode::kMultiply;
+ SkXfermode::kSrcOver_Mode, false);
+ mode = SkXfermode::kMultiply_Mode;
}
drawFormXObjectWithMask(resourceID, std::move(srcFormXObject),
&fExistingClipStack, fExistingClipRegion, mode,
- blendMode == SkBlendMode::kDstOut);
+ xfermode == SkXfermode::kDstOut_Mode);
return;
}
}
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index 7d207e7cf9..be0a277ff5 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -246,7 +246,7 @@ private:
sk_sp<SkPDFObject> mask,
const SkClipStack* clipStack,
const SkRegion& clipRegion,
- SkBlendMode,
+ SkXfermode::Mode mode,
bool invertClip);
// If the paint or clip is such that we shouldn't draw anything, this
@@ -259,7 +259,9 @@ private:
const SkPaint& paint,
bool hasText,
sk_sp<SkPDFObject>* dst);
- void finishContentEntry(SkBlendMode, sk_sp<SkPDFObject> dst, SkPath* shape);
+ void finishContentEntry(SkXfermode::Mode xfermode,
+ sk_sp<SkPDFObject> dst,
+ SkPath* shape);
bool isContentEmpty();
void populateGraphicStateEntryFromPaint(const SkMatrix& matrix,
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index d60526c11a..a78c4c51b5 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -12,58 +12,58 @@
#include "SkPDFGraphicState.h"
#include "SkPDFUtils.h"
-static const char* as_blend_mode(SkBlendMode mode) {
+static const char* as_blend_mode(SkXfermode::Mode mode) {
switch (mode) {
- case SkBlendMode::kSrcOver:
+ case SkXfermode::kSrcOver_Mode:
return "Normal";
- case SkBlendMode::kMultiply:
+ case SkXfermode::kMultiply_Mode:
return "Multiply";
- case SkBlendMode::kScreen:
+ case SkXfermode::kScreen_Mode:
return "Screen";
- case SkBlendMode::kOverlay:
+ case SkXfermode::kOverlay_Mode:
return "Overlay";
- case SkBlendMode::kDarken:
+ case SkXfermode::kDarken_Mode:
return "Darken";
- case SkBlendMode::kLighten:
+ case SkXfermode::kLighten_Mode:
return "Lighten";
- case SkBlendMode::kColorDodge:
+ case SkXfermode::kColorDodge_Mode:
return "ColorDodge";
- case SkBlendMode::kColorBurn:
+ case SkXfermode::kColorBurn_Mode:
return "ColorBurn";
- case SkBlendMode::kHardLight:
+ case SkXfermode::kHardLight_Mode:
return "HardLight";
- case SkBlendMode::kSoftLight:
+ case SkXfermode::kSoftLight_Mode:
return "SoftLight";
- case SkBlendMode::kDifference:
+ case SkXfermode::kDifference_Mode:
return "Difference";
- case SkBlendMode::kExclusion:
+ case SkXfermode::kExclusion_Mode:
return "Exclusion";
- case SkBlendMode::kHue:
+ case SkXfermode::kHue_Mode:
return "Hue";
- case SkBlendMode::kSaturation:
+ case SkXfermode::kSaturation_Mode:
return "Saturation";
- case SkBlendMode::kColor:
+ case SkXfermode::kColor_Mode:
return "Color";
- case SkBlendMode::kLuminosity:
+ case SkXfermode::kLuminosity_Mode:
return "Luminosity";
// These are handled in SkPDFDevice::setUpContentEntry.
- case SkBlendMode::kClear:
- case SkBlendMode::kSrc:
- case SkBlendMode::kDst:
- case SkBlendMode::kDstOver:
- case SkBlendMode::kSrcIn:
- case SkBlendMode::kDstIn:
- case SkBlendMode::kSrcOut:
- case SkBlendMode::kDstOut:
- case SkBlendMode::kSrcATop:
- case SkBlendMode::kDstATop:
- case SkBlendMode::kModulate:
+ case SkXfermode::kClear_Mode:
+ case SkXfermode::kSrc_Mode:
+ case SkXfermode::kDst_Mode:
+ case SkXfermode::kDstOver_Mode:
+ case SkXfermode::kSrcIn_Mode:
+ case SkXfermode::kDstIn_Mode:
+ case SkXfermode::kSrcOut_Mode:
+ case SkXfermode::kDstOut_Mode:
+ case SkXfermode::kSrcATop_Mode:
+ case SkXfermode::kDstATop_Mode:
+ case SkXfermode::kModulate_Mode:
return "Normal";
// TODO(vandebo): Figure out if we can support more of these modes.
- case SkBlendMode::kXor:
- case SkBlendMode::kPlus:
+ case SkXfermode::kXor_Mode:
+ case SkXfermode::kPlus_Mode:
return nullptr;
}
return nullptr;
@@ -71,28 +71,32 @@ static const char* as_blend_mode(SkBlendMode mode) {
// If a SkXfermode is unsupported in PDF, this function returns
// SrcOver, otherwise, it returns that Xfermode as a Mode.
-static SkBlendMode mode_for_pdf(SkBlendMode mode) {
+static SkXfermode::Mode mode_for_pdf(const SkXfermode* xfermode) {
+ SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode;
+ if (xfermode) {
+ xfermode->asMode(&mode);
+ }
switch (mode) {
- case SkBlendMode::kSrcOver:
- case SkBlendMode::kMultiply:
- case SkBlendMode::kScreen:
- case SkBlendMode::kOverlay:
- case SkBlendMode::kDarken:
- case SkBlendMode::kLighten:
- case SkBlendMode::kColorDodge:
- case SkBlendMode::kColorBurn:
- case SkBlendMode::kHardLight:
- case SkBlendMode::kSoftLight:
- case SkBlendMode::kDifference:
- case SkBlendMode::kExclusion:
- case SkBlendMode::kHue:
- case SkBlendMode::kSaturation:
- case SkBlendMode::kColor:
- case SkBlendMode::kLuminosity:
+ case SkXfermode::kSrcOver_Mode:
+ case SkXfermode::kMultiply_Mode:
+ case SkXfermode::kScreen_Mode:
+ case SkXfermode::kOverlay_Mode:
+ case SkXfermode::kDarken_Mode:
+ case SkXfermode::kLighten_Mode:
+ case SkXfermode::kColorDodge_Mode:
+ case SkXfermode::kColorBurn_Mode:
+ case SkXfermode::kHardLight_Mode:
+ case SkXfermode::kSoftLight_Mode:
+ case SkXfermode::kDifference_Mode:
+ case SkXfermode::kExclusion_Mode:
+ case SkXfermode::kHue_Mode:
+ case SkXfermode::kSaturation_Mode:
+ case SkXfermode::kColor_Mode:
+ case SkXfermode::kLuminosity_Mode:
// Mode is suppported and handled by pdf graphics state.
return mode;
default:
- return SkBlendMode::kSrcOver; // Default mode.
+ return SkXfermode::kSrcOver_Mode; // Default mode.
}
}
@@ -102,7 +106,7 @@ SkPDFGraphicState::SkPDFGraphicState(const SkPaint& p)
, fAlpha(p.getAlpha())
, fStrokeCap(SkToU8(p.getStrokeCap()))
, fStrokeJoin(SkToU8(p.getStrokeJoin()))
- , fMode(SkToU8((unsigned)mode_for_pdf(p.getBlendMode()))) {}
+ , fMode(SkToU8(mode_for_pdf(p.getXfermode()))) {}
// static
SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
@@ -182,6 +186,7 @@ void SkPDFGraphicState::emitObject(
SkPaint::Cap strokeCap = (SkPaint::Cap)fStrokeCap;
SkPaint::Join strokeJoin = (SkPaint::Join)fStrokeJoin;
+ SkXfermode::Mode xferMode = (SkXfermode::Mode)fMode;
static_assert(SkPaint::kButt_Cap == 0, "paint_cap_mismatch");
static_assert(SkPaint::kRound_Cap == 1, "paint_cap_mismatch");
@@ -200,6 +205,6 @@ void SkPDFGraphicState::emitObject(
dict->insertScalar("LW", fStrokeWidth);
dict->insertScalar("ML", fStrokeMiter);
dict->insertBool("SA", true); // SA = Auto stroke adjustment.
- dict->insertName("BM", as_blend_mode((SkBlendMode)fMode));
+ dict->insertName("BM", as_blend_mode(xferMode));
dict->emitObject(stream, objNumMap);
}
diff --git a/src/pdf/SkPDFGraphicState.h b/src/pdf/SkPDFGraphicState.h
index 8ee6728f56..0c2e4a0f49 100644
--- a/src/pdf/SkPDFGraphicState.h
+++ b/src/pdf/SkPDFGraphicState.h
@@ -70,7 +70,7 @@ private:
const uint8_t fAlpha;
const uint8_t fStrokeCap; // SkPaint::Cap
const uint8_t fStrokeJoin; // SkPaint::Join
- const uint8_t fMode; // SkBlendMode
+ const uint8_t fMode; // SkXfermode::Mode
SkPDFGraphicState(const SkPaint&);