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 #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); |
| 24 |
| 25 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR |
23 static SkColorFilter* Create(SkData* cubeData, int cubeDimension); | 26 static SkColorFilter* Create(SkData* cubeData, int cubeDimension); |
| 27 #endif |
24 | 28 |
25 void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const overrid
e; | 29 void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const overrid
e; |
26 uint32_t getFlags() const override; | 30 uint32_t getFlags() const override; |
27 | 31 |
28 #if SK_SUPPORT_GPU | 32 #if SK_SUPPORT_GPU |
29 const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; | 33 const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override; |
30 #endif | 34 #endif |
31 | 35 |
32 SK_TO_STRING_OVERRIDE() | 36 SK_TO_STRING_OVERRIDE() |
33 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorCubeFilter) | 37 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorCubeFilter) |
34 | 38 |
35 protected: | 39 protected: |
36 SkColorCubeFilter(SkData* cubeData, int cubeDimension); | 40 SkColorCubeFilter(sk_sp<SkData> cubeData, int cubeDimension); |
37 void flatten(SkWriteBuffer&) const override; | 41 void flatten(SkWriteBuffer&) const override; |
38 | 42 |
39 private: | 43 private: |
40 /** The cache is initialized on-demand when getProcessingLuts is called. | 44 /** The cache is initialized on-demand when getProcessingLuts is called. |
41 */ | 45 */ |
42 class ColorCubeProcesingCache { | 46 class ColorCubeProcesingCache { |
43 public: | 47 public: |
44 ColorCubeProcesingCache(int cubeDimension); | 48 ColorCubeProcesingCache(int cubeDimension); |
45 | 49 |
46 void getProcessingLuts(const int* (*colorToIndex)[2], | 50 void getProcessingLuts(const int* (*colorToIndex)[2], |
(...skipping 22 matching lines...) Expand all Loading... |
69 | 73 |
70 sk_sp<SkData> fCubeData; | 74 sk_sp<SkData> fCubeData; |
71 int32_t fUniqueID; | 75 int32_t fUniqueID; |
72 | 76 |
73 mutable ColorCubeProcesingCache fCache; | 77 mutable ColorCubeProcesingCache fCache; |
74 | 78 |
75 typedef SkColorFilter INHERITED; | 79 typedef SkColorFilter INHERITED; |
76 }; | 80 }; |
77 | 81 |
78 #endif | 82 #endif |
OLD | NEW |