aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/hittestpath.cpp1
-rw-r--r--gyp/SampleApp.gyp1
-rw-r--r--gyp/utils.gypi2
-rw-r--r--include/utils/SkCullPoints.h71
-rw-r--r--samplecode/SampleCull.cpp197
-rw-r--r--samplecode/SampleFillType.cpp1
-rw-r--r--samplecode/SampleWritePixels.cpp1
-rw-r--r--src/utils/SkCullPoints.cpp211
8 files changed, 0 insertions, 485 deletions
diff --git a/gm/hittestpath.cpp b/gm/hittestpath.cpp
index d0fe1aabb3..5d0d1fc461 100644
--- a/gm/hittestpath.cpp
+++ b/gm/hittestpath.cpp
@@ -7,7 +7,6 @@
#include "gm.h"
#include "SkCanvas.h"
-#include "SkCullPoints.h"
#include "SkPath.h"
#include "SkRandom.h"
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index 7983c12bdc..3b4ae851ba 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -58,7 +58,6 @@
'../samplecode/SampleColorFilter.cpp',
'../samplecode/SampleComplexClip.cpp',
'../samplecode/SampleConcavePaths.cpp',
- '../samplecode/SampleCull.cpp',
'../samplecode/SampleDegenerateTwoPtRadials.cpp',
'../samplecode/SampleDither.cpp',
'../samplecode/SampleDitherBitmap.cpp',
diff --git a/gyp/utils.gypi b/gyp/utils.gypi
index 4359805a2e..f9e9b13b92 100644
--- a/gyp/utils.gypi
+++ b/gyp/utils.gypi
@@ -16,7 +16,6 @@
'<(skia_include_path)/utils/SkCamera.h',
'<(skia_include_path)/utils/SkCanvasStateUtils.h',
'<(skia_include_path)/utils/SkCubicInterval.h',
- '<(skia_include_path)/utils/SkCullPoints.h',
'<(skia_include_path)/utils/SkDebugUtils.h',
'<(skia_include_path)/utils/SkDumpCanvas.h',
'<(skia_include_path)/utils/SkEventTracer.h',
@@ -52,7 +51,6 @@
'<(skia_src_path)/utils/SkCanvasStack.cpp',
'<(skia_src_path)/utils/SkCanvasStateUtils.cpp',
'<(skia_src_path)/utils/SkCubicInterval.cpp',
- '<(skia_src_path)/utils/SkCullPoints.cpp',
'<(skia_src_path)/utils/SkDashPath.cpp',
'<(skia_src_path)/utils/SkDashPathPriv.h',
'<(skia_src_path)/utils/SkDumpCanvas.cpp',
diff --git a/include/utils/SkCullPoints.h b/include/utils/SkCullPoints.h
deleted file mode 100644
index fafa0fc085..0000000000
--- a/include/utils/SkCullPoints.h
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkCullPoints_DEFINED
-#define SkCullPoints_DEFINED
-
-#include "SkRect.h"
-
-class SkCullPoints {
-public:
- SkCullPoints();
- SkCullPoints(const SkIRect& r);
-
- void reset(const SkIRect& r);
-
- /** Start a contour at (x,y). Follow this with call(s) to lineTo(...)
- */
- void moveTo(int x, int y);
-
- enum LineToResult {
- kNo_Result, //!< line segment was completely clipped out
- kLineTo_Result, //!< path.lineTo(pts[1]);
- kMoveToLineTo_Result //!< path.moveTo(pts[0]); path.lineTo(pts[1]);
- };
- /** Connect a line to the previous call to lineTo (or moveTo).
- */
- LineToResult lineTo(int x, int y, SkIPoint pts[2]);
-
-private:
- SkIRect fR; // the caller's rectangle
- SkIPoint fAsQuad[4]; // cache of fR as 4 points
- SkIPoint fPrevPt; // private state
- LineToResult fPrevResult; // private state
-
- bool sect_test(int x0, int y0, int x1, int y1) const;
-};
-
-/////////////////////////////////////////////////////////////////////////////////
-
-class SkPath;
-
-/** \class SkCullPointsPath
-
- Similar to SkCullPoints, but this class handles the return values
- from lineTo, and automatically builds a SkPath with the result(s).
-*/
-class SkCullPointsPath {
-public:
- SkCullPointsPath();
- SkCullPointsPath(const SkIRect& r, SkPath* dst);
-
- void reset(const SkIRect& r, SkPath* dst);
-
- void moveTo(int x, int y);
- void lineTo(int x, int y);
-
-private:
- SkCullPoints fCP;
- SkPath* fPath;
-};
-
-bool SkHitTestPath(const SkPath&, SkRect& target, bool hires);
-bool SkHitTestPath(const SkPath&, SkScalar x, SkScalar y, bool hires);
-
-#endif
diff --git a/samplecode/SampleCull.cpp b/samplecode/SampleCull.cpp
deleted file mode 100644
index 011b22f9e7..0000000000
--- a/samplecode/SampleCull.cpp
+++ /dev/null
@@ -1,197 +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 "SampleCode.h"
-#include "SkView.h"
-#include "SkCanvas.h"
-#include "SkCornerPathEffect.h"
-#include "SkCullPoints.h"
-#include "SkGradientShader.h"
-#include "SkPath.h"
-#include "SkRegion.h"
-#include "SkShader.h"
-#include "SkUtils.h"
-#include "SkRandom.h"
-
-static void addbump(SkPath* path, const SkPoint pts[2], SkScalar bump) {
- SkVector tang;
-
- tang.setLength(pts[1].fX - pts[0].fX, pts[1].fY - pts[0].fY, bump);
-
- path->lineTo(SkScalarHalf(pts[0].fX + pts[1].fX) - tang.fY,
- SkScalarHalf(pts[0].fY + pts[1].fY) + tang.fX);
- path->lineTo(pts[1]);
-}
-
-static void subdivide(SkPath* path, SkScalar bump) {
- SkPath::Iter iter(*path, false);
- SkPoint pts[4];
- SkPath tmp;
-
- for (;;)
- switch (iter.next(pts)) {
- case SkPath::kMove_Verb:
- tmp.moveTo(pts[0]);
- break;
- case SkPath::kLine_Verb:
- addbump(&tmp, pts, bump);
- bump = -bump;
- break;
- case SkPath::kDone_Verb:
- goto FINISH;
- default:
- break;
- }
-
-FINISH:
- path->swap(tmp);
-}
-
-static SkIPoint* getpts(const SkPath& path, int* count) {
- SkPoint pts[4];
- int n = 1;
- SkIPoint* array;
-
- {
- SkPath::Iter iter(path, false);
- for (;;)
- switch (iter.next(pts)) {
- case SkPath::kLine_Verb:
- n += 1;
- break;
- case SkPath::kDone_Verb:
- goto FINISHED;
- default:
- break;
- }
- }
-
-FINISHED:
- array = new SkIPoint[n];
- n = 0;
-
- {
- SkPath::Iter iter(path, false);
- for (;;)
- switch (iter.next(pts)) {
- case SkPath::kMove_Verb:
- array[n++].set(SkScalarRoundToInt(pts[0].fX),
- SkScalarRoundToInt(pts[0].fY));
- break;
- case SkPath::kLine_Verb:
- array[n++].set(SkScalarRoundToInt(pts[1].fX),
- SkScalarRoundToInt(pts[1].fY));
- break;
- case SkPath::kDone_Verb:
- goto FINISHED2;
- default:
- break;
- }
- }
-
-FINISHED2:
- *count = n;
- return array;
-}
-
-static SkScalar nextScalarRange(SkRandom& rand, SkScalar min, SkScalar max) {
- return min + SkScalarMul(rand.nextUScalar1(), max - min);
-}
-
-class CullView : public SampleView {
-public:
- CullView() {
- fClip.set(0, 0, SkIntToScalar(160), SkIntToScalar(160));
-
- SkRandom rand;
-
- for (int i = 0; i < 50; i++) {
- SkScalar x = nextScalarRange(rand, -fClip.width()*1, fClip.width()*2);
- SkScalar y = nextScalarRange(rand, -fClip.height()*1, fClip.height()*2);
- if (i == 0)
- fPath.moveTo(x, y);
- else
- fPath.lineTo(x, y);
- }
-
- SkScalar bump = fClip.width()/8;
- subdivide(&fPath, bump);
- subdivide(&fPath, bump);
- subdivide(&fPath, bump);
- fPoints = getpts(fPath, &fPtCount);
-
- this->setBGColor(0xFFDDDDDD);
- }
-
- virtual ~CullView() {
- delete[] fPoints;
- }
-
-protected:
- // overrides from SkEventSink
- virtual bool onQuery(SkEvent* evt) {
- if (SampleCode::TitleQ(*evt)) {
- SampleCode::TitleR(evt, "Culling");
- return true;
- }
- return this->INHERITED::onQuery(evt);
- }
-
- virtual void onDrawContent(SkCanvas* canvas) {
- SkAutoCanvasRestore ar(canvas, true);
-
- canvas->translate( SkScalarHalf(this->width() - fClip.width()),
- SkScalarHalf(this->height() - fClip.height()));
-
- // canvas->scale(SK_Scalar1*3, SK_Scalar1*3, 0, 0);
-
- SkPaint paint;
-
- // paint.setAntiAliasOn(true);
- paint.setStyle(SkPaint::kStroke_Style);
-
- canvas->drawRect(fClip, paint);
-
-#if 1
- paint.setColor(0xFF555555);
- paint.setStrokeWidth(SkIntToScalar(2));
-// paint.setPathEffect(new SkCornerPathEffect(SkIntToScalar(30)))->unref();
- canvas->drawPath(fPath, paint);
-// paint.setPathEffect(nullptr);
-#endif
-
- SkPath tmp;
- SkIRect iclip;
- fClip.round(&iclip);
-
- SkCullPointsPath cpp(iclip, &tmp);
-
- cpp.moveTo(fPoints[0].fX, fPoints[0].fY);
- for (int i = 0; i < fPtCount; i++)
- cpp.lineTo(fPoints[i].fX, fPoints[i].fY);
-
- paint.setColor(SK_ColorRED);
- paint.setStrokeWidth(SkIntToScalar(3));
- paint.setStrokeJoin(SkPaint::kRound_Join);
- canvas->drawPath(tmp, paint);
-
- this->inval(nullptr);
- }
-
-private:
- SkRect fClip;
- SkIPoint* fPoints;
- SkPath fPath;
- int fPtCount;
-
- typedef SampleView INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static SkView* MyFactory() { return new CullView; }
-static SkViewRegister reg(MyFactory);
diff --git a/samplecode/SampleFillType.cpp b/samplecode/SampleFillType.cpp
index aac6aed2e0..af94c9f4f1 100644
--- a/samplecode/SampleFillType.cpp
+++ b/samplecode/SampleFillType.cpp
@@ -9,7 +9,6 @@
#include "SkView.h"
#include "SkCanvas.h"
#include "SkCornerPathEffect.h"
-#include "SkCullPoints.h"
#include "SkGradientShader.h"
#include "SkPath.h"
#include "SkRegion.h"
diff --git a/samplecode/SampleWritePixels.cpp b/samplecode/SampleWritePixels.cpp
index f7829eaada..bce79800c2 100644
--- a/samplecode/SampleWritePixels.cpp
+++ b/samplecode/SampleWritePixels.cpp
@@ -9,7 +9,6 @@
#include "SkView.h"
#include "SkCanvas.h"
#include "SkCornerPathEffect.h"
-#include "SkCullPoints.h"
#include "SkGradientShader.h"
#include "SkPath.h"
#include "SkRegion.h"
diff --git a/src/utils/SkCullPoints.cpp b/src/utils/SkCullPoints.cpp
deleted file mode 100644
index f77acf1023..0000000000
--- a/src/utils/SkCullPoints.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkCullPoints.h"
-
-static bool cross_product_is_neg(const SkIPoint& v, int dx, int dy) {
-#if 0
- return v.fX * dy - v.fY * dx < 0;
-#else
- return sk_64_mul(v.fX, dy) < sk_64_mul(dx, v.fY);
-#endif
-}
-
-bool SkCullPoints::sect_test(int x0, int y0, int x1, int y1) const {
- const SkIRect& r = fR;
-
- if ((x0 < r.fLeft && x1 < r.fLeft) ||
- (x0 > r.fRight && x1 > r.fRight) ||
- (y0 < r.fTop && y1 < r.fTop) ||
- (y0 > r.fBottom && y1 > r.fBottom)) {
- return false;
- }
-
- // since the crossprod test is a little expensive, check for easy-in cases first
- if (r.contains(x0, y0) || r.contains(x1, y1)) {
- return true;
- }
-
- // At this point we're not sure, so we do a crossprod test
- SkIPoint vec;
- const SkIPoint* rAsQuad = fAsQuad;
-
- vec.set(x1 - x0, y1 - y0);
- bool isNeg = cross_product_is_neg(vec, x0 - rAsQuad[0].fX, y0 - rAsQuad[0].fY);
- for (int i = 1; i < 4; i++) {
- if (cross_product_is_neg(vec, x0 - rAsQuad[i].fX, y0 - rAsQuad[i].fY) != isNeg) {
- return true;
- }
- }
- return false; // we didn't intersect
-}
-
-static void toQuad(const SkIRect& r, SkIPoint quad[4]) {
- SkASSERT(quad);
-
- quad[0].set(r.fLeft, r.fTop);
- quad[1].set(r.fRight, r.fTop);
- quad[2].set(r.fRight, r.fBottom);
- quad[3].set(r.fLeft, r.fBottom);
-}
-
-SkCullPoints::SkCullPoints() {
- SkIRect r;
- r.setEmpty();
- this->reset(r);
-}
-
-SkCullPoints::SkCullPoints(const SkIRect& r) {
- this->reset(r);
-}
-
-void SkCullPoints::reset(const SkIRect& r) {
- fR = r;
- toQuad(fR, fAsQuad);
- fPrevPt.set(0, 0);
- fPrevResult = kNo_Result;
-}
-
-void SkCullPoints::moveTo(int x, int y) {
- fPrevPt.set(x, y);
- fPrevResult = kNo_Result; // so we trigger a movetolineto later
-}
-
-SkCullPoints::LineToResult SkCullPoints::lineTo(int x, int y, SkIPoint line[]) {
- SkASSERT(line != nullptr);
-
- LineToResult result = kNo_Result;
- int x0 = fPrevPt.fX;
- int y0 = fPrevPt.fY;
-
- // need to upgrade sect_test to chop the result
- // and to correctly return kLineTo_Result when the result is connected
- // to the previous call-out
- if (this->sect_test(x0, y0, x, y)) {
- line[0].set(x0, y0);
- line[1].set(x, y);
-
- if (fPrevResult != kNo_Result && fPrevPt.equals(x0, y0)) {
- result = kLineTo_Result;
- } else {
- result = kMoveToLineTo_Result;
- }
- }
-
- fPrevPt.set(x, y);
- fPrevResult = result;
-
- return result;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
-
-#include "SkPath.h"
-
-SkCullPointsPath::SkCullPointsPath()
- : fCP(), fPath(nullptr) {
-}
-
-SkCullPointsPath::SkCullPointsPath(const SkIRect& r, SkPath* dst)
- : fCP(r), fPath(dst) {
-}
-
-void SkCullPointsPath::reset(const SkIRect& r, SkPath* dst) {
- fCP.reset(r);
- fPath = dst;
-}
-
-void SkCullPointsPath::moveTo(int x, int y) {
- fCP.moveTo(x, y);
-}
-
-void SkCullPointsPath::lineTo(int x, int y) {
- SkIPoint pts[2];
-
- switch (fCP.lineTo(x, y, pts)) {
- case SkCullPoints::kMoveToLineTo_Result:
- fPath->moveTo(SkIntToScalar(pts[0].fX), SkIntToScalar(pts[0].fY));
- // fall through to the lineto case
- case SkCullPoints::kLineTo_Result:
- fPath->lineTo(SkIntToScalar(pts[1].fX), SkIntToScalar(pts[1].fY));
- break;
- default:
- break;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-#include "SkMatrix.h"
-#include "SkRegion.h"
-
-bool SkHitTestPath(const SkPath& path, SkRect& target, bool hires) {
- if (target.isEmpty()) {
- return false;
- }
-
- bool isInverse = path.isInverseFillType();
- if (path.isEmpty()) {
- return isInverse;
- }
-
- SkRect bounds = path.getBounds();
-
- bool sects = SkRect::Intersects(target, bounds);
- if (isInverse) {
- if (!sects) {
- return true;
- }
- } else {
- if (!sects) {
- return false;
- }
- if (target.contains(bounds)) {
- return true;
- }
- }
-
- SkPath devPath;
- const SkPath* pathPtr;
- SkRect devTarget;
-
- if (hires) {
- const SkScalar coordLimit = SkIntToScalar(16384);
- const SkRect limit = { 0, 0, coordLimit, coordLimit };
-
- SkMatrix matrix;
- matrix.setRectToRect(bounds, limit, SkMatrix::kFill_ScaleToFit);
-
- path.transform(matrix, &devPath);
- matrix.mapRect(&devTarget, target);
-
- pathPtr = &devPath;
- } else {
- devTarget = target;
- pathPtr = &path;
- }
-
- SkIRect iTarget;
- devTarget.round(&iTarget);
- if (iTarget.isEmpty()) {
- iTarget.fLeft = SkScalarFloorToInt(devTarget.fLeft);
- iTarget.fTop = SkScalarFloorToInt(devTarget.fTop);
- iTarget.fRight = iTarget.fLeft + 1;
- iTarget.fBottom = iTarget.fTop + 1;
- }
-
- SkRegion clip(iTarget);
- SkRegion rgn;
- return rgn.setPath(*pathPtr, clip) ^ isInverse;
-}
-
-bool SkHitTestPath(const SkPath& path, SkScalar x, SkScalar y, bool hires) {
- const SkScalar half = SK_ScalarHalf;
- const SkScalar one = SK_Scalar1;
- SkRect r = SkRect::MakeXYWH(x - half, y - half, one, one);
- return SkHitTestPath(path, r, hires);
-}