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