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

Unified Diff: src/effects/SkDropShadowImageFilter.cpp

Issue 646213004: Adding an option to render only the shadow in SkDropShadowImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added dropshadowimagefilter to ignored-tests Created 6 years, 2 months 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
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/core/SkReadBuffer.h ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698