| 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 16 matching lines...) Expand all Loading... |
| 27 BitmapShaderKey(uint32_t pictureID, | 27 BitmapShaderKey(uint32_t pictureID, |
| 28 const SkRect& tile, | 28 const SkRect& tile, |
| 29 SkShader::TileMode tmx, | 29 SkShader::TileMode tmx, |
| 30 SkShader::TileMode tmy, | 30 SkShader::TileMode tmy, |
| 31 const SkSize& scale, | 31 const SkSize& scale, |
| 32 const SkMatrix& localMatrix) | 32 const SkMatrix& localMatrix) |
| 33 : fPictureID(pictureID) | 33 : fPictureID(pictureID) |
| 34 , fTile(tile) | 34 , fTile(tile) |
| 35 , fTmx(tmx) | 35 , fTmx(tmx) |
| 36 , fTmy(tmy) | 36 , fTmy(tmy) |
| 37 , fScale(scale) | 37 , fScale(scale) { |
| 38 , fLocalMatrix(localMatrix) { | 38 |
| 39 for (int i = 0; i < 9; ++i) { |
| 40 fLocalMatrixStorage[i] = localMatrix[i]; |
| 41 } |
| 39 | 42 |
| 40 static const size_t keySize = sizeof(fPictureID) + | 43 static const size_t keySize = sizeof(fPictureID) + |
| 41 sizeof(fTile) + | 44 sizeof(fTile) + |
| 42 sizeof(fTmx) + sizeof(fTmy) + | 45 sizeof(fTmx) + sizeof(fTmy) + |
| 43 sizeof(fScale) + | 46 sizeof(fScale) + |
| 44 sizeof(fLocalMatrix); | 47 sizeof(fLocalMatrixStorage); |
| 45 // This better be packed. | 48 // This better be packed. |
| 46 SkASSERT(sizeof(uint32_t) * (&fEndOfStruct - &fPictureID) == keySize); | 49 SkASSERT(sizeof(uint32_t) * (&fEndOfStruct - &fPictureID) == keySize); |
| 47 this->init(&gBitmapSkaderKeyNamespaceLabel, keySize); | 50 this->init(&gBitmapSkaderKeyNamespaceLabel, keySize); |
| 48 } | 51 } |
| 49 | 52 |
| 50 private: | 53 private: |
| 51 uint32_t fPictureID; | 54 uint32_t fPictureID; |
| 52 SkRect fTile; | 55 SkRect fTile; |
| 53 SkShader::TileMode fTmx, fTmy; | 56 SkShader::TileMode fTmx, fTmy; |
| 54 SkSize fScale; | 57 SkSize fScale; |
| 55 SkMatrix fLocalMatrix; | 58 SkScalar fLocalMatrixStorage[9]; |
| 56 | 59 |
| 57 SkDEBUGCODE(uint32_t fEndOfStruct;) | 60 SkDEBUGCODE(uint32_t fEndOfStruct;) |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 struct BitmapShaderRec : public SkResourceCache::Rec { | 63 struct BitmapShaderRec : public SkResourceCache::Rec { |
| 61 BitmapShaderRec(const BitmapShaderKey& key, SkShader* tileShader, size_t bit
mapBytes) | 64 BitmapShaderRec(const BitmapShaderKey& key, SkShader* tileShader, size_t bit
mapBytes) |
| 62 : fKey(key) | 65 : fKey(key) |
| 63 , fShader(SkRef(tileShader)) | 66 , fShader(SkRef(tileShader)) |
| 64 , fBitmapBytes(bitmapBytes) {} | 67 , fBitmapBytes(bitmapBytes) {} |
| 65 | 68 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 291 } |
| 289 return bitmapShader->asFragmentProcessor(context, paint, NULL, paintColor, f
p); | 292 return bitmapShader->asFragmentProcessor(context, paint, NULL, paintColor, f
p); |
| 290 } | 293 } |
| 291 #else | 294 #else |
| 292 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix*, GrColor*, | 295 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix*, GrColor*, |
| 293 GrFragmentProcessor**) const { | 296 GrFragmentProcessor**) const { |
| 294 SkDEBUGFAIL("Should not call in GPU-less build"); | 297 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 295 return false; | 298 return false; |
| 296 } | 299 } |
| 297 #endif | 300 #endif |
| OLD | NEW |