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

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

Issue 2486523002: Change code to not store Sk4* in data structures. (Closed)
Patch Set: Created 4 years, 1 month 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
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 SkLinearBitmapPipeline_sampler_DEFINED 8 #ifndef SkLinearBitmapPipeline_sampler_DEFINED
9 #define SkLinearBitmapPipeline_sampler_DEFINED 9 #define SkLinearBitmapPipeline_sampler_DEFINED
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 template <SkColorType, SkGammaType> class PixelConverter; 58 template <SkColorType, SkGammaType> class PixelConverter;
59 59
60 // Alpha handling: 60 // Alpha handling:
61 // The alpha from the paint (tintColor) is used in the blend part of the pipel ine to modulate 61 // The alpha from the paint (tintColor) is used in the blend part of the pipel ine to modulate
62 // the entire bitmap. So, the tint color is given an alpha of 1.0 so that the la ter alpha can 62 // the entire bitmap. So, the tint color is given an alpha of 1.0 so that the la ter alpha can
63 // modulate this color later. 63 // modulate this color later.
64 template <> 64 template <>
65 class PixelConverter<kAlpha_8_SkColorType, kLinear_SkGammaType> { 65 class PixelConverter<kAlpha_8_SkColorType, kLinear_SkGammaType> {
66 public: 66 public:
67 using Element = uint8_t; 67 using Element = uint8_t;
68 PixelConverter(const SkPixmap& srcPixmap, SkColor tintColor) 68 PixelConverter(const SkPixmap& srcPixmap, SkColor tintColor) {
69 : fTintColor{set_alpha(Sk4f_from_SkColor(tintColor), 1.0f)} { } 69 set_alpha(Sk4f_from_SkColor(tintColor), 1.0f).store(&fTintColor);
70 }
70 71
71 Sk4f toSk4f(const Element pixel) const { 72 Sk4f toSk4f(const Element pixel) const {
72 return fTintColor * (pixel * (1.0f/255.0f)); 73 return Sk4f::Load(&fTintColor) * (pixel * (1.0f/255.0f));
73 } 74 }
74 75
75 private: 76 private:
76 const Sk4f fTintColor; 77 float fTintColor[4];
mtklein_C 2016/11/07 21:48:15 This may be a good place to use SkColor4f.
herb_g 2016/11/08 14:59:34 Done.
77 }; 78 };
78 79
79 template <SkGammaType gammaType> 80 template <SkGammaType gammaType>
80 static inline Sk4f pmcolor_to_rgba(SkPMColor pixel) { 81 static inline Sk4f pmcolor_to_rgba(SkPMColor pixel) {
81 return swizzle_rb_if_bgra( 82 return swizzle_rb_if_bgra(
82 (gammaType == kSRGB_SkGammaType) ? Sk4f_fromS32(pixel) 83 (gammaType == kSRGB_SkGammaType) ? Sk4f_fromS32(pixel)
83 : Sk4f_fromL32(pixel)); 84 : Sk4f_fromL32(pixel));
84 } 85 }
85 86
86 template <SkGammaType gammaType> 87 template <SkGammaType gammaType>
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 const SkShader::TileMode fXEdgeType; 1028 const SkShader::TileMode fXEdgeType;
1028 const int fXMax; 1029 const int fXMax;
1029 const SkShader::TileMode fYEdgeType; 1030 const SkShader::TileMode fYEdgeType;
1030 const int fYMax; 1031 const int fYMax;
1031 Accessor fAccessor; 1032 Accessor fAccessor;
1032 }; 1033 };
1033 1034
1034 } // namespace 1035 } // namespace
1035 1036
1036 #endif // SkLinearBitmapPipeline_sampler_DEFINED 1037 #endif // SkLinearBitmapPipeline_sampler_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698