Remove GrGLVertexArray from GrGpuResource hierarchy.
Review URL: https://codereview.chromium.org/1137093002
This commit is contained in:
parent
10b063cb91
commit
8780bc65bd
@ -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());
|
||||
|
@ -336,7 +336,7 @@ private:
|
||||
public:
|
||||
HWGeometryState() { fVBOVertexArray = NULL; this->invalidate(); }
|
||||
|
||||
~HWGeometryState() { SkSafeUnref(fVBOVertexArray); }
|
||||
~HWGeometryState() { SkDELETE(fVBOVertexArray); }
|
||||
|
||||
void invalidate() {
|
||||
fBoundVertexArrayIDIsValid = false;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user