OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrGpuGL_DEFINED | 8 #ifndef GrGpuGL_DEFINED |
9 #define GrGpuGL_DEFINED | 9 #define GrGpuGL_DEFINED |
10 | 10 |
11 #include "GrDrawState.h" | 11 #include "GrDrawState.h" |
12 #include "GrGLContext.h" | 12 #include "GrGLContext.h" |
13 #include "GrGLIRect.h" | 13 #include "GrGLIRect.h" |
14 #include "GrGLIndexBuffer.h" | 14 #include "GrGLIndexBuffer.h" |
15 #include "GrGLPathRendering.h" | 15 #include "GrGLPathRendering.h" |
16 #include "GrGLProgram.h" | 16 #include "GrGLProgram.h" |
17 #include "GrGLStencilBuffer.h" | 17 #include "GrGLStencilBuffer.h" |
18 #include "GrGLTexture.h" | 18 #include "GrGLTexture.h" |
19 #include "GrGLVertexArray.h" | 19 #include "GrGLVertexArray.h" |
20 #include "GrGLVertexBuffer.h" | 20 #include "GrGLVertexBuffer.h" |
21 #include "GrGpu.h" | 21 #include "GrGpu.h" |
| 22 #include "GrOptDrawState.h" |
22 #include "SkTypes.h" | 23 #include "SkTypes.h" |
23 | 24 |
24 #ifdef SK_DEVELOPER | 25 #ifdef SK_DEVELOPER |
25 #define PROGRAM_CACHE_STATS | 26 #define PROGRAM_CACHE_STATS |
26 #endif | 27 #endif |
27 | 28 |
28 class GrGpuGL : public GrGpu { | 29 class GrGpuGL : public GrGpu { |
29 public: | 30 public: |
30 GrGpuGL(const GrGLContext& ctx, GrContext* context); | 31 GrGpuGL(const GrGLContext& ctx, GrContext* context); |
31 virtual ~GrGpuGL(); | 32 virtual ~GrGpuGL(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 virtual bool onCopySurface(GrSurface* dst, | 99 virtual bool onCopySurface(GrSurface* dst, |
99 GrSurface* src, | 100 GrSurface* src, |
100 const SkIRect& srcRect, | 101 const SkIRect& srcRect, |
101 const SkIPoint& dstPoint) SK_OVERRIDE; | 102 const SkIPoint& dstPoint) SK_OVERRIDE; |
102 | 103 |
103 virtual bool onCanCopySurface(GrSurface* dst, | 104 virtual bool onCanCopySurface(GrSurface* dst, |
104 GrSurface* src, | 105 GrSurface* src, |
105 const SkIRect& srcRect, | 106 const SkIRect& srcRect, |
106 const SkIPoint& dstPoint) SK_OVERRIDE; | 107 const SkIPoint& dstPoint) SK_OVERRIDE; |
107 | 108 |
| 109 virtual void buildProgramDesc(const GrOptDrawState&, |
| 110 const GrProgramDesc::DescInfo&, |
| 111 GrGpu::DrawType, |
| 112 const GrDeviceCoordTexture* dstCopy, |
| 113 GrProgramDesc*) SK_OVERRIDE; |
| 114 |
108 private: | 115 private: |
109 // GrGpu overrides | 116 // GrGpu overrides |
110 virtual void onResetContext(uint32_t resetBits) SK_OVERRIDE; | 117 virtual void onResetContext(uint32_t resetBits) SK_OVERRIDE; |
111 | 118 |
112 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, | 119 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, |
113 const void* srcData, | 120 const void* srcData, |
114 size_t rowBytes) SK_OVERRIDE; | 121 size_t rowBytes) SK_OVERRIDE; |
115 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 122 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
116 const void* srcData) SK_OVERRID
E; | 123 const void* srcData) SK_OVERRID
E; |
117 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_O
VERRIDE; | 124 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_O
VERRIDE; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex
t); } | 181 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex
t); } |
175 | 182 |
176 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); | 183 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
177 | 184 |
178 class ProgramCache : public ::SkNoncopyable { | 185 class ProgramCache : public ::SkNoncopyable { |
179 public: | 186 public: |
180 ProgramCache(GrGpuGL* gpu); | 187 ProgramCache(GrGpuGL* gpu); |
181 ~ProgramCache(); | 188 ~ProgramCache(); |
182 | 189 |
183 void abandon(); | 190 void abandon(); |
184 GrGLProgram* getProgram(const GrOptDrawState&, | 191 GrGLProgram* getProgram(const GrOptDrawState&, DrawType); |
185 const GrGLProgramDesc&, | |
186 DrawType); | |
187 | 192 |
188 private: | 193 private: |
189 enum { | 194 enum { |
190 // We may actually have kMaxEntries+1 shaders in the GL context beca
use we create a new | 195 // We may actually have kMaxEntries+1 shaders in the GL context beca
use we create a new |
191 // shader before evicting from the cache. | 196 // shader before evicting from the cache. |
192 kMaxEntries = 128, | 197 kMaxEntries = 128, |
193 kHashBits = 6, | 198 kHashBits = 6, |
194 }; | 199 }; |
195 | 200 |
196 struct Entry; | 201 struct Entry; |
197 | 202 |
198 struct ProgDescLess; | 203 struct ProgDescLess; |
199 | 204 |
200 // binary search for entry matching desc. returns index into fEntries th
at matches desc or ~ | 205 // binary search for entry matching desc. returns index into fEntries th
at matches desc or ~ |
201 // of the index of where it should be inserted. | 206 // of the index of where it should be inserted. |
202 int search(const GrGLProgramDesc& desc) const; | 207 int search(const GrProgramDesc& desc) const; |
203 | 208 |
204 // sorted array of all the entries | 209 // sorted array of all the entries |
205 Entry* fEntries[kMaxEntries]; | 210 Entry* fEntries[kMaxEntries]; |
206 // hash table based on lowest kHashBits bits of the program key. Used to
avoid binary | 211 // hash table based on lowest kHashBits bits of the program key. Used to
avoid binary |
207 // searching fEntries. | 212 // searching fEntries. |
208 Entry* fHashTable[1 << kHashBits]; | 213 Entry* fHashTable[1 << kHashBits]; |
209 | 214 |
210 int fCount; | 215 int fCount; |
211 unsigned int fCurrLRUStamp; | 216 unsigned int fCurrLRUStamp; |
212 GrGpuGL* fGpu; | 217 GrGpuGL* fGpu; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 450 |
446 // we record what stencil format worked last time to hopefully exit early | 451 // we record what stencil format worked last time to hopefully exit early |
447 // from our loop that tries stencil formats and calls check fb status. | 452 // from our loop that tries stencil formats and calls check fb status. |
448 int fLastSuccessfulStencilFmtIdx; | 453 int fLastSuccessfulStencilFmtIdx; |
449 | 454 |
450 typedef GrGpu INHERITED; | 455 typedef GrGpu INHERITED; |
451 friend class GrGLPathRendering; // For accessing setTextureUnit. | 456 friend class GrGLPathRendering; // For accessing setTextureUnit. |
452 }; | 457 }; |
453 | 458 |
454 #endif | 459 #endif |
OLD | NEW |