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

Unified Diff: src/utils/SkPatchUtils.cpp

Issue 1842753002: Style bikeshed - remove extraneous whitespace (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/SkPatchUtils.h ('k') | src/utils/SkTextBox.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkPatchUtils.cpp
diff --git a/src/utils/SkPatchUtils.cpp b/src/utils/SkPatchUtils.cpp
index 9d095ae5cfdaff33c9a483e120e1fc3ae4486219..cbaae39e8e9d851755c519ccd3843e1556b6a8c2 100644
--- a/src/utils/SkPatchUtils.cpp
+++ b/src/utils/SkPatchUtils.cpp
@@ -28,20 +28,20 @@
*/
class FwDCubicEvaluator {
-
+
public:
-
+
/**
* Receives the 4 control points of the cubic bezier.
*/
-
+
explicit FwDCubicEvaluator(const SkPoint points[4])
: fCoefs(points) {
memcpy(fPoints, points, 4 * sizeof(SkPoint));
-
+
this->restart(1);
}
-
+
/**
* Restarts the forward differences evaluator to the first value of t = 0.
*/
@@ -58,14 +58,14 @@ public:
fFwDiff[1] = to_point(fCoefs.fA * h3 + fCoefs.fB * h2 + fCoefs.fC * h);
fFwDiff[0] = to_point(fCoefs.fD);
}
-
+
/**
* Check if the evaluator is still within the range of 0<=t<=1
*/
bool done() const {
return fCurrent > fMax;
}
-
+
/**
* Call next to obtain the SkPoint sampled and move to the next one.
*/
@@ -77,11 +77,11 @@ public:
fCurrent++;
return point;
}
-
+
const SkPoint* getCtrlPoints() const {
return fPoints;
}
-
+
private:
SkCubicCoeff fCoefs;
int fMax, fCurrent, fDivisions;
@@ -115,29 +115,29 @@ static SkScalar bilerp(SkScalar tx, SkScalar ty, SkScalar c00, SkScalar c10, SkS
}
SkISize SkPatchUtils::GetLevelOfDetail(const SkPoint cubics[12], const SkMatrix* matrix) {
-
+
// Approximate length of each cubic.
SkPoint pts[kNumPtsCubic];
SkPatchUtils::getTopCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar topLength = approx_arc_length(pts, kNumPtsCubic);
-
+
SkPatchUtils::getBottomCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar bottomLength = approx_arc_length(pts, kNumPtsCubic);
-
+
SkPatchUtils::getLeftCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar leftLength = approx_arc_length(pts, kNumPtsCubic);
-
+
SkPatchUtils::getRightCubic(cubics, pts);
matrix->mapPoints(pts, kNumPtsCubic);
SkScalar rightLength = approx_arc_length(pts, kNumPtsCubic);
-
+
// Level of detail per axis, based on the larger side between top and bottom or left and right
int lodX = static_cast<int>(SkMaxScalar(topLength, bottomLength) / kPartitionSize);
int lodY = static_cast<int>(SkMaxScalar(leftLength, rightLength) / kPartitionSize);
-
+
return SkISize::Make(SkMax32(8, lodX), SkMax32(8, lodY));
}
@@ -210,12 +210,12 @@ bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
}
data->fColors = new uint32_t[data->fVertexCount];
}
-
+
// if texture coordinates are not null then create array for them
if (texCoords) {
data->fTexCoords = new SkPoint[data->fVertexCount];
}
-
+
SkPoint pts[kNumPtsCubic];
SkPatchUtils::getBottomCubic(cubics, pts);
FwDCubicEvaluator fBottom(pts);
@@ -225,10 +225,10 @@ bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
FwDCubicEvaluator fLeft(pts);
SkPatchUtils::getRightCubic(cubics, pts);
FwDCubicEvaluator fRight(pts);
-
+
fBottom.restart(lodX);
fTop.restart(lodX);
-
+
SkScalar u = 0.0f;
int stride = lodY + 1;
for (int x = 0; x <= lodX; x++) {
@@ -238,9 +238,9 @@ bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
SkScalar v = 0.f;
for (int y = 0; y <= lodY; y++) {
int dataIndex = x * (lodY + 1) + y;
-
+
SkPoint left = fLeft.next(), right = fRight.next();
-
+
SkPoint s0 = SkPoint::Make((1.0f - v) * top.x() + v * bottom.x(),
(1.0f - v) * top.y() + v * bottom.y());
SkPoint s1 = SkPoint::Make((1.0f - u) * left.x() + u * right.x(),
@@ -255,7 +255,7 @@ bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
+ v * ((1.0f - u) * fBottom.getCtrlPoints()[0].y()
+ u * fBottom.getCtrlPoints()[3].y()));
data->fPoints[dataIndex] = s0 + s1 - s2;
-
+
if (colors) {
uint8_t a = uint8_t(bilerp(u, v,
SkScalar(SkColorGetA(colorsPM[kTopLeft_Corner])),
@@ -279,7 +279,7 @@ bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
SkScalar(SkColorGetB(colorsPM[kBottomRight_Corner]))));
data->fColors[dataIndex] = SkPackARGB32(a,r,g,b);
}
-
+
if (texCoords) {
data->fTexCoords[dataIndex] = SkPoint::Make(
bilerp(u, v, texCoords[kTopLeft_Corner].x(),
@@ -290,9 +290,9 @@ bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
texCoords[kTopRight_Corner].y(),
texCoords[kBottomLeft_Corner].y(),
texCoords[kBottomRight_Corner].y()));
-
+
}
-
+
if(x < lodX && y < lodY) {
int i = 6 * (x * lodY + y);
data->fIndices[i] = x * stride + y;
« no previous file with comments | « src/utils/SkPatchUtils.h ('k') | src/utils/SkTextBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698