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

Unified Diff: src/effects/SkAlphaThresholdFilter.cpp

Issue 2514543002: Defer more renderTargetContexts in the GPU image filter paths - take 2 (Closed)
Patch Set: Add more bullet proofing Created 4 years, 1 month 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/SkImageFilter.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkAlphaThresholdFilter.cpp
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index b1c8b214609af956510482517706792a6f8ec079..43751e1199926a20dea6257b423f9f317862b79b 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -16,8 +16,9 @@
#if SK_SUPPORT_GPU
#include "GrAlphaThresholdFragmentProcessor.h"
#include "GrContext.h"
-#include "GrRenderTargetContext.h"
#include "GrFixedClip.h"
+#include "GrRenderTargetContext.h"
+#include "GrTextureProxy.h"
#endif
class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter {
@@ -37,7 +38,9 @@ protected:
SkIPoint* offset) const override;
#if SK_SUPPORT_GPU
- sk_sp<GrTexture> createMaskTexture(GrContext*, const SkMatrix&, const SkIRect& bounds) const;
+ sk_sp<GrTextureProxy> createMaskTexture(GrContext*,
+ const SkMatrix&,
+ const SkIRect& bounds) const;
#endif
private:
@@ -93,29 +96,29 @@ SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(const SkRegion& region,
}
#if SK_SUPPORT_GPU
-sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context,
- const SkMatrix& inMatrix,
- const SkIRect& bounds) const {
+sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context,
+ const SkMatrix& inMatrix,
+ const SkIRect& bounds) const {
- sk_sp<GrRenderTargetContext> renderTargetContext(context->makeRenderTargetContextWithFallback(
+ sk_sp<GrRenderTargetContext> rtContext(context->makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig, nullptr));
- if (!renderTargetContext) {
+ if (!rtContext) {
return nullptr;
}
GrPaint grPaint;
grPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkRegion::Iterator iter(fRegion);
- renderTargetContext->clear(nullptr, 0x0, true);
+ rtContext->clear(nullptr, 0x0, true);
GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height()));
while (!iter.done()) {
SkRect rect = SkRect::Make(iter.rect());
- renderTargetContext->drawRect(clip, grPaint, inMatrix, rect);
+ rtContext->drawRect(clip, grPaint, inMatrix, rect);
iter.next();
}
- return renderTargetContext->asTexture();
+ return sk_ref_sp(rtContext->asDeferredTexture());
}
#endif
@@ -158,21 +161,26 @@ sk_sp<SkSpecialImage> SkAlphaThresholdFilterImpl::onFilterImage(SkSpecialImage*
SkMatrix matrix(ctx.ctm());
matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
- sk_sp<GrTexture> maskTexture(this->createMaskTexture(context, matrix, bounds));
- if (!maskTexture) {
+ sk_sp<GrTextureProxy> maskProxy(this->createMaskTexture(context, matrix, bounds));
+ if (!maskProxy) {
return nullptr;
}
const OutputProperties& outProps = ctx.outputProperties();
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(input->getColorSpace(),
outProps.colorSpace());
+
+ GrTexture* maskTex = maskProxy->instantiate(context->textureProvider());
+ if (!maskTex) {
+ return nullptr;
+ }
sk_sp<GrFragmentProcessor> fp(GrAlphaThresholdFragmentProcessor::Make(
- inputTexture.get(),
- std::move(colorSpaceXform),
- maskTexture.get(),
- fInnerThreshold,
- fOuterThreshold,
- bounds));
+ inputTexture.get(),
+ std::move(colorSpaceXform),
+ maskTex,
+ fInnerThreshold,
+ fOuterThreshold,
+ bounds));
if (!fp) {
return nullptr;
}
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698