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

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

Issue 1122673002: Start on simplifying generateGeometry() overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@ibcache
Patch Set: whitespace, remove debug return Created 5 years, 7 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/GrBatch.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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // hairline 495 // hairline
496 primType = kLineStrip_GrPrimitiveType; 496 primType = kLineStrip_GrPrimitiveType;
497 vertex[0].set(args.fRect.fLeft, args.fRect.fTop); 497 vertex[0].set(args.fRect.fLeft, args.fRect.fTop);
498 vertex[1].set(args.fRect.fRight, args.fRect.fTop); 498 vertex[1].set(args.fRect.fRight, args.fRect.fTop);
499 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); 499 vertex[2].set(args.fRect.fRight, args.fRect.fBottom);
500 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); 500 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom);
501 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); 501 vertex[4].set(args.fRect.fLeft, args.fRect.fTop);
502 } 502 }
503 503
504 GrDrawTarget::DrawInfo drawInfo; 504 GrDrawTarget::DrawInfo drawInfo;
505 drawInfo.setPrimitiveType(primType); 505 drawInfo.init(primType, vertexBuffer, firstVertex, vertexCount);
506 drawInfo.setVertexBuffer(vertexBuffer);
507 drawInfo.setStartVertex(firstVertex);
508 drawInfo.setVertexCount(vertexCount);
509 drawInfo.setStartIndex(0);
510 drawInfo.setIndexCount(0);
511 drawInfo.setInstanceCount(0);
512 drawInfo.setVerticesPerInstance(0);
513 drawInfo.setIndicesPerInstance(0);
514 batchTarget->draw(drawInfo); 506 batchTarget->draw(drawInfo);
515 } 507 }
516 508
517 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 509 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
518 510
519 private: 511 private:
520 StrokeRectBatch(const Geometry& geometry) { 512 StrokeRectBatch(const Geometry& geometry) {
521 this->initClassID<StrokeRectBatch>(); 513 this->initClassID<StrokeRectBatch>();
522 514
523 fBatch.fHairline = geometry.fStrokeWidth == 0; 515 fBatch.fHairline = geometry.fStrokeWidth == 0;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, 814 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
823 this->vertexCount( ), 815 this->vertexCount( ),
824 &vertexBuffer, 816 &vertexBuffer,
825 &firstVertex); 817 &firstVertex);
826 818
827 if (!vertices) { 819 if (!vertices) {
828 SkDebugf("Could not allocate vertices\n"); 820 SkDebugf("Could not allocate vertices\n");
829 return; 821 return;
830 } 822 }
831 823
832 const GrIndexBuffer* indexBuffer; 824 const GrIndexBuffer* indexBuffer = NULL;
833 int firstIndex; 825 int firstIndex = 0;
834 826
835 void* indices = NULL; 827 void* indices = NULL;
836 if (this->hasIndices()) { 828 if (this->hasIndices()) {
837 indices = batchTarget->indexPool()->makeSpace(this->indexCount(), 829 indices = batchTarget->indexPool()->makeSpace(this->indexCount(),
838 &indexBuffer, 830 &indexBuffer,
839 &firstIndex); 831 &firstIndex);
840 832
841 if (!indices) { 833 if (!indices) {
842 SkDebugf("Could not allocate indices\n"); 834 SkDebugf("Could not allocate indices\n");
843 return; 835 return;
(...skipping 19 matching lines...) Expand all
863 } 855 }
864 if (this->hasLocalCoords()) { 856 if (this->hasLocalCoords()) {
865 *(SkPoint*)((intptr_t)vertices + texOffset) = args.fLocalCoo rds[j]; 857 *(SkPoint*)((intptr_t)vertices + texOffset) = args.fLocalCoo rds[j];
866 } 858 }
867 vertices = (void*)((intptr_t)vertices + vertexStride); 859 vertices = (void*)((intptr_t)vertices + vertexStride);
868 vertexOffset++; 860 vertexOffset++;
869 } 861 }
870 } 862 }
871 863
872 GrDrawTarget::DrawInfo drawInfo; 864 GrDrawTarget::DrawInfo drawInfo;
873 drawInfo.setPrimitiveType(this->primitiveType());
874 drawInfo.setVertexBuffer(vertexBuffer);
875 drawInfo.setStartVertex(firstVertex);
876 drawInfo.setVertexCount(this->vertexCount());
877 if (this->hasIndices()) { 865 if (this->hasIndices()) {
878 drawInfo.setIndexBuffer(indexBuffer); 866 drawInfo.initIndexed(this->primitiveType(), vertexBuffer, indexBuffe r, firstVertex,
879 drawInfo.setStartIndex(firstIndex); 867 firstIndex, this->vertexCount(), this->indexCou nt());
880 drawInfo.setIndexCount(this->indexCount()); 868
881 } else { 869 } else {
882 drawInfo.setStartIndex(0); 870 drawInfo.init(this->primitiveType(), vertexBuffer, firstVertex, this ->vertexCount());
883 drawInfo.setIndexCount(0);
884 } 871 }
885 batchTarget->draw(drawInfo); 872 batchTarget->draw(drawInfo);
886 } 873 }
887 874
888 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 875 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
889 876
890 private: 877 private:
891 DrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, 878 DrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType,
892 const SkMatrix& viewMatrix, 879 const SkMatrix& viewMatrix,
893 const SkPoint* positions, int vertexCount, 880 const SkPoint* positions, int vertexCount,
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 fDrawBuffer->addGpuTraceMarker(marker); 1889 fDrawBuffer->addGpuTraceMarker(marker);
1903 } 1890 }
1904 } 1891 }
1905 1892
1906 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { 1893 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
1907 fGpu->removeGpuTraceMarker(marker); 1894 fGpu->removeGpuTraceMarker(marker);
1908 if (fDrawBuffer) { 1895 if (fDrawBuffer) {
1909 fDrawBuffer->removeGpuTraceMarker(marker); 1896 fDrawBuffer->removeGpuTraceMarker(marker);
1910 } 1897 }
1911 } 1898 }
OLDNEW
« no previous file with comments | « src/gpu/GrBatch.cpp ('k') | src/gpu/GrDefaultPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698