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

Side by Side Diff: src/gpu/gl/GrGLPathRendering.h

Issue 450283002: Simplify GrGLPathRendering interface (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-state-to-pathrendering-class
Patch Set: Created 6 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 | « src/gpu/gl/GrGLPathRange.cpp ('k') | src/gpu/gl/GrGLPathRendering.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 2014 Google Inc. 2 * Copyright 2014 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 GrGLPathRendering_DEFINED 8 #ifndef GrGLPathRendering_DEFINED
9 #define GrGLPathRendering_DEFINED 9 #define GrGLPathRendering_DEFINED
10 10
(...skipping 10 matching lines...) Expand all
21 /** 21 /**
22 * This class wraps the NV_path_rendering extension and manages its various 22 * This class wraps the NV_path_rendering extension and manages its various
23 * API versions. If a method is not present in the GrGLInterface (because the 23 * API versions. If a method is not present in the GrGLInterface (because the
24 * driver version is old), it tries to provide a backup implementation. But if 24 * driver version is old), it tries to provide a backup implementation. But if
25 * a backup implementation is not practical, it marks the method as not 25 * a backup implementation is not practical, it marks the method as not
26 * supported. 26 * supported.
27 */ 27 */
28 class GrGLPathRendering : public GrPathRendering { 28 class GrGLPathRendering : public GrPathRendering {
29 public: 29 public:
30 /** 30 /**
31 * Create a new GrGLPathRendering object from a given GL interface. Unless 31 * Create a new GrGLPathRendering object from a given GL interface.
32 * otherwise specified in the caps, every method will work properly, even
33 * if it did not exist in the GL interface.
34 */ 32 */
35 static GrGLPathRendering* Create(GrGpuGL* gpu, const GrGLInterface*); 33 GrGLPathRendering(GrGpuGL* gpu, const GrGLInterface*);
36 virtual ~GrGLPathRendering(); 34 virtual ~GrGLPathRendering();
37 35
38 // GrPathRendering implementations. 36 // GrPathRendering implementations.
39 virtual GrPath* createPath(const SkPath&, const SkStrokeRec&) SK_OVERRIDE; 37 virtual GrPath* createPath(const SkPath&, const SkStrokeRec&) SK_OVERRIDE;
40 virtual GrPathRange* createPathRange(size_t size, const SkStrokeRec&) SK_OVE RRIDE; 38 virtual GrPathRange* createPathRange(size_t size, const SkStrokeRec&) SK_OVE RRIDE;
41 virtual void stencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; 39 virtual void stencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE;
42 virtual void drawPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; 40 virtual void drawPath(const GrPath*, SkPath::FillType) SK_OVERRIDE;
43 virtual void drawPaths(const GrPathRange*, const uint32_t indices[], int cou nt, 41 virtual void drawPaths(const GrPathRange*, const uint32_t indices[], int cou nt,
44 const float transforms[], PathTransformType, 42 const float transforms[], PathTransformType,
45 SkPath::FillType) SK_OVERRIDE; 43 SkPath::FillType) SK_OVERRIDE;
46 44
47 /**
48 * Mark certain functionality as not supported if the driver version is too
49 * old and a backup implementation is not practical.
50 */
51 struct Caps {
52 bool fragmentInputGenSupport : 1;
53 };
54 const Caps& caps() const { return fCaps; }
55
56
57 /* Called when the 3D context state is unknown. */ 45 /* Called when the 3D context state is unknown. */
58 void onResetContext(); 46 void onResetContext();
59 47
60 /** 48 /**
61 * Called when the GPU resources have been lost and need to be abandoned 49 * Called when the GPU resources have been lost and need to be abandoned
62 * (for example after a context loss). 50 * (for example after a context loss).
63 */ 51 */
64 void abandonGpuResources(); 52 void abandonGpuResources();
65 53
54
55 enum TexturingMode {
56 FixedFunction_TexturingMode,
57 SeparableShaders_TexturingMode
58 };
59
60 /** Specifies whether texturing should use fixed fuction pipe or separable s haders
61 * Specifies whether texturing should use fixed fuction pipe or whether
62 * it is ok to use normal vertex and fragment shaders, and for path renderin g
63 * populate fragment shaders with setProgramPathFragmentInputTransform.
64 * The fixed function mode will be removed once the other mode is more widel y
65 * available.
66 */
67 TexturingMode texturingMode() const {
68 return caps().fragmentInputGenSupport ?
69 SeparableShaders_TexturingMode : FixedFunction_TexturingMode;
70 }
71
72 // Functions for fixed function texturing support.
66 enum PathTexGenComponents { 73 enum PathTexGenComponents {
67 kS_PathTexGenComponents = 1, 74 kS_PathTexGenComponents = 1,
68 kST_PathTexGenComponents = 2, 75 kST_PathTexGenComponents = 2,
69 kSTR_PathTexGenComponents = 3 76 kSTR_PathTexGenComponents = 3
70 }; 77 };
71 void enablePathTexGen(int unitIdx, PathTexGenComponents, const GrGLfloat* co efficients); 78 void enablePathTexGen(int unitIdx, PathTexGenComponents, const GrGLfloat* co efficients);
72 void enablePathTexGen(int unitIdx, PathTexGenComponents, const SkMatrix& mat rix); 79 void enablePathTexGen(int unitIdx, PathTexGenComponents, const SkMatrix& mat rix);
73 void flushPathTexGenSettings(int numUsedTexCoordSets); 80 void flushPathTexGenSettings(int numUsedTexCoordSets);
81
82 // Functions for "separable shader" texturing support.
83 void setProgramPathFragmentInputTransform(GrGLuint program, GrGLint location ,
84 GrGLenum genMode, GrGLint componen ts,
85 const SkMatrix&);
86
87 /* Sets the projection matrix for path rendering */
74 void setProjectionMatrix(const SkMatrix& matrix, 88 void setProjectionMatrix(const SkMatrix& matrix,
75 const SkISize& renderTargetSize, 89 const SkISize& renderTargetSize,
76 GrSurfaceOrigin renderTargetOrigin); 90 GrSurfaceOrigin renderTargetOrigin);
77 91
78
79 // NV_path_rendering
80 GrGLuint genPaths(GrGLsizei range); 92 GrGLuint genPaths(GrGLsizei range);
81 GrGLvoid deletePaths(GrGLuint path, GrGLsizei range); 93 GrGLvoid deletePaths(GrGLuint path, GrGLsizei range);
82 GrGLvoid pathCommands(GrGLuint path, GrGLsizei numCommands, const GrGLubyte *commands, 94
83 GrGLsizei numCoords, GrGLenum coordType, const GrGLvoi d *coords); 95 private:
84 GrGLvoid pathCoords(GrGLuint path, GrGLsizei numCoords, 96 /**
85 GrGLenum coordType, const GrGLvoid *coords); 97 * Mark certain functionality as not supported if the driver version is too
86 GrGLvoid pathParameteri(GrGLuint path, GrGLenum pname, GrGLint value); 98 * old and a backup implementation is not practical.
87 GrGLvoid pathParameterf(GrGLuint path, GrGLenum pname, GrGLfloat value); 99 */
88 GrGLboolean isPath(GrGLuint path); 100 struct Caps {
89 GrGLvoid pathStencilFunc(GrGLenum func, GrGLint ref, GrGLuint mask); 101 bool thenFunctionsSupport : 1;
Chris Dalton 2014/08/14 17:03:45 I think "stencilThenCoverSupport" might be more cl
Kimmo Kinnunen 2014/08/15 07:02:16 Done.
90 GrGLvoid stencilFillPath(GrGLuint path, GrGLenum fillMode, GrGLuint mask); 102 bool fragmentInputGenSupport : 1;
91 GrGLvoid stencilStrokePath(GrGLuint path, GrGLint reference, GrGLuint mask); 103 };
92 GrGLvoid stencilFillPathInstanced(GrGLsizei numPaths, GrGLenum pathNameType, 104 const Caps& caps() const { return fCaps; }
93 const GrGLvoid *paths, GrGLuint pathBase, GrGLenum fillMode, 105
94 GrGLuint mask, GrGLenum transformType, 106 void flushPathStencilSettings(SkPath::FillType fill);
95 const GrGLfloat *transformValues);
96 GrGLvoid stencilStrokePathInstanced(GrGLsizei numPaths, GrGLenum pathNameTyp e,
97 const GrGLvoid *paths, GrGLuint pathBase ,
98 GrGLint reference, GrGLuint mask, GrGLen um transformType,
99 const GrGLfloat *transformValues);
100 GrGLvoid pathTexGen(GrGLenum texCoordSet, GrGLenum genMode,
101 GrGLint components, const GrGLfloat *coeffs);
102 GrGLvoid coverFillPath(GrGLuint path, GrGLenum coverMode);
103 GrGLvoid coverStrokePath(GrGLuint name, GrGLenum coverMode);
104 GrGLvoid coverFillPathInstanced(GrGLsizei numPaths, GrGLenum pathNameType,
105 const GrGLvoid *paths, GrGLuint pathBase, Gr GLenum coverMode,
106 GrGLenum transformType, const GrGLfloat *tra nsformValues);
107 GrGLvoid coverStrokePathInstanced(GrGLsizei numPaths, GrGLenum pathNameType,
108 const GrGLvoid *paths, GrGLuint pathBase, GrGLenum coverMode,
109 GrGLenum transformType, const GrGLfloat* t ransformValues);
110 107
111 // NV_path_rendering v1.2 108 // NV_path_rendering v1.2
112 virtual GrGLvoid stencilThenCoverFillPath(GrGLuint path, GrGLenum fillMode, 109 void stencilThenCoverFillPath(GrGLuint path, GrGLenum fillMode,
113 GrGLuint mask, GrGLenum coverMode) ; 110 GrGLuint mask, GrGLenum coverMode);
114 virtual GrGLvoid stencilThenCoverStrokePath(GrGLuint path, GrGLint reference , 111
115 GrGLuint mask, GrGLenum coverMod e); 112 void stencilThenCoverStrokePath(GrGLuint path, GrGLint reference,
116 virtual GrGLvoid stencilThenCoverFillPathInstanced( 113 GrGLuint mask, GrGLenum coverMode);
117 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvo id *paths, 114
115 void stencilThenCoverFillPathInstanced(
116 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvoid *paths,
118 GrGLuint pathBase, GrGLenum fillMode, GrGLuint mask, Gr GLenum coverMode, 117 GrGLuint pathBase, GrGLenum fillMode, GrGLuint mask, Gr GLenum coverMode,
119 GrGLenum transformType, const GrGLfloat *transformValue s); 118 GrGLenum transformType, const GrGLfloat *transformValue s);
120 virtual GrGLvoid stencilThenCoverStrokePathInstanced( 119
120 void stencilThenCoverStrokePathInstanced(
121 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvo id *paths, 121 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvo id *paths,
122 GrGLuint pathBase, GrGLint reference, GrGLuint mask, Gr GLenum coverMode, 122 GrGLuint pathBase, GrGLint reference, GrGLuint mask, Gr GLenum coverMode,
123 GrGLenum transformType, const GrGLfloat *transformValue s); 123 GrGLenum transformType, const GrGLfloat *transformValue s);
124 124
125 // NV_path_rendering v1.3
126 virtual GrGLvoid programPathFragmentInputGen(GrGLuint program, GrGLint locat ion,
127 GrGLenum genMode, GrGLint compo nents,
128 const GrGLfloat *coeffs);
129
130 protected:
131 GrGLPathRendering(GrGpuGL* gpu, const GrGLInterface*);
132
133 GrGpuGL* fGpu; 125 GrGpuGL* fGpu;
134 SkAutoTUnref<const GrGLInterface> fGLInterface; 126 SkAutoTUnref<const GrGLInterface> fGLInterface;
135 SkAutoTDelete<GrGLNameAllocator> fPathNameAllocator; 127 SkAutoTDelete<GrGLNameAllocator> fPathNameAllocator;
136 Caps fCaps; 128 Caps fCaps;
137 GrGLProgram::MatrixState fHWProjectionMatrixState; 129 GrGLProgram::MatrixState fHWProjectionMatrixState;
138 GrStencilSettings fHWPathStencilSettings; 130 GrStencilSettings fHWPathStencilSettings;
139 struct PathTexGenData { 131 struct PathTexGenData {
140 GrGLenum fMode; 132 GrGLenum fMode;
141 GrGLint fNumComponents; 133 GrGLint fNumComponents;
142 GrGLfloat fCoefficients[3 * 3]; 134 GrGLfloat fCoefficients[3 * 3];
143 }; 135 };
144 int fHWActivePathTexGenSets; 136 int fHWActivePathTexGenSets;
145 SkTArray<PathTexGenData, true> fHWPathTexGenSettings; 137 SkTArray<PathTexGenData, true> fHWPathTexGenSettings;
146
147 private:
148 void flushPathStencilSettings(SkPath::FillType fill);
149
150 }; 138 };
151 139
152 #endif 140 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPathRange.cpp ('k') | src/gpu/gl/GrGLPathRendering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698