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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMod
e tmy, | 94 SkPictureShader::SkPictureShader(const SkPicture* picture, TileMode tmx, TileMod
e tmy, |
95 const SkMatrix* localMatrix, const SkRect* tile
) | 95 const SkMatrix* localMatrix, const SkRect* tile
) |
96 : INHERITED(localMatrix) | 96 : INHERITED(localMatrix) |
97 , fPicture(SkRef(picture)) | 97 , fPicture(SkRef(picture)) |
98 , fTile(tile ? *tile : picture->cullRect()) | 98 , fTile(tile ? *tile : picture->cullRect()) |
99 , fTmx(tmx) | 99 , fTmx(tmx) |
100 , fTmy(tmy) { | 100 , fTmy(tmy) { |
101 } | 101 } |
102 | 102 |
103 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
104 SkPictureShader::SkPictureShader(SkReadBuffer& buffer) : INHERITED(buffer) { | |
105 fTmx = static_cast<SkShader::TileMode>(buffer.read32()); | |
106 fTmy = static_cast<SkShader::TileMode>(buffer.read32()); | |
107 buffer.readRect(&fTile); | |
108 fPicture = SkPicture::CreateFromBuffer(buffer); | |
109 } | |
110 #endif | |
111 | |
112 SkPictureShader::~SkPictureShader() { | 103 SkPictureShader::~SkPictureShader() { |
113 fPicture->unref(); | 104 fPicture->unref(); |
114 } | 105 } |
115 | 106 |
116 SkPictureShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx,
TileMode tmy, | 107 SkPictureShader* SkPictureShader::Create(const SkPicture* picture, TileMode tmx,
TileMode tmy, |
117 const SkMatrix* localMatrix, const SkRe
ct* tile) { | 108 const SkMatrix* localMatrix, const SkRe
ct* tile) { |
118 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty()))
{ | 109 if (!picture || picture->cullRect().isEmpty() || (tile && tile->isEmpty()))
{ |
119 return NULL; | 110 return NULL; |
120 } | 111 } |
121 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile)); | 112 return SkNEW_ARGS(SkPictureShader, (picture, tmx, tmy, localMatrix, tile)); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 } | 288 } |
298 return bitmapShader->asFragmentProcessor(context, paint, NULL, paintColor, f
p); | 289 return bitmapShader->asFragmentProcessor(context, paint, NULL, paintColor, f
p); |
299 } | 290 } |
300 #else | 291 #else |
301 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix*, GrColor*, | 292 bool SkPictureShader::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix*, GrColor*, |
302 GrFragmentProcessor**) const { | 293 GrFragmentProcessor**) const { |
303 SkDEBUGFAIL("Should not call in GPU-less build"); | 294 SkDEBUGFAIL("Should not call in GPU-less build"); |
304 return false; | 295 return false; |
305 } | 296 } |
306 #endif | 297 #endif |
OLD | NEW |