| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkPictureShader.h" | 8 #include "SkPictureShader.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (!fCachedBitmapShader || tileScale != fCachedTileScale || | 85 if (!fCachedBitmapShader || tileScale != fCachedTileScale || |
| 86 this->getLocalMatrix() != fCachedLocalMatrix) { | 86 this->getLocalMatrix() != fCachedLocalMatrix) { |
| 87 SkBitmap bm; | 87 SkBitmap bm; |
| 88 if (!bm.allocN32Pixels(tileSize.width(), tileSize.height())) { | 88 if (!bm.allocN32Pixels(tileSize.width(), tileSize.height())) { |
| 89 return NULL; | 89 return NULL; |
| 90 } | 90 } |
| 91 bm.eraseColor(SK_ColorTRANSPARENT); | 91 bm.eraseColor(SK_ColorTRANSPARENT); |
| 92 | 92 |
| 93 SkCanvas canvas(bm); | 93 SkCanvas canvas(bm); |
| 94 canvas.scale(tileScale.width(), tileScale.height()); | 94 canvas.scale(tileScale.width(), tileScale.height()); |
| 95 canvas.drawPicture(*fPicture); | 95 canvas.drawPicture(fPicture); |
| 96 | 96 |
| 97 fCachedTileScale = tileScale; | 97 fCachedTileScale = tileScale; |
| 98 fCachedLocalMatrix = this->getLocalMatrix(); | 98 fCachedLocalMatrix = this->getLocalMatrix(); |
| 99 | 99 |
| 100 SkMatrix shaderMatrix = this->getLocalMatrix(); | 100 SkMatrix shaderMatrix = this->getLocalMatrix(); |
| 101 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); | 101 shaderMatrix.preScale(1 / tileScale.width(), 1 / tileScale.height()); |
| 102 fCachedBitmapShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatr
ix)); | 102 fCachedBitmapShader.reset(CreateBitmapShader(bm, fTmx, fTmy, &shaderMatr
ix)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Increment the ref counter inside the mutex to ensure the returned pointer
is still valid. | 105 // Increment the ref counter inside the mutex to ensure the returned pointer
is still valid. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 #if SK_SUPPORT_GPU | 190 #if SK_SUPPORT_GPU |
| 191 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai
nt, | 191 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai
nt, |
| 192 const SkMatrix* localMatrix) const { | 192 const SkMatrix* localMatrix) const { |
| 193 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix
(), localMatrix)); | 193 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix
(), localMatrix)); |
| 194 if (!bitmapShader) { | 194 if (!bitmapShader) { |
| 195 return NULL; | 195 return NULL; |
| 196 } | 196 } |
| 197 return bitmapShader->asNewEffect(context, paint, NULL); | 197 return bitmapShader->asNewEffect(context, paint, NULL); |
| 198 } | 198 } |
| 199 #endif | 199 #endif |
| OLD | NEW |