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

Unified Diff: src/core/SkImageFilter.cpp

Issue 1893993002: Revert of Remove deprecated paths from image filter infrastructure. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/SkDevice.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 22fdd677784c521c6187f7ad331cd93a3f9e89bf..fc59e64b1876766c35864522ee4dda4e6d00386c 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -256,7 +256,12 @@
return true;
}
}
- if (this->onFilterImageDeprecated(proxy, src, context, result, offset)) {
+ /*
+ * Give the proxy first shot at the filter. If it returns false, ask
+ * the filter to do it.
+ */
+ if ((proxy && proxy->filterImage(this, src, context, result, offset)) ||
+ this->onFilterImageDeprecated(proxy, src, context, result, offset)) {
if (context.cache()) {
context.cache()->set(key, *result, *offset);
SkAutoMutexAcquire mutex(fMutex);
@@ -423,6 +428,35 @@
return dstBounds->intersect(ctx.clipBounds());
}
+bool SkImageFilter::applyCropRectDeprecated(const Context& ctx, Proxy* proxy, const SkBitmap& src,
+ SkIPoint* srcOffset, SkIRect* bounds,
+ SkBitmap* dst) const {
+ SkIRect srcBounds;
+ src.getBounds(&srcBounds);
+ srcBounds.offset(*srcOffset);
+ SkIRect dstBounds = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection);
+ fCropRect.applyTo(dstBounds, ctx.ctm(), this->affectsTransparentBlack(), bounds);
+ if (!bounds->intersect(ctx.clipBounds())) {
+ return false;
+ }
+
+ if (srcBounds.contains(*bounds)) {
+ *dst = src;
+ return true;
+ } else {
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds->width(), bounds->height()));
+ if (!device) {
+ return false;
+ }
+ SkCanvas canvas(device);
+ canvas.clear(0x00000000);
+ canvas.drawBitmap(src, srcOffset->x() - bounds->x(), srcOffset->y() - bounds->y());
+ *srcOffset = SkIPoint::Make(bounds->x(), bounds->y());
+ *dst = device->accessBitmap(false);
+ return true;
+ }
+}
+
// Return a larger (newWidth x newHeight) copy of 'src' with black padding
// around it.
static sk_sp<SkSpecialImage> pad_image(SkSpecialImage* src,
@@ -529,6 +563,52 @@
return result;
}
+
+#if SK_SUPPORT_GPU
+
+bool SkImageFilter::filterInputGPUDeprecated(int index, SkImageFilter::Proxy* proxy,
+ const SkBitmap& src, const Context& ctx,
+ SkBitmap* result, SkIPoint* offset) const {
+ SkImageFilter* input = this->getInput(index);
+ if (!input) {
+ return true;
+ }
+
+ // SRGBTODO: Don't handle sRGB here, in anticipation of this code path being deleted.
+ sk_sp<SkSpecialImage> specialSrc(SkSpecialImage::internal_fromBM(proxy, src, nullptr));
+ if (!specialSrc) {
+ return false;
+ }
+
+ sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(),
+ this->mapContext(ctx),
+ offset));
+ if (!tmp) {
+ return false;
+ }
+
+ if (!tmp->internal_getBM(result)) {
+ return false;
+ }
+
+ if (!result->getTexture()) {
+ GrContext* context = src.getTexture()->getContext();
+
+ const SkImageInfo info = result->info();
+ if (kUnknown_SkColorType == info.colorType()) {
+ return false;
+ }
+ SkAutoTUnref<GrTexture> resultTex(
+ GrRefCachedBitmapTexture(context, *result, GrTextureParams::ClampNoFilter()));
+ if (!resultTex) {
+ return false;
+ }
+ result->setPixelRef(new SkGrPixelRef(info, resultTex))->unref();
+ }
+
+ return true;
+}
+#endif
namespace {
@@ -697,3 +777,9 @@
}
return dev;
}
+
+bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src,
+ const SkImageFilter::Context& ctx,
+ SkBitmap* result, SkIPoint* offset) {
+ return fDevice->filterImage(filter, src, ctx, result, offset);
+}
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698