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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 277 if (context->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
278 maskDesc.fConfig = kAlpha_8_GrPixelConfig; | 278 maskDesc.fConfig = kAlpha_8_GrPixelConfig; |
279 } else { | 279 } else { |
280 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; | 280 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; |
281 } | 281 } |
282 maskDesc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureF
lagBit; | 282 maskDesc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureF
lagBit; |
283 // Add one pixel of border to ensure that clamp mode will be all zeros | 283 // Add one pixel of border to ensure that clamp mode will be all zeros |
284 // the outside. | 284 // the outside. |
285 maskDesc.fWidth = texture->width(); | 285 maskDesc.fWidth = texture->width(); |
286 maskDesc.fHeight = texture->height(); | 286 maskDesc.fHeight = texture->height(); |
287 GrAutoScratchTexture ast(context, maskDesc, GrContext::kApprox_ScratchTe
xMatch); | 287 SkAutoTUnref<GrTexture> maskTexture( |
288 GrTexture* maskTexture = ast.texture(); | 288 context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMa
tch)); |
289 if (NULL == maskTexture) { | 289 if (!maskTexture) { |
290 return false; | 290 return false; |
291 } | 291 } |
292 | 292 |
293 { | 293 { |
294 GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarg
et()); | 294 GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget
()); |
295 GrPaint grPaint; | 295 GrPaint grPaint; |
296 grPaint.setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff); | 296 grPaint.setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff); |
297 SkRegion::Iterator iter(fRegion); | 297 SkRegion::Iterator iter(fRegion); |
298 context->clear(NULL, 0x0, true); | 298 context->clear(NULL, 0x0, true); |
299 | 299 |
300 SkMatrix old_matrix = context->getMatrix(); | 300 SkMatrix old_matrix = context->getMatrix(); |
301 context->setMatrix(in_matrix); | 301 context->setMatrix(in_matrix); |
302 | 302 |
303 while (!iter.done()) { | 303 while (!iter.done()) { |
304 SkRect rect = SkRect::Make(iter.rect()); | 304 SkRect rect = SkRect::Make(iter.rect()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 (U8CPU)(SkColorGetG(source) *
scale), | 378 (U8CPU)(SkColorGetG(source) *
scale), |
379 (U8CPU)(SkColorGetB(source) *
scale)); | 379 (U8CPU)(SkColorGetB(source) *
scale)); |
380 } | 380 } |
381 } | 381 } |
382 dptr[y * dst->width() + x] = output_color; | 382 dptr[y * dst->width() + x] = output_color; |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 return true; | 386 return true; |
387 } | 387 } |
OLD | NEW |