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>
"$_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",
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;
/* 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);
#ifndef SkOpCoincidence_DEFINED
#define SkOpCoincidence_DEFINED
+#include "SkArenaAlloc.h"
#include "SkTDArray.h"
-#include "SkOpTAllocator.h"
#include "SkOpSpan.h"
#include "SkPathOpsTypes.h"
SkDEBUGCODE(SkOpGlobalState* globalState() { return fGlobalState; })
void init(SkDEBUGCODE(SkOpGlobalState* globalState)) {
- sk_bzero(this, sizeof(*this));
+ sk_bzero(this, sizeof(*this));
SkDEBUGCODE(fGlobalState = globalState);
}
* found in the LICENSE file.
*/
#include "SkOpContour.h"
-#include "SkOpTAllocator.h"
#include "SkPathWriter.h"
#include "SkReduceOrder.h"
#include "SkTSort.h"
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;
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;
}
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);
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;
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);
}
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);
}
#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"
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;
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;
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;
}
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);
+++ /dev/null
-/*
- * 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
} 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;
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();
}
: 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();