Index: src/effects/SkDropShadowImageFilter.cpp |
diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp |
index 339e9557ad0a807db6183b6109abc892049941ab..0ba8b234b7977f2ed18823c5e6e68b9c43f40fed 100644 |
--- a/src/effects/SkDropShadowImageFilter.cpp |
+++ b/src/effects/SkDropShadowImageFilter.cpp |
@@ -17,14 +17,15 @@ |
SkDropShadowImageFilter::SkDropShadowImageFilter(SkScalar dx, SkScalar dy, |
SkScalar sigmaX, SkScalar sigmaY, SkColor color, |
- SkImageFilter* input, const CropRect* cropRect, |
- uint32_t uniqueID) |
+ ShadowMode shadowMode, SkImageFilter* input, |
+ const CropRect* cropRect, uint32_t uniqueID) |
: INHERITED(1, &input, cropRect, uniqueID) |
, fDx(dx) |
, fDy(dy) |
, fSigmaX(sigmaX) |
, fSigmaY(sigmaY) |
, fColor(color) |
+ , fShadowMode(shadowMode) |
{ |
} |
@@ -36,6 +37,9 @@ SkDropShadowImageFilter::SkDropShadowImageFilter(SkReadBuffer& buffer) |
fSigmaX = buffer.readScalar(); |
fSigmaY = buffer.readScalar(); |
fColor = buffer.readColor(); |
+ fShadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Version) ? |
+ kDrawShadowAndForeground_ShadowMode : |
+ static_cast<ShadowMode>(buffer.readInt()); |
buffer.validate(SkScalarIsFinite(fDx) && |
SkScalarIsFinite(fDy) && |
SkScalarIsFinite(fSigmaX) && |
@@ -50,7 +54,11 @@ SkFlattenable* SkDropShadowImageFilter::CreateProc(SkReadBuffer& buffer) { |
SkScalar sigmaX = buffer.readScalar(); |
SkScalar sigmaY = buffer.readScalar(); |
SkColor color = buffer.readColor(); |
- return Create(dx, dy, sigmaX, sigmaY, color, common.getInput(0), &common.cropRect(), common.uniqueID()); |
+ ShadowMode shadowMode = buffer.isVersionLT(SkReadBuffer::kDropShadowMode_Version) ? |
+ kDrawShadowAndForeground_ShadowMode : |
+ static_cast<ShadowMode>(buffer.readInt()); |
+ return Create(dx, dy, sigmaX, sigmaY, color, shadowMode, common.getInput(0), |
+ &common.cropRect(), common.uniqueID()); |
} |
void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const { |
@@ -60,6 +68,7 @@ void SkDropShadowImageFilter::flatten(SkWriteBuffer& buffer) const { |
buffer.writeScalar(fSigmaX); |
buffer.writeScalar(fSigmaY); |
buffer.writeColor(fColor); |
+ buffer.writeInt(static_cast<int>(fShadowMode)); |
} |
bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, |
@@ -98,7 +107,9 @@ bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source |
canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft), |
SkIntToScalar(srcOffset.fY - bounds.fTop)); |
canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint); |
- canvas.drawBitmap(src, 0, 0); |
+ if (fShadowMode == kDrawShadowAndForeground_ShadowMode) { |
+ canvas.drawBitmap(src, 0, 0); |
+ } |
*result = device->accessBitmap(false); |
offset->fX = bounds.fLeft; |
offset->fY = bounds.fTop; |
@@ -116,7 +127,11 @@ void SkDropShadowImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) |
shadowBounds.offset(fDx, fDy); |
shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)), |
SkScalarMul(fSigmaY, SkIntToScalar(3))); |
- dst->join(shadowBounds); |
+ if (fShadowMode == kDrawShadowAndForeground_ShadowMode) { |
+ dst->join(shadowBounds); |
+ } else { |
+ *dst = shadowBounds; |
+ } |
} |
bool SkDropShadowImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm, |
@@ -130,7 +145,9 @@ bool SkDropShadowImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& |
ctm.mapVectors(&sigma, 1); |
bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), |
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); |
- bounds.join(src); |
+ if (fShadowMode == kDrawShadowAndForeground_ShadowMode) { |
+ bounds.join(src); |
+ } |
if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { |
return false; |
} |