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 "SkColorShader.h" | 9 #include "SkColorShader.h" |
10 #include "SkEmptyShader.h" | 10 #include "SkEmptyShader.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 SkShader::SkShader(const SkMatrix* localMatrix) { | 40 SkShader::SkShader(const SkMatrix* localMatrix) { |
41 inc_shader_counter(); | 41 inc_shader_counter(); |
42 if (localMatrix) { | 42 if (localMatrix) { |
43 fLocalMatrix = *localMatrix; | 43 fLocalMatrix = *localMatrix; |
44 } else { | 44 } else { |
45 fLocalMatrix.reset(); | 45 fLocalMatrix.reset(); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
50 SkShader::SkShader(SkReadBuffer& buffer) : INHERITED(buffer) { | |
51 inc_shader_counter(); | |
52 if (buffer.readBool()) { | |
53 buffer.readMatrix(&fLocalMatrix); | |
54 } else { | |
55 fLocalMatrix.reset(); | |
56 } | |
57 } | |
58 #endif | |
59 | |
60 SkShader::~SkShader() { | 49 SkShader::~SkShader() { |
61 dec_shader_counter(); | 50 dec_shader_counter(); |
62 } | 51 } |
63 | 52 |
64 void SkShader::flatten(SkWriteBuffer& buffer) const { | 53 void SkShader::flatten(SkWriteBuffer& buffer) const { |
65 this->INHERITED::flatten(buffer); | 54 this->INHERITED::flatten(buffer); |
66 bool hasLocalM = !fLocalMatrix.isIdentity(); | 55 bool hasLocalM = !fLocalMatrix.isIdentity(); |
67 buffer.writeBool(hasLocalM); | 56 buffer.writeBool(hasLocalM); |
68 if (hasLocalM) { | 57 if (hasLocalM) { |
69 buffer.writeMatrix(fLocalMatrix); | 58 buffer.writeMatrix(fLocalMatrix); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 #include "SkUtils.h" | 253 #include "SkUtils.h" |
265 | 254 |
266 SkColorShader::SkColorShader(SkColor c) | 255 SkColorShader::SkColorShader(SkColor c) |
267 : fColor(c) { | 256 : fColor(c) { |
268 } | 257 } |
269 | 258 |
270 bool SkColorShader::isOpaque() const { | 259 bool SkColorShader::isOpaque() const { |
271 return SkColorGetA(fColor) == 255; | 260 return SkColorGetA(fColor) == 255; |
272 } | 261 } |
273 | 262 |
274 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
275 SkColorShader::SkColorShader(SkReadBuffer& b) : INHERITED(b) { | |
276 fColor = b.readColor(); | |
277 } | |
278 #endif | |
279 | |
280 SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) { | 263 SkFlattenable* SkColorShader::CreateProc(SkReadBuffer& buffer) { |
281 return SkNEW_ARGS(SkColorShader, (buffer.readColor())); | 264 return SkNEW_ARGS(SkColorShader, (buffer.readColor())); |
282 } | 265 } |
283 | 266 |
284 void SkColorShader::flatten(SkWriteBuffer& buffer) const { | 267 void SkColorShader::flatten(SkWriteBuffer& buffer) const { |
285 buffer.writeColor(fColor); | 268 buffer.writeColor(fColor); |
286 } | 269 } |
287 | 270 |
288 uint32_t SkColorShader::ColorShaderContext::getFlags() const { | 271 uint32_t SkColorShader::ColorShaderContext::getFlags() const { |
289 return fFlags; | 272 return fFlags; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 #include "SkEmptyShader.h" | 385 #include "SkEmptyShader.h" |
403 | 386 |
404 void SkEmptyShader::toString(SkString* str) const { | 387 void SkEmptyShader::toString(SkString* str) const { |
405 str->append("SkEmptyShader: ("); | 388 str->append("SkEmptyShader: ("); |
406 | 389 |
407 this->INHERITED::toString(str); | 390 this->INHERITED::toString(str); |
408 | 391 |
409 str->append(")"); | 392 str->append(")"); |
410 } | 393 } |
411 #endif | 394 #endif |
OLD | NEW |