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

Side by Side Diff: src/gpu/batches/GrNonAAStrokeRectBatch.cpp

Issue 2126913002: Fix bounds computation for non-aa hairlines when snapping to pixel centers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix int scalar warning Created 4 years, 5 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 | « no previous file | 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrNonAAStrokeRectBatch.h" 8 #include "GrNonAAStrokeRectBatch.h"
9 9
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 private: 94 private:
95 void setupBounds(SkRect* bounds, const Geometry& geo, bool snapToPixelCenter s) { 95 void setupBounds(SkRect* bounds, const Geometry& geo, bool snapToPixelCenter s) {
96 *bounds = geo.fRect; 96 *bounds = geo.fRect;
97 SkScalar rad = SkScalarHalf(geo.fStrokeWidth); 97 SkScalar rad = SkScalarHalf(geo.fStrokeWidth);
98 bounds->outset(rad, rad); 98 bounds->outset(rad, rad);
99 geo.fViewMatrix.mapRect(&fBounds); 99 geo.fViewMatrix.mapRect(&fBounds);
100 100
101 // If our caller snaps to pixel centers then we have to round out the bo unds 101 // If our caller snaps to pixel centers then we have to round out the bo unds
102 if (snapToPixelCenters) { 102 if (snapToPixelCenters) {
103 // We want to be consistent with how we snap non-aa lines. To match what we do in
104 // GrGLSLVertexShaderBuilder, we first floor all the vertex values a nd then add half a
105 // pixel to force us to pixel centers.
106 bounds->set(SkScalarFloorToScalar(bounds->fLeft),
107 SkScalarFloorToScalar(bounds->fTop),
108 SkScalarFloorToScalar(bounds->fRight),
109 SkScalarFloorToScalar(bounds->fBottom));
110 bounds->offset(0.5f, 0.5f);
111
112 // Round out the bounds to integer values
103 bounds->roundOut(); 113 bounds->roundOut();
bsalomon 2016/07/07 14:19:06 Do we need this round out? If the rect is rendered
104 } 114 }
105 } 115 }
106 116
107 void onPrepareDraws(Target* target) const override { 117 void onPrepareDraws(Target* target) const override {
108 sk_sp<GrGeometryProcessor> gp; 118 sk_sp<GrGeometryProcessor> gp;
109 { 119 {
110 using namespace GrDefaultGeoProcFactory; 120 using namespace GrDefaultGeoProcFactory;
111 Color color(this->color()); 121 Color color(this->color());
112 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type : 122 Coverage coverage(this->coverageIgnored() ? Coverage::kSolid_Type :
113 Coverage::kNone_Type); 123 Coverage::kNone_Type);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) { 251 DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) {
242 SkMatrix viewMatrix = GrTest::TestMatrix(random); 252 SkMatrix viewMatrix = GrTest::TestMatrix(random);
243 GrColor color = GrRandomColor(random); 253 GrColor color = GrRandomColor(random);
244 SkRect rect = GrTest::TestRect(random); 254 SkRect rect = GrTest::TestRect(random);
245 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f; 255 SkScalar strokeWidth = random->nextBool() ? 0.0f : 1.0f;
246 256
247 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool()); 257 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeWidth, random->nextBool());
248 } 258 }
249 259
250 #endif 260 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698