| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #include "GrGLVertexArray.h" | 8 #include "GrGLVertexArray.h" |
| 9 #include "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 offset)); | 42 offset)); |
| 43 array->fAttribPointerIsValid = true; | 43 array->fAttribPointerIsValid = true; |
| 44 array->fVertexBufferID = buffer->bufferID(); | 44 array->fVertexBufferID = buffer->bufferID(); |
| 45 array->fSize = size; | 45 array->fSize = size; |
| 46 array->fNormalized = normalized; | 46 array->fNormalized = normalized; |
| 47 array->fStride = stride; | 47 array->fStride = stride; |
| 48 array->fOffset = offset; | 48 array->fOffset = offset; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 void GrGLAttribArrayState::setFixedFunctionVertexArray(const GrGpuGL* gpu, | 52 void GrGLAttribArrayState::disableUnusedArrays(const GrGpuGL* gpu, uint64_t used
Mask) { |
| 53 GrGLVertexBuffer* buffer, | |
| 54 GrGLint size, | |
| 55 GrGLenum type, | |
| 56 GrGLsizei stride, | |
| 57 GrGLvoid* offset) { | |
| 58 SkASSERT(gpu->glCaps().fixedFunctionSupport()); | |
| 59 AttribArrayState* array = &fFixedFunctionVertexArray; | |
| 60 if (!array->fEnableIsValid || !array->fEnabled) { | |
| 61 GR_GL_CALL(gpu->glInterface(), EnableClientState(GR_GL_VERTEX_ARRAY)); | |
| 62 array->fEnableIsValid = true; | |
| 63 array->fEnabled = true; | |
| 64 } | |
| 65 if (!array->fAttribPointerIsValid || | |
| 66 array->fVertexBufferID != buffer->bufferID() || | |
| 67 array->fSize != size || | |
| 68 array->fStride != stride || | |
| 69 array->fOffset != offset) { | |
| 70 | |
| 71 buffer->bind(); | |
| 72 GR_GL_CALL(gpu->glInterface(), VertexPointer(size, | |
| 73 type, | |
| 74 stride, | |
| 75 offset)); | |
| 76 array->fAttribPointerIsValid = true; | |
| 77 array->fVertexBufferID = buffer->bufferID(); | |
| 78 array->fSize = size; | |
| 79 array->fStride = stride; | |
| 80 array->fOffset = offset; | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 void GrGLAttribArrayState::disableUnusedArrays(const GrGpuGL* gpu, uint64_t used
Mask, bool usingFFVertexArray) { | |
| 85 int count = fAttribArrayStates.count(); | 53 int count = fAttribArrayStates.count(); |
| 86 for (int i = 0; i < count; ++i) { | 54 for (int i = 0; i < count; ++i) { |
| 87 if (!(usedMask & 0x1)) { | 55 if (!(usedMask & 0x1)) { |
| 88 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f
Enabled) { | 56 if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].f
Enabled) { |
| 89 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i)); | 57 GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i)); |
| 90 fAttribArrayStates[i].fEnableIsValid = true; | 58 fAttribArrayStates[i].fEnableIsValid = true; |
| 91 fAttribArrayStates[i].fEnabled = false; | 59 fAttribArrayStates[i].fEnabled = false; |
| 92 } | 60 } |
| 93 } else { | 61 } else { |
| 94 SkASSERT(fAttribArrayStates[i].fEnableIsValid && fAttribArrayStates[
i].fEnabled); | 62 SkASSERT(fAttribArrayStates[i].fEnableIsValid && fAttribArrayStates[
i].fEnabled); |
| 95 } | 63 } |
| 96 // if the count is greater than 64 then this will become 0 and we will d
isable arrays 64+. | 64 // if the count is greater than 64 then this will become 0 and we will d
isable arrays 64+. |
| 97 usedMask >>= 1; | 65 usedMask >>= 1; |
| 98 } | 66 } |
| 99 | |
| 100 // Deal with fixed-function vertex arrays. | |
| 101 if (gpu->glCaps().fixedFunctionSupport()) { | |
| 102 if (!usingFFVertexArray) { | |
| 103 if (!fFixedFunctionVertexArray.fEnableIsValid || fFixedFunctionVerte
xArray.fEnabled) { | |
| 104 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_VERTEX_A
RRAY)); | |
| 105 fFixedFunctionVertexArray.fEnableIsValid = true; | |
| 106 fFixedFunctionVertexArray.fEnabled = false; | |
| 107 } | |
| 108 } else { | |
| 109 SkASSERT(fFixedFunctionVertexArray.fEnableIsValid && fFixedFunctionV
ertexArray.fEnabled); | |
| 110 } | |
| 111 // When we use fixed function vertex processing we always use the vertex
array and none of | |
| 112 // the other arrays. | |
| 113 if (!fUnusedFixedFunctionArraysDisabled) { | |
| 114 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_NORMAL_ARRAY
)); | |
| 115 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_COLOR_ARRAY)
); | |
| 116 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_SECONDARY_CO
LOR_ARRAY)); | |
| 117 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_INDEX_ARRAY)
); | |
| 118 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_EDGE_FLAG_AR
RAY)); | |
| 119 for (int i = 0; i < gpu->glCaps().maxFixedFunctionTextureCoords(); +
+i) { | |
| 120 GR_GL_CALL(gpu->glInterface(), ClientActiveTexture(GR_GL_TEXTURE
0 + i)); | |
| 121 GR_GL_CALL(gpu->glInterface(), DisableClientState(GR_GL_TEXTURE_
COORD_ARRAY)); | |
| 122 } | |
| 123 fUnusedFixedFunctionArraysDisabled = true; | |
| 124 } | |
| 125 } else { | |
| 126 SkASSERT(!usingFFVertexArray); | |
| 127 } | |
| 128 } | 67 } |
| 129 | 68 |
| 130 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 69 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 131 | 70 |
| 132 GrGLVertexArray::GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount) | 71 GrGLVertexArray::GrGLVertexArray(GrGpuGL* gpu, GrGLint id, int attribCount) |
| 133 : GrResource(gpu, false) | 72 : GrResource(gpu, false) |
| 134 , fID(id) | 73 , fID(id) |
| 135 , fAttribArrays(attribCount) | 74 , fAttribArrays(attribCount) |
| 136 , fIndexBufferIDIsValid(false) { | 75 , fIndexBufferIDIsValid(false) { |
| 137 } | 76 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { | 113 void GrGLVertexArray::notifyIndexBufferDelete(GrGLuint bufferID) { |
| 175 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { | 114 if (fIndexBufferIDIsValid && bufferID == fIndexBufferID) { |
| 176 fIndexBufferID = 0; | 115 fIndexBufferID = 0; |
| 177 } | 116 } |
| 178 } | 117 } |
| 179 | 118 |
| 180 void GrGLVertexArray::invalidateCachedState() { | 119 void GrGLVertexArray::invalidateCachedState() { |
| 181 fAttribArrays.invalidate(); | 120 fAttribArrays.invalidate(); |
| 182 fIndexBufferIDIsValid = false; | 121 fIndexBufferIDIsValid = false; |
| 183 } | 122 } |
| OLD | NEW |