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

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: 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 569 }
570 570
571 571
572 //////////////////////////////////////////////////////////////////////////////// 572 ////////////////////////////////////////////////////////////////////////////////
573 573
574 void GrContext::clear(const SkIRect* rect, 574 void GrContext::clear(const SkIRect* rect,
575 const GrColor color, 575 const GrColor color,
576 bool canIgnoreRect, 576 bool canIgnoreRect,
577 GrRenderTarget* renderTarget) { 577 GrRenderTarget* renderTarget) {
578 ASSERT_OWNED_RESOURCE(renderTarget); 578 ASSERT_OWNED_RESOURCE(renderTarget);
579 SkASSERT(renderTarget);
580
579 AutoRestoreEffects are; 581 AutoRestoreEffects are;
580 AutoCheckFlush acf(this); 582 AutoCheckFlush acf(this);
581 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this); 583 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
582 GrDrawTarget* target = this->prepareToDraw(NULL, &are, &acf); 584 GrDrawTarget* target = this->prepareToDraw(NULL, &are, &acf);
583 if (NULL == target) { 585 if (NULL == target) {
584 return; 586 return;
585 } 587 }
586 target->clear(rect, color, canIgnoreRect, renderTarget); 588 target->clear(rect, color, canIgnoreRect, renderTarget);
587 } 589 }
588 590
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // Does the rect bound the RT? 744 // Does the rect bound the RT?
743 SkPoint srcSpaceRTQuad[4]; 745 SkPoint srcSpaceRTQuad[4];
744 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); 746 invM.mapRectToQuad(srcSpaceRTQuad, rtRect);
745 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && 747 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) &&
746 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && 748 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) &&
747 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && 749 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) &&
748 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { 750 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) {
749 // Will it blend? 751 // Will it blend?
750 GrColor clearColor; 752 GrColor clearColor;
751 if (paint.isOpaqueAndConstantColor(&clearColor)) { 753 if (paint.isOpaqueAndConstantColor(&clearColor)) {
752 target->clear(NULL, clearColor, true); 754 target->clear(NULL, clearColor, true, fRenderTarget);
753 return; 755 return;
754 } 756 }
755 } 757 }
756 } 758 }
757 } 759 }
758 760
759 SkRect devBoundRect; 761 SkRect devBoundRect;
760 bool needAA = paint.isAntiAlias() && 762 bool needAA = paint.isAntiAlias() &&
761 !target->getDrawState().getRenderTarget()->isMultisampled(); 763 !target->getDrawState().getRenderTarget()->isMultisampled();
762 bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix, &devBoun dRect); 764 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
1389 SkASSERT(kBGRA_8888_SkColorType == ct); 1391 SkASSERT(kBGRA_8888_SkColorType == ct);
1390 return kRGBA_8888_SkColorType; 1392 return kRGBA_8888_SkColorType;
1391 } 1393 }
1392 } 1394 }
1393 1395
1394 bool GrContext::readRenderTargetPixels(GrRenderTarget* target, 1396 bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
1395 int left, int top, int width, int height, 1397 int left, int top, int width, int height,
1396 GrPixelConfig dstConfig, void* buffer, si ze_t rowBytes, 1398 GrPixelConfig dstConfig, void* buffer, si ze_t rowBytes,
1397 uint32_t flags) { 1399 uint32_t flags) {
1398 ASSERT_OWNED_RESOURCE(target); 1400 ASSERT_OWNED_RESOURCE(target);
1399 1401 SkASSERT(target);
1400 if (NULL == target) {
1401 target = fRenderTarget.get();
1402 if (NULL == target) {
1403 return false;
1404 }
1405 }
1406 1402
1407 if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWr ite()) { 1403 if (!(kDontFlush_PixelOpsFlag & flags) && target->surfacePriv().hasPendingWr ite()) {
1408 this->flush(); 1404 this->flush();
1409 } 1405 }
1410 1406
1411 // Determine which conversions have to be applied: flipY, swapRAnd, and/or u npremul. 1407 // Determine which conversions have to be applied: flipY, swapRAnd, and/or u npremul.
1412 1408
1413 // If fGpu->readPixels would incur a y-flip cost then we will read the pixel s upside down. We'll 1409 // If fGpu->readPixels would incur a y-flip cost then we will read the pixel s upside down. We'll
1414 // either do the flipY by drawing into a scratch with a matrix or on the cpu after the read. 1410 // either do the flipY by drawing into a scratch with a matrix or on the cpu after the read.
1415 bool flipY = fGpu->readPixelsWillPayForYFlip(target, left, top, 1411 bool flipY = fGpu->readPixelsWillPayForYFlip(target, left, top,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 srcPI.fRowBytes = rowBytes; 1526 srcPI.fRowBytes = rowBytes;
1531 1527
1532 return srcPI.convertPixelsTo(&dstPI, width, height); 1528 return srcPI.convertPixelsTo(&dstPI, width, height);
1533 } 1529 }
1534 return true; 1530 return true;
1535 } 1531 }
1536 1532
1537 void GrContext::resolveRenderTarget(GrRenderTarget* target) { 1533 void GrContext::resolveRenderTarget(GrRenderTarget* target) {
1538 SkASSERT(target); 1534 SkASSERT(target);
1539 ASSERT_OWNED_RESOURCE(target); 1535 ASSERT_OWNED_RESOURCE(target);
1540 // In the future we may track whether there are any pending draws to this 1536 if (!target->needsResolve()) {
1541 // target. We don't today so we always perform a flush. We don't promise 1537 return;
1542 // this to our clients, though. 1538 }
1543 this->flush(); 1539 if (!target->surfacePriv().hasPendingIO()) {
joshualitt 2014/11/03 19:33:14 is the ! correct here?
bsalomon 2014/11/03 19:59:19 ack, no it's not! Fixed.
1540 this->flush();
1541 }
1544 if (fGpu) { 1542 if (fGpu) {
1545 fGpu->resolveRenderTarget(target); 1543 fGpu->resolveRenderTarget(target);
1546 } 1544 }
1547 } 1545 }
1548 1546
1549 void GrContext::discardRenderTarget(GrRenderTarget* renderTarget) { 1547 void GrContext::discardRenderTarget(GrRenderTarget* renderTarget) {
1550 SkASSERT(renderTarget); 1548 SkASSERT(renderTarget);
1551 ASSERT_OWNED_RESOURCE(renderTarget); 1549 ASSERT_OWNED_RESOURCE(renderTarget);
1552 AutoRestoreEffects are; 1550 AutoRestoreEffects are;
1553 AutoCheckFlush acf(this); 1551 AutoCheckFlush acf(this);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 fResourceCache->printStats(); 1780 fResourceCache->printStats();
1783 } 1781 }
1784 #endif 1782 #endif
1785 1783
1786 #if GR_GPU_STATS 1784 #if GR_GPU_STATS
1787 const GrContext::GPUStats* GrContext::gpuStats() const { 1785 const GrContext::GPUStats* GrContext::gpuStats() const {
1788 return fGpu->gpuStats(); 1786 return fGpu->gpuStats();
1789 } 1787 }
1790 #endif 1788 #endif
1791 1789
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