| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 "gl/GrGLProcessor.h" | 50 #include "gl/GrGLProcessor.h" |
| 51 #include "gl/builders/GrGLProgramBuilder.h" | 51 #include "gl/builders/GrGLProgramBuilder.h" |
| 52 #include "GrTBackendProcessorFactory.h" | 52 #include "GrTBackendProcessorFactory.h" |
| 53 #include "GrTextureAccess.h" | 53 #include "GrTextureAccess.h" |
| 54 #include "effects/GrPorterDuffXferProcessor.h" |
| 54 | 55 |
| 55 #include "SkGr.h" | 56 #include "SkGr.h" |
| 56 | 57 |
| 57 class GrGLAlphaThresholdEffect; | 58 class GrGLAlphaThresholdEffect; |
| 58 | 59 |
| 59 class AlphaThresholdEffect : public GrFragmentProcessor { | 60 class AlphaThresholdEffect : public GrFragmentProcessor { |
| 60 | 61 |
| 61 public: | 62 public: |
| 62 static GrFragmentProcessor* Create(GrTexture* texture, | 63 static GrFragmentProcessor* Create(GrTexture* texture, |
| 63 GrTexture* maskTexture, | 64 GrTexture* maskTexture, |
| (...skipping 210 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 GrXPFactory* xpFactory = GrPorterDuffXPFactory::Create(SkXfermode::k
Src_Mode); |
| 286 grPaint.setXPFactory(xpFactory)->unref(); |
| 285 SkRegion::Iterator iter(fRegion); | 287 SkRegion::Iterator iter(fRegion); |
| 286 context->clear(NULL, 0x0, true, maskTexture->asRenderTarget()); | 288 context->clear(NULL, 0x0, true, maskTexture->asRenderTarget()); |
| 287 | 289 |
| 288 SkMatrix old_matrix = context->getMatrix(); | 290 SkMatrix old_matrix = context->getMatrix(); |
| 289 context->setMatrix(in_matrix); | 291 context->setMatrix(in_matrix); |
| 290 | 292 |
| 291 while (!iter.done()) { | 293 while (!iter.done()) { |
| 292 SkRect rect = SkRect::Make(iter.rect()); | 294 SkRect rect = SkRect::Make(iter.rect()); |
| 293 context->drawRect(grPaint, rect); | 295 context->drawRect(grPaint, rect); |
| 294 iter.next(); | 296 iter.next(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 (U8CPU)(SkColorGetG(source) *
scale), | 368 (U8CPU)(SkColorGetG(source) *
scale), |
| 367 (U8CPU)(SkColorGetB(source) *
scale)); | 369 (U8CPU)(SkColorGetB(source) *
scale)); |
| 368 } | 370 } |
| 369 } | 371 } |
| 370 dptr[y * dst->width() + x] = output_color; | 372 dptr[y * dst->width() + x] = output_color; |
| 371 } | 373 } |
| 372 } | 374 } |
| 373 | 375 |
| 374 return true; | 376 return true; |
| 375 } | 377 } |
| OLD | NEW |