| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrGpuGL.h" | 8 #include "GrGpuGL.h" |
| 9 | 9 |
| 10 #include "GrEffect.h" | 10 #include "GrEffect.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // to be msaa-resolved (which will modify bound FBO state). | 210 // to be msaa-resolved (which will modify bound FBO state). |
| 211 this->flushRenderTarget(devRect); | 211 this->flushRenderTarget(devRect); |
| 212 | 212 |
| 213 return true; | 213 return true; |
| 214 } | 214 } |
| 215 | 215 |
| 216 void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { | 216 void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { |
| 217 | 217 |
| 218 GrGLsizei stride = this->getDrawState().getVertexSize(); | 218 GrGLsizei stride = this->getDrawState().getVertexSize(); |
| 219 | 219 |
| 220 size_t vertexOffset; | 220 size_t vertexOffsetInBytes = stride * info.startVertex(); |
| 221 GrGLVertexBuffer* vb= this->setBuffers(info.isIndexed(), &vertexOffset, inde
xOffsetInBytes); | 221 |
| 222 vertexOffset += stride * info.startVertex(); | 222 const GeometryPoolState& geoPoolState = this->getGeomPoolState(); |
| 223 |
| 224 GrGLVertexBuffer* vbuf; |
| 225 switch (this->getGeomSrc().fVertexSrc) { |
| 226 case kBuffer_GeometrySrcType: |
| 227 vbuf = (GrGLVertexBuffer*) this->getGeomSrc().fVertexBuffer; |
| 228 break; |
| 229 case kArray_GeometrySrcType: |
| 230 case kReserved_GeometrySrcType: |
| 231 this->finalizeReservedVertices(); |
| 232 vertexOffsetInBytes += geoPoolState.fPoolStartVertex * this->getGeom
Src().fVertexSize; |
| 233 vbuf = (GrGLVertexBuffer*) geoPoolState.fPoolVertexBuffer; |
| 234 break; |
| 235 default: |
| 236 vbuf = NULL; // suppress warning |
| 237 GrCrash("Unknown geometry src type!"); |
| 238 } |
| 239 |
| 240 GrAssert(NULL != vbuf); |
| 241 GrAssert(!vbuf->isLocked()); |
| 242 vertexOffsetInBytes += vbuf->baseOffset(); |
| 243 |
| 244 GrGLIndexBuffer* ibuf = NULL; |
| 245 if (info.isIndexed()) { |
| 246 GrAssert(NULL != indexOffsetInBytes); |
| 247 |
| 248 switch (this->getGeomSrc().fIndexSrc) { |
| 249 case kBuffer_GeometrySrcType: |
| 250 *indexOffsetInBytes = 0; |
| 251 ibuf = (GrGLIndexBuffer*)this->getGeomSrc().fIndexBuffer; |
| 252 break; |
| 253 case kArray_GeometrySrcType: |
| 254 case kReserved_GeometrySrcType: |
| 255 this->finalizeReservedIndices(); |
| 256 *indexOffsetInBytes = geoPoolState.fPoolStartIndex * sizeof(GrGLusho
rt); |
| 257 ibuf = (GrGLIndexBuffer*) geoPoolState.fPoolIndexBuffer; |
| 258 break; |
| 259 default: |
| 260 ibuf = NULL; // suppress warning |
| 261 GrCrash("Unknown geometry src type!"); |
| 262 } |
| 263 |
| 264 GrAssert(NULL != ibuf); |
| 265 GrAssert(!ibuf->isLocked()); |
| 266 *indexOffsetInBytes += ibuf->baseOffset(); |
| 267 } |
| 268 GrGLAttribArrayState* attribState = |
| 269 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf); |
| 223 | 270 |
| 224 uint32_t usedAttribArraysMask = 0; | 271 uint32_t usedAttribArraysMask = 0; |
| 225 const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs()
; | 272 const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs()
; |
| 226 int vertexAttribCount = this->getDrawState().getVertexAttribCount(); | 273 int vertexAttribCount = this->getDrawState().getVertexAttribCount(); |
| 227 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount; | 274 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount; |
| 228 ++vertexAttribIndex, ++vertexAttrib) { | 275 ++vertexAttribIndex, ++vertexAttrib) { |
| 229 | 276 |
| 230 usedAttribArraysMask |= (1 << vertexAttribIndex); | 277 usedAttribArraysMask |= (1 << vertexAttribIndex); |
| 231 GrVertexAttribType attribType = vertexAttrib->fType; | 278 GrVertexAttribType attribType = vertexAttrib->fType; |
| 232 fHWGeometryState.setAttribArray(this, | 279 attribState->set(this, |
| 233 vertexAttribIndex, | 280 vertexAttribIndex, |
| 234 vb, | 281 vbuf, |
| 235 GrGLProgram::kAttribLayouts[attribType].
fCount, | 282 GrGLProgram::kAttribLayouts[attribType].fCount, |
| 236 GrGLProgram::kAttribLayouts[attribType].
fType, | 283 GrGLProgram::kAttribLayouts[attribType].fType, |
| 237 GrGLProgram::kAttribLayouts[attribType].
fNormalized, | 284 GrGLProgram::kAttribLayouts[attribType].fNormalized, |
| 238 stride, | 285 stride, |
| 239 reinterpret_cast<GrGLvoid*>( | 286 reinterpret_cast<GrGLvoid*>( |
| 240 vertexOffset + vertexAttrib->fOffset)); | 287 vertexOffsetInBytes + vertexAttrib->fOffset)); |
| 241 } | 288 } |
| 242 | 289 |
| 243 fHWGeometryState.disableUnusedAttribArrays(this, usedAttribArraysMask); | 290 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); |
| 244 } | 291 } |
| OLD | NEW |