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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 if (!(filterF & SkColorFilter::kHasFilter16_Flag)) { | 48 if (!(filterF & SkColorFilter::kHasFilter16_Flag)) { |
49 shaderF &= ~SkShader::kHasSpan16_Flag; | 49 shaderF &= ~SkShader::kHasSpan16_Flag; |
50 } | 50 } |
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::createContext(const ContextRec& rec, void* st
orage) const { | 58 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void*
storage) const { |
59 if (!this->validContext(rec, NULL)) { | |
60 return NULL; | |
61 } | |
62 | |
63 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); | 59 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); |
64 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext
Storage); | 60 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext
Storage); |
65 SkASSERT(shaderContext); | 61 SkASSERT(shaderContext); |
66 | 62 |
67 return SkNEW_PLACEMENT_ARGS(storage, FilterShaderContext, (*this, shaderCont
ext, rec)); | 63 return SkNEW_PLACEMENT_ARGS(storage, FilterShaderContext, (*this, shaderCont
ext, rec)); |
68 } | 64 } |
69 | 65 |
70 size_t SkFilterShader::contextSize() const { | 66 size_t SkFilterShader::contextSize() const { |
71 return sizeof(FilterShaderContext) + fShader->contextSize(); | 67 return sizeof(FilterShaderContext) + fShader->contextSize(); |
72 } | 68 } |
73 | 69 |
74 bool SkFilterShader::validContext(const ContextRec& rec, SkMatrix* totalInverse)
const { | |
75 return this->INHERITED::validContext(rec, totalInverse) && fShader->validCon
text(rec); | |
76 } | |
77 | |
78 SkFilterShader::FilterShaderContext::FilterShaderContext(const SkFilterShader& f
ilterShader, | 70 SkFilterShader::FilterShaderContext::FilterShaderContext(const SkFilterShader& f
ilterShader, |
79 SkShader::Context* shad
erContext, | 71 SkShader::Context* shad
erContext, |
80 const ContextRec& rec) | 72 const ContextRec& rec) |
81 : INHERITED(filterShader, rec) | 73 : INHERITED(filterShader, rec) |
82 , fShaderContext(shaderContext) {} | 74 , fShaderContext(shaderContext) {} |
83 | 75 |
84 SkFilterShader::FilterShaderContext::~FilterShaderContext() { | 76 SkFilterShader::FilterShaderContext::~FilterShaderContext() { |
85 fShaderContext->~Context(); | 77 fShaderContext->~Context(); |
86 } | 78 } |
87 | 79 |
(...skipping 21 matching lines...) Expand all Loading... |
109 str->append("Shader: "); | 101 str->append("Shader: "); |
110 fShader->toString(str); | 102 fShader->toString(str); |
111 str->append(" Filter: "); | 103 str->append(" Filter: "); |
112 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added | 104 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added |
113 | 105 |
114 this->INHERITED::toString(str); | 106 this->INHERITED::toString(str); |
115 | 107 |
116 str->append(")"); | 108 str->append(")"); |
117 } | 109 } |
118 #endif | 110 #endif |
OLD | NEW |