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/effects/gradients/Sk4fGradientBase.h

Issue 1783823002: Generic 4f gradient T sampler fallback (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 4 years, 9 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
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 Sk4fGradientBase_DEFINED 8 #ifndef Sk4fGradientBase_DEFINED
9 #define Sk4fGradientBase_DEFINED 9 #define Sk4fGradientBase_DEFINED
10 10
11 #include "SkColor.h" 11 #include "SkColor.h"
12 #include "SkGradientShaderPriv.h" 12 #include "SkGradientShaderPriv.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkNx.h" 14 #include "SkNx.h"
15 #include "SkPM4f.h" 15 #include "SkPM4f.h"
16 #include "SkShader.h" 16 #include "SkShader.h"
17 #include "SkTArray.h" 17 #include "SkTArray.h"
18 18
19 class SkGradientShaderBase:: 19 class SkGradientShaderBase::
20 GradientShaderBase4fContext : public SkShader::Context { 20 GradientShaderBase4fContext : public SkShader::Context {
21 public: 21 public:
22 GradientShaderBase4fContext(const SkGradientShaderBase&, 22 GradientShaderBase4fContext(const SkGradientShaderBase&,
23 const ContextRec&); 23 const ContextRec&);
24 24
25 uint32_t getFlags() const override { return fFlags; } 25 uint32_t getFlags() const override { return fFlags; }
26 26
27 void shadeSpan(int x, int y, SkPMColor dst[], int count) override;
28 void shadeSpan4f(int x, int y, SkPM4f dst[], int count) override;
29
27 protected: 30 protected:
28 struct Interval { 31 struct Interval {
29 Interval(SkPMColor c0, SkScalar p0, 32 Interval(SkPMColor c0, SkScalar p0,
30 SkPMColor c1, SkScalar p1, 33 SkPMColor c1, SkScalar p1,
31 const Sk4f& componentScale); 34 const Sk4f& componentScale);
32 35
33 bool isZeroRamp() const { return fZeroRamp; } 36 bool isZeroRamp() const { return fZeroRamp; }
34 37
35 // true when fx is in [p0,p1)
36 bool contains(SkScalar fx) const;
37
38 SkPM4f fC0, fDc; 38 SkPM4f fC0, fDc;
39 SkScalar fP0, fP1; 39 SkScalar fP0, fP1;
40 bool fZeroRamp; 40 bool fZeroRamp;
41 }; 41 };
42 42
43 virtual void mapTs(int x, int y, SkScalar ts[], int count) const = 0;
44
45 void buildIntervals(const SkGradientShaderBase&, const ContextRec&, bool rev erse);
46
43 SkSTArray<8, Interval, true> fIntervals; 47 SkSTArray<8, Interval, true> fIntervals;
44 SkMatrix fDstToPos; 48 SkMatrix fDstToPos;
45 SkMatrix::MapXYProc fDstToPosProc; 49 SkMatrix::MapXYProc fDstToPosProc;
46 uint8_t fDstToPosClass; 50 uint8_t fDstToPosClass;
47 uint8_t fFlags; 51 uint8_t fFlags;
48 bool fDither; 52 bool fDither;
49 bool fColorsArePremul; 53 bool fColorsArePremul;
50 54
51 private: 55 private:
52 using INHERITED = SkShader::Context; 56 using INHERITED = SkShader::Context;
57
58 void addMirrorIntervals(const SkGradientShaderBase&,
59 const Sk4f& componentScale, bool reverse);
60
61 template<typename DstType, SkShader::TileMode tileMode>
62 class TSampler;
63
64 template <typename DstType, bool do_premul>
65 void shadePremulSpan(int x, int y, DstType[], int count) const;
66
67 template <typename DstType, bool do_premul, SkShader::TileMode tileMode>
68 void shadeSpanInternal(int x, int y, DstType[], int count) const;
53 }; 69 };
54 70
55 #endif // Sk4fGradientBase_DEFINED 71 #endif // Sk4fGradientBase_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698