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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 void SkColorCubeFilter::ColorCubeProcesingCache::initProcessingLuts( | 94 void SkColorCubeFilter::ColorCubeProcesingCache::initProcessingLuts( |
95 SkColorCubeFilter::ColorCubeProcesingCache* cache) { | 95 SkColorCubeFilter::ColorCubeProcesingCache* cache) { |
96 static const SkScalar inv8bit = SkScalarInvert(SkIntToScalar(255)); | 96 static const SkScalar inv8bit = SkScalarInvert(SkIntToScalar(255)); |
97 | 97 |
98 // We need 256 int * 2 for fColorToIndex, so a total of 512 int. | 98 // We need 256 int * 2 for fColorToIndex, so a total of 512 int. |
99 // We need 256 SkScalar * 2 for fColorToFactors and 256 SkScalar | 99 // We need 256 SkScalar * 2 for fColorToFactors and 256 SkScalar |
100 // for fColorToScalar, so a total of 768 SkScalar. | 100 // for fColorToScalar, so a total of 768 SkScalar. |
101 cache->fLutStorage.reset(512 * sizeof(int) + 768 * sizeof(SkScalar)); | 101 cache->fLutStorage.reset(512 * sizeof(int) + 768 * sizeof(SkScalar)); |
102 uint8_t* storage = (uint8_t*)cache->fLutStorage.get(); | 102 uint8_t* storage = cache->fLutStorage.get(); |
103 cache->fColorToIndex[0] = (int*)storage; | 103 cache->fColorToIndex[0] = (int*)storage; |
104 cache->fColorToIndex[1] = cache->fColorToIndex[0] + 256; | 104 cache->fColorToIndex[1] = cache->fColorToIndex[0] + 256; |
105 cache->fColorToFactors[0] = (SkScalar*)(storage + (512 * sizeof(int))); | 105 cache->fColorToFactors[0] = (SkScalar*)(storage + (512 * sizeof(int))); |
106 cache->fColorToFactors[1] = cache->fColorToFactors[0] + 256; | 106 cache->fColorToFactors[1] = cache->fColorToFactors[0] + 256; |
107 cache->fColorToScalar = cache->fColorToFactors[1] + 256; | 107 cache->fColorToScalar = cache->fColorToFactors[1] + 256; |
108 | 108 |
109 SkScalar size = SkIntToScalar(cache->fCubeDimension); | 109 SkScalar size = SkIntToScalar(cache->fCubeDimension); |
110 SkScalar scale = (size - SK_Scalar1) * inv8bit; | 110 SkScalar scale = (size - SK_Scalar1) * inv8bit; |
111 | 111 |
112 for (int i = 0; i < 256; ++i) { | 112 for (int i = 0; i < 256; ++i) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 if (textureCube) { | 328 if (textureCube) { |
329 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); | 329 context->textureProvider()->assignUniqueKeyToTexture(key, textureCub
e); |
330 } else { | 330 } else { |
331 return nullptr; | 331 return nullptr; |
332 } | 332 } |
333 } | 333 } |
334 | 334 |
335 return GrColorCubeEffect::Create(textureCube); | 335 return GrColorCubeEffect::Create(textureCube); |
336 } | 336 } |
337 #endif | 337 #endif |
OLD | NEW |