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