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

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

Issue 2127673002: Consolidate handling of infinitely thin primitives and aa bloat handing WRT batch bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@AAStrokeRect
Patch Set: update for instanced rendering 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
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return nullptr; 65 return nullptr;
66 } 66 }
67 NonAAStrokeRectBatch* batch = new NonAAStrokeRectBatch(); 67 NonAAStrokeRectBatch* batch = new NonAAStrokeRectBatch();
68 batch->fColor = color; 68 batch->fColor = color;
69 batch->fViewMatrix = viewMatrix; 69 batch->fViewMatrix = viewMatrix;
70 batch->fRect = rect; 70 batch->fRect = rect;
71 // Sort the rect for hairlines 71 // Sort the rect for hairlines
72 batch->fRect.sort(); 72 batch->fRect.sort();
73 batch->fStrokeWidth = stroke.getWidth(); 73 batch->fStrokeWidth = stroke.getWidth();
74 74
75 batch->fBounds = batch->fRect;
76 SkScalar rad = SkScalarHalf(batch->fStrokeWidth); 75 SkScalar rad = SkScalarHalf(batch->fStrokeWidth);
77 batch->fBounds.outset(rad, rad); 76 SkRect bounds = rect;
78 batch->fViewMatrix.mapRect(&batch->fBounds); 77 bounds.outset(rad, rad);
79 78
80 // If our caller snaps to pixel centers then we have to round out the bo unds 79 // If our caller snaps to pixel centers then we have to round out the bo unds
81 if (snapToPixelCenters) { 80 if (snapToPixelCenters) {
81 viewMatrix.mapRect(&bounds);
82 // We want to be consistent with how we snap non-aa lines. To match what we do in 82 // We want to be consistent with how we snap non-aa lines. To match what we do in
83 // GrGLSLVertexShaderBuilder, we first floor all the vertex values a nd then add half a 83 // GrGLSLVertexShaderBuilder, we first floor all the vertex values a nd then add half a
84 // pixel to force us to pixel centers. 84 // pixel to force us to pixel centers.
85 batch->fBounds.set(SkScalarFloorToScalar(batch->fBounds.fLeft), 85 bounds.set(SkScalarFloorToScalar(bounds.fLeft),
86 SkScalarFloorToScalar(batch->fBounds.fTop), 86 SkScalarFloorToScalar(bounds.fTop),
87 SkScalarFloorToScalar(batch->fBounds.fRight), 87 SkScalarFloorToScalar(bounds.fRight),
88 SkScalarFloorToScalar(batch->fBounds.fBottom)); 88 SkScalarFloorToScalar(bounds.fBottom));
89 batch->fBounds.offset(0.5f, 0.5f); 89 bounds.offset(0.5f, 0.5f);
90 90 batch->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
91 // Round out the bounds to integer values 91 } else {
92 batch->fBounds.roundOut(); 92 batch->setTransformedBounds(bounds, batch->fViewMatrix, HasAABloat : :kNo,
93 IsZeroArea::kNo);
93 } 94 }
94 return batch; 95 return batch;
95 } 96 }
96 97
97 private: 98 private:
98 NonAAStrokeRectBatch() : INHERITED(ClassID()) {} 99 NonAAStrokeRectBatch() : INHERITED(ClassID()) {}
99 100
100 void onPrepareDraws(Target* target) const override { 101 void onPrepareDraws(Target* target) const override {
101 sk_sp<GrGeometryProcessor> gp; 102 sk_sp<GrGeometryProcessor> gp;
102 { 103 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 SkScalar strokeWidth = random->nextBool() ? 0.0f : 2.0f; 197 SkScalar strokeWidth = random->nextBool() ? 0.0f : 2.0f;
197 SkPaint paint; 198 SkPaint paint;
198 paint.setStrokeWidth(strokeWidth); 199 paint.setStrokeWidth(strokeWidth);
199 paint.setStyle(SkPaint::kStroke_Style); 200 paint.setStyle(SkPaint::kStroke_Style);
200 paint.setStrokeJoin(SkPaint::kMiter_Join); 201 paint.setStrokeJoin(SkPaint::kMiter_Join);
201 SkStrokeRec strokeRec(paint); 202 SkStrokeRec strokeRec(paint);
202 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeRec, ra ndom->nextBool()); 203 return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeRec, ra ndom->nextBool());
203 } 204 }
204 205
205 #endif 206 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp ('k') | src/gpu/batches/GrPLSPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698