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 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); } | 307 HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); } |
308 | 308 |
309 ~HWGeometryState() { SkSafeUnref(fVBOVertexArray); } | 309 ~HWGeometryState() { SkSafeUnref(fVBOVertexArray); } |
310 | 310 |
311 void invalidate() { | 311 void invalidate() { |
312 fBoundVertexArrayIDIsValid = false; | 312 fBoundVertexArrayIDIsValid = false; |
313 fBoundVertexBufferIDIsValid = false; | 313 fBoundVertexBufferIDIsValid = false; |
314 fDefaultVertexArrayBoundIndexBufferID = false; | 314 fDefaultVertexArrayBoundIndexBufferID = false; |
315 fDefaultVertexArrayBoundIndexBufferIDIsValid = false; | 315 fDefaultVertexArrayBoundIndexBufferIDIsValid = false; |
316 fDefaultVertexArrayAttribState.invalidate(); | 316 fDefaultVertexArrayAttribState.invalidate(); |
317 if (NULL != fVBOVertexArray) { | 317 if (fVBOVertexArray) { |
318 fVBOVertexArray->invalidateCachedState(); | 318 fVBOVertexArray->invalidateCachedState(); |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 void notifyVertexArrayDelete(GrGLuint id) { | 322 void notifyVertexArrayDelete(GrGLuint id) { |
323 if (fBoundVertexArrayIDIsValid && fBoundVertexArrayID == id) { | 323 if (fBoundVertexArrayIDIsValid && fBoundVertexArrayID == id) { |
324 // Does implicit bind to 0 | 324 // Does implicit bind to 0 |
325 fBoundVertexArrayID = 0; | 325 fBoundVertexArrayID = 0; |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 void setVertexArrayID(GrGpuGL* gpu, GrGLuint arrayID) { | 329 void setVertexArrayID(GrGpuGL* gpu, GrGLuint arrayID) { |
330 if (!gpu->glCaps().vertexArrayObjectSupport()) { | 330 if (!gpu->glCaps().vertexArrayObjectSupport()) { |
331 SkASSERT(0 == arrayID); | 331 SkASSERT(0 == arrayID); |
332 return; | 332 return; |
333 } | 333 } |
334 if (!fBoundVertexArrayIDIsValid || arrayID != fBoundVertexArrayID) { | 334 if (!fBoundVertexArrayIDIsValid || arrayID != fBoundVertexArrayID) { |
335 GR_GL_CALL(gpu->glInterface(), BindVertexArray(arrayID)); | 335 GR_GL_CALL(gpu->glInterface(), BindVertexArray(arrayID)); |
336 fBoundVertexArrayIDIsValid = true; | 336 fBoundVertexArrayIDIsValid = true; |
337 fBoundVertexArrayID = arrayID; | 337 fBoundVertexArrayID = arrayID; |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 void notifyVertexBufferDelete(GrGLuint id) { | 341 void notifyVertexBufferDelete(GrGLuint id) { |
342 if (fBoundVertexBufferIDIsValid && id == fBoundVertexBufferID) { | 342 if (fBoundVertexBufferIDIsValid && id == fBoundVertexBufferID) { |
343 fBoundVertexBufferID = 0; | 343 fBoundVertexBufferID = 0; |
344 } | 344 } |
345 if (NULL != fVBOVertexArray) { | 345 if (fVBOVertexArray) { |
346 fVBOVertexArray->notifyVertexBufferDelete(id); | 346 fVBOVertexArray->notifyVertexBufferDelete(id); |
347 } | 347 } |
348 fDefaultVertexArrayAttribState.notifyVertexBufferDelete(id); | 348 fDefaultVertexArrayAttribState.notifyVertexBufferDelete(id); |
349 } | 349 } |
350 | 350 |
351 void notifyIndexBufferDelete(GrGLuint id) { | 351 void notifyIndexBufferDelete(GrGLuint id) { |
352 if (fDefaultVertexArrayBoundIndexBufferIDIsValid && | 352 if (fDefaultVertexArrayBoundIndexBufferIDIsValid && |
353 id == fDefaultVertexArrayBoundIndexBufferID) { | 353 id == fDefaultVertexArrayBoundIndexBufferID) { |
354 fDefaultVertexArrayBoundIndexBufferID = 0; | 354 fDefaultVertexArrayBoundIndexBufferID = 0; |
355 } | 355 } |
356 if (NULL != fVBOVertexArray) { | 356 if (fVBOVertexArray) { |
357 fVBOVertexArray->notifyIndexBufferDelete(id); | 357 fVBOVertexArray->notifyIndexBufferDelete(id); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 void setVertexBufferID(GrGpuGL* gpu, GrGLuint id) { | 361 void setVertexBufferID(GrGpuGL* gpu, GrGLuint id) { |
362 if (!fBoundVertexBufferIDIsValid || id != fBoundVertexBufferID) { | 362 if (!fBoundVertexBufferIDIsValid || id != fBoundVertexBufferID) { |
363 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ARRAY_BUFFER, id
)); | 363 GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ARRAY_BUFFER, id
)); |
364 fBoundVertexBufferIDIsValid = true; | 364 fBoundVertexBufferIDIsValid = true; |
365 fBoundVertexBufferID = id; | 365 fBoundVertexBufferID = id; |
366 } | 366 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 // we record what stencil format worked last time to hopefully exit early | 439 // we record what stencil format worked last time to hopefully exit early |
440 // from our loop that tries stencil formats and calls check fb status. | 440 // from our loop that tries stencil formats and calls check fb status. |
441 int fLastSuccessfulStencilFmtIdx; | 441 int fLastSuccessfulStencilFmtIdx; |
442 | 442 |
443 typedef GrGpu INHERITED; | 443 typedef GrGpu INHERITED; |
444 friend class GrGLPathRendering; // For accessing setTextureUnit. | 444 friend class GrGLPathRendering; // For accessing setTextureUnit. |
445 }; | 445 }; |
446 | 446 |
447 #endif | 447 #endif |
OLD | NEW |