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 18 matching lines...) Expand all Loading... |
29 #include "GrResourceCache.h" | 29 #include "GrResourceCache.h" |
30 #include "GrResourceProvider.h" | 30 #include "GrResourceProvider.h" |
31 #include "GrSoftwarePathRenderer.h" | 31 #include "GrSoftwarePathRenderer.h" |
32 #include "GrStencilAndCoverTextContext.h" | 32 #include "GrStencilAndCoverTextContext.h" |
33 #include "GrStrokeInfo.h" | 33 #include "GrStrokeInfo.h" |
34 #include "GrSurfacePriv.h" | 34 #include "GrSurfacePriv.h" |
35 #include "GrTextBlobCache.h" | 35 #include "GrTextBlobCache.h" |
36 #include "GrTexturePriv.h" | 36 #include "GrTexturePriv.h" |
37 #include "GrTraceMarker.h" | 37 #include "GrTraceMarker.h" |
38 #include "GrTracing.h" | 38 #include "GrTracing.h" |
| 39 #include "GrVertices.h" |
39 #include "SkDashPathPriv.h" | 40 #include "SkDashPathPriv.h" |
40 #include "SkConfig8888.h" | 41 #include "SkConfig8888.h" |
41 #include "SkGr.h" | 42 #include "SkGr.h" |
42 #include "SkRRect.h" | 43 #include "SkRRect.h" |
43 #include "SkStrokeRec.h" | 44 #include "SkStrokeRec.h" |
44 #include "SkTLazy.h" | 45 #include "SkTLazy.h" |
45 #include "SkTLS.h" | 46 #include "SkTLS.h" |
46 #include "SkTraceEvent.h" | 47 #include "SkTraceEvent.h" |
47 | 48 |
48 #include "effects/GrConfigConversionEffect.h" | 49 #include "effects/GrConfigConversionEffect.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 Geometry& args = fGeoData[0]; | 467 Geometry& args = fGeoData[0]; |
467 | 468 |
468 int vertexCount = kVertsPerHairlineRect; | 469 int vertexCount = kVertsPerHairlineRect; |
469 if (args.fStrokeWidth > 0) { | 470 if (args.fStrokeWidth > 0) { |
470 vertexCount = kVertsPerStrokeRect; | 471 vertexCount = kVertsPerStrokeRect; |
471 } | 472 } |
472 | 473 |
473 const GrVertexBuffer* vertexBuffer; | 474 const GrVertexBuffer* vertexBuffer; |
474 int firstVertex; | 475 int firstVertex; |
475 | 476 |
476 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 477 void* verts = batchTarget->vertexPool()->makeSpace(vertexStride, |
477 vertexCount, | 478 vertexCount, |
478 &vertexBuffer, | 479 &vertexBuffer, |
479 &firstVertex); | 480 &firstVertex); |
480 | 481 |
481 if (!vertices) { | 482 if (!verts) { |
482 SkDebugf("Could not allocate vertices\n"); | 483 SkDebugf("Could not allocate vertices\n"); |
483 return; | 484 return; |
484 } | 485 } |
485 | 486 |
486 SkPoint* vertex = reinterpret_cast<SkPoint*>(vertices); | 487 SkPoint* vertex = reinterpret_cast<SkPoint*>(verts); |
487 | 488 |
488 GrPrimitiveType primType; | 489 GrPrimitiveType primType; |
489 | 490 |
490 if (args.fStrokeWidth > 0) {; | 491 if (args.fStrokeWidth > 0) {; |
491 primType = kTriangleStrip_GrPrimitiveType; | 492 primType = kTriangleStrip_GrPrimitiveType; |
492 args.fRect.sort(); | 493 args.fRect.sort(); |
493 this->setStrokeRectStrip(vertex, args.fRect, args.fStrokeWidth); | 494 this->setStrokeRectStrip(vertex, args.fRect, args.fStrokeWidth); |
494 } else { | 495 } else { |
495 // hairline | 496 // hairline |
496 primType = kLineStrip_GrPrimitiveType; | 497 primType = kLineStrip_GrPrimitiveType; |
497 vertex[0].set(args.fRect.fLeft, args.fRect.fTop); | 498 vertex[0].set(args.fRect.fLeft, args.fRect.fTop); |
498 vertex[1].set(args.fRect.fRight, args.fRect.fTop); | 499 vertex[1].set(args.fRect.fRight, args.fRect.fTop); |
499 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); | 500 vertex[2].set(args.fRect.fRight, args.fRect.fBottom); |
500 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); | 501 vertex[3].set(args.fRect.fLeft, args.fRect.fBottom); |
501 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); | 502 vertex[4].set(args.fRect.fLeft, args.fRect.fTop); |
502 } | 503 } |
503 | 504 |
504 GrDrawTarget::DrawInfo drawInfo; | 505 GrVertices vertices; |
505 drawInfo.init(primType, vertexBuffer, firstVertex, vertexCount); | 506 vertices.init(primType, vertexBuffer, firstVertex, vertexCount); |
506 batchTarget->draw(drawInfo); | 507 batchTarget->draw(vertices); |
507 } | 508 } |
508 | 509 |
509 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 510 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
510 | 511 |
511 private: | 512 private: |
512 StrokeRectBatch(const Geometry& geometry) { | 513 StrokeRectBatch(const Geometry& geometry) { |
513 this->initClassID<StrokeRectBatch>(); | 514 this->initClassID<StrokeRectBatch>(); |
514 | 515 |
515 fBatch.fHairline = geometry.fStrokeWidth == 0; | 516 fBatch.fHairline = geometry.fStrokeWidth == 0; |
516 | 517 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 size_t vertexStride = gp->getVertexStride(); | 805 size_t vertexStride = gp->getVertexStride(); |
805 | 806 |
806 SkASSERT(vertexStride == sizeof(SkPoint) + (this->hasLocalCoords() ? siz
eof(SkPoint) : 0) | 807 SkASSERT(vertexStride == sizeof(SkPoint) + (this->hasLocalCoords() ? siz
eof(SkPoint) : 0) |
807 + (this->hasColors() ? sizeof(G
rColor) : 0)); | 808 + (this->hasColors() ? sizeof(G
rColor) : 0)); |
808 | 809 |
809 int instanceCount = fGeoData.count(); | 810 int instanceCount = fGeoData.count(); |
810 | 811 |
811 const GrVertexBuffer* vertexBuffer; | 812 const GrVertexBuffer* vertexBuffer; |
812 int firstVertex; | 813 int firstVertex; |
813 | 814 |
814 void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, | 815 void* verts = batchTarget->vertexPool()->makeSpace(vertexStride, |
815 this->vertexCount(
), | 816 this->vertexCount(), |
816 &vertexBuffer, | 817 &vertexBuffer, |
817 &firstVertex); | 818 &firstVertex); |
818 | 819 |
819 if (!vertices) { | 820 if (!verts) { |
820 SkDebugf("Could not allocate vertices\n"); | 821 SkDebugf("Could not allocate vertices\n"); |
821 return; | 822 return; |
822 } | 823 } |
823 | 824 |
824 const GrIndexBuffer* indexBuffer = NULL; | 825 const GrIndexBuffer* indexBuffer = NULL; |
825 int firstIndex = 0; | 826 int firstIndex = 0; |
826 | 827 |
827 void* indices = NULL; | 828 void* indices = NULL; |
828 if (this->hasIndices()) { | 829 if (this->hasIndices()) { |
829 indices = batchTarget->indexPool()->makeSpace(this->indexCount(), | 830 indices = batchTarget->indexPool()->makeSpace(this->indexCount(), |
(...skipping 12 matching lines...) Expand all Loading... |
842 const Geometry& args = fGeoData[i]; | 843 const Geometry& args = fGeoData[i]; |
843 | 844 |
844 // TODO we can actually cache this interleaved and then just memcopy | 845 // TODO we can actually cache this interleaved and then just memcopy |
845 if (this->hasIndices()) { | 846 if (this->hasIndices()) { |
846 for (int j = 0; j < args.fIndices.count(); ++j, ++indexOffset) { | 847 for (int j = 0; j < args.fIndices.count(); ++j, ++indexOffset) { |
847 *((uint16_t*)indices + indexOffset) = args.fIndices[j] + ver
texOffset; | 848 *((uint16_t*)indices + indexOffset) = args.fIndices[j] + ver
texOffset; |
848 } | 849 } |
849 } | 850 } |
850 | 851 |
851 for (int j = 0; j < args.fPositions.count(); ++j) { | 852 for (int j = 0; j < args.fPositions.count(); ++j) { |
852 *((SkPoint*)vertices) = args.fPositions[j]; | 853 *((SkPoint*)verts) = args.fPositions[j]; |
853 if (this->hasColors()) { | 854 if (this->hasColors()) { |
854 *(GrColor*)((intptr_t)vertices + colorOffset) = args.fColors
[j]; | 855 *(GrColor*)((intptr_t)verts + colorOffset) = args.fColors[j]
; |
855 } | 856 } |
856 if (this->hasLocalCoords()) { | 857 if (this->hasLocalCoords()) { |
857 *(SkPoint*)((intptr_t)vertices + texOffset) = args.fLocalCoo
rds[j]; | 858 *(SkPoint*)((intptr_t)verts + texOffset) = args.fLocalCoords
[j]; |
858 } | 859 } |
859 vertices = (void*)((intptr_t)vertices + vertexStride); | 860 verts = (void*)((intptr_t)verts + vertexStride); |
860 vertexOffset++; | 861 vertexOffset++; |
861 } | 862 } |
862 } | 863 } |
863 | 864 |
864 GrDrawTarget::DrawInfo drawInfo; | 865 GrVertices vertices; |
865 if (this->hasIndices()) { | 866 if (this->hasIndices()) { |
866 drawInfo.initIndexed(this->primitiveType(), vertexBuffer, indexBuffe
r, firstVertex, | 867 vertices.initIndexed(this->primitiveType(), vertexBuffer, indexBuffe
r, firstVertex, |
867 firstIndex, this->vertexCount(), this->indexCou
nt()); | 868 firstIndex, this->vertexCount(), this->indexCou
nt()); |
868 | 869 |
869 } else { | 870 } else { |
870 drawInfo.init(this->primitiveType(), vertexBuffer, firstVertex, this
->vertexCount()); | 871 vertices.init(this->primitiveType(), vertexBuffer, firstVertex, this
->vertexCount()); |
871 } | 872 } |
872 batchTarget->draw(drawInfo); | 873 batchTarget->draw(vertices); |
873 } | 874 } |
874 | 875 |
875 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 876 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
876 | 877 |
877 private: | 878 private: |
878 DrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, | 879 DrawVerticesBatch(const Geometry& geometry, GrPrimitiveType primitiveType, |
879 const SkMatrix& viewMatrix, | 880 const SkMatrix& viewMatrix, |
880 const SkPoint* positions, int vertexCount, | 881 const SkPoint* positions, int vertexCount, |
881 const uint16_t* indices, int indexCount, | 882 const uint16_t* indices, int indexCount, |
882 const GrColor* colors, const SkPoint* localCoords, const S
kRect& bounds) { | 883 const GrColor* colors, const SkPoint* localCoords, const S
kRect& bounds) { |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 fDrawBuffer->addGpuTraceMarker(marker); | 1890 fDrawBuffer->addGpuTraceMarker(marker); |
1890 } | 1891 } |
1891 } | 1892 } |
1892 | 1893 |
1893 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 1894 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
1894 fGpu->removeGpuTraceMarker(marker); | 1895 fGpu->removeGpuTraceMarker(marker); |
1895 if (fDrawBuffer) { | 1896 if (fDrawBuffer) { |
1896 fDrawBuffer->removeGpuTraceMarker(marker); | 1897 fDrawBuffer->removeGpuTraceMarker(marker); |
1897 } | 1898 } |
1898 } | 1899 } |
OLD | NEW |