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

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

Issue 1144433002: Move copy-surface-as-draw fallback to GrGLGpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@vares
Patch Set: remove incorrect assert Created 5 years, 7 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
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.h » ('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 /* 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 #include "GrDrawTarget.h" 9 #include "GrDrawTarget.h"
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 desc.fHeight = copyRect.height(); 93 desc.fHeight = copyRect.height();
94 94
95 SkAutoTUnref<GrTexture> copy(fContext->textureProvider()->refScratchTexture( desc, 95 SkAutoTUnref<GrTexture> copy(fContext->textureProvider()->refScratchTexture( desc,
96 GrTextureProvider::kApprox_ScratchTexMatch)); 96 GrTextureProvider::kApprox_ScratchTexMatch));
97 97
98 if (!copy) { 98 if (!copy) {
99 SkDebugf("Failed to create temporary copy of destination texture.\n"); 99 SkDebugf("Failed to create temporary copy of destination texture.\n");
100 return false; 100 return false;
101 } 101 }
102 SkIPoint dstPoint = {0, 0}; 102 SkIPoint dstPoint = {0, 0};
103 if (this->copySurface(copy, rt, copyRect, dstPoint)) { 103 this->copySurface(copy, rt, copyRect, dstPoint);
104 dstCopy->setTexture(copy); 104 dstCopy->setTexture(copy);
105 dstCopy->setOffset(copyRect.fLeft, copyRect.fTop); 105 dstCopy->setOffset(copyRect.fLeft, copyRect.fTop);
106 return true; 106 return true;
107 } else {
108 return false;
109 }
110 } 107 }
111 108
112 void GrDrawTarget::flush() { 109 void GrDrawTarget::flush() {
113 if (fFlushing) { 110 if (fFlushing) {
114 return; 111 return;
115 } 112 }
116 fFlushing = true; 113 fFlushing = true;
117 114
118 this->getGpu()->saveActiveTraceMarkers(); 115 this->getGpu()->saveActiveTraceMarkers();
119 116
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 if (clippedDstPoint->fY + clippedSrcRect->height() > dst->height()) { 411 if (clippedDstPoint->fY + clippedSrcRect->height() > dst->height()) {
415 clippedSrcRect->fBottom = clippedSrcRect->fTop + dst->height() - clipped DstPoint->fY; 412 clippedSrcRect->fBottom = clippedSrcRect->fTop + dst->height() - clipped DstPoint->fY;
416 } 413 }
417 414
418 // The above clipping steps may have inverted the rect if it didn't intersec t either the src or 415 // The above clipping steps may have inverted the rect if it didn't intersec t either the src or
419 // dst bounds. 416 // dst bounds.
420 return !clippedSrcRect->isEmpty(); 417 return !clippedSrcRect->isEmpty();
421 } 418 }
422 } 419 }
423 420
424 bool GrDrawTarget::copySurface(GrSurface* dst, 421 void GrDrawTarget::copySurface(GrSurface* dst,
425 GrSurface* src, 422 GrSurface* src,
426 const SkIRect& srcRect, 423 const SkIRect& srcRect,
427 const SkIPoint& dstPoint) { 424 const SkIPoint& dstPoint) {
428 SkASSERT(dst); 425 SkASSERT(dst);
429 SkASSERT(src); 426 SkASSERT(src);
430 427
431 SkIRect clippedSrcRect; 428 SkIRect clippedSrcRect;
432 SkIPoint clippedDstPoint; 429 SkIPoint clippedDstPoint;
433 // If the rect is outside the src or dst then we've already succeeded. 430 // If the rect is outside the src or dst then we've already succeeded.
434 if (!clip_srcrect_and_dstpoint(dst, 431 if (!clip_srcrect_and_dstpoint(dst,
435 src, 432 src,
436 srcRect, 433 srcRect,
437 dstPoint, 434 dstPoint,
438 &clippedSrcRect, 435 &clippedSrcRect,
439 &clippedDstPoint)) { 436 &clippedDstPoint)) {
440 return true; 437 return;
441 } 438 }
442 439
443 if (this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPoint )) { 440 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
444 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
445 return true;
446 }
447
448 GrRenderTarget* rt = dst->asRenderTarget();
449 GrTexture* tex = src->asTexture();
450
451 if ((dst == src) || !rt || !tex) {
452 return false;
453 }
454
455 GrPipelineBuilder pipelineBuilder;
456 pipelineBuilder.setRenderTarget(rt);
457 SkMatrix matrix;
458 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX) ,
459 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY)) ;
460 matrix.postIDiv(tex->width(), tex->height());
461 pipelineBuilder.addColorTextureProcessor(tex, matrix);
462 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX,
463 clippedDstPoint.fY,
464 clippedSrcRect.width(),
465 clippedSrcRect.height());
466 this->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, SkMatrix::I(), dstRect );
467 return true;
468 }
469
470 bool GrDrawTarget::canCopySurface(const GrSurface* dst,
471 const GrSurface* src,
472 const SkIRect& srcRect,
473 const SkIPoint& dstPoint) {
474 SkASSERT(dst);
475 SkASSERT(src);
476
477 SkIRect clippedSrcRect;
478 SkIPoint clippedDstPoint;
479 // If the rect is outside the src or dst then we're guaranteed success
480 if (!clip_srcrect_and_dstpoint(dst,
481 src,
482 srcRect,
483 dstPoint,
484 &clippedSrcRect,
485 &clippedDstPoint)) {
486 return true;
487 }
488 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) ||
489 this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPo int);
490 } 441 }
491 442
492 void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo, 443 void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo,
493 GrPipeline* pipeline) { 444 GrPipeline* pipeline) {
494 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder, 445 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder,
495 pipelineInfo.fColorPOI, 446 pipelineInfo.fColorPOI,
496 pipelineInfo.fCoveragePOI, 447 pipelineInfo.fCoveragePOI,
497 *this->caps(), 448 *this->caps(),
498 *pipelineInfo.fScissor, 449 *pipelineInfo.fScissor,
499 &pipelineInfo.fDstCopy)); 450 &pipelineInfo.fDstCopy));
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp, 729 GrPipelineBuilder::AutoRestoreFragmentProcessors* a rfp,
779 GrPipelineBuilder::AutoRestoreStencil* ars, 730 GrPipelineBuilder::AutoRestoreStencil* ars,
780 GrScissorState* scissorState, 731 GrScissorState* scissorState,
781 const SkRect* devBounds) { 732 const SkRect* devBounds) {
782 return fClipMaskManager.setupClipping(pipelineBuilder, 733 return fClipMaskManager.setupClipping(pipelineBuilder,
783 arfp, 734 arfp,
784 ars, 735 ars,
785 scissorState, 736 scissorState,
786 devBounds); 737 devBounds);
787 } 738 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698