OLD | NEW |
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 Loading... |
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.init(primType, vertexBuffer, firstVertex, vertexCount); | 505 drawInfo.setPrimitiveType(primType); |
| 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); |
506 batchTarget->draw(drawInfo); | 514 batchTarget->draw(drawInfo); |
507 } | 515 } |
508 | 516 |
509 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 517 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
510 | 518 |
511 private: | 519 private: |
512 StrokeRectBatch(const Geometry& geometry) { | 520 StrokeRectBatch(const Geometry& geometry) { |
513 this->initClassID<StrokeRectBatch>(); | 521 this->initClassID<StrokeRectBatch>(); |
514 | 522 |
515 fBatch.fHairline = geometry.fStrokeWidth == 0; | 523 fBatch.fHairline = geometry.fStrokeWidth == 0; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 822 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, |
815 this->vertexCount(
), | 823 this->vertexCount(
), |
816 &vertexBuffer, | 824 &vertexBuffer, |
817 &firstVertex); | 825 &firstVertex); |
818 | 826 |
819 if (!vertices) { | 827 if (!vertices) { |
820 SkDebugf("Could not allocate vertices\n"); | 828 SkDebugf("Could not allocate vertices\n"); |
821 return; | 829 return; |
822 } | 830 } |
823 | 831 |
824 const GrIndexBuffer* indexBuffer = NULL; | 832 const GrIndexBuffer* indexBuffer; |
825 int firstIndex = 0; | 833 int firstIndex; |
826 | 834 |
827 void* indices = NULL; | 835 void* indices = NULL; |
828 if (this->hasIndices()) { | 836 if (this->hasIndices()) { |
829 indices = batchTarget->indexPool()->makeSpace(this->indexCount(), | 837 indices = batchTarget->indexPool()->makeSpace(this->indexCount(), |
830 &indexBuffer, | 838 &indexBuffer, |
831 &firstIndex); | 839 &firstIndex); |
832 | 840 |
833 if (!indices) { | 841 if (!indices) { |
834 SkDebugf("Could not allocate indices\n"); | 842 SkDebugf("Could not allocate indices\n"); |
835 return; | 843 return; |
(...skipping 19 matching lines...) Expand all Loading... |
855 } | 863 } |
856 if (this->hasLocalCoords()) { | 864 if (this->hasLocalCoords()) { |
857 *(SkPoint*)((intptr_t)vertices + texOffset) = args.fLocalCoo
rds[j]; | 865 *(SkPoint*)((intptr_t)vertices + texOffset) = args.fLocalCoo
rds[j]; |
858 } | 866 } |
859 vertices = (void*)((intptr_t)vertices + vertexStride); | 867 vertices = (void*)((intptr_t)vertices + vertexStride); |
860 vertexOffset++; | 868 vertexOffset++; |
861 } | 869 } |
862 } | 870 } |
863 | 871 |
864 GrDrawTarget::DrawInfo drawInfo; | 872 GrDrawTarget::DrawInfo drawInfo; |
| 873 drawInfo.setPrimitiveType(this->primitiveType()); |
| 874 drawInfo.setVertexBuffer(vertexBuffer); |
| 875 drawInfo.setStartVertex(firstVertex); |
| 876 drawInfo.setVertexCount(this->vertexCount()); |
865 if (this->hasIndices()) { | 877 if (this->hasIndices()) { |
866 drawInfo.initIndexed(this->primitiveType(), vertexBuffer, indexBuffe
r, firstVertex, | 878 drawInfo.setIndexBuffer(indexBuffer); |
867 firstIndex, this->vertexCount(), this->indexCou
nt()); | 879 drawInfo.setStartIndex(firstIndex); |
868 | 880 drawInfo.setIndexCount(this->indexCount()); |
869 } else { | 881 } else { |
870 drawInfo.init(this->primitiveType(), vertexBuffer, firstVertex, this
->vertexCount()); | 882 drawInfo.setStartIndex(0); |
| 883 drawInfo.setIndexCount(0); |
871 } | 884 } |
872 batchTarget->draw(drawInfo); | 885 batchTarget->draw(drawInfo); |
873 } | 886 } |
874 | 887 |
875 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 888 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
876 | 889 |
877 private: | 890 private: |
878 DrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, | 891 DrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, |
879 const SkMatrix& viewMatrix, | 892 const SkMatrix& viewMatrix, |
880 const SkPoint* positions, int vertexCount, | 893 const SkPoint* positions, int vertexCount, |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 fDrawBuffer->addGpuTraceMarker(marker); | 1899 fDrawBuffer->addGpuTraceMarker(marker); |
1887 } | 1900 } |
1888 } | 1901 } |
1889 | 1902 |
1890 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 1903 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
1891 fGpu->removeGpuTraceMarker(marker); | 1904 fGpu->removeGpuTraceMarker(marker); |
1892 if (fDrawBuffer) { | 1905 if (fDrawBuffer) { |
1893 fDrawBuffer->removeGpuTraceMarker(marker); | 1906 fDrawBuffer->removeGpuTraceMarker(marker); |
1894 } | 1907 } |
1895 } | 1908 } |
OLD | NEW |