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

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