* image would be required to fill the given rect (typically, clip bounds).
* Used for clipping and temp-buffer allocations, so the result need not
* be exact, but should never be smaller than the real answer. The default
- * implementation recursively unions all input bounds, or returns false if
- * no inputs.
+ * implementation recursively unions all input bounds, or returns the
+ * source rect if no inputs.
*/
+ SkIRect filterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection = kReverse_MapDirection) const;
+
+#ifdef SK_SUPPORT_LEGACY_FILTERBOUNDS_RETURN
+ /* DEPRECATED */
bool filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst,
MapDirection = kReverse_MapDirection) const;
+#endif
/**
* Returns true if the filter can be processed on the GPU. This is most
CropRect getCropRect() const { return fCropRect; }
// Default impl returns union of all input bounds.
- virtual void computeFastBounds(const SkRect&, SkRect*) const;
+ virtual SkRect computeFastBounds(const SkRect&) const;
// Can this filter DAG compute the resulting bounds of an object-space rectangle?
virtual bool canComputeFastBounds() const;
SkIPoint* offset) const;
/**
- * This function recurses into its inputs with the given clip rect (first
+ * This function recurses into its inputs with the given rect (first
* argument), calls filterBounds() with the given map direction on each,
- * and unions the result (third argument). If the rect cannot be mapped,
- * false is returned and the destination rect is left unchanged.
- * If a derived class has special recursion requirements (e.g., it has an
- * input which does not participate in bounds computation), it can be
- * overridden here.
+ * and returns the union of those results. If a derived class has special
+ * recursion requirements (e.g., it has an input which does not participate
+ * in bounds computation), it can be overridden here.
*
* Note that this function is *not* responsible for mapping the rect for
* this node's filter bounds requirements (i.e., calling
* onFilterNodeBounds()); that is handled by filterBounds().
*/
- virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const;
+ virtual SkIRect onFilterBounds(const SkIRect&, const SkMatrix&, MapDirection) const;
/**
* Performs a forwards or reverse mapping of the given rect to accommodate
* in both forward and reverse directions. Unlike
* onFilterBounds(), this function is non-recursive.
*/
- virtual void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const;
+ virtual SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const;
// Helper function which invokes filter processing on the input at the
// specified "index". If the input is null, it leaves "result" and
return new SkBlurImageFilter(sigmaX, sigmaY, input, cropRect);
}
- void computeFastBounds(const SkRect&, SkRect*) const override;
+ SkRect computeFastBounds(const SkRect&) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter)
void flatten(SkWriteBuffer&) const override;
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
SkIPoint* offset) const override;
- void onFilterNodeBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
bool canFilterImageGPU() const override { return true; }
bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* result, SkIPoint* offset) const override;
SkImageFilter* inputs[2] = { outer, inner };
return new SkComposeImageFilter(inputs);
}
- void computeFastBounds(const SkRect& src, SkRect* dst) const override;
+ SkRect computeFastBounds(const SkRect& src) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter)
}
SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
- bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
+ SkIRect onFilterBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
private:
typedef SkImageFilter INHERITED;
const Context& ctx,
SkBitmap* dst,
SkIPoint* offset) const override;
- void computeFastBounds(const SkRect& src, SkRect* dst) const override;
+ SkRect computeFastBounds(const SkRect& src) const override;
- virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst, MapDirection) const override;
- void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
+ virtual SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&,
+ MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
#if SK_SUPPORT_GPU
bool canFilterImageGPU() const override { return true; }
cropRect);
}
- void computeFastBounds(const SkRect&, SkRect*) const override;
+ SkRect computeFastBounds(const SkRect&) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
void flatten(SkWriteBuffer&) const override;
bool onFilterImageDeprecated(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result,
SkIPoint* loc) const override;
- void onFilterNodeBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
private:
SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
const SkRect& dstRect,
SkFilterQuality);
- void computeFastBounds(const SkRect& src, SkRect* dst) const override;
+ SkRect computeFastBounds(const SkRect& src) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource)
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* loc) const override;
- void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
bool canComputeFastBounds() const override;
#if SK_SUPPORT_GPU
class SK_API SkMorphologyImageFilter : public SkImageFilter {
public:
- void computeFastBounds(const SkRect& src, SkRect* dst) const override;
- void onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection) const override;
+ SkRect computeFastBounds(const SkRect& src) const override;
+ SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
/**
* All morphology procs have the same signature: src is the source buffer, dst the
return new SkOffsetImageFilter(dx, dy, input, cropRect);
}
- void computeFastBounds(const SkRect& src, SkRect* dst) const override;
+ SkRect computeFastBounds(const SkRect& src) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
void flatten(SkWriteBuffer&) const override;
SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
SkIPoint* offset) const override;
- void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
private:
SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect*);
bool onFilterImageDeprecated(Proxy* proxy, const SkBitmap& src, const Context& ctx,
SkBitmap* dst, SkIPoint* offset) const override;
- bool onFilterBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst, MapDirection) const override;
- void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
- void computeFastBounds(const SkRect& src, SkRect* dst) const override;
+ SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
+ SkRect computeFastBounds(const SkRect& src) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix()
if (imageFilter) {
- imageFilter->filterBounds(clipBounds, ctm, &clipBounds);
+ clipBounds = imageFilter->filterBounds(clipBounds, ctm);
if (bounds && !imageFilter->canComputeFastBounds()) {
bounds = nullptr;
}
return tmp->internal_getBM(result);
}
+#ifdef SK_SUPPORT_LEGACY_FILTERBOUNDS_RETURN
bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst,
MapDirection direction) const {
- SkASSERT(dst);
- SkIRect bounds;
+ *dst = filterBounds(src, ctm, direction);
+ return true;
+}
+#endif
+
+SkIRect SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
if (kReverse_MapDirection == direction) {
- this->onFilterNodeBounds(src, ctm, &bounds, direction);
- return this->onFilterBounds(bounds, ctm, dst, direction);
+ SkIRect bounds = this->onFilterNodeBounds(src, ctm, direction);
+ return this->onFilterBounds(bounds, ctm, direction);
} else {
- SkIRect temp;
- if (!this->onFilterBounds(src, ctm, &bounds, direction)) {
- return false;
- }
- this->onFilterNodeBounds(bounds, ctm, &temp, direction);
- this->getCropRect().applyTo(temp, ctm, dst);
- return true;
+ SkIRect bounds = this->onFilterBounds(src, ctm, direction);
+ bounds = this->onFilterNodeBounds(bounds, ctm, direction);
+ SkIRect dst;
+ this->getCropRect().applyTo(bounds, ctm, &dst);
+ return dst;
}
}
-void SkImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
+SkRect SkImageFilter::computeFastBounds(const SkRect& src) const {
if (0 == fInputCount) {
- *dst = src;
- return;
- }
- // We can't work directly on dst, since src and dst may alias.
- SkRect combinedBounds;
- if (this->getInput(0)) {
- this->getInput(0)->computeFastBounds(src, &combinedBounds);
- } else {
- combinedBounds = src;
+ return src;
}
+ SkRect combinedBounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src;
for (int i = 1; i < fInputCount; i++) {
SkImageFilter* input = this->getInput(i);
if (input) {
- SkRect bounds;
- input->computeFastBounds(src, &bounds);
- combinedBounds.join(bounds);
+ combinedBounds.join(input->computeFastBounds(src));
} else {
combinedBounds.join(src);
}
}
- *dst = combinedBounds;
+ return combinedBounds;
}
bool SkImageFilter::canComputeFastBounds() const {
bool SkImageFilter::applyCropRect(const Context& ctx, const SkIRect& srcBounds,
SkIRect* dstBounds) const {
- this->onFilterNodeBounds(srcBounds, ctx.ctm(), dstBounds, kForward_MapDirection);
- fCropRect.applyTo(*dstBounds, ctx.ctm(), dstBounds);
+ SkIRect temp = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection);
+ fCropRect.applyTo(temp, ctx.ctm(), dstBounds);
// Intersect against the clip bounds, in case the crop rect has
// grown the bounds beyond the original clip. This can happen for
// example in tiling, where the clip is much smaller than the filtered
SkIRect srcBounds;
src.getBounds(&srcBounds);
srcBounds.offset(*srcOffset);
- SkIRect dstBounds;
- this->onFilterNodeBounds(srcBounds, ctx.ctm(), &dstBounds, kForward_MapDirection);
+ SkIRect dstBounds = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection);
fCropRect.applyTo(dstBounds, ctx.ctm(), bounds);
if (!bounds->intersect(ctx.clipBounds())) {
return false;
SkIRect srcBounds;
srcBounds = SkIRect::MakeXYWH(srcOffset->fX, srcOffset->fY, src->width(), src->height());
- SkIRect dstBounds;
- this->onFilterNodeBounds(srcBounds, ctx.ctm(), &dstBounds, kForward_MapDirection);
+ SkIRect dstBounds = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection);
fCropRect.applyTo(dstBounds, ctx.ctm(), bounds);
if (!bounds->intersect(ctx.clipBounds())) {
return nullptr;
}
}
-bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
+SkIRect SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
if (fInputCount < 1) {
- *dst = src;
- return true;
+ return src;
}
SkIRect totalBounds;
for (int i = 0; i < fInputCount; ++i) {
SkImageFilter* filter = this->getInput(i);
- SkIRect rect = src;
- if (filter && !filter->filterBounds(src, ctm, &rect, direction)) {
- return false;
- }
+ SkIRect rect = filter ? filter->filterBounds(src, ctm, direction) : src;
if (0 == i) {
totalBounds = rect;
} else {
}
}
- // don't modify dst until now, so we don't accidentally change it in the
- // loop, but then return false on the next filter.
- *dst = totalBounds;
- return true;
+ return totalBounds;
}
-void SkImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst, MapDirection) const {
- *dst = src;
+SkIRect SkImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const {
+ return src;
}
SkImageFilter::Context SkImageFilter::mapContext(const Context& ctx) const {
- SkIRect clipBounds;
- this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(), &clipBounds,
- MapDirection::kReverse_MapDirection);
+ SkIRect clipBounds = this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(),
+ MapDirection::kReverse_MapDirection);
return Context(ctx.ctm(), clipBounds, ctx.cache());
}
return this->filterInputDeprecated(0, proxy, src, localCtx, result, offset);
}
-bool SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& matrix,
- SkIRect* dst, MapDirection direction) const {
- return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM), dst, direction);
+SkIRect SkLocalMatrixImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& matrix,
+ MapDirection direction) const {
+ return this->getInput(0)->filterBounds(src, SkMatrix::Concat(matrix, fLocalM), direction);
}
#ifndef SK_IGNORE_TO_STRING
void flatten(SkWriteBuffer&) const override;
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* offset) const override;
- bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst,
- MapDirection) const override;
+ SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
private:
SkLocalMatrixImageFilter(const SkMatrix& localM, SkImageFilter* input);
return true;
}
-void SkMatrixImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- SkRect bounds = src;
- if (getInput(0)) {
- getInput(0)->computeFastBounds(src, &bounds);
- }
- fTransform.mapRect(dst, bounds);
+SkRect SkMatrixImageFilter::computeFastBounds(const SkRect& src) const {
+ SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src;
+ SkRect dst;
+ fTransform.mapRect(&dst, bounds);
+ return dst;
}
-void SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
+SkIRect SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
SkMatrix matrix;
if (!ctm.invert(&matrix)) {
- *dst = src;
- return;
+ return src;
}
if (kForward_MapDirection == direction) {
matrix.postConcat(fTransform);
} else {
SkMatrix transformInverse;
if (!fTransform.invert(&transformInverse)) {
- *dst = src;
- return;
+ return src;
}
matrix.postConcat(transformInverse);
}
matrix.postConcat(ctm);
SkRect floatBounds;
matrix.mapRect(&floatBounds, SkRect::Make(src));
- SkIRect bounds = floatBounds.roundOut();
- *dst = bounds;
+ return floatBounds.roundOut();
}
#ifndef SK_IGNORE_TO_STRING
SkImageFilter* input = nullptr);
virtual ~SkMatrixImageFilter();
- void computeFastBounds(const SkRect&, SkRect*) const override;
+ SkRect computeFastBounds(const SkRect&) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter)
bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
SkBitmap* result, SkIPoint* loc) const override;
- void onFilterNodeBounds(const SkIRect& src, const SkMatrix&,
- SkIRect* dst, MapDirection) const override;
+ SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
private:
SkMatrix fTransform;
}
if (this->getImageFilter()) {
- this->getImageFilter()->computeFastBounds(*storage, storage);
+ *storage = this->getImageFilter()->computeFastBounds(*storage);
}
return *storage;
}
-void SkBlurImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (this->getInput(0)) {
- this->getInput(0)->computeFastBounds(src, dst);
- } else {
- *dst = src;
- }
-
- dst->outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)),
- SkScalarMul(fSigma.height(), SkIntToScalar(3)));
+SkRect SkBlurImageFilter::computeFastBounds(const SkRect& src) const {
+ SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src;
+ bounds.outset(SkScalarMul(fSigma.width(), SkIntToScalar(3)),
+ SkScalarMul(fSigma.height(), SkIntToScalar(3)));
+ return bounds;
}
-void SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection) const {
- *dst = src;
+SkIRect SkBlurImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection) const {
SkVector sigma = map_sigma(fSigma, ctm);
- dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
- SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
+ return src.makeOutset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
+ SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
}
bool SkBlurImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src,
#include "SkWriteBuffer.h"
-void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
+SkRect SkComposeImageFilter::computeFastBounds(const SkRect& src) const {
SkImageFilter* outer = getInput(0);
SkImageFilter* inner = getInput(1);
- SkRect tmp;
- inner->computeFastBounds(src, &tmp);
- outer->computeFastBounds(tmp, dst);
+ return outer->computeFastBounds(inner->computeFastBounds(src));
}
SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
// filter, so that the inner filter produces the pixels that the outer
// filter requires as input. This matters if the outer filter moves pixels.
SkIRect innerClipBounds;
- getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(), &innerClipBounds);
+ innerClipBounds = getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm());
Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache());
SkIPoint innerOffset = SkIPoint::Make(0, 0);
SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &innerOffset));
return outer.release();
}
-bool SkComposeImageFilter::onFilterBounds(const SkIRect& src,
- const SkMatrix& ctm,
- SkIRect* dst,
- MapDirection direction) const {
+SkIRect SkComposeImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
SkImageFilter* outer = this->getInput(0);
SkImageFilter* inner = this->getInput(1);
- SkIRect tmp;
- return inner->filterBounds(src, ctm, &tmp, direction) &&
- outer->filterBounds(tmp, ctm, dst, direction);
+ return outer->filterBounds(inner->filterBounds(src, ctm, direction), ctm, direction);
}
SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) {
return true;
}
-void SkDisplacementMapEffect::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (this->getColorInput()) {
- this->getColorInput()->computeFastBounds(src, dst);
- } else {
- *dst = src;
- }
- dst->outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_ScalarHalf);
+SkRect SkDisplacementMapEffect::computeFastBounds(const SkRect& src) const {
+ SkRect bounds = this->getColorInput() ? this->getColorInput()->computeFastBounds(src) : src;
+ bounds.outset(SkScalarAbs(fScale) * SK_ScalarHalf, SkScalarAbs(fScale) * SK_ScalarHalf);
+ return bounds;
}
-void SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection) const {
- *dst = src;
+SkIRect SkDisplacementMapEffect::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection) const {
SkVector scale = SkVector::Make(fScale, fScale);
ctm.mapVectors(&scale, 1);
- dst->outset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHalf),
- SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHalf));
+ return src.makeOutset(SkScalarCeilToInt(SkScalarAbs(scale.fX) * SK_ScalarHalf),
+ SkScalarCeilToInt(SkScalarAbs(scale.fY) * SK_ScalarHalf));
}
-bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
+SkIRect SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
// Recurse only into color input.
if (this->getColorInput()) {
- return this->getColorInput()->filterBounds(src, ctm, dst, direction);
+ return this->getColorInput()->filterBounds(src, ctm, direction);
}
- *dst = src;
- return true;
+ return src;
}
#ifndef SK_IGNORE_TO_STRING
return true;
}
-void SkDropShadowImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getInput(0)) {
- getInput(0)->computeFastBounds(src, dst);
- } else {
- *dst = src;
- }
-
- SkRect shadowBounds = *dst;
+SkRect SkDropShadowImageFilter::computeFastBounds(const SkRect& src) const {
+ SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src;
+ SkRect shadowBounds = bounds;
shadowBounds.offset(fDx, fDy);
shadowBounds.outset(SkScalarMul(fSigmaX, SkIntToScalar(3)),
SkScalarMul(fSigmaY, SkIntToScalar(3)));
if (fShadowMode == kDrawShadowAndForeground_ShadowMode) {
- dst->join(shadowBounds);
+ bounds.join(shadowBounds);
} else {
- *dst = shadowBounds;
+ bounds = shadowBounds;
}
+ return bounds;
}
-void SkDropShadowImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
- *dst = src;
+SkIRect SkDropShadowImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
SkVector offsetVec = SkVector::Make(fDx, fDy);
if (kReverse_MapDirection == direction) {
offsetVec.negate();
}
ctm.mapVectors(&offsetVec, 1);
- dst->offset(SkScalarCeilToInt(offsetVec.x()),
- SkScalarCeilToInt(offsetVec.y()));
+ SkIRect dst = src.makeOffset(SkScalarCeilToInt(offsetVec.x()),
+ SkScalarCeilToInt(offsetVec.y()));
SkVector sigma = SkVector::Make(fSigmaX, fSigmaY);
ctm.mapVectors(&sigma, 1);
- dst->outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
+ dst.outset(SkScalarCeilToInt(SkScalarMul(sigma.x(), SkIntToScalar(3))),
SkScalarCeilToInt(SkScalarMul(sigma.y(), SkIntToScalar(3))));
if (fShadowMode == kDrawShadowAndForeground_ShadowMode) {
- dst->join(src);
+ dst.join(src);
}
+ return dst;
}
#ifndef SK_IGNORE_TO_STRING
return surf->makeImageSnapshot().release();
}
-void SkImageSource::computeFastBounds(const SkRect& src, SkRect* dst) const {
- *dst = fDstRect;
+SkRect SkImageSource::computeFastBounds(const SkRect& src) const {
+ return fDstRect;
}
#ifndef SK_IGNORE_TO_STRING
return true;
}
-void SkMatrixConvolutionImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
- *dst = src;
+SkIRect SkMatrixConvolutionImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
+ SkIRect dst = src;
int w = fKernelSize.width() - 1, h = fKernelSize.height() - 1;
- dst->fRight += w;
- dst->fBottom += h;
+ dst.fRight += w;
+ dst.fBottom += h;
if (kReverse_MapDirection == direction) {
- dst->offset(-fKernelOffset);
+ dst.offset(-fKernelOffset);
} else {
- dst->offset(fKernelOffset - SkIPoint::Make(w, h));
+ dst.offset(fKernelOffset - SkIPoint::Make(w, h));
}
+ return dst;
}
bool SkMatrixConvolutionImageFilter::canComputeFastBounds() const {
proxy, source, ctx, dst, offset);
}
-void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (this->getInput(0)) {
- this->getInput(0)->computeFastBounds(src, dst);
- } else {
- *dst = src;
- }
- dst->outset(SkIntToScalar(fRadius.width()), SkIntToScalar(fRadius.height()));
+SkRect SkMorphologyImageFilter::computeFastBounds(const SkRect& src) const {
+ SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src;
+ bounds.outset(SkIntToScalar(fRadius.width()), SkIntToScalar(fRadius.height()));
+ return bounds;
}
-void SkMorphologyImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection) const {
- *dst = src;
+SkIRect SkMorphologyImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection) const {
SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
SkIntToScalar(this->radius().height()));
ctm.mapVectors(&radius, 1);
- dst->outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y()));
+ return src.makeOutset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y()));
}
SkFlattenable* SkErodeImageFilter::CreateProc(SkReadBuffer& buffer) {
}
}
-void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- if (getInput(0)) {
- getInput(0)->computeFastBounds(src, dst);
- } else {
- *dst = src;
- }
- dst->offset(fOffset.fX, fOffset.fY);
+SkRect SkOffsetImageFilter::computeFastBounds(const SkRect& src) const {
+ SkRect bounds = this->getInput(0) ? this->getInput(0)->computeFastBounds(src) : src;
+ bounds.offset(fOffset.fX, fOffset.fY);
+ return bounds;
}
-void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
+SkIRect SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
SkVector vec;
ctm.mapVectors(&vec, &fOffset, 1);
if (kReverse_MapDirection == direction) {
vec.negate();
}
- *dst = src;
- dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
+ return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
}
SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
return true;
}
-void SkTileImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
+SkIRect SkTileImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+ MapDirection direction) const {
SkRect rect = kReverse_MapDirection == direction ? fSrcRect : fDstRect;
ctm.mapRect(&rect);
- rect.roundOut(dst);
+ return rect.roundOut();
}
-bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst, MapDirection direction) const {
+SkIRect SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const {
// Don't recurse into inputs.
- *dst = src;
- return true;
+ return src;
}
-void SkTileImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
- *dst = fDstRect;
+SkRect SkTileImageFilter::computeFastBounds(const SkRect& src) const {
+ return fDstRect;
}
SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) {
totMat.preConcat(info.fLocalMat);
if (info.fPaint && info.fPaint->getImageFilter()) {
- info.fPaint->getImageFilter()->filterBounds(clipBounds, totMat, &clipBounds);
+ clipBounds = info.fPaint->getImageFilter()->filterBounds(clipBounds, totMat);
}
if (!info.fSrcBounds.isEmpty()) {
SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100);
SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236);
- filter2->filterBounds(bounds, SkMatrix::I(), &bounds);
+ bounds = filter2->filterBounds(bounds, SkMatrix::I());
REPORTER_ASSERT(reporter, bounds == expectedBounds);
}
SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100);
SkIRect expectedBounds = SkIRect::MakeXYWH(-133, -133, 236, 236);
- filter2->filterBounds(bounds, SkMatrix::I(), &bounds);
+ bounds = filter2->filterBounds(bounds, SkMatrix::I());
REPORTER_ASSERT(reporter, bounds == expectedBounds);
}
SkIRect bounds = SkIRect::MakeXYWH(0, 0, 100, 100);
SkIRect expectedBounds = SkIRect::MakeXYWH(-132, -132, 234, 234);
- filter2->filterBounds(bounds, SkMatrix::I(), &bounds);
+ bounds = filter2->filterBounds(bounds, SkMatrix::I());
REPORTER_ASSERT(reporter, bounds == expectedBounds);
}
SkRect boundsSrc = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100));
SkRect expectedBounds = SkRect::MakeXYWH(
SkIntToScalar(-6), SkIntToScalar(-6), SkIntToScalar(112), SkIntToScalar(112));
- SkRect boundsDst = SkRect::MakeEmpty();
- composedFilter->computeFastBounds(boundsSrc, &boundsDst);
+ SkRect boundsDst = composedFilter->computeFastBounds(boundsSrc);
REPORTER_ASSERT(reporter, boundsDst == expectedBounds);
}
nullptr, offset.get(), nullptr));
SkRect bounds = SkRect::MakeWH(100, 100);
// Intentionally aliasing here, as that's what the real callers do.
- composite->computeFastBounds(bounds, &bounds);
+ bounds = composite->computeFastBounds(bounds);
REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
}
{
nullptr, nullptr, offset.get()));
SkRect bounds = SkRect::MakeWH(100, 100);
// Intentionally aliasing here, as that's what the real callers do.
- composite->computeFastBounds(bounds, &bounds);
+ bounds = composite->computeFastBounds(bounds);
REPORTER_ASSERT(reporter, bounds == SkRect::MakeWH(150, 100));
}
}