aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Derek Sollenberger <djsollen@google.com>2017-03-07 11:14:59 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-07 11:15:10 +0000
commitc0a4c4f969464ec9854d726836a430262351d63d (patch)
treee62c137641eb1002dbaa91c3b52335e23fbdf48f /src
parentf3b16d01e36574d1a0ddf73975a5f72963727aa4 (diff)
Revert "Move from SkChunkAlloc to SkArenaAlloc for PathOps"
This reverts commit 38c60180241e335e368fdadbf7856aff114ff668. Reason for revert: breaking ASAN run in TAP build Original change's description: > Move from SkChunkAlloc to SkArenaAlloc for PathOps > > Change-Id: Iab111a4ebcae4e896b1fdfe285def9ef0ae2ab6b > Reviewed-on: https://skia-review.googlesource.com/7314 > Reviewed-by: Cary Clark <caryclark@google.com> > Commit-Queue: Herb Derby <herb@google.com> > TBR=herb@google.com,caryclark@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I6364254571bb1617a9f45ed08f2af4a59f9d5841 Reviewed-on: https://skia-review.googlesource.com/9335 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Derek Sollenberger <djsollen@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/pathops/SkOpBuilder.cpp10
-rw-r--r--src/pathops/SkOpContour.cpp4
-rw-r--r--src/pathops/SkOpContour.h2
-rw-r--r--src/pathops/SkOpSegment.h6
-rw-r--r--src/pathops/SkOpSpan.h2
-rw-r--r--src/pathops/SkOpTAllocator.h18
-rw-r--r--src/pathops/SkPathOpsOp.cpp3
-rw-r--r--src/pathops/SkPathOpsSimplify.cpp3
-rw-r--r--src/pathops/SkPathOpsTSect.h24
-rw-r--r--src/pathops/SkPathOpsTightBounds.cpp3
-rw-r--r--src/pathops/SkPathOpsTypes.cpp3
-rw-r--r--src/pathops/SkPathOpsTypes.h8
-rw-r--r--src/pathops/SkPathOpsWinding.cpp7
13 files changed, 46 insertions, 47 deletions
diff --git a/src/pathops/SkOpBuilder.cpp b/src/pathops/SkOpBuilder.cpp
index c4eb0a91b5..abff9827d5 100644
--- a/src/pathops/SkOpBuilder.cpp
+++ b/src/pathops/SkOpBuilder.cpp
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-#include "SkArenaAlloc.h"
#include "SkMatrix.h"
#include "SkOpEdgeBuilder.h"
#include "SkPathPriv.h"
@@ -13,10 +12,10 @@
#include "SkPathOpsCommon.h"
static bool one_contour(const SkPath& path) {
- char storage[256];
- SkArenaAlloc allocator(storage);
+ SkChunkAlloc allocator(256);
int verbCount = path.countVerbs();
- uint8_t* verbs = (uint8_t*) allocator.makeArrayDefault<uint8_t>(verbCount);
+ uint8_t* verbs = (uint8_t*) allocator.alloc(sizeof(uint8_t) * verbCount,
+ SkChunkAlloc::kThrow_AllocFailType);
(void) path.getVerbs(verbs, verbCount);
for (int index = 1; index < verbCount; ++index) {
if (verbs[index] == SkPath::kMove_Verb) {
@@ -51,8 +50,7 @@ bool SkOpBuilder::FixWinding(SkPath* path) {
path->setFillType(fillType);
return true;
}
- char storage[4096];
- SkArenaAlloc allocator(storage);
+ SkChunkAlloc allocator(4096);
SkOpContourHead contourHead;
SkOpGlobalState globalState(&contourHead, &allocator SkDEBUGPARAMS(false)
SkDEBUGPARAMS(nullptr));
diff --git a/src/pathops/SkOpContour.cpp b/src/pathops/SkOpContour.cpp
index ea1659ee2b..62380ab4fa 100644
--- a/src/pathops/SkOpContour.cpp
+++ b/src/pathops/SkOpContour.cpp
@@ -62,7 +62,7 @@ void SkOpContourBuilder::addCurve(SkPath::Verb verb, const SkPoint pts[4], SkSca
this->addLine(pts);
return;
}
- SkArenaAlloc* allocator = fContour->globalState()->allocator();
+ SkChunkAlloc* allocator = fContour->globalState()->allocator();
switch (verb) {
case SkPath::kQuad_Verb: {
SkPoint* ptStorage = SkOpTAllocator<SkPoint>::AllocateArray(allocator, 3);
@@ -106,7 +106,7 @@ void SkOpContourBuilder::addQuad(SkPoint pts[3]) {
void SkOpContourBuilder::flush() {
if (!fLastIsLine)
return;
- SkArenaAlloc* allocator = fContour->globalState()->allocator();
+ SkChunkAlloc* allocator = fContour->globalState()->allocator();
SkPoint* ptStorage = SkOpTAllocator<SkPoint>::AllocateArray(allocator, 2);
memcpy(ptStorage, fLastLine, sizeof(fLastLine));
(void) fContour->addLine(ptStorage);
diff --git a/src/pathops/SkOpContour.h b/src/pathops/SkOpContour.h
index eca45aa20d..a7a6beefc7 100644
--- a/src/pathops/SkOpContour.h
+++ b/src/pathops/SkOpContour.h
@@ -277,7 +277,7 @@ public:
SkDEBUGCODE(fDebugIndent -= 2);
}
- void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkArenaAlloc*);
+ void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkChunkAlloc* );
void reset() {
fTail = nullptr;
diff --git a/src/pathops/SkOpSegment.h b/src/pathops/SkOpSegment.h
index 561fa80779..17c8a8f67e 100644
--- a/src/pathops/SkOpSegment.h
+++ b/src/pathops/SkOpSegment.h
@@ -169,8 +169,8 @@ public:
void debugValidate() const;
#if DEBUG_COINCIDENCE_ORDER
- void debugResetCoinT() const;
- void debugSetCoinT(int, SkScalar ) const;
+ void debugResetCoinT() const;
+ void debugSetCoinT(int, SkScalar ) const;
#endif
#if DEBUG_COIN
@@ -333,7 +333,7 @@ public:
bool ptsDisjoint(double t1, const SkPoint& pt1, double t2, const SkPoint& pt2) const;
- void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkArenaAlloc*);
+ void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkChunkAlloc*);
void release(const SkOpSpan* );
#if DEBUG_COIN
diff --git a/src/pathops/SkOpSpan.h b/src/pathops/SkOpSpan.h
index fea3309598..219020a575 100644
--- a/src/pathops/SkOpSpan.h
+++ b/src/pathops/SkOpSpan.h
@@ -11,7 +11,7 @@
#include "SkPathOpsTypes.h"
#include "SkPoint.h"
-class SkArenaAlloc;
+class SkChunkAlloc;
class SkOpAngle;
class SkOpContour;
class SkOpGlobalState;
diff --git a/src/pathops/SkOpTAllocator.h b/src/pathops/SkOpTAllocator.h
index 599c445f12..e8835f02e6 100644
--- a/src/pathops/SkOpTAllocator.h
+++ b/src/pathops/SkOpTAllocator.h
@@ -7,22 +7,26 @@
#ifndef SkOpTAllocator_DEFINED
#define SkOpTAllocator_DEFINED
-#include "SkArenaAlloc.h"
+#include "SkChunkAlloc.h"
// T is SkOpAngle2, SkOpSpan2, or SkOpSegment2
template<typename T>
class SkOpTAllocator {
public:
- static T* Allocate(SkArenaAlloc* allocator) {
- return allocator->make<T>();
+ static T* Allocate(SkChunkAlloc* allocator) {
+ void* ptr = allocator->allocThrow(sizeof(T));
+ T* record = (T*) ptr;
+ return record;
}
- static T* AllocateArray(SkArenaAlloc* allocator, int count) {
- return allocator->makeArrayDefault<T>(count);
+ static T* AllocateArray(SkChunkAlloc* allocator, int count) {
+ void* ptr = allocator->allocThrow(sizeof(T) * count);
+ T* record = (T*) ptr;
+ return record;
}
- static T* New(SkArenaAlloc* allocator) {
- return allocator->make<T>();
+ static T* New(SkChunkAlloc* allocator) {
+ return new (Allocate(allocator)) T();
}
};
diff --git a/src/pathops/SkPathOpsOp.cpp b/src/pathops/SkPathOpsOp.cpp
index fd08aaaad1..f6b08ead07 100644
--- a/src/pathops/SkPathOpsOp.cpp
+++ b/src/pathops/SkPathOpsOp.cpp
@@ -217,8 +217,7 @@ extern void (*gVerboseFinalize)();
bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result
SkDEBUGPARAMS(bool skipAssert) SkDEBUGPARAMS(const char* testName)) {
- char storage[4096];
- SkArenaAlloc allocator(storage); // FIXME: add a constant expression here, tune
+ SkChunkAlloc allocator(4096); // FIXME: add a constant expression here, tune
SkOpContour contour;
SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour);
SkOpGlobalState globalState(contourList, &allocator
diff --git a/src/pathops/SkPathOpsSimplify.cpp b/src/pathops/SkPathOpsSimplify.cpp
index e671ab81a9..eb71e73f4a 100644
--- a/src/pathops/SkPathOpsSimplify.cpp
+++ b/src/pathops/SkPathOpsSimplify.cpp
@@ -146,8 +146,7 @@ bool SimplifyDebug(const SkPath& path, SkPath* result
return true;
}
// turn path into list of segments
- char storage[4096];
- SkArenaAlloc allocator(storage); // FIXME: constant-ize, tune
+ SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune
SkOpContour contour;
SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour);
SkOpGlobalState globalState(contourList, &allocator
diff --git a/src/pathops/SkPathOpsTSect.h b/src/pathops/SkPathOpsTSect.h
index ef0799de4f..4f2480d62f 100644
--- a/src/pathops/SkPathOpsTSect.h
+++ b/src/pathops/SkPathOpsTSect.h
@@ -7,7 +7,7 @@
#ifndef SkPathOpsTSect_DEFINED
#define SkPathOpsTSect_DEFINED
-#include "SkArenaAlloc.h"
+#include "SkChunkAlloc.h"
#include "SkPathOpsBounds.h"
#include "SkPathOpsRect.h"
#include "SkIntersections.h"
@@ -85,7 +85,7 @@ struct SkTSpanBounded {
template<typename TCurve, typename OppCurve>
class SkTSpan {
public:
- void addBounded(SkTSpan<OppCurve, TCurve>* , SkArenaAlloc* );
+ void addBounded(SkTSpan<OppCurve, TCurve>* , SkChunkAlloc* );
double closestBoundedT(const SkDPoint& pt) const;
bool contains(double t) const;
@@ -174,11 +174,11 @@ public:
initBounds(curve);
}
- bool split(SkTSpan* work, SkArenaAlloc* heap) {
+ bool split(SkTSpan* work, SkChunkAlloc* heap) {
return splitAt(work, (work->fStartT + work->fEndT) * 0.5, heap);
}
- bool splitAt(SkTSpan* work, double t, SkArenaAlloc* heap);
+ bool splitAt(SkTSpan* work, double t, SkChunkAlloc* heap);
double startT() const {
return fStartT;
@@ -317,7 +317,7 @@ private:
void removeSpans(SkTSpan<TCurve, OppCurve>* span, SkTSect<OppCurve, TCurve>* opp);
void removedEndCheck(SkTSpan<TCurve, OppCurve>* span);
- void resetRemovedEnds() {
+ void resetRemovedEnds() {
fRemovedStartT = fRemovedEndT = false;
}
@@ -331,7 +331,7 @@ private:
void validateBounded() const;
const TCurve& fCurve;
- SkArenaAlloc fHeap;
+ SkChunkAlloc fHeap;
SkTSpan<TCurve, OppCurve>* fHead;
SkTSpan<TCurve, OppCurve>* fCoincident;
SkTSpan<TCurve, OppCurve>* fDeleted;
@@ -389,8 +389,9 @@ void SkTCoincident<TCurve, OppCurve>::setPerp(const TCurve& c1, double t,
}
template<typename TCurve, typename OppCurve>
-void SkTSpan<TCurve, OppCurve>::addBounded(SkTSpan<OppCurve, TCurve>* span, SkArenaAlloc* heap) {
- SkTSpanBounded<OppCurve, TCurve>* bounded = heap->make<SkTSpanBounded<OppCurve, TCurve>>();
+void SkTSpan<TCurve, OppCurve>::addBounded(SkTSpan<OppCurve, TCurve>* span, SkChunkAlloc* heap) {
+ SkTSpanBounded<OppCurve, TCurve>* bounded = new (heap->allocThrow(
+ sizeof(SkTSpanBounded<OppCurve, TCurve>)))(SkTSpanBounded<OppCurve, TCurve>);
bounded->fBounded = span;
bounded->fNext = fBounded;
fBounded = bounded;
@@ -755,7 +756,7 @@ bool SkTSpan<TCurve, OppCurve>::removeBounded(const SkTSpan<OppCurve, TCurve>* o
}
template<typename TCurve, typename OppCurve>
-bool SkTSpan<TCurve, OppCurve>::splitAt(SkTSpan* work, double t, SkArenaAlloc* heap) {
+bool SkTSpan<TCurve, OppCurve>::splitAt(SkTSpan* work, double t, SkChunkAlloc* heap) {
fStartT = t;
fEndT = work->fEndT;
if (fStartT == fEndT) {
@@ -857,7 +858,7 @@ void SkTSpan<TCurve, OppCurve>::validatePerpPt(double t, const SkDPoint& pt) con
template<typename TCurve, typename OppCurve>
-SkTSect<TCurve, OppCurve>::SkTSect(const TCurve& c
+SkTSect<TCurve, OppCurve>::SkTSect(const TCurve& c
SkDEBUGPARAMS(SkOpGlobalState* debugGlobalState)
PATH_OPS_DEBUG_T_SECT_PARAMS(int id))
: fCurve(c)
@@ -883,7 +884,8 @@ SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::addOne() {
result = fDeleted;
fDeleted = result->fNext;
} else {
- result = fHeap.make<SkTSpan<TCurve, OppCurve>>();
+ result = new (fHeap.allocThrow(sizeof(SkTSpan<TCurve, OppCurve>)))(
+ SkTSpan<TCurve, OppCurve>);
#if DEBUG_T_SECT
++fDebugAllocatedCount;
#endif
diff --git a/src/pathops/SkPathOpsTightBounds.cpp b/src/pathops/SkPathOpsTightBounds.cpp
index 4236d2d545..f379c9e9a7 100644
--- a/src/pathops/SkPathOpsTightBounds.cpp
+++ b/src/pathops/SkPathOpsTightBounds.cpp
@@ -47,8 +47,7 @@ bool TightBounds(const SkPath& path, SkRect* result) {
*result = path.getBounds();
return true;
}
- char storage[4096];
- SkArenaAlloc allocator(storage); // FIXME: constant-ize, tune
+ SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune
SkOpContour contour;
SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour);
SkOpGlobalState globalState(contourList, &allocator SkDEBUGPARAMS(false)
diff --git a/src/pathops/SkPathOpsTypes.cpp b/src/pathops/SkPathOpsTypes.cpp
index bddfd7e508..5f87076c24 100644
--- a/src/pathops/SkPathOpsTypes.cpp
+++ b/src/pathops/SkPathOpsTypes.cpp
@@ -4,7 +4,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "SkArenaAlloc.h"
#include "SkFloatBits.h"
#include "SkOpCoincidence.h"
#include "SkPathOpsTypes.h"
@@ -226,7 +225,7 @@ double SkDCubeRoot(double x) {
}
SkOpGlobalState::SkOpGlobalState(SkOpContourHead* head,
- SkArenaAlloc* allocator
+ SkChunkAlloc* allocator
SkDEBUGPARAMS(bool debugSkipAssert)
SkDEBUGPARAMS(const char* testName))
: fAllocator(allocator)
diff --git a/src/pathops/SkPathOpsTypes.h b/src/pathops/SkPathOpsTypes.h
index 2fef8266c2..f525ea49db 100644
--- a/src/pathops/SkPathOpsTypes.h
+++ b/src/pathops/SkPathOpsTypes.h
@@ -22,7 +22,7 @@ enum SkPathOpsMask {
kEvenOdd_PathOpsMask = 1
};
-class SkArenaAlloc;
+class SkChunkAlloc;
class SkOpCoincidence;
class SkOpContour;
class SkOpContourHead;
@@ -39,7 +39,7 @@ enum class SkOpPhase : char {
class SkOpGlobalState {
public:
SkOpGlobalState(SkOpContourHead* head,
- SkArenaAlloc* allocator SkDEBUGPARAMS(bool debugSkipAssert)
+ SkChunkAlloc* allocator SkDEBUGPARAMS(bool debugSkipAssert)
SkDEBUGPARAMS(const char* testName));
enum {
@@ -50,7 +50,7 @@ public:
return fAllocatedOpSpan;
}
- SkArenaAlloc* allocator() {
+ SkChunkAlloc* allocator() {
return fAllocator;
}
@@ -181,7 +181,7 @@ public:
}
private:
- SkArenaAlloc* fAllocator;
+ SkChunkAlloc* fAllocator;
SkOpCoincidence* fCoincidence;
SkOpContourHead* fContourHead;
int fNested;
diff --git a/src/pathops/SkPathOpsWinding.cpp b/src/pathops/SkPathOpsWinding.cpp
index 724e6f47bc..7a61fd56b0 100644
--- a/src/pathops/SkPathOpsWinding.cpp
+++ b/src/pathops/SkPathOpsWinding.cpp
@@ -101,7 +101,7 @@ struct SkOpRayHit {
};
void SkOpContour::rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits,
- SkArenaAlloc* allocator) {
+ SkChunkAlloc* allocator) {
// if the bounds extreme is outside the best, we're done
SkScalar baseXY = pt_xy(base.fPt, dir);
SkScalar boundsXY = rect_side(fBounds, dir);
@@ -116,7 +116,7 @@ void SkOpContour::rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit**
}
void SkOpSegment::rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits,
- SkArenaAlloc* allocator) {
+ SkChunkAlloc* allocator) {
if (!sideways_overlap(fBounds, base.fPt, dir)) {
return;
}
@@ -233,8 +233,7 @@ static double get_t_guess(int tTry, int* dirOffset) {
}
bool SkOpSpan::sortableTop(SkOpContour* contourHead) {
- char storage[1024];
- SkArenaAlloc allocator(storage);
+ SkChunkAlloc allocator(1024);
int dirOffset;
double t = get_t_guess(fTopTTry++, &dirOffset);
SkOpRayHit hitBase;