OLD | NEW |
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 Loading... |
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->makeDrawContext(SkBackingFit::kApp
rox, |
107 bounds.width(), bo
unds.height(), | 101 bounds.width(), bo
unds.height(), |
108 config, nullptr)); | 102 kAlpha_8_GrPixelCo
nfig, nullptr)); |
109 if (!drawContext) { | 103 if (!drawContext) { |
110 return nullptr; | 104 return nullptr; |
111 } | 105 } |
112 | 106 |
113 GrPaint grPaint; | 107 GrPaint grPaint; |
114 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 108 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
115 SkRegion::Iterator iter(fRegion); | 109 SkRegion::Iterator iter(fRegion); |
116 drawContext->clear(nullptr, 0x0, true); | 110 drawContext->clear(nullptr, 0x0, true); |
117 | 111 |
118 GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height())); | 112 GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height())); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 dst); | 254 dst); |
261 } | 255 } |
262 | 256 |
263 #ifndef SK_IGNORE_TO_STRING | 257 #ifndef SK_IGNORE_TO_STRING |
264 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { | 258 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { |
265 str->appendf("SkAlphaThresholdImageFilter: ("); | 259 str->appendf("SkAlphaThresholdImageFilter: ("); |
266 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); | 260 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); |
267 str->append(")"); | 261 str->append(")"); |
268 } | 262 } |
269 #endif | 263 #endif |
OLD | NEW |