| 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" |
| 11 #include "SkBitmapProcShader.h" | 11 #include "SkBitmapProcShader.h" |
| 12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 13 #include "SkMatrixUtils.h" | 13 #include "SkMatrixUtils.h" |
| 14 #include "SkPicture.h" | 14 #include "SkPicture.h" |
| 15 #include "SkReadBuffer.h" | 15 #include "SkReadBuffer.h" |
| 16 | 16 |
| 17 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
| 18 #include "GrContext.h" | 18 #include "GrContext.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 SkPictureShader::SkPictureShader(SkPicture* picture, TileMode tmx, TileMode tmy, | 21 SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMod
e tmy, |
| 22 const SkMatrix* localMatrix) | 22 const SkMatrix* localMatrix) |
| 23 : INHERITED(localMatrix) | 23 : INHERITED(localMatrix) |
| 24 , fPicture(SkRef(picture)) | 24 , fPicture(SkRef(picture)) |
| 25 , fTmx(tmx) | 25 , fTmx(tmx) |
| 26 , fTmy(tmy) { } | 26 , fTmy(tmy) { } |
| 27 | 27 |
| 28 SkPictureShader::SkPictureShader(SkReadBuffer& buffer) | 28 SkPictureShader::SkPictureShader(SkReadBuffer& buffer) |
| 29 : INHERITED(buffer) { | 29 : INHERITED(buffer) { |
| 30 fTmx = static_cast<SkShader::TileMode>(buffer.read32()); | 30 fTmx = static_cast<SkShader::TileMode>(buffer.read32()); |
| 31 fTmy = static_cast<SkShader::TileMode>(buffer.read32()); | 31 fTmy = static_cast<SkShader::TileMode>(buffer.read32()); |
| 32 fPicture = SkPicture::CreateFromBuffer(buffer); | 32 fPicture = SkPicture::CreateFromBuffer(buffer); |
| 33 } | 33 } |
| 34 | 34 |
| 35 SkPictureShader::~SkPictureShader() { | 35 SkPictureShader::~SkPictureShader() { |
| 36 fPicture->unref(); | 36 fPicture->unref(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 SkPictureShader* SkPictureShader::Create(SkPicture* picture, TileMode tmx, TileM
ode tmy, | 39 SkPictureShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx,
TileMode tmy, |
| 40 const SkMatrix* localMatrix) { | 40 const SkMatrix* localMatrix) { |
| 41 if (!picture || 0 == picture->width() || 0 == picture->height()) { | 41 if (!picture || 0 == picture->width() || 0 == picture->height()) { |
| 42 return NULL; | 42 return NULL; |
| 43 } | 43 } |
| 44 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix)); | 44 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SkPictureShader::flatten(SkWriteBuffer& buffer) const { | 47 void SkPictureShader::flatten(SkWriteBuffer& buffer) const { |
| 48 this->INHERITED::flatten(buffer); | 48 this->INHERITED::flatten(buffer); |
| 49 | 49 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect); | 195 return bitmapShader->asNewEffect(context, paint, NULL, paintColor, effect); |
| 196 } | 196 } |
| 197 #else | 197 #else |
| 198 bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint, | 198 bool SkPictureShader::asNewEffect(GrContext* context, const SkPaint& paint, |
| 199 const SkMatrix* localMatrix, GrColor* paintCol
or, | 199 const SkMatrix* localMatrix, GrColor* paintCol
or, |
| 200 GrEffect** effect) const { | 200 GrEffect** effect) const { |
| 201 SkDEBUGFAIL("Should not call in GPU-less build"); | 201 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 202 return false; | 202 return false; |
| 203 } | 203 } |
| 204 #endif | 204 #endif |
| OLD | NEW |