Reland of add a ClassID function to GrBatch (patchset #1 id:1 of https://codereview.chromium.org/1353043002/ )
Reason for revert:
DEPS roll seems to have landed w/o this revert, so revert it again
Original issue's description:
> Revert of add a ClassID function to GrBatch (patchset #5 id:80001 of https://codereview.chromium.org/1352813003/ )
>
> Reason for revert:
> Speculative revert to unblock DEPS roll
>
> Original issue's description:
> > add a ClassID function to GrBatch
> >
> > BUG=skia:
> >
> > Committed: https://skia.googlesource.com/skia/+/4078d529e9e199eea13456db7bf3a63a104ab5b9
> >
> > Committed: https://skia.googlesource.com/skia/+/eb44d53cf96a7eaf103a98d76079ce1f5495e343
>
> TBR=robertphillips@google.com,bsalomon@google.com,joshualitt@google.com,joshualitt@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/48e3a45ade15c52c0c1a10cb00907dd444897745
TBR=robertphillips@google.com,bsalomon@google.com,joshualitt@google.com,joshualitt@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/1344373005
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index 1886a4a2..81d5c58 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -32,6 +32,7 @@
class BezierCubicOrConicTestBatch : public GrTestBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry : public GrTestBatch::Geometry {
SkRect fBounds;
};
@@ -46,8 +47,7 @@
private:
BezierCubicOrConicTestBatch(const GrGeometryProcessor* gp, const Geometry& geo,
const SkScalar klmEqs[9], SkScalar sign)
- : INHERITED(gp, geo.fBounds) {
- this->initClassID<BezierCubicOrConicTestBatch>();
+ : INHERITED(ClassID(), gp, geo.fBounds) {
for (int i = 0; i < 9; i++) {
fKlmEqs[i] = klmEqs[i];
}
@@ -432,6 +432,7 @@
class BezierQuadTestBatch : public GrTestBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry : public GrTestBatch::Geometry {
SkRect fBounds;
};
@@ -446,10 +447,9 @@
private:
BezierQuadTestBatch(const GrGeometryProcessor* gp, const Geometry& geo,
const GrPathUtils::QuadUVMatrix& devToUV)
- : INHERITED(gp, geo.fBounds)
+ : INHERITED(ClassID(), gp, geo.fBounds)
, fGeometry(geo)
, fDevToUV(devToUV) {
- this->initClassID<BezierQuadTestBatch>();
}
struct Vertex {
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index c014e6a..35cc498 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -31,6 +31,7 @@
class ConvexPolyTestBatch : public GrTestBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry : public GrTestBatch::Geometry {
SkRect fBounds;
};
@@ -43,9 +44,8 @@
private:
ConvexPolyTestBatch(const GrGeometryProcessor* gp, const Geometry& geo)
- : INHERITED(gp, geo.fBounds)
+ : INHERITED(ClassID(), gp, geo.fBounds)
, fGeometry(geo) {
- this->initClassID<ConvexPolyTestBatch>();
}
Geometry* geoData(int index) override {
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index fa96a8d..822c480 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -1431,6 +1431,8 @@
class TextBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
typedef GrAtlasTextContext::DistanceAdjustTable DistanceAdjustTable;
typedef GrAtlasTextBlob Blob;
typedef Blob::Run Run;
@@ -1448,7 +1450,6 @@
GrBatchFontCache* fontCache) {
TextBatch* batch = new TextBatch;
- batch->initClassID<TextBatch>();
batch->fFontCache = fontCache;
switch (maskFormat) {
case kA8_GrMaskFormat:
@@ -1474,7 +1475,7 @@
SkColor filteredColor, bool isLCD,
bool useBGR) {
TextBatch* batch = new TextBatch;
- batch->initClassID<TextBatch>();
+
batch->fFontCache = fontCache;
batch->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistanceField_MaskType;
batch->fDistanceAdjustTable.reset(SkRef(distanceAdjustTable));
@@ -1783,7 +1784,7 @@
this->flush(target, &flushInfo);
}
- TextBatch() {} // initialized in factory functions.
+ TextBatch() : INHERITED(ClassID()) {} // initialized in factory functions.
~TextBatch() {
for (int i = 0; i < fGeoCount; i++) {
@@ -2044,6 +2045,8 @@
// Distance field properties
SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable;
SkColor fFilteredColor;
+
+ typedef GrVertexBatch INHERITED;
};
void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt,
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index cae1552..b12ac99 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -23,6 +23,7 @@
#include "SkClipStack.h"
#include "SkMatrix.h"
#include "SkPath.h"
+#include "SkStringUtils.h"
#include "SkStrokeRec.h"
#include "SkTArray.h"
#include "SkTLazy.h"
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp
index 8eed382..8a938c2 100644
--- a/src/gpu/GrOvalRenderer.cpp
+++ b/src/gpu/GrOvalRenderer.cpp
@@ -606,13 +606,15 @@
class CircleBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
- GrColor fColor;
SkMatrix fViewMatrix;
+ SkRect fDevBounds;
SkScalar fInnerRadius;
SkScalar fOuterRadius;
+ GrColor fColor;
bool fStroke;
- SkRect fDevBounds;
};
static GrDrawBatch* Create(const Geometry& geometry) { return new CircleBatch(geometry); }
@@ -705,8 +707,7 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
- CircleBatch(const Geometry& geometry) {
- this->initClassID<CircleBatch>();
+ CircleBatch(const Geometry& geometry) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
@@ -753,6 +754,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_circle_batch(GrColor color,
@@ -821,15 +824,17 @@
class EllipseBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
- GrColor fColor;
SkMatrix fViewMatrix;
+ SkRect fDevBounds;
SkScalar fXRadius;
SkScalar fYRadius;
SkScalar fInnerXRadius;
SkScalar fInnerYRadius;
+ GrColor fColor;
bool fStroke;
- SkRect fDevBounds;
};
static GrDrawBatch* Create(const Geometry& geometry) { return new EllipseBatch(geometry); }
@@ -926,8 +931,7 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
- EllipseBatch(const Geometry& geometry) {
- this->initClassID<EllipseBatch>();
+ EllipseBatch(const Geometry& geometry) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
@@ -975,6 +979,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_ellipse_batch(GrColor color,
@@ -1085,17 +1091,19 @@
class DIEllipseBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
- GrColor fColor;
SkMatrix fViewMatrix;
+ SkRect fBounds;
SkScalar fXRadius;
SkScalar fYRadius;
SkScalar fInnerXRadius;
SkScalar fInnerYRadius;
SkScalar fGeoDx;
SkScalar fGeoDy;
+ GrColor fColor;
DIEllipseEdgeEffect::Mode fMode;
- SkRect fBounds;
};
static GrDrawBatch* Create(const Geometry& geometry, const SkRect& bounds) {
@@ -1186,8 +1194,7 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
- DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) {
- this->initClassID<DIEllipseBatch>();
+ DIEllipseBatch(const Geometry& geometry, const SkRect& bounds) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
this->setBounds(bounds);
@@ -1234,6 +1241,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_diellipse_batch(GrColor color,
@@ -1441,13 +1450,15 @@
class RRectCircleRendererBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
- GrColor fColor;
SkMatrix fViewMatrix;
+ SkRect fDevBounds;
SkScalar fInnerRadius;
SkScalar fOuterRadius;
+ GrColor fColor;
bool fStroke;
- SkRect fDevBounds;
};
static GrDrawBatch* Create(const Geometry& geometry) {
@@ -1563,8 +1574,7 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
- RRectCircleRendererBatch(const Geometry& geometry) {
- this->initClassID<RRectCircleRendererBatch>();
+ RRectCircleRendererBatch(const Geometry& geometry) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
@@ -1611,19 +1621,23 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
class RRectEllipseRendererBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
- GrColor fColor;
SkMatrix fViewMatrix;
+ SkRect fDevBounds;
SkScalar fXRadius;
SkScalar fYRadius;
SkScalar fInnerXRadius;
SkScalar fInnerYRadius;
+ GrColor fColor;
bool fStroke;
- SkRect fDevBounds;
};
static GrDrawBatch* Create(const Geometry& geometry) {
@@ -1749,8 +1763,7 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
- RRectEllipseRendererBatch(const Geometry& geometry) {
- this->initClassID<RRectEllipseRendererBatch>();
+ RRectEllipseRendererBatch(const Geometry& geometry) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
this->setBounds(geometry.fDevBounds);
@@ -1798,6 +1811,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_rrect_batch(GrColor color,
diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp
index 75bf332..543885e 100644
--- a/src/gpu/batches/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp
@@ -733,6 +733,7 @@
class AAConvexPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry {
GrColor fColor;
SkMatrix fViewMatrix;
@@ -752,7 +753,6 @@
}
private:
-
void initBatchTracker(const GrPipelineOptimizations& opt) override {
// Handle any color overrides
if (!opt.readsColor()) {
@@ -921,8 +921,7 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
- AAConvexPathBatch(const Geometry& geometry) {
- this->initClassID<AAConvexPathBatch>();
+ AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
// compute bounds
@@ -979,6 +978,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index f06553c..ee5fdb8 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -111,6 +111,8 @@
class AADistanceFieldPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
typedef GrAADistanceFieldPathRenderer::PathData PathData;
typedef SkTDynamicHash<PathData, PathData::Key> PathCache;
typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList;
@@ -276,8 +278,8 @@
AADistanceFieldPathBatch(const Geometry& geometry, GrColor color, const SkMatrix& viewMatrix,
GrBatchAtlas* atlas,
- PathCache* pathCache, PathDataList* pathList) {
- this->initClassID<AADistanceFieldPathBatch>();
+ PathCache* pathCache, PathDataList* pathList)
+ : INHERITED(ClassID()) {
fBatch.fColor = color;
fBatch.fViewMatrix = viewMatrix;
fGeoData.push_back(geometry);
@@ -519,6 +521,8 @@
GrBatchAtlas* fAtlas;
PathCache* fPathCache;
PathDataList* fPathList;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
diff --git a/src/gpu/batches/GrAAHairLinePathRenderer.cpp b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
index c6bdd055..d17ed09 100644
--- a/src/gpu/batches/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/batches/GrAAHairLinePathRenderer.cpp
@@ -672,6 +672,8 @@
class AAHairlineBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
uint8_t fCoverage;
@@ -716,8 +718,7 @@
typedef SkTArray<int, true> IntArray;
typedef SkTArray<float, true> FloatArray;
- AAHairlineBatch(const Geometry& geometry) {
- this->initClassID<AAHairlineBatch>();
+ AAHairlineBatch(const Geometry& geometry) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
// compute bounds
@@ -785,6 +786,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
void AAHairlineBatch::onPrepareDraws(Target* target) {
diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
index d05fe4e..a7e9824 100644
--- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
@@ -119,6 +119,8 @@
class AAFlatteningConvexPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkMatrix fViewMatrix;
@@ -258,8 +260,7 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
- AAFlatteningConvexPathBatch(const Geometry& geometry) {
- this->initClassID<AAFlatteningConvexPathBatch>();
+ AAFlatteningConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
// compute bounds
@@ -308,6 +309,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.h b/src/gpu/batches/GrAAStrokeRectBatch.h
index ae75348..fad5bd9 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.h
+++ b/src/gpu/batches/GrAAStrokeRectBatch.h
@@ -18,6 +18,8 @@
class GrAAStrokeRectBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
// TODO support AA rotated stroke rects by copying around view matrices
struct Geometry {
GrColor fColor;
@@ -48,8 +50,8 @@
void onPrepareDraws(Target*) override;
void initBatchTracker(const GrPipelineOptimizations&) override;
- GrAAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix) {
- this->initClassID<GrAAStrokeRectBatch>();
+ GrAAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix)
+ : INHERITED(ClassID()) {
fBatch.fViewMatrix = viewMatrix;
fGeoData.push_back(geometry);
@@ -105,6 +107,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
diff --git a/src/gpu/batches/GrBatch.cpp b/src/gpu/batches/GrBatch.cpp
index a3a9884..19c19ff 100644
--- a/src/gpu/batches/GrBatch.cpp
+++ b/src/gpu/batches/GrBatch.cpp
@@ -46,10 +46,10 @@
return MemoryPoolAccessor().pool()->release(target);
}
-GrBatch::GrBatch()
- : fClassID(kIllegalBatchID)
+GrBatch::GrBatch(uint32_t classID)
+ : fClassID(classID)
#if GR_BATCH_SPEW
- , fUniqueID(GenID(&gCurrBatchUniqueID))
+ , fUniqueID(GenBatchID())
#endif
{
SkDEBUGCODE(fUsed = false;)
diff --git a/src/gpu/batches/GrBatch.h b/src/gpu/batches/GrBatch.h
index b6eec1f..c5fc80c 100644
--- a/src/gpu/batches/GrBatch.h
+++ b/src/gpu/batches/GrBatch.h
@@ -41,9 +41,16 @@
#define GrBATCH_INFO(...)
#endif
+// A helper macro to generate a class static id
+#define DEFINE_BATCH_CLASS_ID \
+ static uint32_t ClassID() { \
+ static uint32_t kClassID = GenBatchClassID(); \
+ return kClassID; \
+ }
+
class GrBatch : public GrNonAtomicRef {
public:
- GrBatch();
+ GrBatch(uint32_t classID);
~GrBatch() override;
virtual const char* name() const = 0;
@@ -69,10 +76,17 @@
}
/**
- * Helper for down-casting to a GrBatch subclass
+ * Helper for safely down-casting to a GrBatch subclass
*/
- template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
- template <typename T> T* cast() { return static_cast<T*>(this); }
+ template <typename T> const T& cast() const {
+ SkASSERT(T::ClassID() == this->classID());
+ return *static_cast<const T*>(this);
+ }
+
+ template <typename T> T* cast() {
+ SkASSERT(T::ClassID() == this->classID());
+ return static_cast<T*>(this);
+ }
uint32_t classID() const { SkASSERT(kIllegalBatchID != fClassID); return fClassID; }
@@ -96,11 +110,6 @@
virtual SkString dumpInfo() const = 0;
protected:
- template <typename PROC_SUBCLASS> void initClassID() {
- static uint32_t kClassID = GenID(&gCurrBatchClassID);
- fClassID = kClassID;
- }
-
// NOTE, compute some bounds, even if extremely conservative. Do *NOT* setLargest on the bounds
// rect because we outset it for dst copy textures
void setBounds(const SkRect& newBounds) { fBounds = newBounds; }
@@ -109,6 +118,8 @@
return fBounds.joinPossiblyEmptyRect(otherBounds);
}
+ static uint32_t GenBatchClassID() { return GenID(&gCurrBatchClassID); }
+
SkRect fBounds;
private:
@@ -118,8 +129,7 @@
virtual void onDraw(GrBatchFlushState*) = 0;
static uint32_t GenID(int32_t* idCounter) {
- // fCurrProcessorClassID has been initialized to kIllegalProcessorClassID. The
- // atomic inc returns the old value not the incremented value. So we add
+ // The atomic inc returns the old value not the incremented value. So we add
// 1 to the returned value.
uint32_t id = static_cast<uint32_t>(sk_atomic_inc(idCounter)) + 1;
if (!id) {
@@ -133,13 +143,14 @@
kIllegalBatchID = 0,
};
- uint32_t fClassID;
SkDEBUGCODE(bool fUsed;)
+ const uint32_t fClassID;
#if GR_BATCH_SPEW
- uint32_t fUniqueID;
- static int32_t gCurrBatchUniqueID;
+ static uint32_t GenBatchID() { return GenID(&gCurrBatchUniqueID); }
+ const uint32_t fUniqueID;
+ static int32_t gCurrBatchUniqueID;
#endif
- static int32_t gCurrBatchClassID;
+ static int32_t gCurrBatchClassID;
typedef GrNonAtomicRef INHERITED;
};
diff --git a/src/gpu/batches/GrClearBatch.h b/src/gpu/batches/GrClearBatch.h
index f13b073..b973dab 100644
--- a/src/gpu/batches/GrClearBatch.h
+++ b/src/gpu/batches/GrClearBatch.h
@@ -15,11 +15,13 @@
class GrClearBatch final : public GrBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
GrClearBatch(const SkIRect& rect, GrColor color, GrRenderTarget* rt)
- : fRect(rect)
+ : INHERITED(ClassID())
+ , fRect(rect)
, fColor(color)
, fRenderTarget(rt) {
- this->initClassID<GrClearBatch>();
fBounds = SkRect::Make(rect);
}
@@ -50,15 +52,19 @@
SkIRect fRect;
GrColor fColor;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
+
+ typedef GrBatch INHERITED;
};
class GrClearStencilClipBatch final : public GrBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
GrClearStencilClipBatch(const SkIRect& rect, bool insideClip, GrRenderTarget* rt)
- : fRect(rect)
+ : INHERITED(ClassID())
+ , fRect(rect)
, fInsideClip(insideClip)
, fRenderTarget(rt) {
- this->initClassID<GrClearStencilClipBatch>();
fBounds = SkRect::Make(rect);
}
@@ -86,6 +92,8 @@
SkIRect fRect;
bool fInsideClip;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
+
+ typedef GrBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrCopySurfaceBatch.h b/src/gpu/batches/GrCopySurfaceBatch.h
index 584bbab..ed5e77f 100644
--- a/src/gpu/batches/GrCopySurfaceBatch.h
+++ b/src/gpu/batches/GrCopySurfaceBatch.h
@@ -15,6 +15,8 @@
class GrCopySurfaceBatch final : public GrBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
static GrBatch* Create(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
const SkIPoint& dstPoint);
@@ -37,11 +39,11 @@
private:
GrCopySurfaceBatch(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
const SkIPoint& dstPoint)
- : fDst(dst)
+ : INHERITED(ClassID())
+ , fDst(dst)
, fSrc(src)
, fSrcRect(srcRect)
, fDstPoint(dstPoint) {
- this->initClassID<GrCopySurfaceBatch>();
fBounds = SkRect::MakeXYWH(SkIntToScalar(dstPoint.fX), SkIntToScalar(dstPoint.fY),
SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
}
@@ -58,6 +60,8 @@
GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
SkIRect fSrcRect;
SkIPoint fDstPoint;
+
+ typedef GrBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp
index f4ce7c8..67bccb6 100644
--- a/src/gpu/batches/GrDefaultPathRenderer.cpp
+++ b/src/gpu/batches/GrDefaultPathRenderer.cpp
@@ -211,6 +211,8 @@
class DefaultPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkPath fPath;
@@ -376,8 +378,8 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
DefaultPathBatch(const Geometry& geometry, uint8_t coverage, const SkMatrix& viewMatrix,
- bool isHairline, const SkRect& devBounds) {
- this->initClassID<DefaultPathBatch>();
+ bool isHairline, const SkRect& devBounds)
+ : INHERITED(ClassID()) {
fBatch.fCoverage = coverage;
fBatch.fIsHairline = isHairline;
fBatch.fViewMatrix = viewMatrix;
@@ -530,6 +532,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
diff --git a/src/gpu/batches/GrDiscardBatch.h b/src/gpu/batches/GrDiscardBatch.h
index 8a050a7..c13e732 100644
--- a/src/gpu/batches/GrDiscardBatch.h
+++ b/src/gpu/batches/GrDiscardBatch.h
@@ -15,9 +15,11 @@
class GrDiscardBatch final : public GrBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
GrDiscardBatch(GrRenderTarget* rt)
- : fRenderTarget(rt) {
- this->initClassID<GrDiscardBatch>();
+ : INHERITED(ClassID())
+ , fRenderTarget(rt) {
fBounds = SkRect::MakeWH(SkIntToScalar(rt->width()), SkIntToScalar(rt->height()));
}
@@ -43,6 +45,8 @@
}
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
+
+ typedef GrBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrDrawAtlasBatch.cpp b/src/gpu/batches/GrDrawAtlasBatch.cpp
index 3596e16..2254e9c 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.cpp
+++ b/src/gpu/batches/GrDrawAtlasBatch.cpp
@@ -77,8 +77,8 @@
GrDrawAtlasBatch::GrDrawAtlasBatch(const Geometry& geometry, const SkMatrix& viewMatrix,
int spriteCount, const SkRSXform* xforms, const SkRect* rects,
- const SkColor* colors) {
- this->initClassID<GrDrawAtlasBatch>();
+ const SkColor* colors)
+ : INHERITED(ClassID()) {
SkASSERT(xforms);
SkASSERT(rects);
diff --git a/src/gpu/batches/GrDrawAtlasBatch.h b/src/gpu/batches/GrDrawAtlasBatch.h
index 9a864c0..de128f2 100644
--- a/src/gpu/batches/GrDrawAtlasBatch.h
+++ b/src/gpu/batches/GrDrawAtlasBatch.h
@@ -14,11 +14,13 @@
class GrDrawAtlasBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkTArray<uint8_t, true> fVerts;
};
-
+
static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix,
int spriteCount, const SkRSXform* xforms, const SkRect* rects,
const SkColor* colors) {
@@ -66,6 +68,8 @@
bool fColorIgnored;
bool fCoverageIgnored;
bool fHasColors;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrDrawBatch.cpp b/src/gpu/batches/GrDrawBatch.cpp
index 5e5d412..43ef2ec 100644
--- a/src/gpu/batches/GrDrawBatch.cpp
+++ b/src/gpu/batches/GrDrawBatch.cpp
@@ -7,7 +7,7 @@
#include "GrDrawBatch.h"
-GrDrawBatch::GrDrawBatch() : fPipelineInstalled(false) { }
+GrDrawBatch::GrDrawBatch(uint32_t classID) : INHERITED(classID), fPipelineInstalled(false) { }
GrDrawBatch::~GrDrawBatch() {
if (fPipelineInstalled) {
diff --git a/src/gpu/batches/GrDrawBatch.h b/src/gpu/batches/GrDrawBatch.h
index f7c206d..93326efa 100644
--- a/src/gpu/batches/GrDrawBatch.h
+++ b/src/gpu/batches/GrDrawBatch.h
@@ -40,7 +40,7 @@
public:
class Target;
- GrDrawBatch();
+ GrDrawBatch(uint32_t classID);
~GrDrawBatch() override;
virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
diff --git a/src/gpu/batches/GrDrawPathBatch.cpp b/src/gpu/batches/GrDrawPathBatch.cpp
index a47e665..c56c4ad 100644
--- a/src/gpu/batches/GrDrawPathBatch.cpp
+++ b/src/gpu/batches/GrDrawPathBatch.cpp
@@ -57,11 +57,10 @@
GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix,
GrColor color, GrPathRangeDraw* pathRangeDraw)
- : INHERITED(viewMatrix, color)
+ : INHERITED(ClassID(), viewMatrix, color)
, fDraws(4)
, fLocalMatrix(localMatrix) {
SkDEBUGCODE(pathRangeDraw->fUsedInBatch = true;)
- this->initClassID<GrDrawPathRangeBatch>();
fDraws.addToHead(SkRef(pathRangeDraw));
fTotalPathCount = pathRangeDraw->count();
// Don't compute a bounding box. For dst copy texture, we'll opt instead for it to just copy
diff --git a/src/gpu/batches/GrDrawPathBatch.h b/src/gpu/batches/GrDrawPathBatch.h
index 71ef9d4..228ad86 100644
--- a/src/gpu/batches/GrDrawPathBatch.h
+++ b/src/gpu/batches/GrDrawPathBatch.h
@@ -30,8 +30,9 @@
void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings = stencil; }
protected:
- GrDrawPathBatchBase(const SkMatrix& viewMatrix, GrColor initialColor)
- : fViewMatrix(viewMatrix)
+ GrDrawPathBatchBase(uint32_t classID, const SkMatrix& viewMatrix, GrColor initialColor)
+ : INHERITED(classID)
+ , fViewMatrix(viewMatrix)
, fColor(initialColor) {}
const GrStencilSettings& stencilSettings() const { return fStencilSettings; }
@@ -55,6 +56,8 @@
class GrDrawPathBatch final : public GrDrawPathBatchBase {
public:
+ DEFINE_BATCH_CLASS_ID
+
// This can't return a more abstract type because we install the stencil settings late :(
static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, GrColor color,
const GrPath* path) {
@@ -67,11 +70,10 @@
private:
GrDrawPathBatch(const SkMatrix& viewMatrix, GrColor color, const GrPath* path)
- : INHERITED(viewMatrix, color)
+ : INHERITED(ClassID(), viewMatrix, color)
, fPath(path) {
fBounds = path->getBounds();
viewMatrix.mapRect(&fBounds);
- this->initClassID<GrDrawPathBatch>();
}
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; }
@@ -147,7 +149,9 @@
// Template this if we decide to support index types other than 16bit
class GrDrawPathRangeBatch final : public GrDrawPathBatchBase {
public:
- // This can't return a more abstracet type because we install the stencil settings late :(
+ DEFINE_BATCH_CLASS_ID
+
+ // This can't return a more abstract type because we install the stencil settings late :(
static GrDrawPathBatchBase* Create(const SkMatrix& viewMatrix, const SkMatrix& localMatrix,
GrColor color, GrPathRangeDraw* pathRangeDraw) {
return SkNEW_ARGS(GrDrawPathRangeBatch, (viewMatrix, localMatrix, color, pathRangeDraw));
diff --git a/src/gpu/batches/GrDrawVerticesBatch.cpp b/src/gpu/batches/GrDrawVerticesBatch.cpp
index f79b685..33bed0d 100644
--- a/src/gpu/batches/GrDrawVerticesBatch.cpp
+++ b/src/gpu/batches/GrDrawVerticesBatch.cpp
@@ -45,8 +45,8 @@
const SkPoint* positions, int vertexCount,
const uint16_t* indices, int indexCount,
const GrColor* colors, const SkPoint* localCoords,
- const SkRect& bounds) {
- this->initClassID<GrDrawVerticesBatch>();
+ const SkRect& bounds)
+ : INHERITED(ClassID()) {
SkASSERT(positions);
fBatch.fViewMatrix = viewMatrix;
diff --git a/src/gpu/batches/GrDrawVerticesBatch.h b/src/gpu/batches/GrDrawVerticesBatch.h
index aaa7b09..49e93c8 100644
--- a/src/gpu/batches/GrDrawVerticesBatch.h
+++ b/src/gpu/batches/GrDrawVerticesBatch.h
@@ -20,6 +20,8 @@
class GrDrawVerticesBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkTDArray<SkPoint> fPositions;
@@ -91,6 +93,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrStencilPathBatch.h b/src/gpu/batches/GrStencilPathBatch.h
index 9f6740a..a0dcadb 100644
--- a/src/gpu/batches/GrStencilPathBatch.h
+++ b/src/gpu/batches/GrStencilPathBatch.h
@@ -17,6 +17,8 @@
class GrStencilPathBatch final : public GrBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
static GrBatch* Create(const SkMatrix& viewMatrix,
bool useHWAA,
const GrStencilSettings& stencil,
@@ -43,13 +45,13 @@
const GrScissorState& scissor,
GrRenderTarget* renderTarget,
const GrPath* path)
- : fViewMatrix(viewMatrix)
+ : INHERITED(ClassID())
+ , fViewMatrix(viewMatrix)
, fUseHWAA(useHWAA)
, fStencil(stencil)
, fScissor(scissor)
, fRenderTarget(renderTarget)
, fPath(path) {
- this->initClassID<GrStencilPathBatch>();
fBounds = path->getBounds();
}
@@ -69,6 +71,8 @@
GrScissorState fScissor;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
+
+ typedef GrBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrStrokeRectBatch.cpp b/src/gpu/batches/GrStrokeRectBatch.cpp
index 766302b..20c754c 100644
--- a/src/gpu/batches/GrStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrStrokeRectBatch.cpp
@@ -10,9 +10,8 @@
#include "GrBatchFlushState.h"
#include "SkRandom.h"
-GrStrokeRectBatch::GrStrokeRectBatch(const Geometry& geometry, bool snapToPixelCenters) {
- this->initClassID<GrStrokeRectBatch>();
-
+GrStrokeRectBatch::GrStrokeRectBatch(const Geometry& geometry, bool snapToPixelCenters)
+ : INHERITED(ClassID()) {
fBatch.fHairline = geometry.fStrokeWidth == 0;
fGeoData.push_back(geometry);
diff --git a/src/gpu/batches/GrStrokeRectBatch.h b/src/gpu/batches/GrStrokeRectBatch.h
index b374ea8..b1cb8d4 100644
--- a/src/gpu/batches/GrStrokeRectBatch.h
+++ b/src/gpu/batches/GrStrokeRectBatch.h
@@ -14,6 +14,8 @@
class GrStrokeRectBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkMatrix fViewMatrix;
@@ -74,6 +76,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrTInstanceBatch.h b/src/gpu/batches/GrTInstanceBatch.h
index e314959..014ec12 100644
--- a/src/gpu/batches/GrTInstanceBatch.h
+++ b/src/gpu/batches/GrTInstanceBatch.h
@@ -40,6 +40,8 @@
template <typename Impl>
class GrTInstanceBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
typedef typename Impl::Geometry Geometry;
static GrTInstanceBatch* Create() { return new GrTInstanceBatch; }
@@ -72,9 +74,7 @@
}
private:
- GrTInstanceBatch() {
- this->initClassID<GrTInstanceBatch<Impl>>();
-
+ GrTInstanceBatch() : INHERITED(ClassID()) {
// Push back an initial geometry
fGeoData.push_back();
}
@@ -136,6 +136,8 @@
GrPipelineOptimizations fOpts;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrTessellatingPathRenderer.cpp b/src/gpu/batches/GrTessellatingPathRenderer.cpp
index 46fa280..901d383 100644
--- a/src/gpu/batches/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/batches/GrTessellatingPathRenderer.cpp
@@ -1385,6 +1385,7 @@
class TessellatingPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
static GrDrawBatch* Create(const GrColor& color,
const SkPath& path,
@@ -1587,13 +1588,12 @@
const GrStrokeInfo& stroke,
const SkMatrix& viewMatrix,
const SkRect& clipBounds)
- : fColor(color)
+ : INHERITED(ClassID())
+ , fColor(color)
, fPath(path)
, fStroke(stroke)
, fViewMatrix(viewMatrix)
, fClipBounds(clipBounds) {
- this->initClassID<TessellatingPathBatch>();
-
fBounds = path.getBounds();
if (!stroke.isFillStyle()) {
SkScalar radius = SkScalarHalf(stroke.getWidth());
@@ -1614,6 +1614,8 @@
SkMatrix fViewMatrix;
SkRect fClipBounds; // in source space
GrPipelineOptimizations fPipelineInfo;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
diff --git a/src/gpu/batches/GrTestBatch.h b/src/gpu/batches/GrTestBatch.h
index 085b184..02881c9 100644
--- a/src/gpu/batches/GrTestBatch.h
+++ b/src/gpu/batches/GrTestBatch.h
@@ -50,7 +50,8 @@
}
protected:
- GrTestBatch(const GrGeometryProcessor* gp, const SkRect& bounds) {
+ GrTestBatch(uint32_t classID, const GrGeometryProcessor* gp, const SkRect& bounds)
+ : INHERITED(classID) {
fGeometryProcessor.reset(SkRef(gp));
this->setBounds(bounds);
@@ -82,6 +83,8 @@
SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
BatchTracker fBatch;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
diff --git a/src/gpu/batches/GrVertexBatch.cpp b/src/gpu/batches/GrVertexBatch.cpp
index 6e2c157..9ffe518 100644
--- a/src/gpu/batches/GrVertexBatch.cpp
+++ b/src/gpu/batches/GrVertexBatch.cpp
@@ -9,7 +9,7 @@
#include "GrBatchFlushState.h"
#include "GrResourceProvider.h"
-GrVertexBatch::GrVertexBatch() : fDrawArrays(1) {}
+GrVertexBatch::GrVertexBatch(uint32_t classID) : INHERITED(classID), fDrawArrays(1) {}
void GrVertexBatch::onPrepare(GrBatchFlushState* state) {
Target target(state, this);
diff --git a/src/gpu/batches/GrVertexBatch.h b/src/gpu/batches/GrVertexBatch.h
index e2265bc..8922c30 100644
--- a/src/gpu/batches/GrVertexBatch.h
+++ b/src/gpu/batches/GrVertexBatch.h
@@ -24,7 +24,7 @@
public:
class Target;
- GrVertexBatch();
+ GrVertexBatch(uint32_t classID);
protected:
/** Helper for rendering instances using an instanced index index buffer. This class creates the
diff --git a/src/gpu/effects/GrDashingEffect.cpp b/src/gpu/effects/GrDashingEffect.cpp
index 3ca4c7a..106ee49 100644
--- a/src/gpu/effects/GrDashingEffect.cpp
+++ b/src/gpu/effects/GrDashingEffect.cpp
@@ -245,8 +245,9 @@
class DashBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
- GrColor fColor;
SkMatrix fViewMatrix;
SkMatrix fSrcRotInv;
SkPoint fPtsRot[2];
@@ -255,6 +256,7 @@
SkScalar fIntervals[2];
SkScalar fParallelScale;
SkScalar fPerpendicularScale;
+ GrColor fColor;
};
static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode,
@@ -275,8 +277,8 @@
SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
private:
- DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, bool fullDash) {
- this->initClassID<DashBatch>();
+ DashBatch(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode, bool fullDash)
+ : INHERITED(ClassID()) {
fGeoData.push_back(geometry);
fBatch.fAAMode = aaMode;
@@ -674,6 +676,8 @@
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const SkPoint pts[2],
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 1328272a..a61ab548 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -1093,7 +1093,13 @@
}
static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps) {
- class : public GrVertexBatch {
+ class TestLCDCoverageBatch: public GrVertexBatch {
+ public:
+ DEFINE_BATCH_CLASS_ID
+
+ TestLCDCoverageBatch() : INHERITED(ClassID()) {}
+
+ private:
void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
out->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221));
}
@@ -1108,6 +1114,7 @@
bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; }
void onPrepareDraws(Target*) override {};
+ typedef GrVertexBatch INHERITED;
} testLCDCoverageBatch;
GrProcOptInfo colorPOI, covPOI;