aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/src/GrGpuGLFixed.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-11 14:07:02 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-02-11 14:07:02 +0000
commit7acdb8e1d29fe50454431d768ddc862b693db8b0 (patch)
tree06bc174ee033eb862686406e59a3954d3666e09f /gpu/src/GrGpuGLFixed.cpp
parent9db446a5b66412dd0dd48a85253bf1a8310ec76b (diff)
git-svn-id: http://skia.googlecode.com/svn/trunk@783 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrGpuGLFixed.cpp')
-rw-r--r--gpu/src/GrGpuGLFixed.cpp54
1 files changed, 11 insertions, 43 deletions
diff --git a/gpu/src/GrGpuGLFixed.cpp b/gpu/src/GrGpuGLFixed.cpp
index 3fd8d5c866..a028cba154 100644
--- a/gpu/src/GrGpuGLFixed.cpp
+++ b/gpu/src/GrGpuGLFixed.cpp
@@ -263,44 +263,9 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex,
oldTexCoordOffsets,
&oldColorOffset);
- const GLvoid* posPtr = (GLvoid*)(newStride * startVertex);
-
- if (kBuffer_GeometrySrcType == fGeometrySrc.fVertexSrc) {
- GrAssert(NULL != fGeometrySrc.fVertexBuffer);
- GrAssert(!fGeometrySrc.fVertexBuffer->isLocked());
- if (fHWGeometryState.fVertexBuffer != fGeometrySrc.fVertexBuffer) {
- GrGLVertexBuffer* buf =
- (GrGLVertexBuffer*)fGeometrySrc.fVertexBuffer;
- GR_GL(BindBuffer(GL_ARRAY_BUFFER, buf->bufferID()));
- fHWGeometryState.fVertexBuffer = fGeometrySrc.fVertexBuffer;
- }
- } else {
- if (kArray_GeometrySrcType == fGeometrySrc.fVertexSrc) {
- posPtr = (void*)((intptr_t)fGeometrySrc.fVertexArray +
- (intptr_t)posPtr);
- } else {
- GrAssert(kReserved_GeometrySrcType == fGeometrySrc.fVertexSrc);
- posPtr = (void*)((intptr_t)fVertices.get() + (intptr_t)posPtr);
- }
- if (NULL != fHWGeometryState.fVertexBuffer) {
- GR_GL(BindBuffer(GL_ARRAY_BUFFER, 0));
- fHWGeometryState.fVertexBuffer = NULL;
- }
- }
-
- if (kBuffer_GeometrySrcType == fGeometrySrc.fIndexSrc) {
- GrAssert(NULL != fGeometrySrc.fIndexBuffer);
- GrAssert(!fGeometrySrc.fIndexBuffer->isLocked());
- if (fHWGeometryState.fIndexBuffer != fGeometrySrc.fIndexBuffer) {
- GrGLIndexBuffer* buf =
- (GrGLIndexBuffer*)fGeometrySrc.fIndexBuffer;
- GR_GL(BindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf->bufferID()));
- fHWGeometryState.fIndexBuffer = fGeometrySrc.fIndexBuffer;
- }
- } else if (NULL != fHWGeometryState.fIndexBuffer) {
- GR_GL(BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
- fHWGeometryState.fIndexBuffer = NULL;
- }
+ const GLvoid* posPtr = setBuffersAndGetVertexStart(newStride, startVertex,
+ startIndex, vertexCount,
+ indexCount);
GLenum scalarType;
if (fGeometrySrc.fVertexLayout & kTextFormat_VertexLayoutBit) {
@@ -317,7 +282,7 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex,
bool strideChange = newStride != oldStride;
bool posChange = baseChange || scalarChange || strideChange;
- if (posChange) {
+ if (posChange || fHWGeometryState.fArrayPtrsDirty) {
GR_GL(VertexPointer(2, scalarType, newStride, posPtr));
fHWGeometryState.fPositionPtr = posPtr;
}
@@ -330,8 +295,9 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex,
if (oldTexCoordOffsets[s] < 0) {
GR_GL(ClientActiveTexture(GL_TEXTURE0+s));
GR_GL(EnableClientState(GL_TEXTURE_COORD_ARRAY));
- }
- if (posChange || newTexCoordOffsets[s] != oldTexCoordOffsets[s]) {
+ GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordPtr));
+ } else if (fHWGeometryState.fArrayPtrsDirty || posChange ||
+ newTexCoordOffsets[s] != oldTexCoordOffsets[s]) {
GR_GL(ClientActiveTexture(GL_TEXTURE0+s));
GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordPtr));
}
@@ -345,8 +311,9 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex,
GLvoid* colorPtr = (int8_t*)posPtr + newColorOffset;
if (oldColorOffset <= 0) {
GR_GL(EnableClientState(GL_COLOR_ARRAY));
- }
- if (posChange || newColorOffset != oldColorOffset) {
+ GR_GL(ColorPointer(4, GL_UNSIGNED_BYTE, newStride, colorPtr));
+ } else if (fHWGeometryState.fArrayPtrsDirty || posChange ||
+ newColorOffset != oldColorOffset) {
GR_GL(ColorPointer(4, GL_UNSIGNED_BYTE, newStride, colorPtr));
}
} else if (oldColorOffset > 0) {
@@ -354,6 +321,7 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex,
}
fHWGeometryState.fVertexLayout = fGeometrySrc.fVertexLayout;
+ fHWGeometryState.fArrayPtrsDirty = false;
}
#endif