OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
9 #include "SkEmptyShader.h" | 9 #include "SkEmptyShader.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 SkShader::SkShader(const SkMatrix* localMatrix) { | 39 SkShader::SkShader(const SkMatrix* localMatrix) { |
40 inc_shader_counter(); | 40 inc_shader_counter(); |
41 if (localMatrix) { | 41 if (localMatrix) { |
42 fLocalMatrix = *localMatrix; | 42 fLocalMatrix = *localMatrix; |
43 } else { | 43 } else { |
44 fLocalMatrix.reset(); | 44 fLocalMatrix.reset(); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
| 48 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
48 SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) { | 49 SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) { |
49 inc_shader_counter(); | 50 inc_shader_counter(); |
50 if (buffer.readBool()) { | 51 if (buffer.readBool()) { |
51 buffer.readMatrix(&fLocalMatrix); | 52 buffer.readMatrix(&fLocalMatrix); |
52 } else { | 53 } else { |
53 fLocalMatrix.reset(); | 54 fLocalMatrix.reset(); |
54 } | 55 } |
55 } | 56 } |
| 57 #endif |
56 | 58 |
57 SkShader::~SkShader() { | 59 SkShader::~SkShader() { |
58 dec_shader_counter(); | 60 dec_shader_counter(); |
59 } | 61 } |
60 | 62 |
61 void SkShader::flatten(SkWriteBuffer& buffer) const { | 63 void SkShader::flatten(SkWriteBuffer& buffer) const { |
62 this->INHERITED::flatten(buffer); | 64 this->INHERITED::flatten(buffer); |
63 bool hasLocalM = !fLocalMatrix.isIdentity(); | 65 bool hasLocalM = !fLocalMatrix.isIdentity(); |
64 buffer.writeBool(hasLocalM); | 66 buffer.writeBool(hasLocalM); |
65 if (hasLocalM) { | 67 if (hasLocalM) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 #include "SkUtils.h" | 249 #include "SkUtils.h" |
248 | 250 |
249 SkColorShader::SkColorShader(SkColor c) | 251 SkColorShader::SkColorShader(SkColor c) |
250 : fColor(c) { | 252 : fColor(c) { |
251 } | 253 } |
252 | 254 |
253 bool SkColorShader::isOpaque() const { | 255 bool SkColorShader::isOpaque() const { |
254 return SkColorGetA(fColor) == 255; | 256 return SkColorGetA(fColor) == 255; |
255 } | 257 } |
256 | 258 |
| 259 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
257 SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) { | 260 SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) { |
258 // V25_COMPATIBILITY_CODE We had a boolean to make the color shader inherit
the paint's | 261 // V25_COMPATIBILITY_CODE We had a boolean to make the color shader inherit
the paint's |
259 // color. We don't support that any more. | 262 // color. We don't support that any more. |
260 if (b.isVersionLT(SkReadBuffer::kColorShaderNoBool_Version)) { | 263 if (b.isVersionLT(SkReadBuffer::kColorShaderNoBool_Version)) { |
261 if (b.readBool()) { | 264 if (b.readBool()) { |
262 SkDEBUGFAIL("We shouldn't have pictures that recorded the inherited
case."); | 265 SkDEBUGFAIL("We shouldn't have pictures that recorded the inherited
case."); |
263 fColor = SK_ColorWHITE; | 266 fColor = SK_ColorWHITE; |
264 return; | 267 return; |
265 } | 268 } |
266 } | 269 } |
267 fColor = b.readColor(); | 270 fColor = b.readColor(); |
268 } | 271 } |
| 272 #endif |
| 273 |
| 274 SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) { |
| 275 return SkNEW_ARGS(SkColorShader, (buffer.readColor())); |
| 276 } |
269 | 277 |
270 void SkColorShader::flatten(SkWriteBuffer& buffer) const { | 278 void SkColorShader::flatten(SkWriteBuffer& buffer) const { |
271 this->INHERITED::flatten(buffer); | 279 this->INHERITED::flatten(buffer); |
272 buffer.writeColor(fColor); | 280 buffer.writeColor(fColor); |
273 } | 281 } |
274 | 282 |
275 uint32_t SkColorShader::ColorShaderContext::getFlags() const { | 283 uint32_t SkColorShader::ColorShaderContext::getFlags() const { |
276 return fFlags; | 284 return fFlags; |
277 } | 285 } |
278 | 286 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 str->appendHex(fColor); | 384 str->appendHex(fColor); |
377 | 385 |
378 this->INHERITED::toString(str); | 386 this->INHERITED::toString(str); |
379 | 387 |
380 str->append(")"); | 388 str->append(")"); |
381 } | 389 } |
382 #endif | 390 #endif |
383 | 391 |
384 /////////////////////////////////////////////////////////////////////////////// | 392 /////////////////////////////////////////////////////////////////////////////// |
385 | 393 |
| 394 SkFlattenable* SkEmptyShader::CreateProc(SkReadBuffer&) { |
| 395 return SkShader::CreateEmptyShader(); |
| 396 } |
| 397 |
386 #ifndef SK_IGNORE_TO_STRING | 398 #ifndef SK_IGNORE_TO_STRING |
387 #include "SkEmptyShader.h" | 399 #include "SkEmptyShader.h" |
388 | 400 |
389 void SkEmptyShader::toString(SkString* str) const { | 401 void SkEmptyShader::toString(SkString* str) const { |
390 str->append("SkEmptyShader: ("); | 402 str->append("SkEmptyShader: ("); |
391 | 403 |
392 this->INHERITED::toString(str); | 404 this->INHERITED::toString(str); |
393 | 405 |
394 str->append(")"); | 406 str->append(")"); |
395 } | 407 } |
396 #endif | 408 #endif |
OLD | NEW |