| 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 28 matching lines...) Expand all Loading... |
| 39 buffer.writeFlattenable(fShader); | 39 buffer.writeFlattenable(fShader); |
| 40 buffer.writeFlattenable(fFilter); | 40 buffer.writeFlattenable(fFilter); |
| 41 } | 41 } |
| 42 | 42 |
| 43 uint32_t SkFilterShader::FilterShaderContext::getFlags() const { | 43 uint32_t SkFilterShader::FilterShaderContext::getFlags() const { |
| 44 const SkFilterShader& filterShader = static_cast<const SkFilterShader&>(fSha
der); | 44 const SkFilterShader& filterShader = static_cast<const SkFilterShader&>(fSha
der); |
| 45 | 45 |
| 46 uint32_t shaderF = fShaderContext->getFlags(); | 46 uint32_t shaderF = fShaderContext->getFlags(); |
| 47 uint32_t filterF = filterShader.fFilter->getFlags(); | 47 uint32_t filterF = filterShader.fFilter->getFlags(); |
| 48 | 48 |
| 49 // filters don't support 16bit, so clear the matching bit in the shader | |
| 50 shaderF &= ~SkShader::kHasSpan16_Flag; | |
| 51 | |
| 52 // if the filter might change alpha, clear the opaque flag in the shader | 49 // if the filter might change alpha, clear the opaque flag in the shader |
| 53 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) { | 50 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) { |
| 54 shaderF &= ~SkShader::kOpaqueAlpha_Flag; | 51 shaderF &= ~SkShader::kOpaqueAlpha_Flag; |
| 55 } | 52 } |
| 56 return shaderF; | 53 return shaderF; |
| 57 } | 54 } |
| 58 | 55 |
| 59 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void*
storage) const { | 56 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void*
storage) const { |
| 60 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); | 57 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); |
| 61 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext
Storage); | 58 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext
Storage); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 str->append("Shader: "); | 90 str->append("Shader: "); |
| 94 fShader->toString(str); | 91 fShader->toString(str); |
| 95 str->append(" Filter: "); | 92 str->append(" Filter: "); |
| 96 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added | 93 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added |
| 97 | 94 |
| 98 this->INHERITED::toString(str); | 95 this->INHERITED::toString(str); |
| 99 | 96 |
| 100 str->append(")"); | 97 str->append(")"); |
| 101 } | 98 } |
| 102 #endif | 99 #endif |
| OLD | NEW |