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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 SkColorCubeFilter::SkColorCubeFilter(SkReadBuffer& buffer) | 164 SkColorCubeFilter::SkColorCubeFilter(SkReadBuffer& buffer) |
165 : fCache(buffer.readInt()) { | 165 : fCache(buffer.readInt()) { |
166 fCubeData.reset(buffer.readByteArrayAsData()); | 166 fCubeData.reset(buffer.readByteArrayAsData()); |
167 buffer.validate(is_valid_3D_lut(fCubeData, fCache.cubeDimension())); | 167 buffer.validate(is_valid_3D_lut(fCubeData, fCache.cubeDimension())); |
168 fUniqueID = SkNextColorProfileUniqueID(); | 168 fUniqueID = SkNextColorProfileUniqueID(); |
169 } | 169 } |
170 #endif | 170 #endif |
171 | 171 |
172 SkFlattenable* SkColorCubeFilter::CreateProc(SkReadBuffer& buffer) { | 172 SkFlattenable* SkColorCubeFilter::CreateProc(SkReadBuffer& buffer) { |
173 int cubeDimension = buffer.readInt(); | 173 int cubeDimension = buffer.readInt(); |
174 SkData* cubeData = buffer.readByteArrayAsData(); | 174 SkAutoDataUnref cubeData(buffer.readByteArrayAsData()); |
175 if (!buffer.validate(is_valid_3D_lut(cubeData, cubeDimension))) { | 175 if (!buffer.validate(is_valid_3D_lut(cubeData, cubeDimension))) { |
176 SkSafeUnref(cubeData); | |
177 return NULL; | 176 return NULL; |
178 } | 177 } |
179 return Create(cubeData, cubeDimension); | 178 return Create(cubeData, cubeDimension); |
180 } | 179 } |
181 | 180 |
182 void SkColorCubeFilter::flatten(SkWriteBuffer& buffer) const { | 181 void SkColorCubeFilter::flatten(SkWriteBuffer& buffer) const { |
183 this->INHERITED::flatten(buffer); | 182 this->INHERITED::flatten(buffer); |
184 buffer.writeInt(fCache.cubeDimension()); | 183 buffer.writeInt(fCache.cubeDimension()); |
185 buffer.writeDataAsByteArray(fCubeData); | 184 buffer.writeDataAsByteArray(fCubeData); |
186 } | 185 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 static_cast<GrTexture*>(context->findAndRefCachedResource( | 366 static_cast<GrTexture*>(context->findAndRefCachedResource( |
368 GrTexturePriv::ComputeKey(context->getGpu(), NULL, desc, cacheID))))
; | 367 GrTexturePriv::ComputeKey(context->getGpu(), NULL, desc, cacheID))))
; |
369 | 368 |
370 if (!textureCube) { | 369 if (!textureCube) { |
371 textureCube.reset(context->createTexture(NULL, desc, cacheID, fCubeData-
>data(), 0)); | 370 textureCube.reset(context->createTexture(NULL, desc, cacheID, fCubeData-
>data(), 0)); |
372 } | 371 } |
373 | 372 |
374 return textureCube ? GrColorProfileEffect::Create(textureCube) : NULL; | 373 return textureCube ? GrColorProfileEffect::Create(textureCube) : NULL; |
375 } | 374 } |
376 #endif | 375 #endif |
OLD | NEW |