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/SkMutex.h" |
| 14 #include "../private/SkTemplates.h" |
14 | 15 |
15 class SK_API SkColorCubeFilter : public SkColorFilter { | 16 class SK_API SkColorCubeFilter : public SkColorFilter { |
16 public: | 17 public: |
17 /** 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: |
18 * cubeDimension * cubeDimension * cubeDimension * sizeof(SkColor) | 19 * cubeDimension * cubeDimension * cubeDimension * sizeof(SkColor) |
19 * 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). |
20 * The alpha components of the colors must be 0xFF. | 21 * The alpha components of the colors must be 0xFF. |
21 */ | 22 */ |
22 static SkColorFilter* Create(SkData* cubeData, int cubeDimension); | 23 static SkColorFilter* Create(SkData* cubeData, int cubeDimension); |
23 | 24 |
(...skipping 24 matching lines...) Expand all Loading... |
48 | 49 |
49 int cubeDimension() const { return fCubeDimension; } | 50 int cubeDimension() const { return fCubeDimension; } |
50 | 51 |
51 private: | 52 private: |
52 // Working pointers. If any of these is NULL, | 53 // Working pointers. If any of these is NULL, |
53 // we need to recompute the corresponding cache values. | 54 // we need to recompute the corresponding cache values. |
54 int* fColorToIndex[2]; | 55 int* fColorToIndex[2]; |
55 SkScalar* fColorToFactors[2]; | 56 SkScalar* fColorToFactors[2]; |
56 SkScalar* fColorToScalar; | 57 SkScalar* fColorToScalar; |
57 | 58 |
58 SkAutoMalloc fLutStorage; | 59 SkAutoTMalloc<uint8_t> fLutStorage; |
59 | 60 |
60 const int fCubeDimension; | 61 const int fCubeDimension; |
61 | 62 |
62 // Make sure we only initialize the caches once. | 63 // Make sure we only initialize the caches once. |
63 SkMutex fLutsMutex; | 64 SkMutex fLutsMutex; |
64 bool fLutsInited; | 65 bool fLutsInited; |
65 | 66 |
66 static void initProcessingLuts(ColorCubeProcesingCache* cache); | 67 static void initProcessingLuts(ColorCubeProcesingCache* cache); |
67 }; | 68 }; |
68 | 69 |
69 SkAutoDataUnref fCubeData; | 70 SkAutoDataUnref fCubeData; |
70 int32_t fUniqueID; | 71 int32_t fUniqueID; |
71 | 72 |
72 mutable ColorCubeProcesingCache fCache; | 73 mutable ColorCubeProcesingCache fCache; |
73 | 74 |
74 typedef SkColorFilter INHERITED; | 75 typedef SkColorFilter INHERITED; |
75 }; | 76 }; |
76 | 77 |
77 #endif | 78 #endif |
OLD | NEW |