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

Side by Side Diff: src/effects/SkBlurMaskFilter.cpp

Issue 2514543002: Defer more renderTargetContexts in the GPU image filter paths - take 2 (Closed)
Patch Set: Add more bullet proofing Created 4 years 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 unified diff | Download patch
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/gpu/GrBlurUtils.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBlurMaskFilter.h" 8 #include "SkBlurMaskFilter.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkGpuBlurUtils.h" 10 #include "SkGpuBlurUtils.h"
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 SkRRect::kLowerRight_Corner, SkRRect::kLowerLeft_Corner }) { 1115 SkRRect::kLowerRight_Corner, SkRRect::kLowerLeft_Corner }) {
1116 SkASSERT(SkScalarIsInt(rrectToDraw.radii(c).fX) && SkScalarIsInt(rrectTo Draw.radii(c).fY)); 1116 SkASSERT(SkScalarIsInt(rrectToDraw.radii(c).fX) && SkScalarIsInt(rrectTo Draw.radii(c).fY));
1117 builder[index++] = SkScalarCeilToInt(rrectToDraw.radii(c).fX); 1117 builder[index++] = SkScalarCeilToInt(rrectToDraw.radii(c).fX);
1118 builder[index++] = SkScalarCeilToInt(rrectToDraw.radii(c).fY); 1118 builder[index++] = SkScalarCeilToInt(rrectToDraw.radii(c).fY);
1119 } 1119 }
1120 builder.finish(); 1120 builder.finish();
1121 1121
1122 sk_sp<GrTexture> mask(context->textureProvider()->findAndRefTextureByUniqueK ey(key)); 1122 sk_sp<GrTexture> mask(context->textureProvider()->findAndRefTextureByUniqueK ey(key));
1123 if (!mask) { 1123 if (!mask) {
1124 // TODO: this could be approx but the texture coords will need to be upd ated 1124 // TODO: this could be approx but the texture coords will need to be upd ated
1125 sk_sp<GrRenderTargetContext> rtc(context->makeRenderTargetContextWithFal lback( 1125 sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContex tWithFallback(
1126 SkBackingFit::kExact, size.fWidth, size.fHeight, kAlpha_8_GrPixelCon fig, nullptr)); 1126 SkBackingFit::kExact, size.fWidth, size.fHeight, kAlpha_8_GrPixelCon fig, nullptr));
1127 if (!rtc) { 1127 if (!rtc) {
1128 return nullptr; 1128 return nullptr;
1129 } 1129 }
1130 1130
1131 GrPaint grPaint; 1131 GrPaint grPaint;
1132 grPaint.setAntiAlias(doAA); 1132 grPaint.setAntiAlias(doAA);
1133 1133
1134 rtc->clear(nullptr, 0x0, true); 1134 rtc->clear(nullptr, 0x0, true);
1135 rtc->drawRRect(GrNoClip(), grPaint, SkMatrix::I(), rrectToDraw, GrStyle: :SimpleFill()); 1135 rtc->drawRRect(GrNoClip(), grPaint, SkMatrix::I(), rrectToDraw, GrStyle: :SimpleFill());
1136 1136
1137 sk_sp<GrTexture> srcTexture(rtc->asTexture()); 1137 sk_sp<GrTexture> srcTexture(rtc->asTexture());
1138 if (!srcTexture) { 1138 if (!srcTexture) {
1139 return nullptr; 1139 return nullptr;
1140 } 1140 }
1141 sk_sp<GrRenderTargetContext> rtc2(SkGpuBlurUtils::GaussianBlur(context, 1141 sk_sp<GrRenderTargetContext> rtc2(SkGpuBlurUtils::GaussianBlur(context,
1142 srcTextur e.get(), 1142 srcTextur e.get(),
1143 nullptr, 1143 nullptr,
1144 SkIRect:: MakeWH( 1144 SkIRect:: MakeWH(
1145 size. fWidth, 1145 size.fWidth,
1146 size. fHeight), 1146 size.fHeight),
1147 nullptr, 1147 nullptr,
1148 xformedSi gma, xformedSigma, 1148 xformedSi gma, xformedSigma,
1149 SkBacking Fit::kExact)); 1149 SkBacking Fit::kExact));
1150 if (!rtc2) { 1150 if (!rtc2) {
1151 return nullptr; 1151 return nullptr;
1152 } 1152 }
1153 1153
1154 mask = rtc2->asTexture(); 1154 mask = rtc2->asTexture();
1155 SkASSERT(mask); 1155 if (!mask) {
1156 return nullptr;
1157 }
1156 context->textureProvider()->assignUniqueKeyToTexture(key, mask.get()); 1158 context->textureProvider()->assignUniqueKeyToTexture(key, mask.get());
1157 } 1159 }
1158 1160
1159 return mask; 1161 return mask;
1160 } 1162 }
1161 1163
1162 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context, 1164 sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context,
1163 float sigma, float xformedSig ma, 1165 float sigma, float xformedSig ma,
1164 const SkRRect& srcRRect, cons t SkRRect& devRRect) { 1166 const SkRRect& srcRRect, cons t SkRRect& devRRect) {
1165 SkASSERT(!devRRect.isCircle() && !devRRect.isRect()); // Should've been caug ht up-stream 1167 SkASSERT(!devRRect.isCircle() && !devRRect.isRect()); // Should've been caug ht up-stream
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 // = 0 * src + (1 - src) * dst 1535 // = 0 * src + (1 - src) * dst
1534 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op); 1536 paint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op);
1535 } else { 1537 } else {
1536 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op); 1538 paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
1537 } 1539 }
1538 1540
1539 renderTargetContext->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect:: Make(clipRect)); 1541 renderTargetContext->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect:: Make(clipRect));
1540 } 1542 }
1541 1543
1542 *result = renderTargetContext->asTexture().release(); 1544 *result = renderTargetContext->asTexture().release();
1543 return true; 1545 return SkToBool(*result);
1544 } 1546 }
1545 1547
1546 #endif // SK_SUPPORT_GPU 1548 #endif // SK_SUPPORT_GPU
1547 1549
1548 1550
1549 #ifndef SK_IGNORE_TO_STRING 1551 #ifndef SK_IGNORE_TO_STRING
1550 void SkBlurMaskFilterImpl::toString(SkString* str) const { 1552 void SkBlurMaskFilterImpl::toString(SkString* str) const {
1551 str->append("SkBlurMaskFilterImpl: ("); 1553 str->append("SkBlurMaskFilterImpl: (");
1552 1554
1553 str->append("sigma: "); 1555 str->append("sigma: ");
(...skipping 15 matching lines...) Expand all
1569 } else { 1571 } else {
1570 str->append("None"); 1572 str->append("None");
1571 } 1573 }
1572 str->append("))"); 1574 str->append("))");
1573 } 1575 }
1574 #endif 1576 #endif
1575 1577
1576 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1578 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1577 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1579 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1578 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1580 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/gpu/GrBlurUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698