diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-02-11 14:07:02 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-02-11 14:07:02 +0000 |
commit | 7acdb8e1d29fe50454431d768ddc862b693db8b0 (patch) | |
tree | 06bc174ee033eb862686406e59a3954d3666e09f /gpu/src/GrGpuGLShaders2.cpp | |
parent | 9db446a5b66412dd0dd48a85253bf1a8310ec76b (diff) |
git-svn-id: http://skia.googlecode.com/svn/trunk@783 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src/GrGpuGLShaders2.cpp')
-rw-r--r-- | gpu/src/GrGpuGLShaders2.cpp | 68 |
1 files changed, 20 insertions, 48 deletions
diff --git a/gpu/src/GrGpuGLShaders2.cpp b/gpu/src/GrGpuGLShaders2.cpp index 9aa327ae54..81f83c9f1d 100644 --- a/gpu/src/GrGpuGLShaders2.cpp +++ b/gpu/src/GrGpuGLShaders2.cpp @@ -988,11 +988,11 @@ void GrGpuGLShaders2::getProgramDesc(PrimitiveType primType, ProgramDesc* desc) if (kPoints_PrimitiveType != primType) { desc->fOptFlags |= ProgramDesc::kNotPoints_OptFlagBit; } -#if GR_AGGRESSIVE_SHADER_OPTS
- if (!(desc->fVertexLayout & kColor_VertexLayoutBit) &&
- (0xffffffff == fCurrDrawState.fColor)) {
- desc->fOptFlags |= ProgramDesc::kVertexColorAllOnes_OptFlagBit;
- }
+#if GR_AGGRESSIVE_SHADER_OPTS + if (!(desc->fVertexLayout & kColor_VertexLayoutBit) && + (0xffffffff == fCurrDrawState.fColor)) { + desc->fOptFlags |= ProgramDesc::kVertexColorAllOnes_OptFlagBit; + } #endif for (int s = 0; s < kNumStages; ++s) { @@ -1094,7 +1094,7 @@ GrGpuGLShaders2::GrGpuGLShaders2() { fProgram = NULL; fProgramCache = new ProgramCache(); -#if GR_DEBUG +#if 0 ProgramUnitTest(); #endif } @@ -1332,43 +1332,9 @@ void GrGpuGLShaders2::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; bool texCoordNorm; @@ -1388,7 +1354,7 @@ void GrGpuGLShaders2::setupGeometry(uint32_t startVertex, bool strideChange = newStride != oldStride; bool posChange = baseChange || scalarChange || strideChange; - if (posChange) { + if (fHWGeometryState.fArrayPtrsDirty || posChange) { GR_GL(VertexAttribPointer(POS_ATTR_LOCATION, 2, scalarType, false, newStride, posPtr)); fHWGeometryState.fPositionPtr = posPtr; @@ -1399,8 +1365,10 @@ void GrGpuGLShaders2::setupGeometry(uint32_t startVertex, GLvoid* texCoordPtr = (int8_t*)posPtr + newTexCoordOffsets[t]; if (oldTexCoordOffsets[t] <= 0) { GR_GL(EnableVertexAttribArray(TEX_ATTR_LOCATION(t))); - } - if (posChange || newTexCoordOffsets[t] != oldTexCoordOffsets[t]) { + GR_GL(VertexAttribPointer(TEX_ATTR_LOCATION(t), 2, scalarType, + texCoordNorm, newStride, texCoordPtr)); + } else if (fHWGeometryState.fArrayPtrsDirty || posChange || + newTexCoordOffsets[t] != oldTexCoordOffsets[t]) { GR_GL(VertexAttribPointer(TEX_ATTR_LOCATION(t), 2, scalarType, texCoordNorm, newStride, texCoordPtr)); } @@ -1413,8 +1381,11 @@ void GrGpuGLShaders2::setupGeometry(uint32_t startVertex, GLvoid* colorPtr = (int8_t*)posPtr + newColorOffset; if (oldColorOffset <= 0) { GR_GL(EnableVertexAttribArray(COL_ATTR_LOCATION)); - } - if (posChange || newColorOffset != oldColorOffset) { + GR_GL(VertexAttribPointer(COL_ATTR_LOCATION, 4, + GL_UNSIGNED_BYTE, + true, newStride, colorPtr)); + } else if (fHWGeometryState.fArrayPtrsDirty || posChange || + newColorOffset != oldColorOffset) { GR_GL(VertexAttribPointer(COL_ATTR_LOCATION, 4, GL_UNSIGNED_BYTE, true, newStride, colorPtr)); @@ -1427,3 +1398,4 @@ void GrGpuGLShaders2::setupGeometry(uint32_t startVertex, } #endif + |