OLD | NEW |
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" |
| 13 #include "GrStencil.h" |
12 #include "gl/GrGLFunctions.h" | 14 #include "gl/GrGLFunctions.h" |
| 15 #include "gl/GrGLProgram.h" |
13 | 16 |
14 class GrGLNameAllocator; | 17 class GrGLNameAllocator; |
15 struct GrGLInterface; | 18 class GrGpuGL; |
16 | 19 |
17 /** | 20 /** |
18 * 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 |
19 * API versions. If a method is not present in the GrGLInterface (because the | 22 * API versions. If a method is not present in the GrGLInterface of the GrGpuGL |
20 * driver version is old), it tries to provide a backup implementation. But if | 23 * (because the driver version is old), it tries to provide a backup |
21 * a backup implementation is not practical, it marks the method as not | 24 * implementation. But if a backup implementation is not practical, it marks the |
22 * supported. | 25 * method as not supported. |
23 */ | 26 */ |
24 class GrGLPathRendering { | 27 class GrGLPathRendering : public GrPathRendering { |
25 public: | 28 public: |
26 /** | 29 /** |
27 * Create a new GrGLPathRendering object from a given GL interface. Unless | 30 * Create a new GrGLPathRendering object from a given GrGpuGL. Unless |
28 * otherwise specified in the caps, every method will work properly, even | 31 * otherwise specified in the caps, every method will work properly, even |
29 * if it did not exist in the GL interface. | 32 * if it did not exist in the GL interface of the gpu. |
30 */ | 33 */ |
31 static GrGLPathRendering* Create(const GrGLInterface*); | 34 static GrGLPathRendering* Create(GrGpuGL* gpu); |
32 virtual ~GrGLPathRendering(); | 35 virtual ~GrGLPathRendering(); |
33 | 36 |
| 37 // GrPathRendering implementations. |
| 38 virtual GrPath* createPath(const SkPath&, const SkStrokeRec&) SK_OVERRIDE; |
| 39 virtual GrPathRange* createPathRange(size_t size, const SkStrokeRec&) SK_OVE
RRIDE; |
| 40 virtual void stencilPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
| 41 virtual void drawPath(const GrPath*, SkPath::FillType) SK_OVERRIDE; |
| 42 virtual void drawPaths(const GrPathRange*, const uint32_t indices[], int cou
nt, |
| 43 const float transforms[], PathTransformType, |
| 44 SkPath::FillType) SK_OVERRIDE; |
| 45 |
34 /** | 46 /** |
35 * Mark certain functionality as not supported if the driver version is too | 47 * Mark certain functionality as not supported if the driver version is too |
36 * old and a backup implementation is not practical. | 48 * old and a backup implementation is not practical. |
37 */ | 49 */ |
38 struct Caps { | 50 struct Caps { |
39 bool fragmentInputGenSupport : 1; | 51 bool fragmentInputGenSupport : 1; |
40 }; | 52 }; |
41 const Caps& caps() const { return fCaps; } | 53 const Caps& caps() const { return fCaps; } |
42 | 54 |
| 55 |
| 56 /* Called when the 3D context state is unknown. */ |
| 57 void resetContext(); |
| 58 |
43 /** | 59 /** |
44 * Called when the GPU resources have been lost and need to be abandoned | 60 * Called when the GPU resources have been lost and need to be abandoned |
45 * (for example after a context loss). | 61 * (for example after a context loss). |
46 */ | 62 */ |
47 void abandonGpuResources(); | 63 void abandonGpuResources(); |
48 | 64 |
| 65 enum PathTexGenComponents { |
| 66 kS_PathTexGenComponents = 1, |
| 67 kST_PathTexGenComponents = 2, |
| 68 kSTR_PathTexGenComponents = 3 |
| 69 }; |
| 70 void enablePathTexGen(int unitIdx, PathTexGenComponents, const GrGLfloat* co
efficients); |
| 71 void enablePathTexGen(int unitIdx, PathTexGenComponents, const SkMatrix& mat
rix); |
| 72 void flushPathTexGenSettings(int numUsedTexCoordSets); |
| 73 void setProjectionMatrix(const SkMatrix& matrix, |
| 74 const SkISize& renderTargetSize, |
| 75 GrSurfaceOrigin renderTargetOrigin); |
| 76 |
| 77 |
49 // NV_path_rendering | 78 // NV_path_rendering |
50 GrGLuint genPaths(GrGLsizei range); | 79 GrGLuint genPaths(GrGLsizei range); |
51 GrGLvoid deletePaths(GrGLuint path, GrGLsizei range); | 80 GrGLvoid deletePaths(GrGLuint path, GrGLsizei range); |
52 GrGLvoid pathCommands(GrGLuint path, GrGLsizei numCommands, const GrGLubyte
*commands, | 81 GrGLvoid pathCommands(GrGLuint path, GrGLsizei numCommands, const GrGLubyte
*commands, |
53 GrGLsizei numCoords, GrGLenum coordType, const GrGLvoi
d *coords); | 82 GrGLsizei numCoords, GrGLenum coordType, const GrGLvoi
d *coords); |
54 GrGLvoid pathCoords(GrGLuint path, GrGLsizei numCoords, | 83 GrGLvoid pathCoords(GrGLuint path, GrGLsizei numCoords, |
55 GrGLenum coordType, const GrGLvoid *coords); | 84 GrGLenum coordType, const GrGLvoid *coords); |
56 GrGLvoid pathParameteri(GrGLuint path, GrGLenum pname, GrGLint value); | 85 GrGLvoid pathParameteri(GrGLuint path, GrGLenum pname, GrGLint value); |
57 GrGLvoid pathParameterf(GrGLuint path, GrGLenum pname, GrGLfloat value); | 86 GrGLvoid pathParameterf(GrGLuint path, GrGLenum pname, GrGLfloat value); |
58 GrGLboolean isPath(GrGLuint path); | 87 GrGLboolean isPath(GrGLuint path); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvo
id *paths, | 120 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvo
id *paths, |
92 GrGLuint pathBase, GrGLint reference, GrGLuint mask, Gr
GLenum coverMode, | 121 GrGLuint pathBase, GrGLint reference, GrGLuint mask, Gr
GLenum coverMode, |
93 GrGLenum transformType, const GrGLfloat *transformValue
s); | 122 GrGLenum transformType, const GrGLfloat *transformValue
s); |
94 | 123 |
95 // NV_path_rendering v1.3 | 124 // NV_path_rendering v1.3 |
96 virtual GrGLvoid programPathFragmentInputGen(GrGLuint program, GrGLint locat
ion, | 125 virtual GrGLvoid programPathFragmentInputGen(GrGLuint program, GrGLint locat
ion, |
97 GrGLenum genMode, GrGLint compo
nents, | 126 GrGLenum genMode, GrGLint compo
nents, |
98 const GrGLfloat *coeffs); | 127 const GrGLfloat *coeffs); |
99 | 128 |
100 protected: | 129 protected: |
101 GrGLPathRendering(const GrGLInterface*); | 130 GrGLPathRendering(GrGpuGL* gpu); |
102 | 131 |
103 SkAutoTUnref<const GrGLInterface> fGLInterface; | 132 GrGpuGL* fGpu; |
104 SkAutoTDelete<GrGLNameAllocator> fPathNameAllocator; | 133 SkAutoTDelete<GrGLNameAllocator> fPathNameAllocator; |
105 Caps fCaps; | 134 Caps fCaps; |
| 135 GrGLProgram::MatrixState fHWProjectionMatrixState; |
| 136 GrStencilSettings fHWPathStencilSettings; |
| 137 struct PathTexGenData { |
| 138 GrGLenum fMode; |
| 139 GrGLint fNumComponents; |
| 140 GrGLfloat fCoefficients[3 * 3]; |
| 141 }; |
| 142 int fHWActivePathTexGenSets; |
| 143 SkTArray<PathTexGenData, true> fHWPathTexGenSettings; |
| 144 |
| 145 private: |
| 146 void flushPathStencilSettings(SkPath::FillType fill); |
| 147 |
106 }; | 148 }; |
107 | 149 |
108 #endif | 150 #endif |
OLD | NEW |