Remove SkOpTAllocator
authorHerb Derby <herb@google.com>
Wed, 19 Apr 2017 19:09:48 +0000 (15:09 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 19 Apr 2017 20:36:15 +0000 (20:36 +0000)
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>

gn/core.gni
src/pathops/SkOpCoincidence.cpp
src/pathops/SkOpCoincidence.h
src/pathops/SkOpContour.cpp
src/pathops/SkOpContour.h
src/pathops/SkOpSegment.cpp
src/pathops/SkOpSegment.h
src/pathops/SkOpTAllocator.h [deleted file]
src/pathops/SkPathOpsWinding.cpp
tests/PathOpsAngleTest.cpp

index 3a5a4edf075822777b1cc9b2d3aba8af79d87dbc..797a35028689b0f4e8b003e20177b17f2450ee2c 100644 (file)
@@ -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",
index 93a6d66faddbe17e2c76d3dda0cae0c0e6eb9b77..2f9d28f9eed42d17da1a7f2a2724cc5b53a2bcd2 100644 (file)
@@ -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);
index 92076b12c716f2855c6485dddbfc0536c5c292ca..37498c2da706ff464a065365b0b0ec0acd0e435f 100644 (file)
@@ -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);
     }
 
index ea1659ee2bc7aa4ac06ea46efc6103af85f43acc..f5799474ec50b6197b02a6e9b2378582b7afba6d 100644 (file)
@@ -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;
index c283226590371ead9a4ddb1cfde20495fbeb1dcf..17effc619708cbb7cfc48ff13af30048b0849c67 100644 (file)
@@ -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;
index 1dbeaf65072979915e1e4b7c0c52ec1540e318c9..f266ed949f5e57831d78f786171780656dbf0804 100644 (file)
@@ -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);
         }
index 4bde8166f7433d8893012844b028a42b4a709269..ea2504ab58ad2f5d654523d5df6b72d7f3ed81c3 100644 (file)
@@ -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 (file)
index 599c445..0000000
+++ /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
index 724e6f47bc5e2be1ffd6daf8c187bd483c0f6f80..5692ae320925ae8a4807e20c0ca0e68f70dbf50a 100644 (file)
@@ -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;
index 4226a77a79110c9f52e9dc8b63a044b9f67b2f92..cfa8fc0e7bdad14dc70e4502e162ea3fdedd6ec7 100644 (file)
@@ -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();