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

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

Issue 1310533004: Standardize BW to NonAA (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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/batches/GrRectBatchFactory.h ('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 * 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 "GrRectBatchFactory.h" 8 #include "GrRectBatchFactory.h"
9 9
10 #include "GrAAStrokeRectBatch.h" 10 #include "GrAAStrokeRectBatch.h"
(...skipping 12 matching lines...) Expand all
23 geometry.fDevOutside = devOutside; 23 geometry.fDevOutside = devOutside;
24 geometry.fDevOutsideAssist = devOutsideAssist; 24 geometry.fDevOutsideAssist = devOutsideAssist;
25 geometry.fDevInside = devInside; 25 geometry.fDevInside = devInside;
26 geometry.fMiterStroke = miterStroke; 26 geometry.fMiterStroke = miterStroke;
27 27
28 return GrAAStrokeRectBatch::Create(geometry, viewMatrix); 28 return GrAAStrokeRectBatch::Create(geometry, viewMatrix);
29 } 29 }
30 30
31 namespace GrRectBatchFactory { 31 namespace GrRectBatchFactory {
32 32
33 GrDrawBatch* CreateStrokeBW(GrColor color, 33 GrDrawBatch* CreateNonAAStroke(GrColor color,
34 const SkMatrix& viewMatrix, 34 const SkMatrix& viewMatrix,
35 const SkRect& rect, 35 const SkRect& rect,
36 SkScalar strokeWidth, 36 SkScalar strokeWidth,
37 bool snapToPixelCenters) { 37 bool snapToPixelCenters) {
38 GrStrokeRectBatch::Geometry geometry; 38 GrStrokeRectBatch::Geometry geometry;
39 geometry.fColor = color; 39 geometry.fColor = color;
40 geometry.fViewMatrix = viewMatrix; 40 geometry.fViewMatrix = viewMatrix;
41 geometry.fRect = rect; 41 geometry.fRect = rect;
42 geometry.fStrokeWidth = strokeWidth; 42 geometry.fStrokeWidth = strokeWidth;
43 return GrStrokeRectBatch::Create(geometry, snapToPixelCenters); 43 return GrStrokeRectBatch::Create(geometry, snapToPixelCenters);
44 } 44 }
45 45
46 GrDrawBatch* CreateStrokeAA(GrColor color, 46 GrDrawBatch* CreateAAStroke(GrColor color,
47 const SkMatrix& viewMatrix, 47 const SkMatrix& viewMatrix,
48 const SkRect& rect, 48 const SkRect& rect,
49 const SkRect& devRect, 49 const SkRect& devRect,
50 const SkStrokeRec& stroke) { 50 const SkStrokeRec& stroke) {
51 SkVector devStrokeSize; 51 SkVector devStrokeSize;
52 SkScalar width = stroke.getWidth(); 52 SkScalar width = stroke.getWidth();
53 if (width > 0) { 53 if (width > 0) {
54 devStrokeSize.set(width, width); 54 devStrokeSize.set(width, width);
55 viewMatrix.mapVectors(&devStrokeSize, 1); 55 viewMatrix.mapVectors(&devStrokeSize, 1);
56 devStrokeSize.setAbs(devStrokeSize); 56 devStrokeSize.setAbs(devStrokeSize);
(...skipping 18 matching lines...) Expand all
75 75
76 bool miterStroke = true; 76 bool miterStroke = true;
77 // For hairlines, make bevel and round joins appear the same as mitered ones . 77 // For hairlines, make bevel and round joins appear the same as mitered ones .
78 // small miter limit means right angles show bevel... 78 // small miter limit means right angles show bevel...
79 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join || 79 if ((width > 0) && (stroke.getJoin() != SkPaint::kMiter_Join ||
80 stroke.getMiter() < SK_ScalarSqrt2)) { 80 stroke.getMiter() < SK_ScalarSqrt2)) {
81 miterStroke = false; 81 miterStroke = false;
82 } 82 }
83 83
84 if (spare <= 0 && miterStroke) { 84 if (spare <= 0 && miterStroke) {
85 return CreateFillAA(color, viewMatrix, devOutside, devOutside); 85 return CreateAAFill(color, viewMatrix, devOutside, devOutside);
86 } 86 }
87 87
88 SkRect devInside(devRect); 88 SkRect devInside(devRect);
89 devInside.inset(rx, ry); 89 devInside.inset(rx, ry);
90 90
91 SkRect devOutsideAssist(devRect); 91 SkRect devOutsideAssist(devRect);
92 92
93 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist) 93 // For bevel-stroke, use 2 SkRect instances(devOutside and devOutsideAssist)
94 // to draw the outer of the rect. Because there are 8 vertices on the outer 94 // to draw the outer of the rect. Because there are 8 vertices on the outer
95 // edge, while vertex number of inner edge is 4, the same as miter-stroke. 95 // edge, while vertex number of inner edge is 4, the same as miter-stroke.
96 if (!miterStroke) { 96 if (!miterStroke) {
97 devOutside.inset(0, ry); 97 devOutside.inset(0, ry);
98 devOutsideAssist.outset(0, ry); 98 devOutsideAssist.outset(0, ry);
99 } 99 }
100 100
101 return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutsideAssis t, devInside, 101 return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutsideAssis t, devInside,
102 miterStroke); 102 miterStroke);
103 } 103 }
104 104
105 GrDrawBatch* CreateFillNestedRectsAA(GrColor color, 105 GrDrawBatch* CreateAAFillNestedRects(GrColor color,
106 const SkMatrix& viewMatrix, 106 const SkMatrix& viewMatrix,
107 const SkRect rects[2]) { 107 const SkRect rects[2]) {
108 SkASSERT(viewMatrix.rectStaysRect()); 108 SkASSERT(viewMatrix.rectStaysRect());
109 SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty()); 109 SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
110 110
111 SkRect devOutside, devInside; 111 SkRect devOutside, devInside;
112 viewMatrix.mapRect(&devOutside, rects[0]); 112 viewMatrix.mapRect(&devOutside, rects[0]);
113 viewMatrix.mapRect(&devInside, rects[1]); 113 viewMatrix.mapRect(&devInside, rects[1]);
114 114
115 if (devInside.isEmpty()) { 115 if (devInside.isEmpty()) {
116 return CreateFillAA(color, viewMatrix, devOutside, devOutside); 116 return CreateAAFill(color, viewMatrix, devOutside, devOutside);
117 } 117 }
118 118
119 return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutside, dev Inside, true); 119 return create_stroke_aa_batch(color, viewMatrix, devOutside, devOutside, dev Inside, true);
120 } 120 }
121 121
122 }; 122 };
OLDNEW
« no previous file with comments | « src/gpu/batches/GrRectBatchFactory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698