Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: src/gpu/gl/GrGpuGL.h

Issue 674543004: OptState owns program descriptor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 GrTextureDesc& desc, 119 virtual GrTexture* onCreateTexture(const GrTextureDesc& 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 GrTextureDesc& desc, 122 virtual GrTexture* onCreateCompressedTexture(const GrTextureDesc& 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); } 179 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); }
173 180
174 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); 181 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
175 182
176 class ProgramCache : public ::SkNoncopyable { 183 class ProgramCache : public ::SkNoncopyable {
177 public: 184 public:
178 ProgramCache(GrGpuGL* gpu); 185 ProgramCache(GrGpuGL* gpu);
179 ~ProgramCache(); 186 ~ProgramCache();
180 187
181 void abandon(); 188 void abandon();
182 GrGLProgram* getProgram(const GrOptDrawState&, 189 GrGLProgram* getProgram(const GrOptDrawState&, DrawType);
183 const GrGLProgramDesc&,
184 DrawType);
185 190
186 private: 191 private:
187 enum { 192 enum {
188 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new 193 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new
189 // shader before evicting from the cache. 194 // shader before evicting from the cache.
190 kMaxEntries = 128, 195 kMaxEntries = 128,
191 kHashBits = 6, 196 kHashBits = 6,
192 }; 197 };
193 198
194 struct Entry; 199 struct Entry;
195 200
196 struct ProgDescLess; 201 struct ProgDescLess;
197 202
198 // binary search for entry matching desc. returns index into fEntries th at matches desc or ~ 203 // 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. 204 // of the index of where it should be inserted.
200 int search(const GrGLProgramDesc& desc) const; 205 int search(const GrProgramDesc& desc) const;
201 206
202 // sorted array of all the entries 207 // sorted array of all the entries
203 Entry* fEntries[kMaxEntries]; 208 Entry* fEntries[kMaxEntries];
204 // hash table based on lowest kHashBits bits of the program key. Used to avoid binary 209 // hash table based on lowest kHashBits bits of the program key. Used to avoid binary
205 // searching fEntries. 210 // searching fEntries.
206 Entry* fHashTable[1 << kHashBits]; 211 Entry* fHashTable[1 << kHashBits];
207 212
208 int fCount; 213 int fCount;
209 unsigned int fCurrLRUStamp; 214 unsigned int fCurrLRUStamp;
210 GrGpuGL* fGpu; 215 GrGpuGL* fGpu;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 445
441 // we record what stencil format worked last time to hopefully exit early 446 // 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. 447 // from our loop that tries stencil formats and calls check fb status.
443 int fLastSuccessfulStencilFmtIdx; 448 int fLastSuccessfulStencilFmtIdx;
444 449
445 typedef GrGpu INHERITED; 450 typedef GrGpu INHERITED;
446 friend class GrGLPathRendering; // For accessing setTextureUnit. 451 friend class GrGLPathRendering; // For accessing setTextureUnit.
447 }; 452 };
448 453
449 #endif 454 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698