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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 EDT Created 5 years, 3 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/SkError.cpp ('k') | src/core/SkFont.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 14 matching lines...) Expand all
25 fFilter->unref(); 25 fFilter->unref();
26 fShader->unref(); 26 fShader->unref();
27 } 27 }
28 28
29 SkFlattenable* SkFilterShader::CreateProc(SkReadBuffer& buffer) { 29 SkFlattenable* SkFilterShader::CreateProc(SkReadBuffer& buffer) {
30 SkAutoTUnref<SkShader> shader(buffer.readShader()); 30 SkAutoTUnref<SkShader> shader(buffer.readShader());
31 SkAutoTUnref<SkColorFilter> filter(buffer.readColorFilter()); 31 SkAutoTUnref<SkColorFilter> filter(buffer.readColorFilter());
32 if (!shader.get() || !filter.get()) { 32 if (!shader.get() || !filter.get()) {
33 return NULL; 33 return NULL;
34 } 34 }
35 return SkNEW_ARGS(SkFilterShader, (shader, filter)); 35 return new SkFilterShader(shader, filter);
36 } 36 }
37 37
38 void SkFilterShader::flatten(SkWriteBuffer& buffer) const { 38 void SkFilterShader::flatten(SkWriteBuffer& buffer) const {
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 49 // filters don't support 16bit, so clear the matching bit in the shader
50 shaderF &= ~SkShader::kHasSpan16_Flag; 50 shaderF &= ~SkShader::kHasSpan16_Flag;
51 51
52 // 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
53 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) { 53 if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) {
54 shaderF &= ~SkShader::kOpaqueAlpha_Flag; 54 shaderF &= ~SkShader::kOpaqueAlpha_Flag;
55 } 55 }
56 return shaderF; 56 return shaderF;
57 } 57 }
58 58
59 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void* storage) const { 59 SkShader::Context* SkFilterShader::onCreateContext(const ContextRec& rec, void* storage) const {
60 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext); 60 char* shaderContextStorage = (char*)storage + sizeof(FilterShaderContext);
61 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext Storage); 61 SkShader::Context* shaderContext = fShader->createContext(rec, shaderContext Storage);
62 if (NULL == shaderContext) { 62 if (NULL == shaderContext) {
63 return NULL; 63 return NULL;
64 } 64 }
65 return SkNEW_PLACEMENT_ARGS(storage, FilterShaderContext, (*this, shaderCont ext, rec)); 65 return new (storage) FilterShaderContext(*this, shaderContext, rec);
66 } 66 }
67 67
68 size_t SkFilterShader::contextSize() const { 68 size_t SkFilterShader::contextSize() const {
69 return sizeof(FilterShaderContext) + fShader->contextSize(); 69 return sizeof(FilterShaderContext) + fShader->contextSize();
70 } 70 }
71 71
72 SkFilterShader::FilterShaderContext::FilterShaderContext(const SkFilterShader& f ilterShader, 72 SkFilterShader::FilterShaderContext::FilterShaderContext(const SkFilterShader& f ilterShader,
73 SkShader::Context* shad erContext, 73 SkShader::Context* shad erContext,
74 const ContextRec& rec) 74 const ContextRec& rec)
75 : INHERITED(filterShader, rec) 75 : INHERITED(filterShader, rec)
(...skipping 17 matching lines...) Expand all
93 str->append("Shader: "); 93 str->append("Shader: ");
94 fShader->toString(str); 94 fShader->toString(str);
95 str->append(" Filter: "); 95 str->append(" Filter: ");
96 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added 96 // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added
97 97
98 this->INHERITED::toString(str); 98 this->INHERITED::toString(str);
99 99
100 str->append(")"); 100 str->append(")");
101 } 101 }
102 #endif 102 #endif
OLDNEW
« no previous file with comments | « src/core/SkError.cpp ('k') | src/core/SkFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698