| 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 "SkBitmapAlphaThresholdShader.h" | 8 #include "SkBitmapAlphaThresholdShader.h" |
| 9 | 9 |
| 10 class BATShader : public SkShader { | 10 class BATShader : public SkShader { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 SkRegion::Iterator iter(fRegion); | 242 SkRegion::Iterator iter(fRegion); |
| 243 context->setRenderTarget(maskTexture->asRenderTarget()); | 243 context->setRenderTarget(maskTexture->asRenderTarget()); |
| 244 context->clear(NULL, 0x0); | 244 context->clear(NULL, 0x0); |
| 245 | 245 |
| 246 // offset to ensure border is zero on top/left | 246 // offset to ensure border is zero on top/left |
| 247 SkMatrix matrix; | 247 SkMatrix matrix; |
| 248 matrix.setTranslate(SK_Scalar1, SK_Scalar1); | 248 matrix.setTranslate(SK_Scalar1, SK_Scalar1); |
| 249 context->setMatrix(matrix); | 249 context->setMatrix(matrix); |
| 250 | 250 |
| 251 while (!iter.done()) { | 251 while (!iter.done()) { |
| 252 SkRect rect = SkRect::MakeFromIRect(iter.rect()); | 252 SkRect rect = SkRect::Make(iter.rect()); |
| 253 context->drawRect(grPaint, rect); | 253 context->drawRect(grPaint, rect); |
| 254 iter.next(); | 254 iter.next(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 GrTexture* bmpTexture = GrLockAndRefCachedBitmapTexture(context, fBitmap, NU
LL); | 257 GrTexture* bmpTexture = GrLockAndRefCachedBitmapTexture(context, fBitmap, NU
LL); |
| 258 if (NULL == bmpTexture) { | 258 if (NULL == bmpTexture) { |
| 259 return NULL; | 259 return NULL; |
| 260 } | 260 } |
| 261 | 261 |
| 262 SkMatrix bmpMatrix = localInverse; | 262 SkMatrix bmpMatrix = localInverse; |
| 263 bmpMatrix.postIDiv(bmpTexture->width(), bmpTexture->height()); | 263 bmpMatrix.postIDiv(bmpTexture->width(), bmpTexture->height()); |
| 264 | 264 |
| 265 SkMatrix maskMatrix = localInverse; | 265 SkMatrix maskMatrix = localInverse; |
| 266 // compensate for the border | 266 // compensate for the border |
| 267 maskMatrix.postTranslate(SK_Scalar1, SK_Scalar1); | 267 maskMatrix.postTranslate(SK_Scalar1, SK_Scalar1); |
| 268 maskMatrix.postIDiv(maskTexture->width(), maskTexture->height()); | 268 maskMatrix.postIDiv(maskTexture->width(), maskTexture->height()); |
| 269 | 269 |
| 270 GrEffectRef* effect = ThresholdEffect::Create(bmpTexture, bmpMatrix, | 270 GrEffectRef* effect = ThresholdEffect::Create(bmpTexture, bmpMatrix, |
| 271 maskTexture, maskMatrix, | 271 maskTexture, maskMatrix, |
| 272 fThreshold); | 272 fThreshold); |
| 273 | 273 |
| 274 GrUnlockAndUnrefCachedBitmapTexture(bmpTexture); | 274 GrUnlockAndUnrefCachedBitmapTexture(bmpTexture); |
| 275 | 275 |
| 276 return effect; | 276 return effect; |
| 277 } | 277 } |
| 278 | 278 |
| 279 #endif | 279 #endif |
| OLD | NEW |