Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Side by Side Diff: src/core/SkFilterShader.cpp

Issue 1016103004: Revert of Revert of remove colorfilter native-565 support. complicating w/ no real value. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkFilterShader.h ('k') | src/effects/SkColorFilters.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // if the filter doesn't support 16bit, clear the matching bit in the shader 49 // filters don't support 16bit, so clear the matching bit in the shader
50 if (!(filterF & SkColorFilter::kHasFilter16_Flag)) { 50 shaderF &= ~SkShader::kHasSpan16_Flag;
51 shaderF &= ~SkShader::kHasSpan16_Flag; 51
52 }
53 // if the filter might change alpha, clear the opaque flag in the shader 52 // if the filter might change alpha, clear the opaque flag in the shader
54 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) { 53 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) {
55 shaderF &= ~(SkShader::kOpaqueAlpha_Flag | SkShader::kHasSpan16_Flag); 54 shaderF &= ~SkShader::kOpaqueAlpha_Flag;
56 } 55 }
57 return shaderF; 56 return shaderF;
58 } 57 }
59 58
60 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void* storage) const { 59 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void* storage) const {
61 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); 60 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext);
62 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext Storage); 61 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext Storage);
63 if (NULL == shaderContext) { 62 if (NULL == shaderContext) {
64 return NULL; 63 return NULL;
65 } 64 }
(...skipping 14 matching lines...) Expand all
80 fShaderContext->~Context(); 79 fShaderContext->~Context();
81 } 80 }
82 81
83 void SkFilterShader::FilterShaderContext::shadeSpan(int x, int y, SkPMColor resu lt[], int count) { 82 void SkFilterShader::FilterShaderContext::shadeSpan(int x, int y, SkPMColor resu lt[], int count) {
84 const SkFilterShader& filterShader = static_cast<const SkFilterShader&>(fSha der); 83 const SkFilterShader& filterShader = static_cast<const SkFilterShader&>(fSha der);
85 84
86 fShaderContext->shadeSpan(x, y, result, count); 85 fShaderContext->shadeSpan(x, y, result, count);
87 filterShader.fFilter->filterSpan(result, count, result); 86 filterShader.fFilter->filterSpan(result, count, result);
88 } 87 }
89 88
90 void SkFilterShader::FilterShaderContext::shadeSpan16(int x, int y, uint16_t res ult[], int count) {
91 const SkFilterShader& filterShader = static_cast<const SkFilterShader&>(fSha der);
92
93 SkASSERT(fShaderContext->getFlags() & SkShader::kHasSpan16_Flag);
94 SkASSERT(filterShader.fFilter->getFlags() & SkColorFilter::kHasFilter16_Flag );
95
96 fShaderContext->shadeSpan16(x, y, result, count);
97 filterShader.fFilter->filterSpan16(result, count, result);
98 }
99
100 #ifndef SK_IGNORE_TO_STRING 89 #ifndef SK_IGNORE_TO_STRING
101 void SkFilterShader::toString(SkString* str) const { 90 void SkFilterShader::toString(SkString* str) const {
102 str->append("SkFilterShader: ("); 91 str->append("SkFilterShader: (");
103 92
104 str->append("Shader: "); 93 str->append("Shader: ");
105 fShader->toString(str); 94 fShader->toString(str);
106 str->append(" Filter: "); 95 str->append(" Filter: ");
107 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added 96 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added
108 97
109 this->INHERITED::toString(str); 98 this->INHERITED::toString(str);
110 99
111 str->append(")"); 100 str->append(")");
112 } 101 }
113 #endif 102 #endif
OLDNEW
« no previous file with comments | « src/core/SkFilterShader.h ('k') | src/effects/SkColorFilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698