OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2014 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef GrGLPathRendering_DEFINED | |
9 #define GrGLPathRendering_DEFINED | |
10 | |
11 #include "SkRefCnt.h" | |
12 #include "gl/GrGLFunctions.h" | |
13 | |
14 class GrGLNameAllocator; | |
15 struct GrGLInterface; | |
16 | |
17 /** | |
18 * 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 | |
20 * driver version is old), it tries to provide a backup implementation. But if | |
21 * a backup implementation is not practical, it marks the method as not | |
22 * supported. | |
23 */ | |
24 class GrGLPathRendering { | |
25 public: | |
26 /** | |
27 * Create a new GrGLPathRendering object from a given GL interface. Unless | |
28 * otherwise specified in the caps, every method will work properly, even | |
29 * if it did not exist in the GL interface. | |
30 */ | |
31 static GrGLPathRendering* Create(const GrGLInterface*); | |
32 virtual ~GrGLPathRendering(); | |
33 | |
34 /** | |
35 * Mark certain functionality as not supported if the driver version is too | |
36 * old and a backup implementation is not practical. | |
37 */ | |
38 struct Caps { | |
39 bool fragmentInputGenSupport : 1; | |
40 }; | |
41 const Caps& caps() const { return fCaps; } | |
42 | |
43 /** | |
44 * Called when the GPU resources have been lost and need to be abandoned | |
45 * (for example after a context loss). | |
46 */ | |
47 void abandonGpuResources(); | |
48 | |
49 // NV_path_rendering | |
50 GrGLuint genPaths(GrGLsizei range); | |
51 GrGLvoid deletePaths(GrGLuint path, GrGLsizei range); | |
52 GrGLvoid pathCommands(GrGLuint path, GrGLsizei numCommands, const GrGLubyte
*commands, | |
53 GrGLsizei numCoords, GrGLenum coordType, const GrGLvoi
d *coords); | |
54 GrGLvoid pathCoords(GrGLuint path, GrGLsizei numCoords, | |
55 GrGLenum coordType, const GrGLvoid *coords); | |
56 GrGLvoid pathParameteri(GrGLuint path, GrGLenum pname, GrGLint value); | |
57 GrGLvoid pathParameterf(GrGLuint path, GrGLenum pname, GrGLfloat value); | |
58 GrGLboolean isPath(GrGLuint path); | |
59 GrGLvoid pathStencilFunc(GrGLenum func, GrGLint ref, GrGLuint mask); | |
60 GrGLvoid stencilFillPath(GrGLuint path, GrGLenum fillMode, GrGLuint mask); | |
61 GrGLvoid stencilStrokePath(GrGLuint path, GrGLint reference, GrGLuint mask); | |
62 GrGLvoid stencilFillPathInstanced(GrGLsizei numPaths, GrGLenum pathNameType, | |
63 const GrGLvoid *paths, GrGLuint pathBase,
GrGLenum fillMode, | |
64 GrGLuint mask, GrGLenum transformType, | |
65 const GrGLfloat *transformValues); | |
66 GrGLvoid stencilStrokePathInstanced(GrGLsizei numPaths, GrGLenum pathNameTyp
e, | |
67 const GrGLvoid *paths, GrGLuint pathBase
, | |
68 GrGLint reference, GrGLuint mask, GrGLen
um transformType, | |
69 const GrGLfloat *transformValues); | |
70 GrGLvoid pathTexGen(GrGLenum texCoordSet, GrGLenum genMode, | |
71 GrGLint components, const GrGLfloat *coeffs); | |
72 GrGLvoid coverFillPath(GrGLuint path, GrGLenum coverMode); | |
73 GrGLvoid coverStrokePath(GrGLuint name, GrGLenum coverMode); | |
74 GrGLvoid coverFillPathInstanced(GrGLsizei numPaths, GrGLenum pathNameType, | |
75 const GrGLvoid *paths, GrGLuint pathBase, Gr
GLenum coverMode, | |
76 GrGLenum transformType, const GrGLfloat *tra
nsformValues); | |
77 GrGLvoid coverStrokePathInstanced(GrGLsizei numPaths, GrGLenum pathNameType, | |
78 const GrGLvoid *paths, GrGLuint pathBase,
GrGLenum coverMode, | |
79 GrGLenum transformType, const GrGLfloat* t
ransformValues); | |
80 | |
81 // NV_path_rendering v1.2 | |
82 virtual GrGLvoid stencilThenCoverFillPath(GrGLuint path, GrGLenum fillMode, | |
83 GrGLuint mask, GrGLenum coverMode)
; | |
84 virtual GrGLvoid stencilThenCoverStrokePath(GrGLuint path, GrGLint reference
, | |
85 GrGLuint mask, GrGLenum coverMod
e); | |
86 virtual GrGLvoid stencilThenCoverFillPathInstanced( | |
87 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvo
id *paths, | |
88 GrGLuint pathBase, GrGLenum fillMode, GrGLuint mask, Gr
GLenum coverMode, | |
89 GrGLenum transformType, const GrGLfloat *transformValue
s); | |
90 virtual GrGLvoid stencilThenCoverStrokePathInstanced( | |
91 GrGLsizei numPaths, GrGLenum pathNameType, const GrGLvo
id *paths, | |
92 GrGLuint pathBase, GrGLint reference, GrGLuint mask, Gr
GLenum coverMode, | |
93 GrGLenum transformType, const GrGLfloat *transformValue
s); | |
94 | |
95 // NV_path_rendering v1.3 | |
96 virtual GrGLvoid programPathFragmentInputGen(GrGLuint program, GrGLint locat
ion, | |
97 GrGLenum genMode, GrGLint compo
nents, | |
98 const GrGLfloat *coeffs); | |
99 | |
100 protected: | |
101 GrGLPathRendering(const GrGLInterface*); | |
102 | |
103 SkAutoTUnref<const GrGLInterface> fGLInterface; | |
104 SkAutoTDelete<GrGLNameAllocator> fPathNameAllocator; | |
105 Caps fCaps; | |
106 }; | |
107 | |
108 #endif | |
OLD | NEW |