| 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 #ifndef SkColorCubeFilter_DEFINED | 8 #ifndef SkColorCubeFilter_DEFINED |
| 9 #define SkColorCubeFilter_DEFINED | 9 #define SkColorCubeFilter_DEFINED |
| 10 | 10 |
| 11 #include "SkColorFilter.h" | 11 #include "SkColorFilter.h" |
| 12 #include "SkData.h" | 12 #include "SkData.h" |
| 13 #include "../private/SkMutex.h" | 13 #include "../private/SkOnce.h" |
| 14 #include "../private/SkTemplates.h" | 14 #include "../private/SkTemplates.h" |
| 15 | 15 |
| 16 class SK_API SkColorCubeFilter : public SkColorFilter { | 16 class SK_API SkColorCubeFilter : public SkColorFilter { |
| 17 public: | 17 public: |
| 18 /** cubeData must containt a 3D data in the form of cube of the size: | 18 /** cubeData must containt a 3D data in the form of cube of the size: |
| 19 * cubeDimension * cubeDimension * cubeDimension * sizeof(SkColor) | 19 * cubeDimension * cubeDimension * cubeDimension * sizeof(SkColor) |
| 20 * This cube contains a transform where (x,y,z) maps to the (r,g,b). | 20 * This cube contains a transform where (x,y,z) maps to the (r,g,b). |
| 21 * The alpha components of the colors must be 0xFF. | 21 * The alpha components of the colors must be 0xFF. |
| 22 */ | 22 */ |
| 23 static sk_sp<SkColorFilter> Make(sk_sp<SkData> cubeData, int cubeDimension); | 23 static sk_sp<SkColorFilter> Make(sk_sp<SkData> cubeData, int cubeDimension); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // we need to recompute the corresponding cache values. | 58 // we need to recompute the corresponding cache values. |
| 59 int* fColorToIndex[2]; | 59 int* fColorToIndex[2]; |
| 60 SkScalar* fColorToFactors[2]; | 60 SkScalar* fColorToFactors[2]; |
| 61 SkScalar* fColorToScalar; | 61 SkScalar* fColorToScalar; |
| 62 | 62 |
| 63 SkAutoTMalloc<uint8_t> fLutStorage; | 63 SkAutoTMalloc<uint8_t> fLutStorage; |
| 64 | 64 |
| 65 const int fCubeDimension; | 65 const int fCubeDimension; |
| 66 | 66 |
| 67 // Make sure we only initialize the caches once. | 67 // Make sure we only initialize the caches once. |
| 68 SkMutex fLutsMutex; | 68 SkOnce fLutsInitOnce; |
| 69 bool fLutsInited; | |
| 70 | 69 |
| 71 static void initProcessingLuts(ColorCubeProcesingCache* cache); | 70 static void initProcessingLuts(ColorCubeProcesingCache* cache); |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 sk_sp<SkData> fCubeData; | 73 sk_sp<SkData> fCubeData; |
| 75 int32_t fUniqueID; | 74 int32_t fUniqueID; |
| 76 | 75 |
| 77 mutable ColorCubeProcesingCache fCache; | 76 mutable ColorCubeProcesingCache fCache; |
| 78 | 77 |
| 79 typedef SkColorFilter INHERITED; | 78 typedef SkColorFilter INHERITED; |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 #endif | 81 #endif |
| OLD | NEW |