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

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

Issue 2486523002: Change code to not store Sk4* in data structures. (Closed)
Patch Set: Address comments 2 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
« no previous file with comments | « src/core/SkLinearBitmapPipeline_matrix.h ('k') | src/core/SkLinearBitmapPipeline_tile.h » ('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 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 fTintColor = SkColor4f::FromColor(tintColor);
70 fTintColor.fA = 1.0f;
71 }
70 72
71 Sk4f toSk4f(const Element pixel) const { 73 Sk4f toSk4f(const Element pixel) const {
72 return fTintColor * (pixel * (1.0f/255.0f)); 74 return Sk4f::Load(&fTintColor) * (pixel * (1.0f/255.0f));
73 } 75 }
74 76
75 private: 77 private:
76 const Sk4f fTintColor; 78 SkColor4f fTintColor;
77 }; 79 };
78 80
79 template <SkGammaType gammaType> 81 template <SkGammaType gammaType>
80 static inline Sk4f pmcolor_to_rgba(SkPMColor pixel) { 82 static inline Sk4f pmcolor_to_rgba(SkPMColor pixel) {
81 return swizzle_rb_if_bgra( 83 return swizzle_rb_if_bgra(
82 (gammaType == kSRGB_SkGammaType) ? Sk4f_fromS32(pixel) 84 (gammaType == kSRGB_SkGammaType) ? Sk4f_fromS32(pixel)
83 : Sk4f_fromL32(pixel)); 85 : Sk4f_fromL32(pixel));
84 } 86 }
85 87
86 template <SkGammaType gammaType> 88 template <SkGammaType gammaType>
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 const SkShader::TileMode fXEdgeType; 1029 const SkShader::TileMode fXEdgeType;
1028 const int fXMax; 1030 const int fXMax;
1029 const SkShader::TileMode fYEdgeType; 1031 const SkShader::TileMode fYEdgeType;
1030 const int fYMax; 1032 const int fYMax;
1031 Accessor fAccessor; 1033 Accessor fAccessor;
1032 }; 1034 };
1033 1035
1034 } // namespace 1036 } // namespace
1035 1037
1036 #endif // SkLinearBitmapPipeline_sampler_DEFINED 1038 #endif // SkLinearBitmapPipeline_sampler_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkLinearBitmapPipeline_matrix.h ('k') | src/core/SkLinearBitmapPipeline_tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698