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

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

Issue 695663003: Cleanup: Go with SkDebugf instead of GrPrintf. (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/gpu/GrBitmapTextContext.cpp ('k') | src/gpu/GrDefaultPathRenderer.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 /* 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 SkMatrix inverse; 606 SkMatrix inverse;
607 SkTCopyOnFirstWrite<GrPaint> paint(origPaint); 607 SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
608 AutoMatrix am; 608 AutoMatrix am;
609 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::drawPaint", this); 609 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::drawPaint", this);
610 610
611 // We attempt to map r by the inverse matrix and draw that. mapRect will 611 // We attempt to map r by the inverse matrix and draw that. mapRect will
612 // map the four corners and bound them with a new rect. This will not 612 // map the four corners and bound them with a new rect. This will not
613 // produce a correct result for some perspective matrices. 613 // produce a correct result for some perspective matrices.
614 if (!this->getMatrix().hasPerspective()) { 614 if (!this->getMatrix().hasPerspective()) {
615 if (!fViewMatrix.invert(&inverse)) { 615 if (!fViewMatrix.invert(&inverse)) {
616 GrPrintf("Could not invert matrix\n"); 616 SkDebugf("Could not invert matrix\n");
617 return; 617 return;
618 } 618 }
619 inverse.mapRect(&r); 619 inverse.mapRect(&r);
620 } else { 620 } else {
621 if (!am.setIdentity(this, paint.writable())) { 621 if (!am.setIdentity(this, paint.writable())) {
622 GrPrintf("Could not invert matrix\n"); 622 SkDebugf("Could not invert matrix\n");
623 return; 623 return;
624 } 624 }
625 } 625 }
626 // by definition this fills the entire clip, no need for AA 626 // by definition this fills the entire clip, no need for AA
627 if (paint->isAntiAlias()) { 627 if (paint->isAntiAlias()) {
628 paint.writable()->setAntiAlias(false); 628 paint.writable()->setAntiAlias(false);
629 } 629 }
630 this->drawRect(*paint, r); 630 this->drawRect(*paint, r);
631 } 631 }
632 632
(...skipping 21 matching lines...) Expand all
654 verts[3].set(rect.fRight + rad, rect.fTop - rad); 654 verts[3].set(rect.fRight + rad, rect.fTop - rad);
655 verts[4].set(rect.fRight - rad, rect.fBottom - rad); 655 verts[4].set(rect.fRight - rad, rect.fBottom - rad);
656 verts[5].set(rect.fRight + rad, rect.fBottom + rad); 656 verts[5].set(rect.fRight + rad, rect.fBottom + rad);
657 verts[6].set(rect.fLeft + rad, rect.fBottom - rad); 657 verts[6].set(rect.fLeft + rad, rect.fBottom - rad);
658 verts[7].set(rect.fLeft - rad, rect.fBottom + rad); 658 verts[7].set(rect.fLeft - rad, rect.fBottom + rad);
659 verts[8] = verts[0]; 659 verts[8] = verts[0];
660 verts[9] = verts[1]; 660 verts[9] = verts[1];
661 } 661 }
662 662
663 static inline bool is_irect(const SkRect& r) { 663 static inline bool is_irect(const SkRect& r) {
664 return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&» 664 return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
665 SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);» 665 SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
666 } 666 }
667 667
668 static bool apply_aa_to_rect(GrDrawTarget* target, 668 static bool apply_aa_to_rect(GrDrawTarget* target,
669 const SkRect& rect, 669 const SkRect& rect,
670 SkScalar strokeWidth, 670 SkScalar strokeWidth,
671 const SkMatrix& combinedMatrix, 671 const SkMatrix& combinedMatrix,
672 SkRect* devBoundRect) { 672 SkRect* devBoundRect) {
673 if (!target->getDrawState().canTweakAlphaForCoverage() && 673 if (!target->getDrawState().canTweakAlphaForCoverage() &&
674 target->shouldDisableCoverageAAForBlend()) { 674 target->shouldDisableCoverageAAForBlend()) {
675 #ifdef SK_DEBUG 675 #ifdef SK_DEBUG
676 //GrPrintf("Turning off AA to correctly apply blend.\n"); 676 //SkDebugf("Turning off AA to correctly apply blend.\n");
677 #endif 677 #endif
678 return false; 678 return false;
679 } 679 }
680 const GrDrawState& drawState = target->getDrawState(); 680 const GrDrawState& drawState = target->getDrawState();
681 if (drawState.getRenderTarget()->isMultisampled()) { 681 if (drawState.getRenderTarget()->isMultisampled()) {
682 return false; 682 return false;
683 } 683 }
684 684
685 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) 685 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
686 if (strokeWidth >= 0) { 686 if (strokeWidth >= 0) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 if (width >= 0) { 793 if (width >= 0) {
794 // TODO: consider making static vertex buffers for these cases. 794 // TODO: consider making static vertex buffers for these cases.
795 // Hairline could be done by just adding closing vertex to 795 // Hairline could be done by just adding closing vertex to
796 // unitSquareVertexBuffer() 796 // unitSquareVertexBuffer()
797 797
798 static const int worstCaseVertCount = 10; 798 static const int worstCaseVertCount = 10;
799 target->drawState()->setDefaultVertexAttribs(); 799 target->drawState()->setDefaultVertexAttribs();
800 GrDrawTarget::AutoReleaseGeometry geo(target, worstCaseVertCount, 0); 800 GrDrawTarget::AutoReleaseGeometry geo(target, worstCaseVertCount, 0);
801 801
802 if (!geo.succeeded()) { 802 if (!geo.succeeded()) {
803 GrPrintf("Failed to get space for vertices!\n"); 803 SkDebugf("Failed to get space for vertices!\n");
804 return; 804 return;
805 } 805 }
806 806
807 GrPrimitiveType primType; 807 GrPrimitiveType primType;
808 int vertCount; 808 int vertCount;
809 SkPoint* vertex = geo.positions(); 809 SkPoint* vertex = geo.positions();
810 810
811 if (width > 0) { 811 if (width > 0) {
812 vertCount = 10; 812 vertCount = 10;
813 primType = kTriangleStrip_GrPrimitiveType; 813 primType = kTriangleStrip_GrPrimitiveType;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 GrDrawState* drawState = target->drawState(); 909 GrDrawState* drawState = target->drawState();
910 910
911 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target); 911 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target);
912 912
913 int colorOffset = -1, texOffset = -1; 913 int colorOffset = -1, texOffset = -1;
914 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset ); 914 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset );
915 915
916 size_t VertexStride = drawState->getVertexStride(); 916 size_t VertexStride = drawState->getVertexStride();
917 if (sizeof(SkPoint) != VertexStride) { 917 if (sizeof(SkPoint) != VertexStride) {
918 if (!geo.set(target, vertexCount, 0)) { 918 if (!geo.set(target, vertexCount, 0)) {
919 GrPrintf("Failed to get space for vertices!\n"); 919 SkDebugf("Failed to get space for vertices!\n");
920 return; 920 return;
921 } 921 }
922 void* curVertex = geo.vertices(); 922 void* curVertex = geo.vertices();
923 923
924 for (int i = 0; i < vertexCount; ++i) { 924 for (int i = 0; i < vertexCount; ++i) {
925 *((SkPoint*)curVertex) = positions[i]; 925 *((SkPoint*)curVertex) = positions[i];
926 926
927 if (texOffset >= 0) { 927 if (texOffset >= 0) {
928 *(SkPoint*)((intptr_t)curVertex + texOffset) = texCoords[i]; 928 *(SkPoint*)((intptr_t)curVertex + texOffset) = texCoords[i];
929 } 929 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 } 1226 }
1227 } 1227 }
1228 } 1228 }
1229 1229
1230 // This time, allow SW renderer 1230 // This time, allow SW renderer
1231 pr = this->getPathRenderer(*pathPtr, *stroke, target, true, type); 1231 pr = this->getPathRenderer(*pathPtr, *stroke, target, true, type);
1232 } 1232 }
1233 1233
1234 if (NULL == pr) { 1234 if (NULL == pr) {
1235 #ifdef SK_DEBUG 1235 #ifdef SK_DEBUG
1236 GrPrintf("Unable to find path renderer compatible with path.\n"); 1236 SkDebugf("Unable to find path renderer compatible with path.\n");
1237 #endif 1237 #endif
1238 return; 1238 return;
1239 } 1239 }
1240 1240
1241 pr->drawPath(*pathPtr, *stroke, target, useCoverageAA); 1241 pr->drawPath(*pathPtr, *stroke, target, useCoverageAA);
1242 } 1242 }
1243 1243
1244 //////////////////////////////////////////////////////////////////////////////// 1244 ////////////////////////////////////////////////////////////////////////////////
1245 1245
1246 void GrContext::flush(int flagsBitfield) { 1246 void GrContext::flush(int flagsBitfield) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 } 1612 }
1613 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); 1613 ASSERT_OWNED_RESOURCE(fRenderTarget.get());
1614 if (paint) { 1614 if (paint) {
1615 SkASSERT(are); 1615 SkASSERT(are);
1616 SkASSERT(acf); 1616 SkASSERT(acf);
1617 are->set(fDrawState); 1617 are->set(fDrawState);
1618 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get()); 1618 fDrawState->setFromPaint(*paint, fViewMatrix, fRenderTarget.get());
1619 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK 1619 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK
1620 if ((paint->hasMask() || 0xff != paint->fCoverage) && 1620 if ((paint->hasMask() || 0xff != paint->fCoverage) &&
1621 !fDrawState->couldApplyCoverage(fGpu->caps())) { 1621 !fDrawState->couldApplyCoverage(fGpu->caps())) {
1622 GrPrintf("Partial pixel coverage will be incorrectly blended.\n"); 1622 SkDebugf("Partial pixel coverage will be incorrectly blended.\n");
1623 } 1623 }
1624 #endif 1624 #endif
1625 // Clear any vertex attributes configured for the previous use of the 1625 // Clear any vertex attributes configured for the previous use of the
1626 // GrDrawState which can effect which blend optimizations are in effect. 1626 // GrDrawState which can effect which blend optimizations are in effect.
1627 fDrawState->setDefaultVertexAttribs(); 1627 fDrawState->setDefaultVertexAttribs();
1628 } else { 1628 } else {
1629 fDrawState->reset(fViewMatrix); 1629 fDrawState->reset(fViewMatrix);
1630 fDrawState->setRenderTarget(fRenderTarget.get()); 1630 fDrawState->setRenderTarget(fRenderTarget.get());
1631 } 1631 }
1632 GrDrawTarget* target; 1632 GrDrawTarget* target;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 fResourceCache->printStats(); 1801 fResourceCache->printStats();
1802 } 1802 }
1803 #endif 1803 #endif
1804 1804
1805 #if GR_GPU_STATS 1805 #if GR_GPU_STATS
1806 const GrContext::GPUStats* GrContext::gpuStats() const { 1806 const GrContext::GPUStats* GrContext::gpuStats() const {
1807 return fGpu->gpuStats(); 1807 return fGpu->gpuStats();
1808 } 1808 }
1809 #endif 1809 #endif
1810 1810
OLDNEW
« no previous file with comments | « src/gpu/GrBitmapTextContext.cpp ('k') | src/gpu/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698