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

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

Issue 2296193005: Add a makeDrawContextWithFallback that handles config fallback (Closed)
Patch Set: update Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/effects/SkBlurMaskFilter.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkAlphaThresholdFilter.h" 8 #include "SkAlphaThresholdFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 : INHERITED(&input, 1, cropRect) 89 : INHERITED(&input, 1, cropRect)
90 , fRegion(region) 90 , fRegion(region)
91 , fInnerThreshold(innerThreshold) 91 , fInnerThreshold(innerThreshold)
92 , fOuterThreshold(outerThreshold) { 92 , fOuterThreshold(outerThreshold) {
93 } 93 }
94 94
95 #if SK_SUPPORT_GPU 95 #if SK_SUPPORT_GPU
96 sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* contex t, 96 sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* contex t,
97 const SkMatrix& i nMatrix, 97 const SkMatrix& i nMatrix,
98 const SkIRect& bo unds) const { 98 const SkIRect& bo unds) const {
99 GrPixelConfig config;
100 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) {
101 config = kAlpha_8_GrPixelConfig;
102 } else {
103 config = kRGBA_8888_GrPixelConfig;
104 }
105 99
106 sk_sp<GrDrawContext> drawContext(context->makeDrawContext(SkBackingFit::kApp rox, 100 sk_sp<GrDrawContext> drawContext(context->makeDrawContextWithFallback(SkBack ingFit::kApprox,
107 bounds.width(), bo unds.height(), 101 bounds .width(),
108 config, nullptr)); 102 bounds .height(),
103 kAlpha _8_GrPixelConfig,
104 nullpt r));
109 if (!drawContext) { 105 if (!drawContext) {
110 return nullptr; 106 return nullptr;
111 } 107 }
112 108
113 GrPaint grPaint; 109 GrPaint grPaint;
114 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 110 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
115 SkRegion::Iterator iter(fRegion); 111 SkRegion::Iterator iter(fRegion);
116 drawContext->clear(nullptr, 0x0, true); 112 drawContext->clear(nullptr, 0x0, true);
117 113
118 GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height())); 114 GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height()));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 dst); 256 dst);
261 } 257 }
262 258
263 #ifndef SK_IGNORE_TO_STRING 259 #ifndef SK_IGNORE_TO_STRING
264 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { 260 void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
265 str->appendf("SkAlphaThresholdImageFilter: ("); 261 str->appendf("SkAlphaThresholdImageFilter: (");
266 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); 262 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
267 str->append(")"); 263 str->append(")");
268 } 264 }
269 #endif 265 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698