OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkFilterShader.h" | 8 #include "SkFilterShader.h" |
9 | 9 |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // if the filter might change alpha, clear the opaque flag in the shader | 51 // if the filter might change alpha, clear the opaque flag in the shader |
52 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) { | 52 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) { |
53 shaderF &= ~(SkShader::kOpaqueAlpha_Flag | SkShader::kHasSpan16_Flag); | 53 shaderF &= ~(SkShader::kOpaqueAlpha_Flag | SkShader::kHasSpan16_Flag); |
54 } | 54 } |
55 return shaderF; | 55 return shaderF; |
56 } | 56 } |
57 | 57 |
58 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void*
storage) const { | 58 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void*
storage) const { |
59 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); | 59 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); |
60 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext
Storage); | 60 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext
Storage); |
61 SkASSERT(shaderContext); | 61 if (NULL == shaderContext) { |
62 | 62 return NULL; |
| 63 } |
63 return SkNEW_PLACEMENT_ARGS(storage, FilterShaderContext, (*this, shaderCont
ext, rec)); | 64 return SkNEW_PLACEMENT_ARGS(storage, FilterShaderContext, (*this, shaderCont
ext, rec)); |
64 } | 65 } |
65 | 66 |
66 size_t SkFilterShader::contextSize() const { | 67 size_t SkFilterShader::contextSize() const { |
67 return sizeof(FilterShaderContext) + fShader->contextSize(); | 68 return sizeof(FilterShaderContext) + fShader->contextSize(); |
68 } | 69 } |
69 | 70 |
70 SkFilterShader::FilterShaderContext::FilterShaderContext(const SkFilterShader& f
ilterShader, | 71 SkFilterShader::FilterShaderContext::FilterShaderContext(const SkFilterShader& f
ilterShader, |
71 SkShader::Context* shad
erContext, | 72 SkShader::Context* shad
erContext, |
72 const ContextRec& rec) | 73 const ContextRec& rec) |
(...skipping 28 matching lines...) Expand all Loading... |
101 str->append("Shader: "); | 102 str->append("Shader: "); |
102 fShader->toString(str); | 103 fShader->toString(str); |
103 str->append(" Filter: "); | 104 str->append(" Filter: "); |
104 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added | 105 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added |
105 | 106 |
106 this->INHERITED::toString(str); | 107 this->INHERITED::toString(str); |
107 | 108 |
108 str->append(")"); | 109 str->append(")"); |
109 } | 110 } |
110 #endif | 111 #endif |
OLD | NEW |