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

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

Issue 1135693003: Revert of Revert of stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrPathUtils.cpp » ('j') | 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 2013 Google Inc. 2 * Copyright 2013 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 "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 1246
1247 for (int i = 0; i < instanceCount; i++) { 1247 for (int i = 0; i < instanceCount; i++) {
1248 Geometry& geom = fGeoData[i]; 1248 Geometry& geom = fGeoData[i];
1249 1249
1250 SkScalar xRadius = geom.fXRadius; 1250 SkScalar xRadius = geom.fXRadius;
1251 SkScalar yRadius = geom.fYRadius; 1251 SkScalar yRadius = geom.fYRadius;
1252 1252
1253 const SkRect& bounds = geom.fBounds; 1253 const SkRect& bounds = geom.fBounds;
1254 1254
1255 // This adjusts the "radius" to include the half-pixel border 1255 // This adjusts the "radius" to include the half-pixel border
1256 SkScalar offsetDx = SkScalarDiv(geom.fGeoDx, xRadius); 1256 SkScalar offsetDx = geom.fGeoDx / xRadius;
1257 SkScalar offsetDy = SkScalarDiv(geom.fGeoDy, yRadius); 1257 SkScalar offsetDy = geom.fGeoDy / yRadius;
1258 1258
1259 SkScalar innerRatioX = SkScalarDiv(xRadius, geom.fInnerXRadius); 1259 SkScalar innerRatioX = xRadius / geom.fInnerXRadius;
1260 SkScalar innerRatioY = SkScalarDiv(yRadius, geom.fInnerYRadius); 1260 SkScalar innerRatioY = yRadius / geom.fInnerYRadius;
1261 1261
1262 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop); 1262 verts[0].fPos = SkPoint::Make(bounds.fLeft, bounds.fTop);
1263 verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offs etDy); 1263 verts[0].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, -1.0f - offs etDy);
1264 verts[0].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, -inne rRatioY - offsetDy); 1264 verts[0].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, -inne rRatioY - offsetDy);
1265 1265
1266 verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom); 1266 verts[1].fPos = SkPoint::Make(bounds.fLeft, bounds.fBottom);
1267 verts[1].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, 1.0f + offse tDy); 1267 verts[1].fOuterOffset = SkPoint::Make(-1.0f - offsetDx, 1.0f + offse tDy);
1268 verts[1].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, inner RatioY + offsetDy); 1268 verts[1].fInnerOffset = SkPoint::Make(-innerRatioX - offsetDx, inner RatioY + offsetDy);
1269 1269
1270 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 1270 verts[2].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 if (DIEllipseEdgeEffect::kStroke == mode) { 1379 if (DIEllipseEdgeEffect::kStroke == mode) {
1380 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke : 1380 mode = (innerXRadius > 0 && innerYRadius > 0) ? DIEllipseEdgeEffect::kSt roke :
1381 DIEllipseEdgeEffect::kFi ll; 1381 DIEllipseEdgeEffect::kFi ll;
1382 } 1382 }
1383 1383
1384 // This expands the outer rect so that after CTM we end up with a half-pixel border 1384 // This expands the outer rect so that after CTM we end up with a half-pixel border
1385 SkScalar a = viewMatrix[SkMatrix::kMScaleX]; 1385 SkScalar a = viewMatrix[SkMatrix::kMScaleX];
1386 SkScalar b = viewMatrix[SkMatrix::kMSkewX]; 1386 SkScalar b = viewMatrix[SkMatrix::kMSkewX];
1387 SkScalar c = viewMatrix[SkMatrix::kMSkewY]; 1387 SkScalar c = viewMatrix[SkMatrix::kMSkewY];
1388 SkScalar d = viewMatrix[SkMatrix::kMScaleY]; 1388 SkScalar d = viewMatrix[SkMatrix::kMScaleY];
1389 SkScalar geoDx = SkScalarDiv(SK_ScalarHalf, SkScalarSqrt(a*a + c*c)); 1389 SkScalar geoDx = SK_ScalarHalf / SkScalarSqrt(a*a + c*c);
1390 SkScalar geoDy = SkScalarDiv(SK_ScalarHalf, SkScalarSqrt(b*b + d*d)); 1390 SkScalar geoDy = SK_ScalarHalf / SkScalarSqrt(b*b + d*d);
1391 1391
1392 DIEllipseBatch::Geometry geometry; 1392 DIEllipseBatch::Geometry geometry;
1393 geometry.fViewMatrix = viewMatrix; 1393 geometry.fViewMatrix = viewMatrix;
1394 geometry.fColor = color; 1394 geometry.fColor = color;
1395 geometry.fXRadius = xRadius; 1395 geometry.fXRadius = xRadius;
1396 geometry.fYRadius = yRadius; 1396 geometry.fYRadius = yRadius;
1397 geometry.fInnerXRadius = innerXRadius; 1397 geometry.fInnerXRadius = innerXRadius;
1398 geometry.fInnerYRadius = innerYRadius; 1398 geometry.fInnerYRadius = innerYRadius;
1399 geometry.fGeoDx = geoDx; 1399 geometry.fGeoDx = geoDx;
1400 geometry.fGeoDy = geoDy; 1400 geometry.fGeoDy = geoDy;
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 } 2118 }
2119 2119
2120 BATCH_TEST_DEFINE(RRectBatch) { 2120 BATCH_TEST_DEFINE(RRectBatch) {
2121 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); 2121 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random);
2122 GrColor color = GrRandomColor(random); 2122 GrColor color = GrRandomColor(random);
2123 const SkRRect& rrect = GrTest::TestRRectSimple(random); 2123 const SkRRect& rrect = GrTest::TestRRectSimple(random);
2124 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); 2124 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom));
2125 } 2125 }
2126 2126
2127 #endif 2127 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrPathUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698