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

Side by Side Diff: src/effects/SkDropShadowImageFilter.cpp

Issue 196353021: Revert "Implement support for expanding crop rects in image filters" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDropShadowImageFilter.h" 8 #include "SkDropShadowImageFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source , const Context& ctx, SkBitmap* result, SkIPoint* offset) const 61 bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source , const Context& ctx, SkBitmap* result, SkIPoint* offset) const
62 { 62 {
63 SkBitmap src = source; 63 SkBitmap src = source;
64 SkIPoint srcOffset = SkIPoint::Make(0, 0); 64 SkIPoint srcOffset = SkIPoint::Make(0, 0);
65 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcO ffset)) 65 if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcO ffset))
66 return false; 66 return false;
67 67
68 SkIRect bounds; 68 SkIRect bounds;
69 if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) { 69 src.getBounds(&bounds);
70 bounds.offset(srcOffset);
71 if (!this->applyCropRect(&bounds, ctx.ctm())) {
70 return false; 72 return false;
71 } 73 }
72 74
73 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height())); 75 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
74 if (NULL == device.get()) { 76 if (NULL == device.get()) {
75 return false; 77 return false;
76 } 78 }
77 SkCanvas canvas(device.get()); 79 SkCanvas canvas(device.get());
78 80
79 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); 81 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY);
80 ctx.ctm().mapVectors(&sigma, &localSigma, 1); 82 ctx.ctm().mapVectors(&sigma, &localSigma, 1);
81 sigma.fX = SkMaxScalar(0, sigma.fX); 83 sigma.fX = SkMaxScalar(0, sigma.fX);
82 sigma.fY = SkMaxScalar(0, sigma.fY); 84 sigma.fY = SkMaxScalar(0, sigma.fY);
83 SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, s igma.fY)); 85 SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, s igma.fY));
84 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol or, SkXfermode::kSrcIn_Mode)); 86 SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fCol or, SkXfermode::kSrcIn_Mode));
85 SkPaint paint; 87 SkPaint paint;
86 paint.setImageFilter(blurFilter.get()); 88 paint.setImageFilter(blurFilter.get());
87 paint.setColorFilter(colorFilter.get()); 89 paint.setColorFilter(colorFilter.get());
88 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); 90 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
89 SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy); 91 SkVector offsetVec, localOffsetVec = SkVector::Make(fDx, fDy);
90 ctx.ctm().mapVectors(&offsetVec, &localOffsetVec, 1); 92 ctx.ctm().mapVectors(&offsetVec, &localOffsetVec, 1);
91 canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft), 93 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
92 SkIntToScalar(srcOffset.fY - bounds.fTop));
93 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint); 94 canvas.drawBitmap(src, offsetVec.fX, offsetVec.fY, &paint);
94 canvas.drawBitmap(src, 0, 0); 95 canvas.drawBitmap(src, 0, 0);
95 *result = device->accessBitmap(false); 96 *result = device->accessBitmap(false);
96 offset->fX = bounds.fLeft; 97 offset->fX = bounds.fLeft;
97 offset->fY = bounds.fTop; 98 offset->fY = bounds.fTop;
98 return true; 99 return true;
99 } 100 }
100 101
101 void SkDropShadowImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { 102 void SkDropShadowImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
102 if (getInput(0)) { 103 if (getInput(0)) {
(...skipping 20 matching lines...) Expand all
123 bounds.offset(-SkScalarCeilToInt(offsetVec.x()), 124 bounds.offset(-SkScalarCeilToInt(offsetVec.x()),
124 -SkScalarCeilToInt(offsetVec.y())); 125 -SkScalarCeilToInt(offsetVec.y()));
125 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY); 126 SkVector sigma, localSigma = SkVector::Make(fSigmaX, fSigmaY);
126 ctm.mapVectors(&sigma, &localSigma, 1); 127 ctm.mapVectors(&sigma, &localSigma, 1);
127 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))), 128 bounds.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
128 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3)))); 129 SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
129 bounds.join(src); 130 bounds.join(src);
130 *dst = bounds; 131 *dst = bounds;
131 return true; 132 return true;
132 } 133 }
OLDNEW
« no previous file with comments | « src/effects/SkDisplacementMapEffect.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698