aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-05-13 09:56:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-05-13 09:56:37 -0700
commit8780bc65bd5a53a38ac4b0a53a5fb283e066ec40 (patch)
tree1b93b068a795e3a727f679a8721ace371c4e349c /src
parent10b063cb91c52fd1f570ee63307fe7e68c1501f1 (diff)
Remove GrGLVertexArray from GrGpuResource hierarchy.
Diffstat (limited to 'src')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp7
-rw-r--r--src/gpu/gl/GrGLGpu.h2
-rw-r--r--src/gpu/gl/GrGLVertexArray.cpp35
-rw-r--r--src/gpu/gl/GrGLVertexArray.h19
4 files changed, 17 insertions, 46 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 917a2ff1f5..3d7d6918f1 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2834,14 +2834,13 @@ GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw(
// We use a vertex array if we're on a core profile and the verts are in a VBO.
if (gpu->glCaps().isCoreProfile() && !vbuffer->isCPUBacked()) {
- if (NULL == fVBOVertexArray || fVBOVertexArray->wasDestroyed()) {
- SkSafeUnref(fVBOVertexArray);
+ if (!fVBOVertexArray) {
GrGLuint arrayID;
GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID));
int attrCount = gpu->glCaps().maxVertexAttributes();
- fVBOVertexArray = SkNEW_ARGS(GrGLVertexArray, (gpu, arrayID, attrCount));
+ fVBOVertexArray = SkNEW_ARGS(GrGLVertexArray, (arrayID, attrCount));
}
- attribState = fVBOVertexArray->bindWithIndexBuffer(ibuffer);
+ attribState = fVBOVertexArray->bindWithIndexBuffer(gpu, ibuffer);
} else {
if (ibuffer) {
this->setIndexBufferIDOnDefaultVertexArray(gpu, ibuffer->bufferID());
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index e1bc869497..4409b0c8fc 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -336,7 +336,7 @@ private:
public:
HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); }
- ~HWGeometryState() { SkSafeUnref(fVBOVertexArray); }
+ ~HWGeometryState() { SkDELETE(fVBOVertexArray); }
void invalidate() {
fBoundVertexArrayIDIsValid = false;
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index bb409c6acd..e20dbb5fed 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -8,8 +8,6 @@
#include "GrGLVertexArray.h"
#include "GrGLGpu.h"
-#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
-#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X);
void GrGLAttribArrayState::set(const GrGLGpu* gpu,
int index,
@@ -68,42 +66,27 @@ void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t used
///////////////////////////////////////////////////////////////////////////////////////////////////
-GrGLVertexArray::GrGLVertexArray(GrGLGpu* gpu, GrGLint id, int attribCount)
- : INHERITED(gpu, kCached_LifeCycle)
- , fID(id)
+GrGLVertexArray::GrGLVertexArray(GrGLint id, int attribCount)
+ : fID(id)
, fAttribArrays(attribCount)
, fIndexBufferIDIsValid(false) {
- this->registerWithCache();
}
-void GrGLVertexArray::onAbandon() {
- fID = 0;
- INHERITED::onAbandon();
-}
-
-void GrGLVertexArray::onRelease() {
- if (0 != fID) {
- GL_CALL(DeleteVertexArrays(1, &fID));
- GPUGL->notifyVertexArrayDelete(fID);
- fID = 0;
- }
- INHERITED::onRelease();
-}
-
-GrGLAttribArrayState* GrGLVertexArray::bind() {
+GrGLAttribArrayState* GrGLVertexArray::bind(GrGLGpu* gpu) {
if (0 == fID) {
return NULL;
}
- GPUGL->bindVertexArray(fID);
+ gpu->bindVertexArray(fID);
return &fAttribArrays;
}
-GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(const GrGLIndexBuffer* buffer) {
- GrGLAttribArrayState* state = this->bind();
+GrGLAttribArrayState* GrGLVertexArray::bindWithIndexBuffer(GrGLGpu* gpu,
+ const GrGLIndexBuffer* buffer) {
+ GrGLAttribArrayState* state = this->bind(gpu);
if (state && buffer) {
GrGLuint bufferID = buffer->bufferID();
- if (!fIndexBufferIDIsValid || bufferID != fIndexBufferID) {
- GL_CALL(BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, bufferID));
+ if (!fIndexBufferIDIsValid || bufferID != fIndexBufferID) {
+ GR_GL_CALL(gpu->glInterface(), BindBuffer(GR_GL_ELEMENT_ARRAY_BUFFER, bufferID));
fIndexBufferIDIsValid = true;
fIndexBufferID = bufferID;
}
diff --git a/src/gpu/gl/GrGLVertexArray.h b/src/gpu/gl/GrGLVertexArray.h
index 77f4fd0eec..a8feb73087 100644
--- a/src/gpu/gl/GrGLVertexArray.h
+++ b/src/gpu/gl/GrGLVertexArray.h
@@ -8,11 +8,9 @@
#ifndef GrGLVertexArray_DEFINED
#define GrGLVertexArray_DEFINED
-#include "GrGpuResource.h"
#include "GrTypesPriv.h"
#include "gl/GrGLDefines.h"
#include "gl/GrGLFunctions.h"
-
#include "SkTArray.h"
class GrGLVertexBuffer;
@@ -134,22 +132,22 @@ private:
* This class represents an OpenGL vertex array object. It manages the lifetime of the vertex array
* and is used to track the state of the vertex array to avoid redundant GL calls.
*/
-class GrGLVertexArray : public GrGpuResource {
+class GrGLVertexArray {
public:
- GrGLVertexArray(GrGLGpu* gpu, GrGLint id, int attribCount);
+ GrGLVertexArray(GrGLint id, int attribCount);
/**
* Binds this vertex array. If the ID has been deleted or abandoned then NULL is returned.
* Otherwise, the GrGLAttribArrayState that is tracking this vertex array's attrib bindings is
* returned.
*/
- GrGLAttribArrayState* bind();
+ GrGLAttribArrayState* bind(GrGLGpu*);
/**
* This is a version of the above function that also binds an index buffer to the vertex
* array object.
*/
- GrGLAttribArrayState* bindWithIndexBuffer(const GrGLIndexBuffer* indexBuffer);
+ GrGLAttribArrayState* bindWithIndexBuffer(GrGLGpu* gpu, const GrGLIndexBuffer*);
void notifyIndexBufferDelete(GrGLuint bufferID);
@@ -161,20 +159,11 @@ public:
void invalidateCachedState();
-protected:
- size_t onGpuMemorySize() const override { return 0; }
-
- void onAbandon() override;
-
- void onRelease() override;
-
private:
GrGLuint fID;
GrGLAttribArrayState fAttribArrays;
GrGLuint fIndexBufferID;
bool fIndexBufferIDIsValid;
-
- typedef GrGpuResource INHERITED;
};
#endif