| 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 "builders/GrGLProgramBuilder.h" | 10 #include "builders/GrGLProgramBuilder.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); | 257 this->flushScissor(scissorState, glRT->getViewport(), glRT->origin()); |
| 258 this->flushAAState(*optState.get(), type); | 258 this->flushAAState(*optState.get(), type); |
| 259 | 259 |
| 260 // This must come after textures are flushed because a texture may need | 260 // This must come after textures are flushed because a texture may need |
| 261 // to be msaa-resolved (which will modify bound FBO state). | 261 // to be msaa-resolved (which will modify bound FBO state). |
| 262 this->flushRenderTarget(glRT, NULL); | 262 this->flushRenderTarget(glRT, NULL); |
| 263 | 263 |
| 264 return true; | 264 return true; |
| 265 } | 265 } |
| 266 | 266 |
| 267 void GrGpuGL::setupGeometry(const DrawInfo& info, size_t* indexOffsetInBytes) { | 267 void GrGpuGL::setupGeometry(const GrDrawTarget::DrawInfo& info, size_t* indexOff
setInBytes) { |
| 268 SkAutoTUnref<GrOptDrawState> optState( | 268 SkAutoTUnref<GrOptDrawState> optState( |
| 269 GrOptDrawState::Create(this->getDrawState(), this, info.getDstCopy(), | 269 GrOptDrawState::Create(this->getDrawState(), this, info.getDstCopy(), |
| 270 PrimTypeToDrawType(info.primitiveType()))); | 270 PrimTypeToDrawType(info.primitiveType()))); |
| 271 | 271 |
| 272 // If the optState would is NULL it should have been caught in flushGraphics
State before getting | 272 // If the optState would is NULL it should have been caught in flushGraphics
State before getting |
| 273 // here. | 273 // here. |
| 274 SkASSERT(optState); | 274 SkASSERT(optState); |
| 275 | 275 |
| 276 GrGLsizei stride = static_cast<GrGLsizei>(optState->getVertexStride()); | 276 GrGLsizei stride = static_cast<GrGLsizei>(optState->getVertexStride()); |
| 277 | 277 |
| 278 size_t vertexOffsetInBytes = stride * info.startVertex(); | 278 size_t vertexOffsetInBytes = stride * info.startVertex(); |
| 279 | 279 |
| 280 const GeometryPoolState& geoPoolState = this->getGeomPoolState(); | 280 const GeometryPoolState& geoPoolState = this->getGeomPoolState(); |
| 281 | 281 |
| 282 GrGLVertexBuffer* vbuf; | 282 GrGLVertexBuffer* vbuf; |
| 283 switch (this->getGeomSrc().fVertexSrc) { | 283 switch (this->getGeomSrc().fVertexSrc) { |
| 284 case kBuffer_GeometrySrcType: | 284 case GrDrawTarget::kBuffer_GeometrySrcType: |
| 285 vbuf = (GrGLVertexBuffer*) this->getGeomSrc().fVertexBuffer; | 285 vbuf = (GrGLVertexBuffer*) this->getGeomSrc().fVertexBuffer; |
| 286 break; | 286 break; |
| 287 case kReserved_GeometrySrcType: | 287 case GrDrawTarget::kReserved_GeometrySrcType: |
| 288 this->finalizeReservedVertices(); | 288 this->finalizeReservedVertices(); |
| 289 vertexOffsetInBytes += geoPoolState.fPoolStartVertex * this->getGeom
Src().fVertexSize; | 289 vertexOffsetInBytes += geoPoolState.fPoolStartVertex * this->getGeom
Src().fVertexSize; |
| 290 vbuf = (GrGLVertexBuffer*) geoPoolState.fPoolVertexBuffer; | 290 vbuf = (GrGLVertexBuffer*) geoPoolState.fPoolVertexBuffer; |
| 291 break; | 291 break; |
| 292 default: | 292 default: |
| 293 vbuf = NULL; // suppress warning | 293 vbuf = NULL; // suppress warning |
| 294 SkFAIL("Unknown geometry src type!"); | 294 SkFAIL("Unknown geometry src type!"); |
| 295 } | 295 } |
| 296 | 296 |
| 297 SkASSERT(vbuf); | 297 SkASSERT(vbuf); |
| 298 SkASSERT(!vbuf->isMapped()); | 298 SkASSERT(!vbuf->isMapped()); |
| 299 vertexOffsetInBytes += vbuf->baseOffset(); | 299 vertexOffsetInBytes += vbuf->baseOffset(); |
| 300 | 300 |
| 301 GrGLIndexBuffer* ibuf = NULL; | 301 GrGLIndexBuffer* ibuf = NULL; |
| 302 if (info.isIndexed()) { | 302 if (info.isIndexed()) { |
| 303 SkASSERT(indexOffsetInBytes); | 303 SkASSERT(indexOffsetInBytes); |
| 304 | 304 |
| 305 switch (this->getGeomSrc().fIndexSrc) { | 305 switch (this->getGeomSrc().fIndexSrc) { |
| 306 case kBuffer_GeometrySrcType: | 306 case GrDrawTarget::kBuffer_GeometrySrcType: |
| 307 *indexOffsetInBytes = 0; | 307 *indexOffsetInBytes = 0; |
| 308 ibuf = (GrGLIndexBuffer*)this->getGeomSrc().fIndexBuffer; | 308 ibuf = (GrGLIndexBuffer*)this->getGeomSrc().fIndexBuffer; |
| 309 break; | 309 break; |
| 310 case kReserved_GeometrySrcType: | 310 case GrDrawTarget::kReserved_GeometrySrcType: |
| 311 this->finalizeReservedIndices(); | 311 this->finalizeReservedIndices(); |
| 312 *indexOffsetInBytes = geoPoolState.fPoolStartIndex * sizeof(GrGLusho
rt); | 312 *indexOffsetInBytes = geoPoolState.fPoolStartIndex * sizeof(GrGLusho
rt); |
| 313 ibuf = (GrGLIndexBuffer*) geoPoolState.fPoolIndexBuffer; | 313 ibuf = (GrGLIndexBuffer*) geoPoolState.fPoolIndexBuffer; |
| 314 break; | 314 break; |
| 315 default: | 315 default: |
| 316 ibuf = NULL; // suppress warning | 316 ibuf = NULL; // suppress warning |
| 317 SkFAIL("Unknown geometry src type!"); | 317 SkFAIL("Unknown geometry src type!"); |
| 318 } | 318 } |
| 319 | 319 |
| 320 SkASSERT(ibuf); | 320 SkASSERT(ibuf); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 349 | 349 |
| 350 void GrGpuGL::buildProgramDesc(const GrOptDrawState& optState, | 350 void GrGpuGL::buildProgramDesc(const GrOptDrawState& optState, |
| 351 const GrProgramDesc::DescInfo& descInfo, | 351 const GrProgramDesc::DescInfo& descInfo, |
| 352 GrGpu::DrawType drawType, | 352 GrGpu::DrawType drawType, |
| 353 const GrDeviceCoordTexture* dstCopy, | 353 const GrDeviceCoordTexture* dstCopy, |
| 354 GrProgramDesc* desc) { | 354 GrProgramDesc* desc) { |
| 355 if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, dstCo
py, desc)) { | 355 if (!GrGLProgramDescBuilder::Build(optState, descInfo, drawType, this, dstCo
py, desc)) { |
| 356 SkDEBUGFAIL("Failed to generate GL program descriptor"); | 356 SkDEBUGFAIL("Failed to generate GL program descriptor"); |
| 357 } | 357 } |
| 358 } | 358 } |
| OLD | NEW |