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

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

Issue 1690053002: Revert of Make copySurface work for texture dsts, return a bool, & add unit test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « include/gpu/GrDrawContext.h ('k') | src/gpu/GrDrawContext.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 "GrContext.h" 8 #include "GrContext.h"
9 #include "GrContextOptions.h" 9 #include "GrContextOptions.h"
10 #include "GrDrawingManager.h" 10 #include "GrDrawingManager.h"
11 #include "GrDrawContext.h" 11 #include "GrDrawContext.h"
12 #include "GrLayerCache.h" 12 #include "GrLayerCache.h"
13 #include "GrResourceCache.h" 13 #include "GrResourceCache.h"
14 #include "GrResourceProvider.h" 14 #include "GrResourceProvider.h"
15 #include "GrSoftwarePathRenderer.h" 15 #include "GrSoftwarePathRenderer.h"
16 #include "GrSurfacePriv.h" 16 #include "GrSurfacePriv.h"
17 17
18 #include "SkConfig8888.h" 18 #include "SkConfig8888.h"
19 #include "SkGrPriv.h" 19 #include "SkGrPriv.h"
20 20
21 #include "batches/GrCopySurfaceBatch.h"
22 #include "effects/GrConfigConversionEffect.h" 21 #include "effects/GrConfigConversionEffect.h"
23 #include "text/GrTextBlobCache.h" 22 #include "text/GrTextBlobCache.h"
24 23
25 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) 24 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
26 #define ASSERT_SINGLE_OWNER \ 25 #define ASSERT_SINGLE_OWNER \
27 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);) 26 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);)
28 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 27 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
29 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; } 28 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; }
30 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; } 29 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; }
31 30
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 ASSERT_OWNED_RESOURCE(surface); 502 ASSERT_OWNED_RESOURCE(surface);
504 if (surface->surfacePriv().hasPendingIO()) { 503 if (surface->surfacePriv().hasPendingIO()) {
505 this->flush(); 504 this->flush();
506 } 505 }
507 GrRenderTarget* rt = surface->asRenderTarget(); 506 GrRenderTarget* rt = surface->asRenderTarget();
508 if (fGpu && rt) { 507 if (fGpu && rt) {
509 fGpu->resolveRenderTarget(rt); 508 fGpu->resolveRenderTarget(rt);
510 } 509 }
511 } 510 }
512 511
513 bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe ct, 512 void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe ct,
514 const SkIPoint& dstPoint) { 513 const SkIPoint& dstPoint, uint32_t pixelOpsFlags) {
515 ASSERT_SINGLE_OWNER 514 ASSERT_SINGLE_OWNER
516 RETURN_FALSE_IF_ABANDONED 515 RETURN_IF_ABANDONED
517 GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface"); 516 GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface");
518 517
519 if (!src || !dst) { 518 if (!src || !dst) {
520 return false; 519 return;
521 } 520 }
522 ASSERT_OWNED_RESOURCE(src); 521 ASSERT_OWNED_RESOURCE(src);
523 ASSERT_OWNED_RESOURCE(dst); 522 ASSERT_OWNED_RESOURCE(dst);
524 523
524 // Since we're going to the draw target and not GPU, no need to check kNoFlu sh
525 // here.
525 if (!dst->asRenderTarget()) { 526 if (!dst->asRenderTarget()) {
526 SkIRect clippedSrcRect; 527 return;
527 SkIPoint clippedDstPoint;
528 if (!GrCopySurfaceBatch::ClipSrcRectAndDstPoint(dst, src, srcRect, dstPo int,
529 &clippedSrcRect, &clippe dDstPoint)) {
530 return false;
531 }
532 // If we don't have an RT for the dst then we won't have a GrDrawContext to insert the
533 // the copy surface into. In the future we plan to have a more limited C ontext type
534 // (GrCopyContext?) that has the subset of GrDrawContext operations that should be
535 // allowed on textures that aren't render targets.
536 // For now we just flush any writes to the src and issue an immediate co py to the dst.
537 src->flushWrites();
538 return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint);
539 } 528 }
529
540 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarge t())); 530 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarge t()));
541 if (!drawContext) { 531 if (!drawContext) {
542 return false; 532 return;
543 } 533 }
544 534
545 if (!drawContext->copySurface(src, srcRect, dstPoint)) { 535 drawContext->copySurface(src, srcRect, dstPoint);
546 return false; 536
537 if (kFlushWrites_PixelOp & pixelOpsFlags) {
538 this->flush();
547 } 539 }
548 return true;
549 } 540 }
550 541
551 void GrContext::flushSurfaceWrites(GrSurface* surface) { 542 void GrContext::flushSurfaceWrites(GrSurface* surface) {
552 ASSERT_SINGLE_OWNER 543 ASSERT_SINGLE_OWNER
553 RETURN_IF_ABANDONED 544 RETURN_IF_ABANDONED
554 if (surface->surfacePriv().hasPendingWrite()) { 545 if (surface->surfacePriv().hasPendingWrite()) {
555 this->flush(); 546 this->flush();
556 } 547 }
557 } 548 }
558 549
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 ASSERT_SINGLE_OWNER 652 ASSERT_SINGLE_OWNER
662 fResourceCache->setLimits(maxTextures, maxTextureBytes); 653 fResourceCache->setLimits(maxTextures, maxTextureBytes);
663 } 654 }
664 655
665 ////////////////////////////////////////////////////////////////////////////// 656 //////////////////////////////////////////////////////////////////////////////
666 657
667 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 658 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
668 ASSERT_SINGLE_OWNER 659 ASSERT_SINGLE_OWNER
669 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 660 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
670 } 661 }
OLDNEW
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/GrDrawContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698