| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 , fOuterThreshold(outerThreshold) { | 265 , fOuterThreshold(outerThreshold) { |
| 266 } | 266 } |
| 267 | 267 |
| 268 #if SK_SUPPORT_GPU | 268 #if SK_SUPPORT_GPU |
| 269 bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, | 269 bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, |
| 270 GrTexture* texture, | 270 GrTexture* texture, |
| 271 const SkMatrix& in_matrix, | 271 const SkMatrix& in_matrix, |
| 272 const SkIRect&) const { | 272 const SkIRect&) const { |
| 273 if (fp) { | 273 if (fp) { |
| 274 GrContext* context = texture->getContext(); | 274 GrContext* context = texture->getContext(); |
| 275 GrTextureDesc maskDesc; | 275 GrSurfaceDesc maskDesc; |
| 276 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 276 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
| 277 maskDesc.fConfig = kAlpha_8_GrPixelConfig; | 277 maskDesc.fConfig = kAlpha_8_GrPixelConfig; |
| 278 } else { | 278 } else { |
| 279 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; | 279 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 280 } | 280 } |
| 281 maskDesc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureF
lagBit; | 281 maskDesc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag
; |
| 282 // Add one pixel of border to ensure that clamp mode will be all zeros | 282 // Add one pixel of border to ensure that clamp mode will be all zeros |
| 283 // the outside. | 283 // the outside. |
| 284 maskDesc.fWidth = texture->width(); | 284 maskDesc.fWidth = texture->width(); |
| 285 maskDesc.fHeight = texture->height(); | 285 maskDesc.fHeight = texture->height(); |
| 286 SkAutoTUnref<GrTexture> maskTexture( | 286 SkAutoTUnref<GrTexture> maskTexture( |
| 287 context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMa
tch)); | 287 context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMa
tch)); |
| 288 if (!maskTexture) { | 288 if (!maskTexture) { |
| 289 return false; | 289 return false; |
| 290 } | 290 } |
| 291 | 291 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 (U8CPU)(SkColorGetG(source) *
scale), | 377 (U8CPU)(SkColorGetG(source) *
scale), |
| 378 (U8CPU)(SkColorGetB(source) *
scale)); | 378 (U8CPU)(SkColorGetB(source) *
scale)); |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 dptr[y * dst->width() + x] = output_color; | 381 dptr[y * dst->width() + x] = output_color; |
| 382 } | 382 } |
| 383 } | 383 } |
| 384 | 384 |
| 385 return true; | 385 return true; |
| 386 } | 386 } |
| OLD | NEW |