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

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

Issue 680413005: Don't allow renderTarget==NULL to GrContext::clear() and friends. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comment Created 6 years, 1 month 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/effects/SkMorphologyImageFilter.cpp ('k') | src/gpu/GrDrawTarget.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 2011 Google Inc. 3 * Copyright 2011 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 "GrContext.h" 9 #include "GrContext.h"
10 10
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 } 573 }
574 574
575 575
576 //////////////////////////////////////////////////////////////////////////////// 576 ////////////////////////////////////////////////////////////////////////////////
577 577
578 void GrContext::clear(const SkIRect* rect, 578 void GrContext::clear(const SkIRect* rect,
579 const GrColor color, 579 const GrColor color,
580 bool canIgnoreRect, 580 bool canIgnoreRect,
581 GrRenderTarget* renderTarget) { 581 GrRenderTarget* renderTarget) {
582 ASSERT_OWNED_RESOURCE(renderTarget); 582 ASSERT_OWNED_RESOURCE(renderTarget);
583 SkASSERT(renderTarget);
584
583 AutoRestoreEffects are; 585 AutoRestoreEffects are;
584 AutoCheckFlush acf(this); 586 AutoCheckFlush acf(this);
585 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this); 587 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
586 GrDrawTarget* target = this->prepareToDraw(NULL, &are, &acf); 588 GrDrawTarget* target = this->prepareToDraw(NULL, &are, &acf);
587 if (NULL == target) { 589 if (NULL == target) {
588 return; 590 return;
589 } 591 }
590 target->clear(rect, color, canIgnoreRect, renderTarget); 592 target->clear(rect, color, canIgnoreRect, renderTarget);
591 } 593 }
592 594
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 // Does the rect bound the RT? 748 // Does the rect bound the RT?
747 SkPoint srcSpaceRTQuad[4]; 749 SkPoint srcSpaceRTQuad[4];
748 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); 750 invM.mapRectToQuad(srcSpaceRTQuad, rtRect);
749 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && 751 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) &&
750 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && 752 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) &&
751 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && 753 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) &&
752 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { 754 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) {
753 // Will it blend? 755 // Will it blend?
754 GrColor clearColor; 756 GrColor clearColor;
755 if (paint.isOpaqueAndConstantColor(&clearColor)) { 757 if (paint.isOpaqueAndConstantColor(&clearColor)) {
756 target->clear(NULL, clearColor, true); 758 target->clear(NULL, clearColor, true, fRenderTarget);
757 return; 759 return;
758 } 760 }
759 } 761 }
760 } 762 }
761 } 763 }
762 764
763 SkRect devBoundRect; 765 SkRect devBoundRect;
764 bool needAA = paint.isAntiAlias() && 766 bool needAA = paint.isAntiAlias() &&
765 !target->getDrawState().getRenderTarget()->isMultisampled(); 767 !target->getDrawState().getRenderTarget()->isMultisampled();
766 bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix, &devBoun dRect); 768 bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix, &devBoun dRect);
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 SkASSERT(kBGRA_8888_SkColorType == ct); 1395 SkASSERT(kBGRA_8888_SkColorType == ct);
1394 return kRGBA_8888_SkColorType; 1396 return kRGBA_8888_SkColorType;
1395 } 1397 }
1396 } 1398 }
1397 1399
1398 bool GrContext::readRenderTargetPixels(GrRenderTarget* target, 1400 bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
1399 int left, int top, int width, int height, 1401 int left, int top, int width, int height,
1400 GrPixelConfig dstConfig, void* buffer, si ze_t rowBytes, 1402 GrPixelConfig dstConfig, void* buffer, si ze_t rowBytes,
1401 uint32_t flags) { 1403 uint32_t flags) {
1402 ASSERT_OWNED_RESOURCE(target); 1404 ASSERT_OWNED_RESOURCE(target);
1403 1405 SkASSERT(target);
1404 if (NULL == target) {
1405 target = fRenderTarget.get();
1406 if (NULL == target) {
1407 return false;
1408 }
1409 }
1410 1406
1411 if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWr ite()) { 1407 if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWr ite()) {
1412 this->flush(); 1408 this->flush();
1413 } 1409 }
1414 1410
1415 // Determine which conversions have to be applied: flipY, swapRAnd, and/or u npremul. 1411 // Determine which conversions have to be applied: flipY, swapRAnd, and/or u npremul.
1416 1412
1417 // If fGpu->readPixels would incur a y-flip cost then we will read the pixel s upside down. We'll 1413 // If fGpu->readPixels would incur a y-flip cost then we will read the pixel s upside down. We'll
1418 // either do the flipY by drawing into a scratch with a matrix or on the cpu after the read. 1414 // either do the flipY by drawing into a scratch with a matrix or on the cpu after the read.
1419 bool flipY = fGpu->readPixelsWillPayForYFlip(target, left, top, 1415 bool flipY = fGpu->readPixelsWillPayForYFlip(target, left, top,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 srcPI.fRowBytes = rowBytes; 1530 srcPI.fRowBytes = rowBytes;
1535 1531
1536 return srcPI.convertPixelsTo(&dstPI, width, height); 1532 return srcPI.convertPixelsTo(&dstPI, width, height);
1537 } 1533 }
1538 return true; 1534 return true;
1539 } 1535 }
1540 1536
1541 void GrContext::resolveRenderTarget(GrRenderTarget* target) { 1537 void GrContext::resolveRenderTarget(GrRenderTarget* target) {
1542 SkASSERT(target); 1538 SkASSERT(target);
1543 ASSERT_OWNED_RESOURCE(target); 1539 ASSERT_OWNED_RESOURCE(target);
1544 // In the future we may track whether there are any pending draws to this 1540 if (!target->needsResolve()) {
1545 // target. We don't today so we always perform a flush. We don't promise 1541 return;
1546 // this to our clients, though. 1542 }
1547 this->flush(); 1543 if (target->surfacePriv().hasPendingIO()) {
1544 this->flush();
1545 }
1548 if (fGpu) { 1546 if (fGpu) {
1549 fGpu->resolveRenderTarget(target); 1547 fGpu->resolveRenderTarget(target);
1550 } 1548 }
1551 } 1549 }
1552 1550
1553 void GrContext::discardRenderTarget(GrRenderTarget* renderTarget) { 1551 void GrContext::discardRenderTarget(GrRenderTarget* renderTarget) {
1554 SkASSERT(renderTarget); 1552 SkASSERT(renderTarget);
1555 ASSERT_OWNED_RESOURCE(renderTarget); 1553 ASSERT_OWNED_RESOURCE(renderTarget);
1556 AutoRestoreEffects are; 1554 AutoRestoreEffects are;
1557 AutoCheckFlush acf(this); 1555 AutoCheckFlush acf(this);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 fResourceCache->printStats(); 1784 fResourceCache->printStats();
1787 } 1785 }
1788 #endif 1786 #endif
1789 1787
1790 #if GR_GPU_STATS 1788 #if GR_GPU_STATS
1791 const GrContext::GPUStats* GrContext::gpuStats() const { 1789 const GrContext::GPUStats* GrContext::gpuStats() const {
1792 return fGpu->gpuStats(); 1790 return fGpu->gpuStats();
1793 } 1791 }
1794 #endif 1792 #endif
1795 1793
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698