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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 | 515 |
516 fBatch.fHairline = geometry.fStrokeWidth == 0; | 516 fBatch.fHairline = geometry.fStrokeWidth == 0; |
517 | 517 |
518 fGeoData.push_back(geometry); | 518 fGeoData.push_back(geometry); |
519 | 519 |
520 // setup bounds | 520 // setup bounds |
521 fBounds = geometry.fRect; | 521 fBounds = geometry.fRect; |
522 SkScalar rad = SkScalarHalf(geometry.fStrokeWidth); | 522 SkScalar rad = SkScalarHalf(geometry.fStrokeWidth); |
523 fBounds.outset(rad, rad); | 523 fBounds.outset(rad, rad); |
524 geometry.fViewMatrix.mapRect(&fBounds); | 524 geometry.fViewMatrix.mapRect(&fBounds); |
525 | |
robertphillips
2015/05/07 13:17:17
rm "then" ?
| |
526 // Since we don't have AA then we outset for a half pixel in each direct ion to account for | |
527 // snapping | |
robertphillips
2015/05/07 13:17:17
// This is conservative but, b.c. the hardware can
| |
528 fBounds.outset(0.5f, 0.5f); | |
robertphillips
2015/05/07 13:17:17
Shouldn't this only occur for hairlines? For fills
| |
525 } | 529 } |
526 | 530 |
527 /* create a triangle strip that strokes the specified rect. There are 8 | 531 /* create a triangle strip that strokes the specified rect. There are 8 |
528 unique vertices, but we repeat the last 2 to close up. Alternatively we | 532 unique vertices, but we repeat the last 2 to close up. Alternatively we |
529 could use an indices array, and then only send 8 verts, but not sure that | 533 could use an indices array, and then only send 8 verts, but not sure that |
530 would be faster. | 534 would be faster. |
531 */ | 535 */ |
532 void setStrokeRectStrip(SkPoint verts[10], const SkRect& rect, SkScalar widt h) { | 536 void setStrokeRectStrip(SkPoint verts[10], const SkRect& rect, SkScalar widt h) { |
533 const SkScalar rad = SkScalarHalf(width); | 537 const SkScalar rad = SkScalarHalf(width); |
534 // TODO we should be able to enable this assert, but we'd have to filter these draws | 538 // TODO we should be able to enable this assert, but we'd have to filter these draws |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1014 | 1018 |
1015 // TODO clients should give us bounds | 1019 // TODO clients should give us bounds |
1016 SkRect bounds; | 1020 SkRect bounds; |
1017 if (!bounds.setBoundsCheck(positions, vertexCount)) { | 1021 if (!bounds.setBoundsCheck(positions, vertexCount)) { |
1018 SkDebugf("drawVertices call empty bounds\n"); | 1022 SkDebugf("drawVertices call empty bounds\n"); |
1019 return; | 1023 return; |
1020 } | 1024 } |
1021 | 1025 |
1022 viewMatrix.mapRect(&bounds); | 1026 viewMatrix.mapRect(&bounds); |
1023 | 1027 |
1028 // If we don't have AA then we outset for a half pixel in each direction to account for | |
1029 // snapping | |
1030 if (!paint.isAntiAlias()) { | |
1031 bounds.outset(0.5f, 0.5f); | |
1032 } | |
1033 | |
1024 DrawVerticesBatch::Geometry geometry; | 1034 DrawVerticesBatch::Geometry geometry; |
1025 geometry.fColor = paint.getColor(); | 1035 geometry.fColor = paint.getColor(); |
1026 SkAutoTUnref<GrBatch> batch(DrawVerticesBatch::Create(geometry, primitiveTyp e, viewMatrix, | 1036 SkAutoTUnref<GrBatch> batch(DrawVerticesBatch::Create(geometry, primitiveTyp e, viewMatrix, |
1027 positions, vertexCount , indices, | 1037 positions, vertexCount , indices, |
1028 indexCount, colors, te xCoords, | 1038 indexCount, colors, te xCoords, |
1029 bounds)); | 1039 bounds)); |
1030 | 1040 |
1031 target->drawBatch(&pipelineBuilder, batch); | 1041 target->drawBatch(&pipelineBuilder, batch); |
1032 } | 1042 } |
1033 | 1043 |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1892 fDrawBuffer->addGpuTraceMarker(marker); | 1902 fDrawBuffer->addGpuTraceMarker(marker); |
1893 } | 1903 } |
1894 } | 1904 } |
1895 | 1905 |
1896 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | 1906 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
1897 fGpu->removeGpuTraceMarker(marker); | 1907 fGpu->removeGpuTraceMarker(marker); |
1898 if (fDrawBuffer) { | 1908 if (fDrawBuffer) { |
1899 fDrawBuffer->removeGpuTraceMarker(marker); | 1909 fDrawBuffer->removeGpuTraceMarker(marker); |
1900 } | 1910 } |
1901 } | 1911 } |
OLD | NEW |