diff options
author | 2017-03-19 16:26:20 -0400 | |
---|---|---|
committer | 2017-03-20 12:40:31 +0000 | |
commit | 5e21e0991968271ee37f446de7e08620ad1b50bb (patch) | |
tree | ed772b1d27bf1a1fa13fa04da944ebc7924e61e8 /src/utils | |
parent | 2f6b5a47a50cdd218bc3302273be3a4a71add8fb (diff) |
remove unused SkMeshUtils and SkBoundaryPatch
BUG=skia:6366
Change-Id: Ibacd397e0a246dbeefde074c98712ada3848a7b6
Reviewed-on: https://skia-review.googlesource.com/9852
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/SkBoundaryPatch.cpp | 78 | ||||
-rw-r--r-- | src/utils/SkMeshUtils.cpp | 101 |
2 files changed, 0 insertions, 179 deletions
diff --git a/src/utils/SkBoundaryPatch.cpp b/src/utils/SkBoundaryPatch.cpp deleted file mode 100644 index 0cfb09c2c7..0000000000 --- a/src/utils/SkBoundaryPatch.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "SkBoundaryPatch.h" - -SkBoundaryPatch::SkBoundaryPatch() : fBoundary(nullptr) {} - -SkBoundaryPatch::~SkBoundaryPatch() { - SkSafeUnref(fBoundary); -} - -SkBoundary* SkBoundaryPatch::setBoundary(SkBoundary* b) { - SkRefCnt_SafeAssign(fBoundary, b); - return b; -} - -static SkPoint SkMakePoint(SkScalar x, SkScalar y) { - SkPoint pt; - pt.set(x, y); - return pt; -} - -static SkPoint SkPointInterp(const SkPoint& a, const SkPoint& b, SkScalar t) { - return SkMakePoint(SkScalarInterp(a.fX, b.fX, t), - SkScalarInterp(a.fY, b.fY, t)); -} - -SkPoint SkBoundaryPatch::eval(SkScalar unitU, SkScalar unitV) { - SkBoundary* b = fBoundary; - SkPoint u = SkPointInterp(b->eval(SkBoundary::kLeft, SK_Scalar1 - unitV), - b->eval(SkBoundary::kRight, unitV), - unitU); - SkPoint v = SkPointInterp(b->eval(SkBoundary::kTop, unitU), - b->eval(SkBoundary::kBottom, SK_Scalar1 - unitU), - unitV); - return SkMakePoint(SkScalarAve(u.fX, v.fX), - SkScalarAve(u.fY, v.fY)); -} - -bool SkBoundaryPatch::evalPatch(SkPoint verts[], int rows, int cols) { - if (rows < 2 || cols < 2) { - return false; - } - - const SkScalar invR = SkScalarInvert(SkIntToScalar(rows - 1)); - const SkScalar invC = SkScalarInvert(SkIntToScalar(cols - 1)); - - for (int y = 0; y < cols; y++) { - SkScalar yy = y * invC; - for (int x = 0; x < rows; x++) { - *verts++ = this->eval(x * invR, yy); - } - } - return true; -} - -//////////////////////////////////////////////////////////////////////// - -#include "SkGeometry.h" - -SkPoint SkLineBoundary::eval(Edge e, SkScalar t) { - SkASSERT((unsigned)e < 4); - return SkPointInterp(fPts[e], fPts[(e + 1) & 3], t); -} - -SkPoint SkCubicBoundary::eval(Edge e, SkScalar t) { - SkASSERT((unsigned)e < 4); - - // ensure our 4th cubic wraps to the start of the first - fPts[12] = fPts[0]; - - SkPoint loc; - SkEvalCubicAt(&fPts[e * 3], t, &loc, nullptr, nullptr); - return loc; -} diff --git a/src/utils/SkMeshUtils.cpp b/src/utils/SkMeshUtils.cpp deleted file mode 100644 index 4c9c0d04c7..0000000000 --- a/src/utils/SkMeshUtils.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2011 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "SkMeshUtils.h" -#include "SkCanvas.h" -#include "SkPaint.h" - -SkMeshIndices::SkMeshIndices() { - sk_bzero(this, sizeof(*this)); -} - -SkMeshIndices::~SkMeshIndices() { - sk_free(fStorage); -} - -bool SkMeshIndices::init(SkPoint tex[], uint16_t indices[], - int texW, int texH, int rows, int cols) { - if (rows < 2 || cols < 2) { - sk_free(fStorage); - fStorage = nullptr; - fTex = nullptr; - fIndices = nullptr; - fTexCount = fIndexCount = 0; - return false; - } - - sk_free(fStorage); - fStorage = nullptr; - - fTexCount = rows * cols; - rows -= 1; - cols -= 1; - fIndexCount = rows * cols * 6; - - if (tex) { - fTex = tex; - fIndices = indices; - } else { - fStorage = sk_malloc_throw(fTexCount * sizeof(SkPoint) + - fIndexCount * sizeof(uint16_t)); - fTex = (SkPoint*)fStorage; - fIndices = (uint16_t*)(fTex + fTexCount); - } - - // compute the indices - { - uint16_t* idx = fIndices; - int index = 0; - for (int y = 0; y < cols; y++) { - for (int x = 0; x < rows; x++) { - *idx++ = index; - *idx++ = index + rows + 1; - *idx++ = index + 1; - - *idx++ = index + 1; - *idx++ = index + rows + 1; - *idx++ = index + rows + 2; - - index += 1; - } - index += 1; - } - } - - // compute texture coordinates - { - SkPoint* tex = fTex; - const SkScalar dx = SkIntToScalar(texW) / rows; - const SkScalar dy = SkIntToScalar(texH) / cols; - for (int y = 0; y <= cols; y++) { - for (int x = 0; x <= rows; x++) { - tex->set(x*dx, y*dy); - tex += 1; - } - } - } - return true; -} - -/////////////////////////////////////////////////////////////////////////////// - -#include "SkShader.h" - -void SkMeshUtils::Draw(SkCanvas* canvas, const SkBitmap& bitmap, - int rows, int cols, const SkPoint verts[], - const SkColor colors[], const SkPaint& paint) { - SkMeshIndices idx; - - if (idx.init(bitmap.width(), bitmap.height(), rows, cols)) { - SkPaint p(paint); - p.setShader(SkShader::MakeBitmapShader(bitmap, - SkShader::kClamp_TileMode, - SkShader::kClamp_TileMode)); - canvas->drawVertices(SkCanvas::kTriangles_VertexMode, - rows * cols, verts, idx.tex(), colors, SkBlendMode::kModulate, - idx.indices(), idx.indexCount(), p); - } -} |