| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 6, | 291 6, |
| 292 MAX_QUADS, | 292 MAX_QUADS, |
| 293 4); | 293 4); |
| 294 } | 294 } |
| 295 | 295 |
| 296 return fQuadIndexBuffer; | 296 return fQuadIndexBuffer; |
| 297 } | 297 } |
| 298 | 298 |
| 299 //////////////////////////////////////////////////////////////////////////////// | 299 //////////////////////////////////////////////////////////////////////////////// |
| 300 | 300 |
| 301 bool GrGpu::setupClipAndFlushState(DrawType type, | 301 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds
tCopy, |
| 302 const GrDeviceCoordTexture* dstCopy, | |
| 303 GrDrawState::AutoRestoreEffects* are, | 302 GrDrawState::AutoRestoreEffects* are, |
| 304 GrDrawState::AutoRestoreStencil* ars, | |
| 305 const SkRect* devBounds) { | 303 const SkRect* devBounds) { |
| 306 if (!fClipMaskManager.setupClipping(this->getClip(), are, ars, devBounds)) { | 304 if (!fClipMaskManager.setupClipping(this->getClip(), are, devBounds)) { |
| 307 return false; | 305 return false; |
| 308 } | 306 } |
| 309 | 307 |
| 310 if (!this->flushGraphicsState(type, dstCopy)) { | 308 if (!this->flushGraphicsState(type, dstCopy)) { |
| 311 return false; | 309 return false; |
| 312 } | 310 } |
| 313 | 311 |
| 314 return true; | 312 return true; |
| 315 } | 313 } |
| 316 | 314 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 339 | 337 |
| 340 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { | 338 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { |
| 341 // if popping last entry then pops are unbalanced with pushes | 339 // if popping last entry then pops are unbalanced with pushes |
| 342 SkASSERT(fGeomPoolStateStack.count() > 1); | 340 SkASSERT(fGeomPoolStateStack.count() > 1); |
| 343 fGeomPoolStateStack.pop_back(); | 341 fGeomPoolStateStack.pop_back(); |
| 344 } | 342 } |
| 345 | 343 |
| 346 void GrGpu::onDraw(const DrawInfo& info) { | 344 void GrGpu::onDraw(const DrawInfo& info) { |
| 347 this->handleDirtyContext(); | 345 this->handleDirtyContext(); |
| 348 GrDrawState::AutoRestoreEffects are; | 346 GrDrawState::AutoRestoreEffects are; |
| 349 GrDrawState::AutoRestoreStencil asr; | |
| 350 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), | 347 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), |
| 351 info.getDstCopy(), &are, &asr, info.getDev
Bounds())) { | 348 info.getDstCopy(), &are, info.getDevBounds
())) { |
| 352 return; | 349 return; |
| 353 } | 350 } |
| 354 this->onGpuDraw(info); | 351 this->onGpuDraw(info); |
| 355 } | 352 } |
| 356 | 353 |
| 357 void GrGpu::onStencilPath(const GrPath* path, SkPath::FillType fill) { | 354 void GrGpu::onStencilPath(const GrPath* path, SkPath::FillType fill) { |
| 358 this->handleDirtyContext(); | 355 this->handleDirtyContext(); |
| 359 | 356 |
| 360 GrDrawState::AutoRestoreEffects are; | 357 GrDrawState::AutoRestoreEffects are; |
| 361 GrDrawState::AutoRestoreStencil asr; | 358 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are, NULL))
{ |
| 362 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are, &asr, N
ULL)) { | |
| 363 return; | 359 return; |
| 364 } | 360 } |
| 365 | 361 |
| 366 this->pathRendering()->stencilPath(path, fill); | 362 this->pathRendering()->stencilPath(path, fill); |
| 367 } | 363 } |
| 368 | 364 |
| 369 | 365 |
| 370 void GrGpu::onDrawPath(const GrPath* path, SkPath::FillType fill, | 366 void GrGpu::onDrawPath(const GrPath* path, SkPath::FillType fill, |
| 371 const GrDeviceCoordTexture* dstCopy) { | 367 const GrDeviceCoordTexture* dstCopy) { |
| 372 this->handleDirtyContext(); | 368 this->handleDirtyContext(); |
| 373 | 369 |
| 374 drawState()->setDefaultVertexAttribs(); | 370 drawState()->setDefaultVertexAttribs(); |
| 375 | 371 |
| 376 GrDrawState::AutoRestoreEffects are; | 372 GrDrawState::AutoRestoreEffects are; |
| 377 GrDrawState::AutoRestoreStencil asr; | 373 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, &are, NULL))
{ |
| 378 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, &are, &asr, N
ULL)) { | |
| 379 return; | 374 return; |
| 380 } | 375 } |
| 381 | 376 |
| 382 this->pathRendering()->drawPath(path, fill); | 377 this->pathRendering()->drawPath(path, fill); |
| 383 } | 378 } |
| 384 | 379 |
| 385 void GrGpu::onDrawPaths(const GrPathRange* pathRange, | 380 void GrGpu::onDrawPaths(const GrPathRange* pathRange, |
| 386 const uint32_t indices[], int count, | 381 const uint32_t indices[], int count, |
| 387 const float transforms[], PathTransformType transformsTy
pe, | 382 const float transforms[], PathTransformType transformsTy
pe, |
| 388 SkPath::FillType fill, const GrDeviceCoordTexture* dstCo
py) { | 383 SkPath::FillType fill, const GrDeviceCoordTexture* dstCo
py) { |
| 389 this->handleDirtyContext(); | 384 this->handleDirtyContext(); |
| 390 | 385 |
| 391 drawState()->setDefaultVertexAttribs(); | 386 drawState()->setDefaultVertexAttribs(); |
| 392 | 387 |
| 393 GrDrawState::AutoRestoreEffects are; | 388 GrDrawState::AutoRestoreEffects are; |
| 394 GrDrawState::AutoRestoreStencil asr; | 389 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, &are, NULL))
{ |
| 395 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, &are, &asr,
NULL)) { | |
| 396 return; | 390 return; |
| 397 } | 391 } |
| 398 | 392 |
| 399 pathRange->willDrawPaths(indices, count); | 393 pathRange->willDrawPaths(indices, count); |
| 400 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, fill); | 394 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, fill); |
| 401 } | 395 } |
| 402 | 396 |
| 403 void GrGpu::finalizeReservedVertices() { | 397 void GrGpu::finalizeReservedVertices() { |
| 404 SkASSERT(fVertexPool); | 398 SkASSERT(fVertexPool); |
| 405 fVertexPool->unmap(); | 399 fVertexPool->unmap(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 } | 524 } |
| 531 | 525 |
| 532 void GrGpu::releaseIndexArray() { | 526 void GrGpu::releaseIndexArray() { |
| 533 // if index source was array, we stowed data in the pool | 527 // if index source was array, we stowed data in the pool |
| 534 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 528 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 535 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 529 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 536 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 530 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 537 fIndexPool->putBack(bytes); | 531 fIndexPool->putBack(bytes); |
| 538 --fIndexPoolUseCnt; | 532 --fIndexPoolUseCnt; |
| 539 } | 533 } |
| OLD | NEW |