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

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

Issue 1123253003: fix bounds for BW lines, AA Hairlines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more 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/GrAAHairLinePathRenderer.cpp ('k') | no next file » | 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 14:42:02 For this case, BW hairline rect draw, I believe we
bsalomon 2015/05/07 14:47:45 Correct. This is an unfortunate case of coupling w
526 // This is conservative but, b.c. the hardware can employ somewhat arbit rary
527 // snapping rules to BW lines, it is the best we can do.
528 if (fBatch.fHairline) {
529 fBounds.outset(0.5f, 0.5f);
530 }
525 } 531 }
526 532
527 /* create a triangle strip that strokes the specified rect. There are 8 533 /* 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 534 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 535 could use an indices array, and then only send 8 verts, but not sure that
530 would be faster. 536 would be faster.
531 */ 537 */
532 void setStrokeRectStrip(SkPoint verts[10], const SkRect& rect, SkScalar widt h) { 538 void setStrokeRectStrip(SkPoint verts[10], const SkRect& rect, SkScalar widt h) {
533 const SkScalar rad = SkScalarHalf(width); 539 const SkScalar rad = SkScalarHalf(width);
534 // TODO we should be able to enable this assert, but we'd have to filter these draws 540 // 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
1014 1020
1015 // TODO clients should give us bounds 1021 // TODO clients should give us bounds
1016 SkRect bounds; 1022 SkRect bounds;
1017 if (!bounds.setBoundsCheck(positions, vertexCount)) { 1023 if (!bounds.setBoundsCheck(positions, vertexCount)) {
1018 SkDebugf("drawVertices call empty bounds\n"); 1024 SkDebugf("drawVertices call empty bounds\n");
1019 return; 1025 return;
1020 } 1026 }
1021 1027
1022 viewMatrix.mapRect(&bounds); 1028 viewMatrix.mapRect(&bounds);
1023 1029
1030 // If we don't have AA then we outset for a half pixel in each direction to account for
1031 // snapping
1032 if (!paint.isAntiAlias()) {
1033 bounds.outset(0.5f, 0.5f);
1034 }
1035
1024 DrawVerticesBatch::Geometry geometry; 1036 DrawVerticesBatch::Geometry geometry;
1025 geometry.fColor = paint.getColor(); 1037 geometry.fColor = paint.getColor();
1026 SkAutoTUnref<GrBatch> batch(DrawVerticesBatch::Create(geometry, primitiveTyp e, viewMatrix, 1038 SkAutoTUnref<GrBatch> batch(DrawVerticesBatch::Create(geometry, primitiveTyp e, viewMatrix,
1027 positions, vertexCount , indices, 1039 positions, vertexCount , indices,
1028 indexCount, colors, te xCoords, 1040 indexCount, colors, te xCoords,
1029 bounds)); 1041 bounds));
1030 1042
1031 target->drawBatch(&pipelineBuilder, batch); 1043 target->drawBatch(&pipelineBuilder, batch);
1032 } 1044 }
1033 1045
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 fDrawBuffer->addGpuTraceMarker(marker); 1904 fDrawBuffer->addGpuTraceMarker(marker);
1893 } 1905 }
1894 } 1906 }
1895 1907
1896 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { 1908 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
1897 fGpu->removeGpuTraceMarker(marker); 1909 fGpu->removeGpuTraceMarker(marker);
1898 if (fDrawBuffer) { 1910 if (fDrawBuffer) {
1899 fDrawBuffer->removeGpuTraceMarker(marker); 1911 fDrawBuffer->removeGpuTraceMarker(marker);
1900 } 1912 }
1901 } 1913 }
OLDNEW
« no previous file with comments | « src/gpu/GrAAHairLinePathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698