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 buildKey(const GrOptDrawState* optState, | |
bsalomon
2014/10/23 18:10:29
This name seems vague. buildProgramDesc?
| |
110 GrGpu::DrawType drawType, | |
111 const GrDeviceCoordTexture* dstCopy, | |
112 GrProgramDesc* desc) SK_OVERRIDE; | |
113 | |
108 private: | 114 private: |
109 // GrGpu overrides | 115 // GrGpu overrides |
110 virtual void onResetContext(uint32_t resetBits) SK_OVERRIDE; | 116 virtual void onResetContext(uint32_t resetBits) SK_OVERRIDE; |
111 | 117 |
112 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, | 118 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
113 const void* srcData, | 119 const void* srcData, |
114 size_t rowBytes) SK_OVERRIDE; | 120 size_t rowBytes) SK_OVERRIDE; |
115 virtual GrTexture* onCreateCompressedTexture(const GrTextureDesc& desc, | 121 virtual GrTexture* onCreateCompressedTexture(const GrTextureDesc& desc, |
116 const void* srcData) SK_OVERRID E; | 122 const void* srcData) SK_OVERRID E; |
117 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_O VERRIDE; | 123 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) SK_O VERRIDE; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); } | 178 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); } |
173 | 179 |
174 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); | 180 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); |
175 | 181 |
176 class ProgramCache : public ::SkNoncopyable { | 182 class ProgramCache : public ::SkNoncopyable { |
177 public: | 183 public: |
178 ProgramCache(GrGpuGL* gpu); | 184 ProgramCache(GrGpuGL* gpu); |
179 ~ProgramCache(); | 185 ~ProgramCache(); |
180 | 186 |
181 void abandon(); | 187 void abandon(); |
182 GrGLProgram* getProgram(const GrOptDrawState&, | 188 GrGLProgram* getProgram(const GrOptDrawState&, DrawType); |
183 const GrGLProgramDesc&, | |
184 DrawType); | |
185 | 189 |
186 private: | 190 private: |
187 enum { | 191 enum { |
188 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new | 192 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new |
189 // shader before evicting from the cache. | 193 // shader before evicting from the cache. |
190 kMaxEntries = 128, | 194 kMaxEntries = 128, |
191 kHashBits = 6, | 195 kHashBits = 6, |
192 }; | 196 }; |
193 | 197 |
194 struct Entry; | 198 struct Entry; |
195 | 199 |
196 struct ProgDescLess; | 200 struct ProgDescLess; |
197 | 201 |
198 // binary search for entry matching desc. returns index into fEntries th at matches desc or ~ | 202 // binary search for entry matching desc. returns index into fEntries th at matches desc or ~ |
199 // of the index of where it should be inserted. | 203 // of the index of where it should be inserted. |
200 int search(const GrGLProgramDesc& desc) const; | 204 int search(const GrProgramDesc& desc) const; |
201 | 205 |
202 // sorted array of all the entries | 206 // sorted array of all the entries |
203 Entry* fEntries[kMaxEntries]; | 207 Entry* fEntries[kMaxEntries]; |
204 // hash table based on lowest kHashBits bits of the program key. Used to avoid binary | 208 // hash table based on lowest kHashBits bits of the program key. Used to avoid binary |
205 // searching fEntries. | 209 // searching fEntries. |
206 Entry* fHashTable[1 << kHashBits]; | 210 Entry* fHashTable[1 << kHashBits]; |
207 | 211 |
208 int fCount; | 212 int fCount; |
209 unsigned int fCurrLRUStamp; | 213 unsigned int fCurrLRUStamp; |
210 GrGpuGL* fGpu; | 214 GrGpuGL* fGpu; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 | 444 |
441 // we record what stencil format worked last time to hopefully exit early | 445 // we record what stencil format worked last time to hopefully exit early |
442 // from our loop that tries stencil formats and calls check fb status. | 446 // from our loop that tries stencil formats and calls check fb status. |
443 int fLastSuccessfulStencilFmtIdx; | 447 int fLastSuccessfulStencilFmtIdx; |
444 | 448 |
445 typedef GrGpu INHERITED; | 449 typedef GrGpu INHERITED; |
446 friend class GrGLPathRendering; // For accessing setTextureUnit. | 450 friend class GrGLPathRendering; // For accessing setTextureUnit. |
447 }; | 451 }; |
448 | 452 |
449 #endif | 453 #endif |
OLD | NEW |