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 "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this, des
c)); | 1160 GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this, des
c)); |
1161 return vertexBuffer; | 1161 return vertexBuffer; |
1162 } else { | 1162 } else { |
1163 GL_CALL(GenBuffers(1, &desc.fID)); | 1163 GL_CALL(GenBuffers(1, &desc.fID)); |
1164 if (desc.fID) { | 1164 if (desc.fID) { |
1165 fHWGeometryState.setVertexBufferID(this, desc.fID); | 1165 fHWGeometryState.setVertexBufferID(this, desc.fID); |
1166 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); | 1166 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
1167 // make sure driver can allocate memory for this buffer | 1167 // make sure driver can allocate memory for this buffer |
1168 GL_ALLOC_CALL(this->glInterface(), | 1168 GL_ALLOC_CALL(this->glInterface(), |
1169 BufferData(GR_GL_ARRAY_BUFFER, | 1169 BufferData(GR_GL_ARRAY_BUFFER, |
1170 desc.fSizeInBytes, | 1170 (GrGLsizeiptr) desc.fSizeInBytes, |
1171 NULL, // data ptr | 1171 NULL, // data ptr |
1172 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_
STATIC_DRAW)); | 1172 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_
STATIC_DRAW)); |
1173 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) { | 1173 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) { |
1174 GL_CALL(DeleteBuffers(1, &desc.fID)); | 1174 GL_CALL(DeleteBuffers(1, &desc.fID)); |
1175 this->notifyVertexBufferDelete(desc.fID); | 1175 this->notifyVertexBufferDelete(desc.fID); |
1176 return NULL; | 1176 return NULL; |
1177 } | 1177 } |
1178 GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this,
desc)); | 1178 GrGLVertexBuffer* vertexBuffer = SkNEW_ARGS(GrGLVertexBuffer, (this,
desc)); |
1179 return vertexBuffer; | 1179 return vertexBuffer; |
1180 } | 1180 } |
(...skipping 12 matching lines...) Expand all Loading... |
1193 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc)); | 1193 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc)); |
1194 return indexBuffer; | 1194 return indexBuffer; |
1195 } else { | 1195 } else { |
1196 GL_CALL(GenBuffers(1, &desc.fID)); | 1196 GL_CALL(GenBuffers(1, &desc.fID)); |
1197 if (desc.fID) { | 1197 if (desc.fID) { |
1198 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID
); | 1198 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID
); |
1199 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); | 1199 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); |
1200 // make sure driver can allocate memory for this buffer | 1200 // make sure driver can allocate memory for this buffer |
1201 GL_ALLOC_CALL(this->glInterface(), | 1201 GL_ALLOC_CALL(this->glInterface(), |
1202 BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, | 1202 BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, |
1203 desc.fSizeInBytes, | 1203 (GrGLsizeiptr) desc.fSizeInBytes, |
1204 NULL, // data ptr | 1204 NULL, // data ptr |
1205 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_
STATIC_DRAW)); | 1205 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_
STATIC_DRAW)); |
1206 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) { | 1206 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) { |
1207 GL_CALL(DeleteBuffers(1, &desc.fID)); | 1207 GL_CALL(DeleteBuffers(1, &desc.fID)); |
1208 this->notifyIndexBufferDelete(desc.fID); | 1208 this->notifyIndexBufferDelete(desc.fID); |
1209 return NULL; | 1209 return NULL; |
1210 } | 1210 } |
1211 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc
)); | 1211 GrIndexBuffer* indexBuffer = SkNEW_ARGS(GrGLIndexBuffer, (this, desc
)); |
1212 return indexBuffer; | 1212 return indexBuffer; |
1213 } | 1213 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 } | 1441 } |
1442 size_t readDstRowBytes = tightRowBytes; | 1442 size_t readDstRowBytes = tightRowBytes; |
1443 void* readDst = buffer; | 1443 void* readDst = buffer; |
1444 | 1444 |
1445 // determine if GL can read using the passed rowBytes or if we need | 1445 // determine if GL can read using the passed rowBytes or if we need |
1446 // a scratch buffer. | 1446 // a scratch buffer. |
1447 SkAutoSMalloc<32 * sizeof(GrColor)> scratch; | 1447 SkAutoSMalloc<32 * sizeof(GrColor)> scratch; |
1448 if (rowBytes != tightRowBytes) { | 1448 if (rowBytes != tightRowBytes) { |
1449 if (this->glCaps().packRowLengthSupport()) { | 1449 if (this->glCaps().packRowLengthSupport()) { |
1450 SkASSERT(!(rowBytes % sizeof(GrColor))); | 1450 SkASSERT(!(rowBytes % sizeof(GrColor))); |
1451 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, rowBytes / sizeof(GrColor
))); | 1451 GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, |
| 1452 static_cast<GrGLint>(rowBytes / sizeof(GrColor))
)); |
1452 readDstRowBytes = rowBytes; | 1453 readDstRowBytes = rowBytes; |
1453 } else { | 1454 } else { |
1454 scratch.reset(tightRowBytes * height); | 1455 scratch.reset(tightRowBytes * height); |
1455 readDst = scratch.get(); | 1456 readDst = scratch.get(); |
1456 } | 1457 } |
1457 } | 1458 } |
1458 if (flipY && this->glCaps().packFlipYSupport()) { | 1459 if (flipY && this->glCaps().packFlipYSupport()) { |
1459 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, 1)); | 1460 GL_CALL(PixelStorei(GR_GL_PACK_REVERSE_ROW_ORDER, 1)); |
1460 } | 1461 } |
1461 GL_CALL(ReadPixels(readRect.fLeft, readRect.fBottom, | 1462 GL_CALL(ReadPixels(readRect.fLeft, readRect.fBottom, |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 this->setVertexArrayID(gpu, 0); | 2675 this->setVertexArrayID(gpu, 0); |
2675 } | 2676 } |
2676 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2677 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2677 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2678 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2678 fDefaultVertexArrayAttribState.resize(attrCount); | 2679 fDefaultVertexArrayAttribState.resize(attrCount); |
2679 } | 2680 } |
2680 attribState = &fDefaultVertexArrayAttribState; | 2681 attribState = &fDefaultVertexArrayAttribState; |
2681 } | 2682 } |
2682 return attribState; | 2683 return attribState; |
2683 } | 2684 } |
OLD | NEW |