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

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

Issue 979343002: handle null vertex or index buffers in batch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 9 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 | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.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 "GrAAHairLinePathRenderer.h" 8 #include "GrAAHairLinePathRenderer.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 const GrVertexBuffer* vertexBuffer; 888 const GrVertexBuffer* vertexBuffer;
889 int firstVertex; 889 int firstVertex;
890 890
891 size_t vertexStride = lineGP->getVertexStride(); 891 size_t vertexStride = lineGP->getVertexStride();
892 int vertexCount = kLineSegNumVertices * lineCount; 892 int vertexCount = kLineSegNumVertices * lineCount;
893 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 893 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
894 vertexCount, 894 vertexCount,
895 &vertexBuffer, 895 &vertexBuffer,
896 &firstVertex); 896 &firstVertex);
897 897
898 if (!vertices) {
899 SkDebugf("Could not allocate vertices\n");
900 return;
901 }
902
898 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex)); 903 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex));
899 904
900 LineVertex* verts = reinterpret_cast<LineVertex*>(vertices); 905 LineVertex* verts = reinterpret_cast<LineVertex*>(vertices);
901 for (int i = 0; i < lineCount; ++i) { 906 for (int i = 0; i < lineCount; ++i) {
902 add_line(&lines[2*i], toSrc, this->coverage(), &verts); 907 add_line(&lines[2*i], toSrc, this->coverage(), &verts);
903 } 908 }
904 909
905 { 910 {
906 GrDrawTarget::DrawInfo info; 911 GrDrawTarget::DrawInfo info;
907 info.setVertexBuffer(vertexBuffer); 912 info.setVertexBuffer(vertexBuffer);
(...skipping 19 matching lines...) Expand all
927 const GrVertexBuffer* vertexBuffer; 932 const GrVertexBuffer* vertexBuffer;
928 int firstVertex; 933 int firstVertex;
929 934
930 size_t vertexStride = sizeof(BezierVertex); 935 size_t vertexStride = sizeof(BezierVertex);
931 int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * coni cCount; 936 int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * coni cCount;
932 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 937 void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
933 vertexCount, 938 vertexCount,
934 &vertexBuffer, 939 &vertexBuffer,
935 &firstVertex); 940 &firstVertex);
936 941
942 if (!vertices) {
943 SkDebugf("Could not allocate vertices\n");
944 return;
945 }
946
937 // Setup vertices 947 // Setup vertices
938 BezierVertex* verts = reinterpret_cast<BezierVertex*>(vertices); 948 BezierVertex* verts = reinterpret_cast<BezierVertex*>(vertices);
939 949
940 int unsubdivQuadCnt = quads.count() / 3; 950 int unsubdivQuadCnt = quads.count() / 3;
941 for (int i = 0; i < unsubdivQuadCnt; ++i) { 951 for (int i = 0; i < unsubdivQuadCnt; ++i) {
942 SkASSERT(qSubdivs[i] >= 0); 952 SkASSERT(qSubdivs[i] >= 0);
943 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts); 953 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts);
944 } 954 }
945 955
946 // Start Conics 956 // Start Conics
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 } 1024 }
1015 } 1025 }
1016 1026
1017 bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target, 1027 bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target,
1018 GrPipelineBuilder* pipelineBuilder, 1028 GrPipelineBuilder* pipelineBuilder,
1019 GrColor color, 1029 GrColor color,
1020 const SkMatrix& viewMatrix, 1030 const SkMatrix& viewMatrix,
1021 const SkPath& path, 1031 const SkPath& path,
1022 const SkStrokeRec& stroke, 1032 const SkStrokeRec& stroke,
1023 bool) { 1033 bool) {
1034 if (!fLinesIndexBuffer || !fQuadsIndexBuffer) {
1035 SkDebugf("unable to allocate indices\n");
1036 return false;
1037 }
1038
1024 SkScalar hairlineCoverage; 1039 SkScalar hairlineCoverage;
1025 uint8_t newCoverage = 0xff; 1040 uint8_t newCoverage = 0xff;
1026 if (IsStrokeHairlineOrEquivalent(stroke, viewMatrix, &hairlineCoverage)) { 1041 if (IsStrokeHairlineOrEquivalent(stroke, viewMatrix, &hairlineCoverage)) {
1027 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff); 1042 newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff);
1028 } 1043 }
1029 1044
1030 SkIRect devClipBounds; 1045 SkIRect devClipBounds;
1031 pipelineBuilder->clip().getConservativeBounds(pipelineBuilder->getRenderTarg et(), 1046 pipelineBuilder->clip().getConservativeBounds(pipelineBuilder->getRenderTarg et(),
1032 &devClipBounds); 1047 &devClipBounds);
1033 1048
(...skipping 10 matching lines...) Expand all
1044 geometry.fPath = path; 1059 geometry.fPath = path;
1045 SkDEBUGCODE(geometry.fDevBounds = devRect;) 1060 SkDEBUGCODE(geometry.fDevBounds = devRect;)
1046 geometry.fDevClipBounds = devClipBounds; 1061 geometry.fDevClipBounds = devClipBounds;
1047 1062
1048 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry, fLinesIndexBuf fer, 1063 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry, fLinesIndexBuf fer,
1049 fQuadsIndexBuffer)); 1064 fQuadsIndexBuffer));
1050 target->drawBatch(pipelineBuilder, batch, &devRect); 1065 target->drawBatch(pipelineBuilder, batch, &devRect);
1051 1066
1052 return true; 1067 return true;
1053 } 1068 }
OLDNEW
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698