Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/core/SkColorSpaceXform.h

Issue 2206403003: Optimize color xforms when src and dst are matching (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bench/ColorCodecBench.cpp ('k') | src/core/SkColorSpaceXform.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 SkColorSpaceXform_DEFINED 8 #ifndef SkColorSpaceXform_DEFINED
9 #define SkColorSpaceXform_DEFINED 9 #define SkColorSpaceXform_DEFINED
10 10
(...skipping 18 matching lines...) Expand all
29 * Apply the color conversion to a src buffer, storing the output in the ds t buffer. 29 * Apply the color conversion to a src buffer, storing the output in the ds t buffer.
30 * The src is stored as RGBA (8888). The dst is stored in the format indic ated by 30 * The src is stored as RGBA (8888). The dst is stored in the format indic ated by
31 * |dstColorType| and is premultiplied by alpha if |premul| is set. 31 * |dstColorType| and is premultiplied by alpha if |premul| is set.
32 */ 32 */
33 virtual void apply(void* dst, const uint32_t* src, int len, SkColorType dstC olorType, 33 virtual void apply(void* dst, const uint32_t* src, int len, SkColorType dstC olorType,
34 SkAlphaType dstAlphaType) const = 0; 34 SkAlphaType dstAlphaType) const = 0;
35 35
36 virtual ~SkColorSpaceXform() {} 36 virtual ~SkColorSpaceXform() {}
37 }; 37 };
38 38
39 template <SkColorSpace::GammaNamed kDst> 39 enum ColorSpaceMatch {
40 kNone_ColorSpaceMatch,
41 kGamut_ColorSpaceMatch,
42 kFull_ColorSpaceMatch,
43 };
44
45 template <SkColorSpace::GammaNamed kDst, ColorSpaceMatch kCSM>
40 class SkColorSpaceXform_Base : public SkColorSpaceXform { 46 class SkColorSpaceXform_Base : public SkColorSpaceXform {
41 public: 47 public:
42 48
43 void apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType , 49 void apply(void* dst, const uint32_t* src, int len, SkColorType dstColorType ,
44 SkAlphaType dstAlphaType) const override; 50 SkAlphaType dstAlphaType) const override;
45 51
46 static constexpr int kDstGammaTableSize = 1024; 52 static constexpr int kDstGammaTableSize = 1024;
47 53
48 private: 54 private:
49 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44 & srcToDst, 55 SkColorSpaceXform_Base(const sk_sp<SkColorSpace>& srcSpace, const SkMatrix44 & srcToDst,
50 const sk_sp<SkColorSpace>& dstSpace); 56 const sk_sp<SkColorSpace>& dstSpace);
51 57
52 sk_sp<SkColorLookUpTable> fColorLUT; 58 sk_sp<SkColorLookUpTable> fColorLUT;
53 59
54 // May contain pointers into storage or pointers into precomputed tables. 60 // May contain pointers into storage or pointers into precomputed tables.
55 const float* fSrcGammaTables[3]; 61 const float* fSrcGammaTables[3];
56 float fSrcGammaTableStorage[3 * 256]; 62 float fSrcGammaTableStorage[3 * 256];
57 63
58 float fSrcToDst[16]; 64 float fSrcToDst[16];
59 65
60 // May contain pointers into storage or pointers into precomputed tables. 66 // May contain pointers into storage or pointers into precomputed tables.
61 const uint8_t* fDstGammaTables[3]; 67 const uint8_t* fDstGammaTables[3];
62 uint8_t fDstGammaTableStorage[3 * kDstGammaTableSize]; 68 uint8_t fDstGammaTableStorage[3 * kDstGammaTableSize];
63 69
64 friend class SkColorSpaceXform; 70 friend class SkColorSpaceXform;
65 }; 71 };
66 72
67 #endif 73 #endif
OLDNEW
« no previous file with comments | « bench/ColorCodecBench.cpp ('k') | src/core/SkColorSpaceXform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698