Revert "Revert "remove unused SkMeshUtils and SkBoundaryPatch""

This reverts commit 006c8da9c6.

Reason for revert: PDFium references have been removed

Original change's description:
> Revert "remove unused SkMeshUtils and SkBoundaryPatch"
> 
> This reverts commit 5e21e09919.
> 
> Reason for revert: Breaks Pdfium build see:
>     https://chromium-swarm.appspot.com/task?id=3504e60d4bc10810&refresh=10
> 
> Original change's description:
> > 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>
> > 
> 
> TBR=djsollen@google.com,reed@google.com,reviews@skia.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:6366
> 
> Change-Id: I2403bae0a17bce8eeec743c6f433bb51b214e669
> Reviewed-on: https://skia-review.googlesource.com/9891
> Reviewed-by: Stephan Altmueller <stephana@google.com>
> Commit-Queue: Stephan Altmueller <stephana@google.com>
> 

TBR=djsollen@google.com,reviews@skia.org,stephana@google.com,reed@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:6366

Change-Id: Iefe14394a09c16bd0ad00807dbda947311f926e8
Reviewed-on: https://skia-review.googlesource.com/9910
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2017-03-20 20:53:02 +00:00 committed by Skia Commit-Bot
parent 02f577b0f4
commit 18ea65a347
5 changed files with 0 additions and 299 deletions

View File

@ -8,14 +8,12 @@ _src = get_path_info("../src", "abspath")
_include = get_path_info("../include", "abspath")
skia_utils_sources = [
"$_include/utils/SkBoundaryPatch.h",
"$_include/utils/SkFrontBufferedStream.h",
"$_include/utils/SkCamera.h",
"$_include/utils/SkCanvasStateUtils.h",
"$_include/utils/SkDumpCanvas.h",
"$_include/utils/SkEventTracer.h",
"$_include/utils/SkInterpolator.h",
"$_include/utils/SkMeshUtils.h",
"$_include/utils/SkNoDrawCanvas.h",
"$_include/utils/SkNWayCanvas.h",
"$_include/utils/SkNullCanvas.h",
@ -31,7 +29,6 @@ skia_utils_sources = [
"$_src/utils/SkBitmapSourceDeserializer.cpp",
"$_src/utils/SkBitmapSourceDeserializer.h",
"$_src/utils/SkBitSet.h",
"$_src/utils/SkBoundaryPatch.cpp",
"$_src/utils/SkFrontBufferedStream.cpp",
"$_src/utils/SkCamera.cpp",
"$_src/utils/SkCanvasStack.h",
@ -48,7 +45,6 @@ skia_utils_sources = [
"$_src/utils/SkInterpolator.cpp",
"$_src/utils/SkMatrix22.cpp",
"$_src/utils/SkMatrix22.h",
"$_src/utils/SkMeshUtils.cpp",
"$_src/utils/SkMultiPictureDocument.cpp",
"$_src/utils/SkNWayCanvas.cpp",
"$_src/utils/SkNullCanvas.cpp",

View File

@ -1,66 +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.
*/
#ifndef SkBoundaryPatch_DEFINED
#define SkBoundaryPatch_DEFINED
#include "SkPoint.h"
#include "SkRefCnt.h"
class SkBoundary : public SkRefCnt {
public:
// These must be 0, 1, 2, 3 for efficiency in the subclass implementations
enum Edge {
kTop = 0,
kRight = 1,
kBottom = 2,
kLeft = 3
};
// Edge index goes clockwise around the boundary, beginning at the "top"
virtual SkPoint eval(Edge, SkScalar unitInterval) = 0;
private:
typedef SkRefCnt INHERITED;
};
class SkBoundaryPatch {
public:
SkBoundaryPatch();
~SkBoundaryPatch();
SkBoundary* getBoundary() const { return fBoundary; }
SkBoundary* setBoundary(SkBoundary*);
SkPoint eval(SkScalar unitU, SkScalar unitV);
bool evalPatch(SkPoint verts[], int rows, int cols);
private:
SkBoundary* fBoundary;
};
////////////////////////////////////////////////////////////////////////
class SkLineBoundary : public SkBoundary {
public:
SkPoint fPts[4];
// override
virtual SkPoint eval(Edge, SkScalar);
};
class SkCubicBoundary : public SkBoundary {
public:
// the caller sets the first 12 entries. The 13th is used by the impl.
SkPoint fPts[13];
// override
virtual SkPoint eval(Edge, SkScalar);
};
#endif

View File

@ -1,50 +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.
*/
#ifndef SkMeshUtils_DEFINED
#define SkMeshUtils_DEFINED
#include "SkPoint.h"
#include "SkColor.h"
class SkBitmap;
class SkCanvas;
class SkPaint;
class SkMeshIndices {
public:
SkMeshIndices();
~SkMeshIndices();
bool init(int texW, int texH, int rows, int cols) {
return this->init(NULL, NULL, texW, texH, rows, cols);
}
bool init(SkPoint tex[], uint16_t indices[],
int texW, int texH, int rows, int cols);
int indexCount() const { return fIndexCount; }
const uint16_t* indices() const { return fIndices; }
size_t texCount() const { return fTexCount; }
const SkPoint* tex() const { return fTex; }
private:
int fIndexCount, fTexCount;
SkPoint* fTex;
uint16_t* fIndices;
void* fStorage; // may be null
};
class SkMeshUtils {
public:
static void Draw(SkCanvas*, const SkBitmap&, int rows, int cols,
const SkPoint verts[], const SkColor colors[],
const SkPaint& paint);
};
#endif

View File

@ -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;
}

View File

@ -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);
}
}