const SkMatrix& ctm = fMCRec->fMatrix; // this->getTotalMatrix()
-// This is a temporary hack, until individual filters can do their own
-// bloating, when this will be removed.
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- SkRect storage;
-#endif
if (imageFilter) {
imageFilter->filterBounds(clipBounds, ctm, &clipBounds);
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- if (bounds && imageFilter->canComputeFastBounds()) {
- imageFilter->computeFastBounds(*bounds, &storage);
- bounds = &storage;
- } else {
- bounds = nullptr;
- }
-#else
if (bounds && !imageFilter->canComputeFastBounds()) {
bounds = nullptr;
}
-#endif
}
SkIRect ir;
if (bounds) {
const SkBitmap& src = srcDev->accessBitmap(false);
SkMatrix matrix = *iter.fMatrix;
matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y()));
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height());
-#else
SkIRect clipBounds = iter.fClip->getBounds().makeOffset(-pos.x(), -pos.y());
-#endif
SkAutoTUnref<SkImageFilter::Cache> cache(dstDev->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) {
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix = *draw.fMatrix;
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- const SkIRect clipBounds = bitmap.bounds();
-#else
const SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y);
-#endif
SkAutoTUnref<SkImageFilter::Cache> cache(this->getImageFilterCache());
SkImageFilter::Context ctx(matrix, clipBounds, cache.get());
if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) {
}
src.getBounds(srcBounds);
srcBounds->offset(srcOffset);
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- return fCropRect.applyTo(*srcBounds, ctx, dstBounds);
-#else
this->onFilterNodeBounds(*srcBounds, ctx.ctm(), dstBounds, kForward_MapDirection);
return fCropRect.applyTo(*dstBounds, ctx, dstBounds);
-#endif
}
bool SkImageFilter::applyCropRect(const Context& ctx, Proxy* proxy, const SkBitmap& src,
SkIRect srcBounds;
src.getBounds(&srcBounds);
srcBounds.offset(*srcOffset);
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- if (!fCropRect.applyTo(srcBounds, ctx, bounds)) {
-#else
SkIRect dstBounds;
this->onFilterNodeBounds(srcBounds, ctx.ctm(), &dstBounds, kForward_MapDirection);
if (!fCropRect.applyTo(dstBounds, ctx, bounds)) {
-#endif
return false;
}
SkImageFilter::Context SkImageFilter::mapContext(const Context& ctx) const {
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- return ctx;
-#else
SkIRect clipBounds;
this->onFilterNodeBounds(ctx.clipBounds(), ctx.ctm(), &clipBounds,
MapDirection::kReverse_MapDirection);
return Context(ctx.ctm(), clipBounds, ctx.cache());
-#endif
}
bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*,
getInput(0)->computeFastBounds(src, &bounds);
}
fTransform.mapRect(dst, bounds);
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- dst->join(bounds); // Work around for skia:3194
-#endif
}
void SkMatrixImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
} else {
*dst = src;
}
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- SkRect copy = *dst;
-#endif
dst->offset(fOffset.fX, fOffset.fY);
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- dst->join(copy);
-#endif
}
void SkOffsetImageFilter::onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
*dst = src;
dst->offset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY));
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- dst->join(src);
-#endif
}
SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) {
SkRect rect = kReverse_MapDirection == direction ? fSrcRect : fDstRect;
ctm.mapRect(&rect);
rect.roundOut(dst);
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- dst->join(src);
-#endif
}
bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
}
void SkTileImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- // This is a workaround for skia:3194.
- *dst = src;
- dst->join(fDstRect);
-#else
*dst = fDstRect;
-#endif
}
SkFlattenable* SkTileImageFilter::CreateProc(SkReadBuffer& buffer) {
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix(*draw.fMatrix);
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
-#else
SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-left, -top);
-#endif
SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());
// This cache is transient, and is freed (along with all its contained
// textures) when it goes out of scope.
SkIPoint offset = SkIPoint::Make(0, 0);
SkMatrix matrix(*draw.fMatrix);
matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
-#ifdef SK_SUPPORT_SRC_BOUNDS_BLOAT_FOR_IMAGEFILTERS
- SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height());
-#else
SkIRect clipBounds = draw.fClip->getBounds().makeOffset(-x, -y);
-#endif
// This cache is transient, and is freed (along with all its contained
// textures) when it goes out of scope.
SkAutoTUnref<SkImageFilter::Cache> cache(getImageFilterCache());