Chromium Code Reviews| Index: include/effects/SkColorProfileFilter.h |
| diff --git a/include/effects/SkColorProfileFilter.h b/include/effects/SkColorProfileFilter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ff485b04943a7777257c0cf897a4e65d11b4ec05 |
| --- /dev/null |
| +++ b/include/effects/SkColorProfileFilter.h |
| @@ -0,0 +1,75 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SkColorProfileFilter_DEFINED |
| +#define SkColorProfileFilter_DEFINED |
| + |
| +#include "SkColorFilter.h" |
| +#include "SkData.h" |
| + |
| +class SK_API SkColorProfileFilter : public SkColorFilter { |
| +public: |
| + // cubeData must containt a 3D data in the form of cube of the size: |
| + // cubeDimension * cubeDimension * cubeDimension * sizeof(SkPMColor) |
| + // This cube contains a transform where (x,y,z) maps to the (r,g,b). |
| + static SkColorProfileFilter* Create(SkData* cubeData, int cubeDimension); |
|
bsalomon
2014/10/03 19:45:00
Can this return SkColorFilter* rather than the der
sugoi1
2014/10/06 15:04:54
Done.
|
| + |
| + virtual void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const SK_OVERRIDE; |
| + |
| +#if SK_SUPPORT_GPU |
| + virtual GrFragmentProcessor* asFragmentProcessor(GrContext*) const SK_OVERRIDE; |
| +#endif |
| + |
| + SK_TO_STRING_OVERRIDE() |
| + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorProfileFilter) |
| + |
| +protected: |
| + SkColorProfileFilter(SkData* cubeData, int cubeDimension); |
| +#ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| + SkColorProfileFilter(SkReadBuffer& buffer); |
| +#endif |
| + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| + |
| +private: |
| + // The cache is initialized on-demand when getColorLuts is called. |
| + class ColorProfileCache { |
|
bsalomon
2014/10/03 19:45:00
Why is this dynamically allocated when it is creat
sugoi1
2014/10/06 15:04:54
If I don't keep it as a pointer, then I get an err
bsalomon
2014/10/06 17:26:17
I don't fully grok the immutability requirements f
|
| + public: |
| + ColorProfileCache(int cubeDimension); |
| + |
| + void getProcessingLuts(const int* (*colorToIndex)[2], |
| + const SkScalar* (*colorToFactors)[2], |
| + const SkScalar** colorToScalar); |
| + |
| + int cubeDimension() const { return fCubeDimension; } |
| + |
| + private: |
| + // Working pointers. If any of these is NULL, |
| + // we need to recompute the corresponding cache values. |
| + int* fColorToIndex[2]; |
| + SkScalar* fColorToFactors[2]; |
| + SkScalar* fColorToScalar; |
| + |
| + SkAutoMalloc fLutStorage; |
| + |
| + const int fCubeDimension; |
| + |
| + // Make sure we only initialize the caches once. |
| + SkMutex fLutsMutex; |
| + bool fLutsInited; |
| + |
| + static void initProcessingLuts(ColorProfileCache* cache); |
| + }; |
| + |
| + SkAutoDataUnref fCubeData; |
| + int32_t fUniqueID; |
| + |
| + SkAutoTDelete<ColorProfileCache> fCache; |
| + |
| + typedef SkColorFilter INHERITED; |
| +}; |
| + |
| +#endif |