| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 // The actual scale, compensating for rounding & clamping. | 102 // The actual scale, compensating for rounding & clamping. |
| 103 SkSize tileScale = SkSize::Make(SkIntToScalar(tileSize.width()) / fTile.widt
h(), | 103 SkSize tileScale = SkSize::Make(SkIntToScalar(tileSize.width()) / fTile.widt
h(), |
| 104 SkIntToScalar(tileSize.height()) / fTile.hei
ght()); | 104 SkIntToScalar(tileSize.height()) / fTile.hei
ght()); |
| 105 | 105 |
| 106 SkAutoMutexAcquire ama(fCachedBitmapShaderMutex); | 106 SkAutoMutexAcquire ama(fCachedBitmapShaderMutex); |
| 107 | 107 |
| 108 if (!fCachedBitmapShader || tileScale != fCachedTileScale) { | 108 if (!fCachedBitmapShader || tileScale != fCachedTileScale) { |
| 109 SkBitmap bm; | 109 SkBitmap bm; |
| 110 if (!bm.allocN32Pixels(tileSize.width(), tileSize.height())) { | 110 if (!bm.tryAllocN32Pixels(tileSize.width(), tileSize.height())) { |
| 111 return NULL; | 111 return NULL; |
| 112 } | 112 } |
| 113 bm.eraseColor(SK_ColorTRANSPARENT); | 113 bm.eraseColor(SK_ColorTRANSPARENT); |
| 114 | 114 |
| 115 SkCanvas canvas(bm); | 115 SkCanvas canvas(bm); |
| 116 canvas.scale(tileScale.width(), tileScale.height()); | 116 canvas.scale(tileScale.width(), tileScale.height()); |
| 117 canvas.translate(fTile.x(), fTile.y()); | 117 canvas.translate(fTile.x(), fTile.y()); |
| 118 canvas.drawPicture(fPicture); | 118 canvas.drawPicture(fPicture); |
| 119 | 119 |
| 120 fCachedTileScale = tileScale; | 120 fCachedTileScale = tileScale; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect); | 222 return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect); |
| 223 } | 223 } |
| 224 #else | 224 #else |
| 225 bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint, | 225 bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint, |
| 226 const SkMatrix* localMatrix, GrColor* paintCol
or, | 226 const SkMatrix* localMatrix, GrColor* paintCol
or, |
| 227 GrEffect** effect) const { | 227 GrEffect** effect) const { |
| 228 SkDEBUGFAIL("Should not call in GPU-less build"); | 228 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 229 return false; | 229 return false; |
| 230 } | 230 } |
| 231 #endif | 231 #endif |
| OLD | NEW |