Result of running tools/sanitize_source_files.py (which was added in https://codereview.appspot.com/6465078/)
This CL is part III of IV (I broke down the 1280 files into 4 CLs).
Review URL: https://codereview.appspot.com/6475053
git-svn-id: http://skia.googlecode.com/svn/trunk@5264 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleWarp.cpp b/samplecode/SampleWarp.cpp
index b421c60..323df80 100644
--- a/samplecode/SampleWarp.cpp
+++ b/samplecode/SampleWarp.cpp
@@ -62,30 +62,30 @@
canvas->drawBitmap(mask, 0, 0, &paint);
paint.setMaskFilter(NULL);
canvas->drawBitmap(orig, -offset.fX, -offset.fY, &paint);
-
+
canvas->translate(120, 0);
-
+
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(orig, -offset.fX, -offset.fY, &paint);
-
+
canvas->translate(120, 0);
-
+
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(orig, -offset.fX, -offset.fY, &paint);
-
+
canvas->translate(120, 0);
-
+
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(orig, -offset.fX, -offset.fY, &paint);
-
+
canvas->translate(120, 0);
-
+
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
canvas->drawBitmap(mask, 0, 0, &paint);
@@ -116,13 +116,13 @@
pts[0].set(x0, y0);
pts[3].set(x3, y3);
-
+
tmp = SkPointInterp(pts[0], pts[3], SK_Scalar1/3);
tmp2 = pts[0] - tmp;
tmp2.rotateCW();
tmp2.scale(scale);
pts[1] = tmp + tmp2;
-
+
tmp = SkPointInterp(pts[0], pts[3], 2*SK_Scalar1/3);
tmp2 = pts[3] - tmp;
tmp2.rotateCW();
@@ -131,40 +131,40 @@
}
static void test_patch(SkCanvas* canvas, const SkBitmap& bm, SkScalar scale) {
- SkCubicBoundary cubic;
+ SkCubicBoundary cubic;
set_cubic(cubic.fPts + 0, 0, 0, 100, 0, scale);
set_cubic(cubic.fPts + 3, 100, 0, 100, 100, scale);
set_cubic(cubic.fPts + 6, 100, 100, 0, 100, -scale);
set_cubic(cubic.fPts + 9, 0, 100, 0, 0, 0);
-
+
SkBoundaryPatch patch;
patch.setBoundary(&cubic);
-
+
const int Rows = 16;
const int Cols = 16;
SkPoint pts[Rows * Cols];
patch.evalPatch(pts, Rows, Cols);
-
+
SkPaint paint;
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setStrokeWidth(1);
paint.setStrokeCap(SkPaint::kRound_Cap);
-
+
canvas->translate(50, 50);
canvas->scale(3, 3);
-
+
SkMeshUtils::Draw(canvas, bm, Rows, Cols, pts, NULL, paint);
}
static void test_drag(SkCanvas* canvas, const SkBitmap& bm,
const SkPoint& p0, const SkPoint& p1) {
- SkCubicBoundary cubic;
+ SkCubicBoundary cubic;
set_cubic(cubic.fPts + 0, 0, 0, 100, 0, 0);
set_cubic(cubic.fPts + 3, 100, 0, 100, 100, 0);
set_cubic(cubic.fPts + 6, 100, 100, 0, 100, 0);
set_cubic(cubic.fPts + 9, 0, 100, 0, 0, 0);
-
+
#if 0
cubic.fPts[1] += p1 - p0;
cubic.fPts[2] += p1 - p0;
@@ -182,21 +182,21 @@
SkBoundaryPatch patch;
patch.setBoundary(&cubic);
-
+
const int Rows = 16;
const int Cols = 16;
SkPoint pts[Rows * Cols];
patch.evalPatch(pts, Rows, Cols);
-
+
SkPaint paint;
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setStrokeWidth(1);
paint.setStrokeCap(SkPaint::kRound_Cap);
-
+
canvas->translate(50, 50);
canvas->scale(3, 3);
-
+
SkAutoCanvasRestore acr(canvas, true);
SkRect r = { 0, 0, 100, 100 };
@@ -256,7 +256,7 @@
fPts = new SkPoint[fCount * 2];
fTex = fPts + fCount;
memcpy(fPts, src.fPts, fCount * 2 * sizeof(SkPoint));
-
+
delete[] fIndices;
fIndexCount = src.fIndexCount;
fIndices = new uint16_t[fIndexCount];
@@ -281,7 +281,7 @@
delete[] fIndices;
fIndexCount = rows * cols * 6;
fIndices = new uint16_t[fIndexCount];
-
+
SkPoint* pts = fPts;
const SkScalar dx = bounds.width() / rows;
const SkScalar dy = bounds.height() / cols;
@@ -296,7 +296,7 @@
pts += 1;
tex->set(texture.fLeft + x*dtx, texture.fTop + y*dty);
tex += 1;
-
+
if (y < cols && x < rows) {
*idx++ = index;
*idx++ = index + rows + 1;
@@ -305,7 +305,7 @@
*idx++ = index + 1;
*idx++ = index + rows + 1;
*idx++ = index + rows + 2;
-
+
index += 1;
}
}
@@ -332,22 +332,22 @@
SkBitmap fBitmap;
SkMatrix fMatrix, fInverse;
public:
- WarpView() {
+ WarpView() {
SkBitmap bm;
// SkImageDecoder::DecodeFile("/skimages/marker.png", &bm);
SkImageDecoder::DecodeFile("/skimages/logo.gif", &bm);
// SkImageDecoder::DecodeFile("/beach_shot.JPG", &bm);
fBitmap = bm;
-
+
SkRect bounds, texture;
texture.set(0, 0, SkIntToScalar(fBitmap.width()),
SkIntToScalar(fBitmap.height()));
bounds = texture;
-
+
// fMesh.init(bounds, fBitmap.width() / 40, fBitmap.height() / 40, texture);
fMesh.init(bounds, fBitmap.width()/16, fBitmap.height()/16, texture);
fOrig = fMesh;
-
+
fP0.set(0, 0);
fP1 = fP0;
@@ -364,7 +364,7 @@
}
return this->INHERITED::onQuery(evt);
}
-
+
static SkPoint apply_warp(const SkVector& drag, SkScalar dragLength,
const SkPoint& dragStart, const SkPoint& dragCurr,
const SkPoint& orig) {
@@ -373,10 +373,10 @@
if (length <= kNearlyZero) {
return orig;
}
-
+
const SkScalar period = 20;
const SkScalar mag = dragLength / 3;
-
+
SkScalar d = length / (period);
d = mag * SkScalarSin(d) / d;
SkScalar dx = delta.fX * d;
@@ -385,7 +385,7 @@
SkScalar py = orig.fY + dy;
return SkPoint::Make(px, py);
}
-
+
static SkPoint apply_warp2(const SkVector& drag, SkScalar dragLength,
const SkPoint& dragStart, const SkPoint& dragCurr,
const SkPoint& orig) {
@@ -394,24 +394,24 @@
if (length <= kNearlyZero) {
return orig;
}
-
+
const SkScalar period = 10 + dragLength/4;
const SkScalar mag = dragLength / 3;
-
+
SkScalar d = length / (period);
if (d > SK_ScalarPI) {
d = SK_ScalarPI;
}
d = -mag * SkScalarSin(d);
-
+
SkScalar dx = delta.fX * d;
SkScalar dy = delta.fY * d;
SkScalar px = orig.fX + dx;
SkScalar py = orig.fY + dy;
return SkPoint::Make(px, py);
}
-
+
typedef SkPoint (*WarpProc)(const SkVector& drag, SkScalar dragLength,
const SkPoint& dragStart, const SkPoint& dragCurr,
const SkPoint& orig);
@@ -428,11 +428,11 @@
fP0 = p0;
fP1 = p1;
}
-
+
virtual void onDraw(SkCanvas* canvas) {
canvas->drawColor(SK_ColorLTGRAY);
// test_bigblur(canvas); return;
-
+
canvas->concat(fMatrix);
SkPaint paint;
@@ -441,18 +441,18 @@
SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode))->unref();
fMesh.draw(canvas, paint); //return;
-
+
paint.setShader(NULL);
paint.setColor(SK_ColorRED);
fMesh.draw(canvas, paint);
// test_drag(canvas, fBitmap, fP0, fP1);
}
-
+
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
return new Click(this);
}
-
+
virtual bool onClick(Click* click) {
SkPoint pts[2] = { click->fOrig, click->fCurr };
fInverse.mapPoints(pts, 2);
@@ -460,7 +460,7 @@
this->inval(NULL);
return true;
}
-
+
private:
SkIRect fBase, fRect;
SkPoint fP0, fP1;