OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkColorCubeFilter.h" | 8 #include "SkColorCubeFilter.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkOnce.h" | 10 #include "SkOnce.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 size_t minMemorySize = sizeof(uint8_t) * 4 * cubeDimension * cubeDimension *
cubeDimension; | 44 size_t minMemorySize = sizeof(uint8_t) * 4 * cubeDimension * cubeDimension *
cubeDimension; |
45 return (cubeDimension >= MIN_CUBE_SIZE) && (cubeDimension <= MAX_CUBE_SIZE)
&& | 45 return (cubeDimension >= MIN_CUBE_SIZE) && (cubeDimension <= MAX_CUBE_SIZE)
&& |
46 (NULL != cubeData) && (cubeData->size() >= minMemorySize); | 46 (NULL != cubeData) && (cubeData->size() >= minMemorySize); |
47 } | 47 } |
48 | 48 |
49 SkColorFilter* SkColorCubeFilter::Create(SkData* cubeData, int cubeDimension) { | 49 SkColorFilter* SkColorCubeFilter::Create(SkData* cubeData, int cubeDimension) { |
50 if (!is_valid_3D_lut(cubeData, cubeDimension)) { | 50 if (!is_valid_3D_lut(cubeData, cubeDimension)) { |
51 return NULL; | 51 return NULL; |
52 } | 52 } |
53 | 53 |
54 return SkNEW_ARGS(SkColorCubeFilter, (cubeData, cubeDimension)); | 54 return new SkColorCubeFilter(cubeData, cubeDimension); |
55 } | 55 } |
56 | 56 |
57 SkColorCubeFilter::SkColorCubeFilter(SkData* cubeData, int cubeDimension) | 57 SkColorCubeFilter::SkColorCubeFilter(SkData* cubeData, int cubeDimension) |
58 : fCubeData(SkRef(cubeData)) | 58 : fCubeData(SkRef(cubeData)) |
59 , fUniqueID(SkNextColorCubeUniqueID()) | 59 , fUniqueID(SkNextColorCubeUniqueID()) |
60 , fCache(cubeDimension) { | 60 , fCache(cubeDimension) { |
61 } | 61 } |
62 | 62 |
63 uint32_t SkColorCubeFilter::getFlags() const { | 63 uint32_t SkColorCubeFilter::getFlags() const { |
64 return this->INHERITED::getFlags() | kAlphaUnchanged_Flag; | 64 return this->INHERITED::getFlags() | kAlphaUnchanged_Flag; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 str->append("SkColorCubeFilter "); | 154 str->append("SkColorCubeFilter "); |
155 } | 155 } |
156 #endif | 156 #endif |
157 | 157 |
158 /////////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////////// |
159 #if SK_SUPPORT_GPU | 159 #if SK_SUPPORT_GPU |
160 | 160 |
161 class GrColorCubeEffect : public GrFragmentProcessor { | 161 class GrColorCubeEffect : public GrFragmentProcessor { |
162 public: | 162 public: |
163 static GrFragmentProcessor* Create(GrTexture* colorCube) { | 163 static GrFragmentProcessor* Create(GrTexture* colorCube) { |
164 return (NULL != colorCube) ? SkNEW_ARGS(GrColorCubeEffect, (colorCube))
: NULL; | 164 return (NULL != colorCube) ? new GrColorCubeEffect(colorCube) : NULL; |
165 } | 165 } |
166 | 166 |
167 virtual ~GrColorCubeEffect(); | 167 virtual ~GrColorCubeEffect(); |
168 | 168 |
169 const char* name() const override { return "ColorCube"; } | 169 const char* name() const override { return "ColorCube"; } |
170 | 170 |
171 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } | 171 int colorCubeSize() const { return fColorCubeAccess.getTexture()->width(); } |
172 | 172 |
173 | 173 |
174 void onComputeInvariantOutput(GrInvariantOutput*) const override; | 174 void onComputeInvariantOutput(GrInvariantOutput*) const override; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 216 } |
217 | 217 |
218 GrColorCubeEffect::~GrColorCubeEffect() { | 218 GrColorCubeEffect::~GrColorCubeEffect() { |
219 } | 219 } |
220 | 220 |
221 void GrColorCubeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK
eyBuilder* b) const { | 221 void GrColorCubeEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorK
eyBuilder* b) const { |
222 GLProcessor::GenKey(*this, caps, b); | 222 GLProcessor::GenKey(*this, caps, b); |
223 } | 223 } |
224 | 224 |
225 GrGLFragmentProcessor* GrColorCubeEffect::onCreateGLInstance() const { | 225 GrGLFragmentProcessor* GrColorCubeEffect::onCreateGLInstance() const { |
226 return SkNEW_ARGS(GLProcessor, (*this)); | 226 return new GLProcessor(*this); |
227 } | 227 } |
228 | 228 |
229 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ | 229 void GrColorCubeEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const
{ |
230 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | 230 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); |
231 } | 231 } |
232 | 232 |
233 /////////////////////////////////////////////////////////////////////////////// | 233 /////////////////////////////////////////////////////////////////////////////// |
234 | 234 |
235 GrColorCubeEffect::GLProcessor::GLProcessor(const GrProcessor&) { | 235 GrColorCubeEffect::GLProcessor::GLProcessor(const GrProcessor&) { |
236 } | 236 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 *array->append() = frag; | 333 *array->append() = frag; |
334 } else { | 334 } else { |
335 frag->unref(); | 335 frag->unref(); |
336 SkDEBUGCODE(frag = NULL;) | 336 SkDEBUGCODE(frag = NULL;) |
337 } | 337 } |
338 return true; | 338 return true; |
339 } | 339 } |
340 return false; | 340 return false; |
341 } | 341 } |
342 #endif | 342 #endif |
OLD | NEW |