| 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 30 matching lines...) Expand all Loading... |
| 41 SkImageFilter* input) { | 41 SkImageFilter* input) { |
| 42 return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outer
Threshold, input)); | 42 return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outer
Threshold, input)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 #if SK_SUPPORT_GPU | 45 #if SK_SUPPORT_GPU |
| 46 #include "GrContext.h" | 46 #include "GrContext.h" |
| 47 #include "GrCoordTransform.h" | 47 #include "GrCoordTransform.h" |
| 48 #include "GrFragmentProcessor.h" | 48 #include "GrFragmentProcessor.h" |
| 49 #include "GrInvariantOutput.h" | 49 #include "GrInvariantOutput.h" |
| 50 #include "GrTextureAccess.h" | 50 #include "GrTextureAccess.h" |
| 51 #include "effects/GrPorterDuffXferProcessor.h" |
| 51 | 52 |
| 52 #include "SkGr.h" | 53 #include "SkGr.h" |
| 53 | 54 |
| 54 #include "gl/GrGLProcessor.h" | 55 #include "gl/GrGLProcessor.h" |
| 55 #include "gl/builders/GrGLProgramBuilder.h" | 56 #include "gl/builders/GrGLProgramBuilder.h" |
| 56 | 57 |
| 57 class AlphaThresholdEffect : public GrFragmentProcessor { | 58 class AlphaThresholdEffect : public GrFragmentProcessor { |
| 58 | 59 |
| 59 public: | 60 public: |
| 60 static GrFragmentProcessor* Create(GrTexture* texture, | 61 static GrFragmentProcessor* Create(GrTexture* texture, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 maskDesc.fHeight = texture->height(); | 275 maskDesc.fHeight = texture->height(); |
| 275 SkAutoTUnref<GrTexture> maskTexture( | 276 SkAutoTUnref<GrTexture> maskTexture( |
| 276 context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMa
tch)); | 277 context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMa
tch)); |
| 277 if (!maskTexture) { | 278 if (!maskTexture) { |
| 278 return false; | 279 return false; |
| 279 } | 280 } |
| 280 | 281 |
| 281 { | 282 { |
| 282 GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget
()); | 283 GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget
()); |
| 283 GrPaint grPaint; | 284 GrPaint grPaint; |
| 284 grPaint.setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff); | 285 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
| 285 SkRegion::Iterator iter(fRegion); | 286 SkRegion::Iterator iter(fRegion); |
| 286 context->clear(NULL, 0x0, true, maskTexture->asRenderTarget()); | 287 context->clear(NULL, 0x0, true, maskTexture->asRenderTarget()); |
| 287 | 288 |
| 288 SkMatrix old_matrix = context->getMatrix(); | 289 SkMatrix old_matrix = context->getMatrix(); |
| 289 context->setMatrix(in_matrix); | 290 context->setMatrix(in_matrix); |
| 290 | 291 |
| 291 while (!iter.done()) { | 292 while (!iter.done()) { |
| 292 SkRect rect = SkRect::Make(iter.rect()); | 293 SkRect rect = SkRect::Make(iter.rect()); |
| 293 context->drawRect(grPaint, rect); | 294 context->drawRect(grPaint, rect); |
| 294 iter.next(); | 295 iter.next(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 (U8CPU)(SkColorGetG(source) *
scale), | 367 (U8CPU)(SkColorGetG(source) *
scale), |
| 367 (U8CPU)(SkColorGetB(source) *
scale)); | 368 (U8CPU)(SkColorGetB(source) *
scale)); |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 dptr[y * dst->width() + x] = output_color; | 371 dptr[y * dst->width() + x] = output_color; |
| 371 } | 372 } |
| 372 } | 373 } |
| 373 | 374 |
| 374 return true; | 375 return true; |
| 375 } | 376 } |
| OLD | NEW |