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

Unified Diff: src/core/SkImageFilter.cpp

Issue 1879643003: Switch AlphaThresholdFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix serialize-8888 config (deserialize crop rect) 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 | « include/effects/SkAlphaThresholdFilter.h ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('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 6cbdf625fbd868c14aaae6a7a71c0b9396039237..af2b278e3d8721a4aa9a477da1ebed66ce2ca773 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -414,7 +414,7 @@ bool SkImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src,
GrContext* context = srcTexture->getContext();
GrSurfaceDesc desc;
- desc.fFlags = kRenderTarget_GrSurfaceFlag,
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = bounds.width();
desc.fHeight = bounds.height();
desc.fConfig = kRGBA_8888_GrPixelConfig;
@@ -452,6 +452,44 @@ bool SkImageFilter::filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src,
return false;
}
+#if SK_SUPPORT_GPU
+sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
+ sk_sp<GrFragmentProcessor> fp,
+ const SkIRect& bounds,
+ SkImageFilter::Proxy* proxy) {
+ GrPaint paint;
+ paint.addColorFragmentProcessor(fp.get());
+ paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
+
+ GrSurfaceDesc desc;
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ desc.fWidth = bounds.width();
+ desc.fHeight = bounds.height();
+ desc.fConfig = kRGBA_8888_GrPixelConfig;
+
+ sk_sp<GrTexture> dst(context->textureProvider()->createApproxTexture(desc));
+ if (!dst) {
+ return nullptr;
+ }
+
+ sk_sp<GrDrawContext> drawContext(context->drawContext(dst->asRenderTarget()));
+ if (!drawContext) {
+ return nullptr;
+ }
+
+ SkRect srcRect = SkRect::Make(bounds);
+ SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
+ GrClip clip(dstRect);
+ drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
+
+ return SkSpecialImage::MakeFromGpu(proxy,
+ SkIRect::MakeWH(bounds.width(), bounds.height()),
+ kNeedNewImageUniqueID_SpecialImage,
+ dst.get());
+
+}
+#endif
+
bool SkImageFilter::asAColorFilter(SkColorFilter** filterPtr) const {
SkASSERT(nullptr != filterPtr);
if (!this->isColorFilterNode(filterPtr)) {
@@ -530,8 +568,8 @@ sk_sp<SkSpecialImage> SkImageFilter::applyCropRect(const Context& ctx,
SkSpecialImage* src,
SkIPoint* srcOffset,
SkIRect* bounds) const {
- SkIRect srcBounds;
- srcBounds = SkIRect::MakeXYWH(srcOffset->fX, srcOffset->fY, src->width(), src->height());
+ const SkIRect srcBounds = SkIRect::MakeXYWH(srcOffset->x(), srcOffset->y(),
+ src->width(), src->height());
SkIRect dstBounds = this->onFilterNodeBounds(srcBounds, ctx.ctm(), kForward_MapDirection);
fCropRect.applyTo(dstBounds, ctx.ctm(), this->affectsTransparentBlack(), bounds);
« no previous file with comments | « include/effects/SkAlphaThresholdFilter.h ('k') | src/effects/SkAlphaThresholdFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698