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 | 8 |
9 #include "GrGLGpu.h" | 9 #include "GrGLGpu.h" |
10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 *indexOffsetInBytes = 0; | 1401 *indexOffsetInBytes = 0; |
1402 ibuf = (GrGLIndexBuffer*)info.indexBuffer(); | 1402 ibuf = (GrGLIndexBuffer*)info.indexBuffer(); |
1403 | 1403 |
1404 SkASSERT(ibuf); | 1404 SkASSERT(ibuf); |
1405 SkASSERT(!ibuf->isMapped()); | 1405 SkASSERT(!ibuf->isMapped()); |
1406 *indexOffsetInBytes += ibuf->baseOffset(); | 1406 *indexOffsetInBytes += ibuf->baseOffset(); |
1407 } | 1407 } |
1408 GrGLAttribArrayState* attribState = | 1408 GrGLAttribArrayState* attribState = |
1409 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf); | 1409 fHWGeometryState.bindArrayAndBuffersToDraw(this, vbuf, ibuf); |
1410 | 1410 |
1411 if (fCurrentProgram->hasVertexShader()) { | 1411 const GrPrimitiveProcessor* primProc = optState.getPrimitiveProcessor(); |
1412 const GrGeometryProcessor* gp = optState.getGeometryProcessor(); | 1412 int vaCount = primProc->numAttribs(); |
| 1413 if (vaCount > 0) { |
1413 | 1414 |
1414 GrGLsizei stride = static_cast<GrGLsizei>(gp->getVertexStride()); | 1415 GrGLsizei stride = static_cast<GrGLsizei>(primProc->getVertexStride()); |
1415 | 1416 |
1416 size_t vertexOffsetInBytes = stride * info.startVertex(); | 1417 size_t vertexOffsetInBytes = stride * info.startVertex(); |
1417 | 1418 |
1418 vertexOffsetInBytes += vbuf->baseOffset(); | 1419 vertexOffsetInBytes += vbuf->baseOffset(); |
1419 | 1420 |
1420 const SkTArray<GrGeometryProcessor::GrAttribute, true>& attribs = gp->ge
tAttribs(); | |
1421 int vaCount = attribs.count(); | |
1422 uint32_t usedAttribArraysMask = 0; | 1421 uint32_t usedAttribArraysMask = 0; |
1423 size_t offset = 0; | 1422 size_t offset = 0; |
1424 | 1423 |
1425 for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) { | 1424 for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) { |
| 1425 const GrGeometryProcessor::Attribute& attrib = primProc->getAttrib(a
ttribIndex); |
1426 usedAttribArraysMask |= (1 << attribIndex); | 1426 usedAttribArraysMask |= (1 << attribIndex); |
1427 GrVertexAttribType attribType = attribs[attribIndex].fType; | 1427 GrVertexAttribType attribType = attrib.fType; |
1428 attribState->set(this, | 1428 attribState->set(this, |
1429 attribIndex, | 1429 attribIndex, |
1430 vbuf, | 1430 vbuf, |
1431 GrGLAttribTypeToLayout(attribType).fCount, | 1431 GrGLAttribTypeToLayout(attribType).fCount, |
1432 GrGLAttribTypeToLayout(attribType).fType, | 1432 GrGLAttribTypeToLayout(attribType).fType, |
1433 GrGLAttribTypeToLayout(attribType).fNormalized, | 1433 GrGLAttribTypeToLayout(attribType).fNormalized, |
1434 stride, | 1434 stride, |
1435 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o
ffset)); | 1435 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o
ffset)); |
1436 offset += attribs[attribIndex].fOffset; | 1436 offset += attrib.fOffset; |
1437 } | 1437 } |
1438 attribState->disableUnusedArrays(this, usedAttribArraysMask); | 1438 attribState->disableUnusedArrays(this, usedAttribArraysMask); |
1439 } | 1439 } |
1440 } | 1440 } |
1441 | 1441 |
1442 void GrGLGpu::buildProgramDesc(const GrOptDrawState& optState, | 1442 void GrGLGpu::buildProgramDesc(const GrOptDrawState& optState, |
1443 const GrProgramDesc::DescInfo& descInfo, | 1443 const GrProgramDesc::DescInfo& descInfo, |
1444 GrGpu::DrawType drawType, | 1444 GrGpu::DrawType drawType, |
1445 GrProgramDesc* desc) { | 1445 GrProgramDesc* desc) { |
1446 if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, desc)
) { | 1446 if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, desc)
) { |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2750 this->setVertexArrayID(gpu, 0); | 2750 this->setVertexArrayID(gpu, 0); |
2751 } | 2751 } |
2752 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2752 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2753 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2753 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2754 fDefaultVertexArrayAttribState.resize(attrCount); | 2754 fDefaultVertexArrayAttribState.resize(attrCount); |
2755 } | 2755 } |
2756 attribState = &fDefaultVertexArrayAttribState; | 2756 attribState = &fDefaultVertexArrayAttribState; |
2757 } | 2757 } |
2758 return attribState; | 2758 return attribState; |
2759 } | 2759 } |
OLD | NEW |