diff options
author | Herb Derby <herb@google.com> | 2017-04-19 15:09:48 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-19 20:36:15 +0000 |
commit | ecc364c42691f24b41a672de1636b3a5f181160a (patch) | |
tree | 0cdf5ad810cc3b83d353ac72ae97d43130eb54ae | |
parent | 66f2332b1e34610cb78d0ced9740e3455521c4fb (diff) |
Remove SkOpTAllocator
Have the callsites of SkOpTAllocator call SkArenaAlloc directly.
Bug: skia:
Change-Id: Ic54e92c3e9a0abed038aa3ae40e8a195895af99d
Reviewed-on: https://skia-review.googlesource.com/13870
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Herb Derby <herb@google.com>
-rw-r--r-- | gn/core.gni | 1 | ||||
-rw-r--r-- | src/pathops/SkOpCoincidence.cpp | 5 | ||||
-rw-r--r-- | src/pathops/SkOpCoincidence.h | 4 | ||||
-rw-r--r-- | src/pathops/SkOpContour.cpp | 9 | ||||
-rw-r--r-- | src/pathops/SkOpContour.h | 6 | ||||
-rw-r--r-- | src/pathops/SkOpSegment.cpp | 6 | ||||
-rw-r--r-- | src/pathops/SkOpSegment.h | 12 | ||||
-rw-r--r-- | src/pathops/SkOpTAllocator.h | 29 | ||||
-rw-r--r-- | src/pathops/SkPathOpsWinding.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsAngleTest.cpp | 4 |
10 files changed, 20 insertions, 58 deletions
diff --git a/gn/core.gni b/gn/core.gni index 3a5a4edf07..797a350286 100644 --- a/gn/core.gni +++ b/gn/core.gni @@ -525,7 +525,6 @@ skia_core_sources = [ "$_src/pathops/SkOpEdgeBuilder.h", "$_src/pathops/SkOpSegment.h", "$_src/pathops/SkOpSpan.h", - "$_src/pathops/SkOpTAllocator.h", "$_src/pathops/SkPathOpsBounds.h", "$_src/pathops/SkPathOpsCommon.h", "$_src/pathops/SkPathOpsConic.h", diff --git a/src/pathops/SkOpCoincidence.cpp b/src/pathops/SkOpCoincidence.cpp index 93a6d66fad..2f9d28f9ee 100644 --- a/src/pathops/SkOpCoincidence.cpp +++ b/src/pathops/SkOpCoincidence.cpp @@ -266,8 +266,7 @@ void SkOpCoincidence::add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* o SkOPASSERT(!oppPtTEnd->deleted()); DebugCheckAdd(fHead, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); DebugCheckAdd(fTop, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); - SkCoincidentSpans* coinRec = SkOpTAllocator<SkCoincidentSpans>::Allocate( - this->globalState()->allocator()); + SkCoincidentSpans* coinRec = this->globalState()->allocator()->make<SkCoincidentSpans>(); coinRec->init(SkDEBUGCODE(fGlobalState)); coinRec->set(this->fHead, coinPtTStart, coinPtTEnd, oppPtTStart, oppPtTEnd); fHead = coinRec; @@ -611,7 +610,7 @@ bool SkOpCoincidence::checkOverlap(SkCoincidentSpans* check, /* Please keep this in sync with debugAddIfMissing() */ // note that over1s, over1e, over2s, over2e are ordered bool SkOpCoincidence::addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over2s, - double tStart, double tEnd, SkOpSegment* coinSeg, SkOpSegment* oppSeg, bool* added + double tStart, double tEnd, SkOpSegment* coinSeg, SkOpSegment* oppSeg, bool* added SkDEBUGPARAMS(const SkOpPtT* over1e) SkDEBUGPARAMS(const SkOpPtT* over2e)) { SkASSERT(tStart < tEnd); SkASSERT(over1s->fT < over1e->fT); diff --git a/src/pathops/SkOpCoincidence.h b/src/pathops/SkOpCoincidence.h index 92076b12c7..37498c2da7 100644 --- a/src/pathops/SkOpCoincidence.h +++ b/src/pathops/SkOpCoincidence.h @@ -7,8 +7,8 @@ #ifndef SkOpCoincidence_DEFINED #define SkOpCoincidence_DEFINED +#include "SkArenaAlloc.h" #include "SkTDArray.h" -#include "SkOpTAllocator.h" #include "SkOpSpan.h" #include "SkPathOpsTypes.h" @@ -60,7 +60,7 @@ public: SkDEBUGCODE(SkOpGlobalState* globalState() { return fGlobalState; }) void init(SkDEBUGCODE(SkOpGlobalState* globalState)) { - sk_bzero(this, sizeof(*this)); + sk_bzero(this, sizeof(*this)); SkDEBUGCODE(fGlobalState = globalState); } diff --git a/src/pathops/SkOpContour.cpp b/src/pathops/SkOpContour.cpp index ea1659ee2b..f5799474ec 100644 --- a/src/pathops/SkOpContour.cpp +++ b/src/pathops/SkOpContour.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ #include "SkOpContour.h" -#include "SkOpTAllocator.h" #include "SkPathWriter.h" #include "SkReduceOrder.h" #include "SkTSort.h" @@ -65,17 +64,17 @@ void SkOpContourBuilder::addCurve(SkPath::Verb verb, const SkPoint pts[4], SkSca SkArenaAlloc* allocator = fContour->globalState()->allocator(); switch (verb) { case SkPath::kQuad_Verb: { - SkPoint* ptStorage = SkOpTAllocator<SkPoint>::AllocateArray(allocator, 3); + SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(3); memcpy(ptStorage, pts, sizeof(SkPoint) * 3); this->addQuad(ptStorage); } break; case SkPath::kConic_Verb: { - SkPoint* ptStorage = SkOpTAllocator<SkPoint>::AllocateArray(allocator, 3); + SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(3); memcpy(ptStorage, pts, sizeof(SkPoint) * 3); this->addConic(ptStorage, weight); } break; case SkPath::kCubic_Verb: { - SkPoint* ptStorage = SkOpTAllocator<SkPoint>::AllocateArray(allocator, 4); + SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(4); memcpy(ptStorage, pts, sizeof(SkPoint) * 4); this->addCubic(ptStorage); } break; @@ -107,7 +106,7 @@ void SkOpContourBuilder::flush() { if (!fLastIsLine) return; SkArenaAlloc* allocator = fContour->globalState()->allocator(); - SkPoint* ptStorage = SkOpTAllocator<SkPoint>::AllocateArray(allocator, 2); + SkPoint* ptStorage = allocator->makeArrayDefault<SkPoint>(2); memcpy(ptStorage, fLastLine, sizeof(fLastLine)); (void) fContour->addLine(ptStorage); fLastIsLine = false; diff --git a/src/pathops/SkOpContour.h b/src/pathops/SkOpContour.h index c283226590..17effc6197 100644 --- a/src/pathops/SkOpContour.h +++ b/src/pathops/SkOpContour.h @@ -45,8 +45,8 @@ public: } SkOpSegment& appendSegment() { - SkOpSegment* result = fCount++ - ? SkOpTAllocator<SkOpSegment>::Allocate(this->globalState()->allocator()) : &fHead; + SkOpSegment* result = fCount++ ? this->globalState()->allocator()->make<SkOpSegment>() + : &fHead; result->setPrev(fTail); if (fTail) { fTail->setNext(result); @@ -391,7 +391,7 @@ protected: class SkOpContourHead : public SkOpContour { public: SkOpContour* appendContour() { - SkOpContour* contour = SkOpTAllocator<SkOpContour>::New(this->globalState()->allocator()); + SkOpContour* contour = this->globalState()->allocator()->make<SkOpContour>(); contour->setNext(nullptr); SkOpContour* prev = this; SkOpContour* next; diff --git a/src/pathops/SkOpSegment.cpp b/src/pathops/SkOpSegment.cpp index 1dbeaf6507..f266ed949f 100644 --- a/src/pathops/SkOpSegment.cpp +++ b/src/pathops/SkOpSegment.cpp @@ -286,8 +286,7 @@ void SkOpSegment::calcAngles() { SkOpSpanBase* spanBase = fHead.next(); while (spanBase != &fTail) { if (activePrior) { - SkOpAngle* priorAngle = SkOpTAllocator<SkOpAngle>::Allocate( - this->globalState()->allocator()); + SkOpAngle* priorAngle = this->globalState()->allocator()->make<SkOpAngle>(); priorAngle->set(spanBase, prior); spanBase->setFromAngle(priorAngle); } @@ -295,8 +294,7 @@ void SkOpSegment::calcAngles() { bool active = !span->isCanceled(); SkOpSpanBase* next = span->next(); if (active) { - SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate( - this->globalState()->allocator()); + SkOpAngle* angle = this->globalState()->allocator()->make<SkOpAngle>(); angle->set(span, next); span->setToAngle(angle); } diff --git a/src/pathops/SkOpSegment.h b/src/pathops/SkOpSegment.h index 4bde8166f7..ea2504ab58 100644 --- a/src/pathops/SkOpSegment.h +++ b/src/pathops/SkOpSegment.h @@ -7,9 +7,9 @@ #ifndef SkOpSegment_DEFINE #define SkOpSegment_DEFINE +#include "SkArenaAlloc.h" #include "SkOpAngle.h" #include "SkOpSpan.h" -#include "SkOpTAllocator.h" #include "SkPathOpsBounds.h" #include "SkPathOpsCubic.h" #include "SkPathOpsCurve.h" @@ -60,7 +60,7 @@ public: bool addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, SkPathWriter* path) const; SkOpAngle* addEndSpan() { - SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate(this->globalState()->allocator()); + SkOpAngle* angle = this->globalState()->allocator()->make<SkOpAngle>(); angle->set(&fTail, fTail.prev()); fTail.setFromAngle(angle); return angle; @@ -78,7 +78,7 @@ public: SkOpPtT* addMissing(double t, SkOpSegment* opp, bool* allExist); SkOpAngle* addStartSpan() { - SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate(this->globalState()->allocator()); + SkOpAngle* angle = this->globalState()->allocator()->make<SkOpAngle>(); angle->set(&fHead, fHead.next()); fHead.setToAngle(angle); return angle; @@ -95,10 +95,6 @@ public: SkOpPtT* addT(double t); SkOpPtT* addT(double t, const SkPoint& pt); - template<typename T> T* allocateArray(int count) { - return SkOpTAllocator<T>::AllocateArray(this->globalState()->allocator(), count); - } - const SkPathOpsBounds& bounds() const { return fBounds; } @@ -237,7 +233,7 @@ public: SkOpSpan* insert(SkOpSpan* prev) { SkOpGlobalState* globalState = this->globalState(); globalState->setAllocatedOpSpan(); - SkOpSpan* result = SkOpTAllocator<SkOpSpan>::Allocate(globalState->allocator()); + SkOpSpan* result = globalState->allocator()->make<SkOpSpan>(); SkOpSpanBase* next = prev->next(); result->setPrev(prev); prev->setNext(result); diff --git a/src/pathops/SkOpTAllocator.h b/src/pathops/SkOpTAllocator.h deleted file mode 100644 index 599c445f12..0000000000 --- a/src/pathops/SkOpTAllocator.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2014 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef SkOpTAllocator_DEFINED -#define SkOpTAllocator_DEFINED - -#include "SkArenaAlloc.h" - -// T is SkOpAngle2, SkOpSpan2, or SkOpSegment2 -template<typename T> -class SkOpTAllocator { -public: - static T* Allocate(SkArenaAlloc* allocator) { - return allocator->make<T>(); - } - - static T* AllocateArray(SkArenaAlloc* allocator, int count) { - return allocator->makeArrayDefault<T>(count); - } - - static T* New(SkArenaAlloc* allocator) { - return allocator->make<T>(); - } -}; - -#endif diff --git a/src/pathops/SkPathOpsWinding.cpp b/src/pathops/SkPathOpsWinding.cpp index 724e6f47bc..5692ae3209 100644 --- a/src/pathops/SkPathOpsWinding.cpp +++ b/src/pathops/SkPathOpsWinding.cpp @@ -174,7 +174,7 @@ void SkOpSegment::rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** } else if (!span->windValue() && !span->oppValue()) { continue; } - SkOpRayHit* newHit = SkOpTAllocator<SkOpRayHit>::Allocate(allocator); + SkOpRayHit* newHit = allocator->make<SkOpRayHit>(); newHit->fNext = *hits; newHit->fPt = pt; newHit->fSlope = slope; diff --git a/tests/PathOpsAngleTest.cpp b/tests/PathOpsAngleTest.cpp index 4226a77a79..cfa8fc0e7b 100644 --- a/tests/PathOpsAngleTest.cpp +++ b/tests/PathOpsAngleTest.cpp @@ -445,7 +445,7 @@ DEF_TEST(PathOpsAngleAfter, reporter) { contour.reset(); for (int index3 = 0; index3 < 3; ++index3) { IntersectData& data = dataArray[index2 + index3]; - SkPoint* temp = (SkPoint*) SkOpTAllocator<FourPoints>::Allocate(&allocator); + SkPoint* temp = (SkPoint*) allocator.make<FourPoints>(); for (int idx2 = 0; idx2 < data.fPtCount; ++idx2) { temp[idx2] = data.fPts.fPts[idx2].asSkPoint(); } @@ -485,7 +485,7 @@ void SkOpSegment::debugAddAngle(double startT, double endT) { : this->addT(startT); SkOpPtT* endPtT = endT == 0 ? fHead.ptT() : endT == 1 ? fTail.ptT() : this->addT(endT); - SkOpAngle* angle = SkOpTAllocator<SkOpAngle>::Allocate(this->globalState()->allocator()); + SkOpAngle* angle = this->globalState()->allocator()->make<SkOpAngle>(); SkOpSpanBase* startSpan = &fHead; while (startSpan->ptT() != startPtT) { startSpan = startSpan->upCast()->next(); |