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

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

Issue 1684313002: Make copySurface work for texture dsts, return a bool, & add unit test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try again 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"
21 #include "effects/GrConfigConversionEffect.h" 22 #include "effects/GrConfigConversionEffect.h"
22 #include "text/GrTextBlobCache.h" 23 #include "text/GrTextBlobCache.h"
23 24
24 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this) 25 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
25 #define ASSERT_SINGLE_OWNER \ 26 #define ASSERT_SINGLE_OWNER \
26 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);) 27 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);)
27 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 28 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
28 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; } 29 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fal se; }
29 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; } 30 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return null ptr; }
30 31
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 ASSERT_OWNED_RESOURCE(surface); 503 ASSERT_OWNED_RESOURCE(surface);
503 if (surface->surfacePriv().hasPendingIO()) { 504 if (surface->surfacePriv().hasPendingIO()) {
504 this->flush(); 505 this->flush();
505 } 506 }
506 GrRenderTarget* rt = surface->asRenderTarget(); 507 GrRenderTarget* rt = surface->asRenderTarget();
507 if (fGpu && rt) { 508 if (fGpu && rt) {
508 fGpu->resolveRenderTarget(rt); 509 fGpu->resolveRenderTarget(rt);
509 } 510 }
510 } 511 }
511 512
512 void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe ct, 513 bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe ct,
513 const SkIPoint& dstPoint, uint32_t pixelOpsFlags) { 514 const SkIPoint& dstPoint) {
514 ASSERT_SINGLE_OWNER 515 ASSERT_SINGLE_OWNER
515 RETURN_IF_ABANDONED 516 RETURN_FALSE_IF_ABANDONED
516 GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface"); 517 GR_AUDIT_TRAIL_AUTO_FRAME(&fAuditTrail, "GrContext::copySurface");
517 518
518 if (!src || !dst) { 519 if (!src || !dst) {
519 return; 520 return false;
520 } 521 }
521 ASSERT_OWNED_RESOURCE(src); 522 ASSERT_OWNED_RESOURCE(src);
522 ASSERT_OWNED_RESOURCE(dst); 523 ASSERT_OWNED_RESOURCE(dst);
523 524
524 // Since we're going to the draw target and not GPU, no need to check kNoFlu sh
525 // here.
526 if (!dst->asRenderTarget()) { 525 if (!dst->asRenderTarget()) {
527 return; 526 SkIRect clippedSrcRect;
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 }
540 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarge t()));
541 if (!drawContext) {
542 return false;
528 } 543 }
529 544
530 SkAutoTUnref<GrDrawContext> drawContext(this->drawContext(dst->asRenderTarge t())); 545 if (!drawContext->copySurface(src, srcRect, dstPoint)) {
531 if (!drawContext) { 546 return false;
532 return;
533 } 547 }
534 548 return true;
535 drawContext->copySurface(src, srcRect, dstPoint);
536
537 if (kFlushWrites_PixelOp & pixelOpsFlags) {
538 this->flush();
539 }
540 } 549 }
541 550
542 void GrContext::flushSurfaceWrites(GrSurface* surface) { 551 void GrContext::flushSurfaceWrites(GrSurface* surface) {
543 ASSERT_SINGLE_OWNER 552 ASSERT_SINGLE_OWNER
544 RETURN_IF_ABANDONED 553 RETURN_IF_ABANDONED
545 if (surface->surfacePriv().hasPendingWrite()) { 554 if (surface->surfacePriv().hasPendingWrite()) {
546 this->flush(); 555 this->flush();
547 } 556 }
548 } 557 }
549 558
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 ASSERT_SINGLE_OWNER 661 ASSERT_SINGLE_OWNER
653 fResourceCache->setLimits(maxTextures, maxTextureBytes); 662 fResourceCache->setLimits(maxTextures, maxTextureBytes);
654 } 663 }
655 664
656 ////////////////////////////////////////////////////////////////////////////// 665 //////////////////////////////////////////////////////////////////////////////
657 666
658 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { 667 void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
659 ASSERT_SINGLE_OWNER 668 ASSERT_SINGLE_OWNER
660 fResourceCache->dumpMemoryStatistics(traceMemoryDump); 669 fResourceCache->dumpMemoryStatistics(traceMemoryDump);
661 } 670 }
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