Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 22686002: Implement path cover with nv_path_rendering (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix a comment Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrStencilAndCoverPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 default: 378 default:
379 GrCrash("unknown geom src type"); 379 GrCrash("unknown geom src type");
380 } 380 }
381 draw->fIndexBuffer->ref(); 381 draw->fIndexBuffer->ref();
382 } else { 382 } else {
383 draw->fIndexBuffer = NULL; 383 draw->fIndexBuffer = NULL;
384 } 384 }
385 } 385 }
386 386
387 GrInOrderDrawBuffer::StencilPath::StencilPath() : fStroke(SkStrokeRec::kFill_Ini tStyle) {} 387 GrInOrderDrawBuffer::StencilPath::StencilPath() : fStroke(SkStrokeRec::kFill_Ini tStyle) {}
388 GrInOrderDrawBuffer::FillPath::FillPath() : fStroke(SkStrokeRec::kFill_InitStyle ) {}
388 389
389 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, const SkStrokeRec& s troke, 390 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, const SkStrokeRec& s troke,
390 SkPath::FillType fill) { 391 SkPath::FillType fill) {
391 if (this->needsNewClip()) { 392 if (this->needsNewClip()) {
392 this->recordClip(); 393 this->recordClip();
393 } 394 }
394 // Only compare the subset of GrDrawState relevant to path stenciling? 395 // Only compare the subset of GrDrawState relevant to path stenciling?
395 if (this->needsNewState()) { 396 if (this->needsNewState()) {
396 this->recordState(); 397 this->recordState();
397 } 398 }
398 StencilPath* sp = this->recordStencilPath(); 399 StencilPath* sp = this->recordStencilPath();
399 sp->fPath.reset(path); 400 sp->fPath.reset(path);
400 path->ref(); 401 path->ref();
401 sp->fFill = fill; 402 sp->fFill = fill;
402 sp->fStroke = stroke; 403 sp->fStroke = stroke;
403 } 404 }
404 405
406 void GrInOrderDrawBuffer::onFillPath(const GrPath* path, const SkStrokeRec& stro ke,
407 SkPath::FillType fill, const GrDeviceCoordT exture* dstCopy) {
408 if (this->needsNewClip()) {
409 this->recordClip();
410 }
411 // TODO: Only compare the subset of GrDrawState relevant to path covering?
412 if (this->needsNewState()) {
413 this->recordState();
414 }
415 FillPath* cp = this->recordFillPath();
416 cp->fPath.reset(path);
417 path->ref();
418 cp->fFill = fill;
419 cp->fStroke = stroke;
420 if (NULL != dstCopy) {
421 cp->fDstCopy = *dstCopy;
422 }
423 }
424
405 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg et* renderTarget) { 425 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg et* renderTarget) {
406 SkIRect r; 426 SkIRect r;
407 if (NULL == renderTarget) { 427 if (NULL == renderTarget) {
408 renderTarget = this->drawState()->getRenderTarget(); 428 renderTarget = this->drawState()->getRenderTarget();
409 SkASSERT(NULL != renderTarget); 429 SkASSERT(NULL != renderTarget);
410 } 430 }
411 if (NULL == rect) { 431 if (NULL == rect) {
412 // We could do something smart and remove previous draws and clears to 432 // We could do something smart and remove previous draws and clears to
413 // the current render target. If we get that smart we have to make sure 433 // the current render target. If we get that smart we have to make sure
414 // those draws aren't read before this clear (render-to-texture). 434 // those draws aren't read before this clear (render-to-texture).
(...skipping 14 matching lines...) Expand all
429 int numDraws = fDraws.count(); 449 int numDraws = fDraws.count();
430 for (int d = 0; d < numDraws; ++d) { 450 for (int d = 0; d < numDraws; ++d) {
431 // we always have a VB, but not always an IB 451 // we always have a VB, but not always an IB
432 SkASSERT(NULL != fDraws[d].fVertexBuffer); 452 SkASSERT(NULL != fDraws[d].fVertexBuffer);
433 fDraws[d].fVertexBuffer->unref(); 453 fDraws[d].fVertexBuffer->unref();
434 SkSafeUnref(fDraws[d].fIndexBuffer); 454 SkSafeUnref(fDraws[d].fIndexBuffer);
435 } 455 }
436 fCmds.reset(); 456 fCmds.reset();
437 fDraws.reset(); 457 fDraws.reset();
438 fStencilPaths.reset(); 458 fStencilPaths.reset();
459 fFillPaths.reset();
439 fStates.reset(); 460 fStates.reset();
440 fClears.reset(); 461 fClears.reset();
441 fVertexPool.reset(); 462 fVertexPool.reset();
442 fIndexPool.reset(); 463 fIndexPool.reset();
443 fClips.reset(); 464 fClips.reset();
444 fClipOrigins.reset(); 465 fClipOrigins.reset();
445 fCopySurfaces.reset(); 466 fCopySurfaces.reset();
446 fClipSet = true; 467 fClipSet = true;
447 } 468 }
448 469
(...skipping 24 matching lines...) Expand all
473 prevDrawState->ref(); 494 prevDrawState->ref();
474 fDstGpu->setDrawState(&playbackState); 495 fDstGpu->setDrawState(&playbackState);
475 496
476 GrClipData clipData; 497 GrClipData clipData;
477 498
478 int currState = 0; 499 int currState = 0;
479 int currClip = 0; 500 int currClip = 0;
480 int currClear = 0; 501 int currClear = 0;
481 int currDraw = 0; 502 int currDraw = 0;
482 int currStencilPath = 0; 503 int currStencilPath = 0;
504 int currFillPath = 0;
483 int currCopySurface = 0; 505 int currCopySurface = 0;
484 506
485 for (int c = 0; c < numCmds; ++c) { 507 for (int c = 0; c < numCmds; ++c) {
486 switch (fCmds[c]) { 508 switch (fCmds[c]) {
487 case kDraw_Cmd: { 509 case kDraw_Cmd: {
488 const DrawRecord& draw = fDraws[currDraw]; 510 const DrawRecord& draw = fDraws[currDraw];
489 fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer); 511 fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer);
490 if (draw.isIndexed()) { 512 if (draw.isIndexed()) {
491 fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer); 513 fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer);
492 } 514 }
493 fDstGpu->executeDraw(draw); 515 fDstGpu->executeDraw(draw);
494 516
495 ++currDraw; 517 ++currDraw;
496 break; 518 break;
497 } 519 }
498 case kStencilPath_Cmd: { 520 case kStencilPath_Cmd: {
499 const StencilPath& sp = fStencilPaths[currStencilPath]; 521 const StencilPath& sp = fStencilPaths[currStencilPath];
500 fDstGpu->stencilPath(sp.fPath.get(), sp.fStroke, sp.fFill); 522 fDstGpu->stencilPath(sp.fPath.get(), sp.fStroke, sp.fFill);
501 ++currStencilPath; 523 ++currStencilPath;
502 break; 524 break;
503 } 525 }
526 case kFillPath_Cmd: {
527 const FillPath& cp = fFillPaths[currFillPath];
528 fDstGpu->executeFillPath(cp.fPath.get(), cp.fStroke, cp.fFill,
529 NULL != cp.fDstCopy.texture() ? &cp.fDs tCopy : NULL);
530 ++currFillPath;
531 break;
532 }
504 case kSetState_Cmd: 533 case kSetState_Cmd:
505 fStates[currState].restoreTo(&playbackState); 534 fStates[currState].restoreTo(&playbackState);
506 ++currState; 535 ++currState;
507 break; 536 break;
508 case kSetClip_Cmd: 537 case kSetClip_Cmd:
509 clipData.fClipStack = &fClips[currClip]; 538 clipData.fClipStack = &fClips[currClip];
510 clipData.fOrigin = fClipOrigins[currClip]; 539 clipData.fOrigin = fClipOrigins[currClip];
511 fDstGpu->setClip(&clipData); 540 fDstGpu->setClip(&clipData);
512 ++currClip; 541 ++currClip;
513 break; 542 break;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info) { 832 GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info) {
804 fCmds.push_back(kDraw_Cmd); 833 fCmds.push_back(kDraw_Cmd);
805 return &fDraws.push_back(info); 834 return &fDraws.push_back(info);
806 } 835 }
807 836
808 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() { 837 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() {
809 fCmds.push_back(kStencilPath_Cmd); 838 fCmds.push_back(kStencilPath_Cmd);
810 return &fStencilPaths.push_back(); 839 return &fStencilPaths.push_back();
811 } 840 }
812 841
842 GrInOrderDrawBuffer::FillPath* GrInOrderDrawBuffer::recordFillPath() {
843 fCmds.push_back(kFillPath_Cmd);
844 return &fFillPaths.push_back();
845 }
846
813 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() { 847 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() {
814 fCmds.push_back(kClear_Cmd); 848 fCmds.push_back(kClear_Cmd);
815 return &fClears.push_back(); 849 return &fClears.push_back();
816 } 850 }
817 851
818 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { 852 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() {
819 fCmds.push_back(kCopySurface_Cmd); 853 fCmds.push_back(kCopySurface_Cmd);
820 return &fCopySurfaces.push_back(); 854 return &fCopySurfaces.push_back();
821 } 855 }
822 856
823 857
824 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { 858 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) {
825 INHERITED::clipWillBeSet(newClipData); 859 INHERITED::clipWillBeSet(newClipData);
826 fClipSet = true; 860 fClipSet = true;
827 fClipProxyState = kUnknown_ClipProxyState; 861 fClipProxyState = kUnknown_ClipProxyState;
828 } 862 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrStencilAndCoverPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698