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

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

Issue 808593003: Rename GrGpuGL to GrGLGpu for consistency (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years 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
« no previous file with comments | « src/gpu/gl/GrGLVertexBuffer.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrGLRenderTarget.h" 17 #include "GrGLRenderTarget.h"
18 #include "GrGLStencilBuffer.h" 18 #include "GrGLStencilBuffer.h"
19 #include "GrGLTexture.h" 19 #include "GrGLTexture.h"
20 #include "GrGLVertexArray.h" 20 #include "GrGLVertexArray.h"
21 #include "GrGLVertexBuffer.h" 21 #include "GrGLVertexBuffer.h"
22 #include "GrGpu.h" 22 #include "GrGpu.h"
23 #include "GrOptDrawState.h" 23 #include "GrOptDrawState.h"
24 #include "SkTypes.h" 24 #include "SkTypes.h"
25 25
26 #ifdef SK_DEVELOPER 26 #ifdef SK_DEVELOPER
27 #define PROGRAM_CACHE_STATS 27 #define PROGRAM_CACHE_STATS
28 #endif 28 #endif
29 29
30 class GrGpuGL : public GrGpu { 30 class GrGLGpu : public GrGpu {
31 public: 31 public:
32 GrGpuGL(const GrGLContext& ctx, GrContext* context); 32 GrGLGpu(const GrGLContext& ctx, GrContext* context);
33 virtual ~GrGpuGL(); 33 virtual ~GrGLGpu();
34 34
35 virtual void contextAbandoned() SK_OVERRIDE; 35 virtual void contextAbandoned() SK_OVERRIDE;
36 36
37 const GrGLContext& glContext() const { return fGLContext; } 37 const GrGLContext& glContext() const { return fGLContext; }
38 38
39 const GrGLInterface* glInterface() const { return fGLContext.interface(); } 39 const GrGLInterface* glInterface() const { return fGLContext.interface(); }
40 const GrGLContextInfo& ctxInfo() const { return fGLContext; } 40 const GrGLContextInfo& ctxInfo() const { return fGLContext; }
41 GrGLStandard glStandard() const { return fGLContext.standard(); } 41 GrGLStandard glStandard() const { return fGLContext.standard(); }
42 GrGLVersion glVersion() const { return fGLContext.version(); } 42 GrGLVersion glVersion() const { return fGLContext.version(); }
43 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration() ; } 43 GrGLSLGeneration glslGeneration() const { return fGLContext.glslGeneration() ; }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 // Subclasses should call this to flush the blend state. 174 // Subclasses should call this to flush the blend state.
175 void flushBlend(const GrOptDrawState& optState); 175 void flushBlend(const GrOptDrawState& optState);
176 176
177 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); } 177 bool hasExtension(const char* ext) const { return fGLContext.hasExtension(ex t); }
178 178
179 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff); 179 static bool BlendCoeffReferencesConstant(GrBlendCoeff coeff);
180 180
181 class ProgramCache : public ::SkNoncopyable { 181 class ProgramCache : public ::SkNoncopyable {
182 public: 182 public:
183 ProgramCache(GrGpuGL* gpu); 183 ProgramCache(GrGLGpu* gpu);
184 ~ProgramCache(); 184 ~ProgramCache();
185 185
186 void abandon(); 186 void abandon();
187 GrGLProgram* getProgram(const GrOptDrawState&); 187 GrGLProgram* getProgram(const GrOptDrawState&);
188 188
189 private: 189 private:
190 enum { 190 enum {
191 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new 191 // We may actually have kMaxEntries+1 shaders in the GL context beca use we create a new
192 // shader before evicting from the cache. 192 // shader before evicting from the cache.
193 kMaxEntries = 128, 193 kMaxEntries = 128,
194 kHashBits = 6, 194 kHashBits = 6,
195 }; 195 };
196 196
197 struct Entry; 197 struct Entry;
198 198
199 struct ProgDescLess; 199 struct ProgDescLess;
200 200
201 // binary search for entry matching desc. returns index into fEntries th at matches desc or ~ 201 // binary search for entry matching desc. returns index into fEntries th at matches desc or ~
202 // of the index of where it should be inserted. 202 // of the index of where it should be inserted.
203 int search(const GrProgramDesc& desc) const; 203 int search(const GrProgramDesc& desc) const;
204 204
205 // sorted array of all the entries 205 // sorted array of all the entries
206 Entry* fEntries[kMaxEntries]; 206 Entry* fEntries[kMaxEntries];
207 // hash table based on lowest kHashBits bits of the program key. Used to avoid binary 207 // hash table based on lowest kHashBits bits of the program key. Used to avoid binary
208 // searching fEntries. 208 // searching fEntries.
209 Entry* fHashTable[1 << kHashBits]; 209 Entry* fHashTable[1 << kHashBits];
210 210
211 int fCount; 211 int fCount;
212 unsigned int fCurrLRUStamp; 212 unsigned int fCurrLRUStamp;
213 GrGpuGL* fGpu; 213 GrGLGpu* fGpu;
214 #ifdef PROGRAM_CACHE_STATS 214 #ifdef PROGRAM_CACHE_STATS
215 int fTotalRequests; 215 int fTotalRequests;
216 int fCacheMisses; 216 int fCacheMisses;
217 int fHashMisses; // cache hit but hash table mis sed 217 int fHashMisses; // cache hit but hash table mis sed
218 #endif 218 #endif
219 }; 219 };
220 220
221 // flushes dithering, color-mask, and face culling stat 221 // flushes dithering, color-mask, and face culling stat
222 void flushMiscFixedFunctionState(const GrOptDrawState&); 222 void flushMiscFixedFunctionState(const GrOptDrawState&);
223 223
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 } 326 }
327 327
328 void notifyVertexArrayDelete(GrGLuint id) { 328 void notifyVertexArrayDelete(GrGLuint id) {
329 if (fBoundVertexArrayIDIsValid && fBoundVertexArrayID == id) { 329 if (fBoundVertexArrayIDIsValid && fBoundVertexArrayID == id) {
330 // Does implicit bind to 0 330 // Does implicit bind to 0
331 fBoundVertexArrayID = 0; 331 fBoundVertexArrayID = 0;
332 } 332 }
333 } 333 }
334 334
335 void setVertexArrayID(GrGpuGL* gpu, GrGLuint arrayID) { 335 void setVertexArrayID(GrGLGpu* gpu, GrGLuint arrayID) {
336 if (!gpu->glCaps().vertexArrayObjectSupport()) { 336 if (!gpu->glCaps().vertexArrayObjectSupport()) {
337 SkASSERT(0 == arrayID); 337 SkASSERT(0 == arrayID);
338 return; 338 return;
339 } 339 }
340 if (!fBoundVertexArrayIDIsValid || arrayID != fBoundVertexArrayID) { 340 if (!fBoundVertexArrayIDIsValid || arrayID != fBoundVertexArrayID) {
341 GR_GL_CALL(gpu->glInterface(), BindVertexArray(arrayID)); 341 GR_GL_CALL(gpu->glInterface(), BindVertexArray(arrayID));
342 fBoundVertexArrayIDIsValid = true; 342 fBoundVertexArrayIDIsValid = true;
343 fBoundVertexArrayID = arrayID; 343 fBoundVertexArrayID = arrayID;
344 } 344 }
345 } 345 }
(...skipping 11 matching lines...) Expand all
357 void notifyIndexBufferDelete(GrGLuint id) { 357 void notifyIndexBufferDelete(GrGLuint id) {
358 if (fDefaultVertexArrayBoundIndexBufferIDIsValid && 358 if (fDefaultVertexArrayBoundIndexBufferIDIsValid &&
359 id == fDefaultVertexArrayBoundIndexBufferID) { 359 id == fDefaultVertexArrayBoundIndexBufferID) {
360 fDefaultVertexArrayBoundIndexBufferID = 0; 360 fDefaultVertexArrayBoundIndexBufferID = 0;
361 } 361 }
362 if (fVBOVertexArray) { 362 if (fVBOVertexArray) {
363 fVBOVertexArray->notifyIndexBufferDelete(id); 363 fVBOVertexArray->notifyIndexBufferDelete(id);
364 } 364 }
365 } 365 }
366 366
367 void setVertexBufferID(GrGpuGL* gpu, GrGLuint id) { 367 void setVertexBufferID(GrGLGpu* gpu, GrGLuint id) {
368 if (!fBoundVertexBufferIDIsValid || id != fBoundVertexBufferID) { 368 if (!fBoundVertexBufferIDIsValid || id != fBoundVertexBufferID) {
369 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ARRAY_BUFFER, id )); 369 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ARRAY_BUFFER, id ));
370 fBoundVertexBufferIDIsValid = true; 370 fBoundVertexBufferIDIsValid = true;
371 fBoundVertexBufferID = id; 371 fBoundVertexBufferID = id;
372 } 372 }
373 } 373 }
374 374
375 /** 375 /**
376 * Binds the default vertex array and binds the index buffer. This is us ed when binding 376 * Binds the default vertex array and binds the index buffer. This is us ed when binding
377 * an index buffer in order to update it. 377 * an index buffer in order to update it.
378 */ 378 */
379 void setIndexBufferIDOnDefaultVertexArray(GrGpuGL* gpu, GrGLuint id) { 379 void setIndexBufferIDOnDefaultVertexArray(GrGLGpu* gpu, GrGLuint id) {
380 this->setVertexArrayID(gpu, 0); 380 this->setVertexArrayID(gpu, 0);
381 if (!fDefaultVertexArrayBoundIndexBufferIDIsValid || 381 if (!fDefaultVertexArrayBoundIndexBufferIDIsValid ||
382 id != fDefaultVertexArrayBoundIndexBufferID) { 382 id != fDefaultVertexArrayBoundIndexBufferID) {
383 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BU FFER, id)); 383 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BU FFER, id));
384 fDefaultVertexArrayBoundIndexBufferIDIsValid = true; 384 fDefaultVertexArrayBoundIndexBufferIDIsValid = true;
385 fDefaultVertexArrayBoundIndexBufferID = id; 385 fDefaultVertexArrayBoundIndexBufferID = id;
386 } 386 }
387 } 387 }
388 388
389 /** 389 /**
390 * Binds the vertex array object that should be used to render from the vertex buffer. 390 * Binds the vertex array object that should be used to render from the vertex buffer.
391 * The vertex array is bound and its attrib array state object is return ed. The vertex 391 * The vertex array is bound and its attrib array state object is return ed. The vertex
392 * buffer is bound. The index buffer (if non-NULL) is bound to the verte x array. The 392 * buffer is bound. The index buffer (if non-NULL) is bound to the verte x array. The
393 * returned GrGLAttribArrayState should be used to set vertex attribute arrays. 393 * returned GrGLAttribArrayState should be used to set vertex attribute arrays.
394 */ 394 */
395 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGpuGL* gpu, 395 GrGLAttribArrayState* bindArrayAndBuffersToDraw(GrGLGpu* gpu,
396 const GrGLVertexBuffer* vbuffer, 396 const GrGLVertexBuffer* vbuffer,
397 const GrGLIndexBuffer* i buffer); 397 const GrGLIndexBuffer* i buffer);
398 398
399 private: 399 private:
400 GrGLuint fBoundVertexArrayID; 400 GrGLuint fBoundVertexArrayID;
401 GrGLuint fBoundVertexBufferID; 401 GrGLuint fBoundVertexBufferID;
402 bool fBoundVertexArrayIDIsValid; 402 bool fBoundVertexArrayIDIsValid;
403 bool fBoundVertexBufferIDIsValid; 403 bool fBoundVertexBufferIDIsValid;
404 404
405 GrGLuint fDefaultVertexArrayBoundIndexBufferID; 405 GrGLuint fDefaultVertexArrayBoundIndexBufferID;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 444
445 // 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
446 // 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.
447 int fLastSuccessfulStencilFmtIdx; 447 int fLastSuccessfulStencilFmtIdx;
448 448
449 typedef GrGpu INHERITED; 449 typedef GrGpu INHERITED;
450 friend class GrGLPathRendering; // For accessing setTextureUnit. 450 friend class GrGLPathRendering; // For accessing setTextureUnit.
451 }; 451 };
452 452
453 #endif 453 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLVertexBuffer.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698