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 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // Add one pixel of border to ensure that clamp mode will be all zeros | 280 // Add one pixel of border to ensure that clamp mode will be all zeros |
281 // the outside. | 281 // the outside. |
282 maskDesc.fWidth = texture->width(); | 282 maskDesc.fWidth = texture->width(); |
283 maskDesc.fHeight = texture->height(); | 283 maskDesc.fHeight = texture->height(); |
284 SkAutoTUnref<GrTexture> maskTexture(context->textureProvider()->refScrat
chTexture( | 284 SkAutoTUnref<GrTexture> maskTexture(context->textureProvider()->refScrat
chTexture( |
285 maskDesc, GrTextureProvider::kApprox_ScratchTexMatch)); | 285 maskDesc, GrTextureProvider::kApprox_ScratchTexMatch)); |
286 if (!maskTexture) { | 286 if (!maskTexture) { |
287 return false; | 287 return false; |
288 } | 288 } |
289 | 289 |
290 GrDrawContext* drawContext = context->drawContext(); | 290 GrDrawContext* drawContext = context->drawContext(maskTexture->asRenderT
arget()); |
291 if (drawContext) { | 291 if (drawContext) { |
292 GrPaint grPaint; | 292 GrPaint grPaint; |
293 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); | 293 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
294 SkRegion::Iterator iter(fRegion); | 294 SkRegion::Iterator iter(fRegion); |
295 drawContext->clear(maskTexture->asRenderTarget(), NULL, 0x0, true); | 295 drawContext->clear(maskTexture->asRenderTarget(), NULL, 0x0, true); |
296 | 296 |
297 while (!iter.done()) { | 297 while (!iter.done()) { |
298 SkRect rect = SkRect::Make(iter.rect()); | 298 SkRect rect = SkRect::Make(iter.rect()); |
299 drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::Wid
eOpen(), grPaint, | 299 drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::Wid
eOpen(), grPaint, |
300 in_matrix, rect); | 300 in_matrix, rect); |
301 iter.next(); | 301 iter.next(); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
| 305 // TODO: whoever uses the resulting 'fp' needs to "use" the correct |
| 306 // drawContext |
305 *fp = AlphaThresholdEffect::Create(texture, | 307 *fp = AlphaThresholdEffect::Create(texture, |
306 maskTexture, | 308 maskTexture, |
307 fInnerThreshold, | 309 fInnerThreshold, |
308 fOuterThreshold); | 310 fOuterThreshold); |
309 } | 311 } |
310 return true; | 312 return true; |
311 } | 313 } |
312 #endif | 314 #endif |
313 | 315 |
314 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { | 316 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 383 } |
382 | 384 |
383 #ifndef SK_IGNORE_TO_STRING | 385 #ifndef SK_IGNORE_TO_STRING |
384 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { | 386 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { |
385 str->appendf("SkAlphaThresholdImageFilter: ("); | 387 str->appendf("SkAlphaThresholdImageFilter: ("); |
386 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); | 388 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); |
387 str->append(")"); | 389 str->append(")"); |
388 } | 390 } |
389 #endif | 391 #endif |
390 | 392 |
OLD | NEW |