OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkComposeShader.h" | 10 #include "SkComposeShader.h" |
11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #include "SkColorShader.h" | 13 #include "SkColorShader.h" |
14 #include "SkReadBuffer.h" | 14 #include "SkReadBuffer.h" |
15 #include "SkWriteBuffer.h" | 15 #include "SkWriteBuffer.h" |
16 #include "SkXfermode.h" | 16 #include "SkXfermode.h" |
17 #include "SkString.h" | 17 #include "SkString.h" |
18 | 18 |
19 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
20 | 20 |
21 SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) { | 21 SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) { |
22 fShaderA = sA; sA->ref(); | 22 fShaderA = sA; sA->ref(); |
23 fShaderB = sB; sB->ref(); | 23 fShaderB = sB; sB->ref(); |
24 // mode may be null | 24 // mode may be null |
25 fMode = mode; | 25 fMode = mode; |
26 SkSafeRef(mode); | 26 SkSafeRef(mode); |
27 } | 27 } |
28 | 28 |
29 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
30 SkComposeShader::SkComposeShader(SkReadBuffer& buffer) : INHERITED(buffer) { | |
31 fShaderA = buffer.readShader(); | |
32 if (NULL == fShaderA) { | |
33 fShaderA = SkNEW_ARGS(SkColorShader, ((SkColor)0)); | |
34 } | |
35 fShaderB = buffer.readShader(); | |
36 if (NULL == fShaderB) { | |
37 fShaderB = SkNEW_ARGS(SkColorShader, ((SkColor)0)); | |
38 } | |
39 fMode = buffer.readXfermode(); | |
40 } | |
41 #endif | |
42 | |
43 SkComposeShader::~SkComposeShader() { | 29 SkComposeShader::~SkComposeShader() { |
44 SkSafeUnref(fMode); | 30 SkSafeUnref(fMode); |
45 fShaderB->unref(); | 31 fShaderB->unref(); |
46 fShaderA->unref(); | 32 fShaderA->unref(); |
47 } | 33 } |
48 | 34 |
49 size_t SkComposeShader::contextSize() const { | 35 size_t SkComposeShader::contextSize() const { |
50 return sizeof(ComposeShaderContext) + fShaderA->contextSize() + fShaderB->co
ntextSize(); | 36 return sizeof(ComposeShaderContext) + fShaderA->contextSize() + fShaderB->co
ntextSize(); |
51 } | 37 } |
52 | 38 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 str->append(" ShaderB: "); | 203 str->append(" ShaderB: "); |
218 fShaderB->toString(str); | 204 fShaderB->toString(str); |
219 str->append(" Xfermode: "); | 205 str->append(" Xfermode: "); |
220 fMode->toString(str); | 206 fMode->toString(str); |
221 | 207 |
222 this->INHERITED::toString(str); | 208 this->INHERITED::toString(str); |
223 | 209 |
224 str->append(")"); | 210 str->append(")"); |
225 } | 211 } |
226 #endif | 212 #endif |
OLD | NEW |