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 "SkFlattenableBuffers.h" | 14 #include "SkFlattenableBuffers.h" |
15 #include "SkXfermode.h" | 15 #include "SkXfermode.h" |
16 #include "SkString.h" | 16 #include "SkString.h" |
17 | 17 |
18 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
19 | 19 |
20 SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) { | 20 SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode) { |
21 fShaderA = sA; sA->ref(); | 21 fShaderA = sA; sA->ref(); |
22 fShaderB = sB; sB->ref(); | 22 fShaderB = sB; sB->ref(); |
23 // mode may be null | 23 // mode may be null |
24 fMode = mode; | 24 fMode = mode; |
25 SkSafeRef(mode); | 25 SkSafeRef(mode); |
26 } | 26 } |
27 | 27 |
28 SkComposeShader::SkComposeShader(SkFlattenableReadBuffer& buffer) : | 28 SkComposeShader::SkComposeShader(SkFlattenableReadBuffer& buffer) : |
29 INHERITED(buffer) { | 29 INHERITED(buffer) { |
30 fShaderA = buffer.readFlattenableT<SkShader>(); | 30 fShaderA = buffer.readShader(); |
31 if (NULL == fShaderA) { | 31 if (NULL == fShaderA) { |
32 fShaderA = SkNEW_ARGS(SkColorShader, (0)); | 32 fShaderA = SkNEW_ARGS(SkColorShader, (0)); |
33 } | 33 } |
34 fShaderB = buffer.readFlattenableT<SkShader>(); | 34 fShaderB = buffer.readShader(); |
35 if (NULL == fShaderB) { | 35 if (NULL == fShaderB) { |
36 fShaderB = SkNEW_ARGS(SkColorShader, (0)); | 36 fShaderB = SkNEW_ARGS(SkColorShader, (0)); |
37 } | 37 } |
38 fMode = buffer.readFlattenableT<SkXfermode>(); | 38 fMode = buffer.readXfermode(); |
39 } | 39 } |
40 | 40 |
41 SkComposeShader::~SkComposeShader() { | 41 SkComposeShader::~SkComposeShader() { |
42 SkSafeUnref(fMode); | 42 SkSafeUnref(fMode); |
43 fShaderB->unref(); | 43 fShaderB->unref(); |
44 fShaderA->unref(); | 44 fShaderA->unref(); |
45 } | 45 } |
46 | 46 |
47 class SkAutoAlphaRestore { | 47 class SkAutoAlphaRestore { |
48 public: | 48 public: |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 str->append(" ShaderB: "); | 183 str->append(" ShaderB: "); |
184 fShaderB->toString(str); | 184 fShaderB->toString(str); |
185 str->append(" Xfermode: "); | 185 str->append(" Xfermode: "); |
186 fMode->toString(str); | 186 fMode->toString(str); |
187 | 187 |
188 this->INHERITED::toString(str); | 188 this->INHERITED::toString(str); |
189 | 189 |
190 str->append(")"); | 190 str->append(")"); |
191 } | 191 } |
192 #endif | 192 #endif |
OLD | NEW |