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(const SkPicture* picture, TileMode tmx, TileMod
e tmy, | 21 SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMod
e tmy, |
22 const SkMatrix* localMatrix, const SkRect* tile
) | 22 const SkMatrix* localMatrix, const SkRect* tile
) |
23 : INHERITED(localMatrix) | 23 : INHERITED(localMatrix) |
24 , fPicture(SkRef(picture)) | 24 , fPicture(SkRef(picture)) |
25 , fTile(NULL != tile ? *tile : picture->cullRect()) | 25 , fTile(tile ? *tile : picture->cullRect()) |
26 , fTmx(tmx) | 26 , fTmx(tmx) |
27 , fTmy(tmy) { | 27 , fTmy(tmy) { |
28 } | 28 } |
29 | 29 |
30 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 30 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
31 SkPictureShader::SkPictureShader(SkReadBuffer& buffer) : INHERITED(buffer) { | 31 SkPictureShader::SkPictureShader(SkReadBuffer& buffer) : INHERITED(buffer) { |
32 fTmx = static_cast<SkShader::TileMode>(buffer.read32()); | 32 fTmx = static_cast<SkShader::TileMode>(buffer.read32()); |
33 fTmy = static_cast<SkShader::TileMode>(buffer.read32()); | 33 fTmy = static_cast<SkShader::TileMode>(buffer.read32()); |
34 buffer.readRect(&fTile); | 34 buffer.readRect(&fTile); |
35 fPicture = SkPicture::CreateFromBuffer(buffer); | 35 fPicture = SkPicture::CreateFromBuffer(buffer); |
36 } | 36 } |
37 #endif | 37 #endif |
38 | 38 |
39 SkPictureShader::~SkPictureShader() { | 39 SkPictureShader::~SkPictureShader() { |
40 fPicture->unref(); | 40 fPicture->unref(); |
41 } | 41 } |
42 | 42 |
43 SkPictureShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx,
TileMode tmy, | 43 SkPictureShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx,
TileMode tmy, |
44 const SkMatrix* localMatrix, const SkRe
ct* tile) { | 44 const SkMatrix* localMatrix, const SkRe
ct* tile) { |
45 if (!picture || picture->cullRect().isEmpty() || (NULL != tile && tile->isEm
pty())) { | 45 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty()))
{ |
46 return NULL; | 46 return NULL; |
47 } | 47 } |
48 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile)); | 48 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile)); |
49 } | 49 } |
50 | 50 |
51 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) { | 51 SkFlattenable* SkPictureShader::CreateProc(SkReadBuffer& buffer) { |
52 SkMatrix lm; | 52 SkMatrix lm; |
53 buffer.readMatrix(&lm); | 53 buffer.readMatrix(&lm); |
54 TileMode mx = (TileMode)buffer.read32(); | 54 TileMode mx = (TileMode)buffer.read32(); |
55 TileMode my = (TileMode)buffer.read32(); | 55 TileMode my = (TileMode)buffer.read32(); |
(...skipping 166 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 |