class BezierCubicOrConicTestBatch : public GrTestBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry : public GrTestBatch::Geometry {
SkRect fBounds;
};
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];
}
class BezierQuadTestBatch : public GrTestBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry : public GrTestBatch::Geometry {
SkRect fBounds;
};
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 {
class ConvexPolyTestBatch : public GrTestBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry : public GrTestBatch::Geometry {
SkRect fBounds;
};
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 {
class TextBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
typedef GrAtlasTextContext::DistanceAdjustTable DistanceAdjustTable;
typedef GrAtlasTextBlob Blob;
typedef Blob::Run Run;
GrBatchFontCache* fontCache) {
TextBatch* batch = new TextBatch;
- batch->initClassID<TextBatch>();
batch->fFontCache = fontCache;
switch (maskFormat) {
case kA8_GrMaskFormat:
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));
this->flush(target, &flushInfo);
}
- TextBatch() {} // initialized in factory functions.
+ TextBatch() : INHERITED(ClassID()) {} // initialized in factory functions.
~TextBatch() {
for (int i = 0; i < fGeoCount; i++) {
// Distance field properties
SkAutoTUnref<const DistanceAdjustTable> fDistanceAdjustTable;
SkColor fFilteredColor;
+
+ typedef GrVertexBatch INHERITED;
};
void GrAtlasTextContext::flushRunAsPaths(GrDrawContext* dc, GrRenderTarget* rt,
#include "SkClipStack.h"
#include "SkMatrix.h"
#include "SkPath.h"
+#include "SkStringUtils.h"
#include "SkStrokeRec.h"
#include "SkTArray.h"
#include "SkTLazy.h"
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); }
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);
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_circle_batch(GrColor color,
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); }
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);
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_ellipse_batch(GrColor color,
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) {
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);
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_diellipse_batch(GrColor color,
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) {
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);
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) {
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);
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_rrect_batch(GrColor color,
class AAConvexPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
struct Geometry {
GrColor fColor;
SkMatrix fViewMatrix;
}
private:
-
void initBatchTracker(const GrPipelineOptimizations& opt) override {
// Handle any color overrides
if (!opt.readsColor()) {
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
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
class AADistanceFieldPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
typedef GrAADistanceFieldPathRenderer::PathData PathData;
typedef SkTDynamicHash<PathData, PathData::Key> PathCache;
typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList;
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);
GrBatchAtlas* fAtlas;
PathCache* fPathCache;
PathDataList* fPathList;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
class AAHairlineBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
uint8_t fCoverage;
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
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
void AAHairlineBatch::onPrepareDraws(Target* target) {
class AAFlatteningConvexPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkMatrix fViewMatrix;
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
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
class GrAAStrokeRectBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
// TODO support AA rotated stroke rects by copying around view matrices
struct Geometry {
GrColor fColor;
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);
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
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;)
#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;
}
/**
- * 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; }
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; }
return fBounds.joinPossiblyEmptyRect(otherBounds);
}
+ static uint32_t GenBatchClassID() { return GenID(&gCurrBatchClassID); }
+
SkRect fBounds;
private:
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) {
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;
};
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);
}
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);
}
SkIRect fRect;
bool fInsideClip;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
+
+ typedef GrBatch INHERITED;
};
#endif
class GrCopySurfaceBatch final : public GrBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
static GrBatch* Create(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
const SkIPoint& dstPoint);
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()));
}
GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
SkIRect fSrcRect;
SkIPoint fDstPoint;
+
+ typedef GrBatch INHERITED;
};
#endif
class DefaultPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkPath fPath;
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;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
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()));
}
}
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
+
+ typedef GrBatch INHERITED;
};
#endif
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);
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) {
bool fColorIgnored;
bool fCoverageIgnored;
bool fHasColors;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
#include "GrDrawBatch.h"
-GrDrawBatch::GrDrawBatch() : fPipelineInstalled(false) { }
+GrDrawBatch::GrDrawBatch(uint32_t classID) : INHERITED(classID), fPipelineInstalled(false) { }
GrDrawBatch::~GrDrawBatch() {
if (fPipelineInstalled) {
public:
class Target;
- GrDrawBatch();
+ GrDrawBatch(uint32_t classID);
~GrDrawBatch() override;
virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const = 0;
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
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; }
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) {
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; }
// 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));
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;
class GrDrawVerticesBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkTDArray<SkPoint> fPositions;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
class GrStencilPathBatch final : public GrBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
static GrBatch* Create(const SkMatrix& viewMatrix,
bool useHWAA,
const GrStencilSettings& stencil,
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();
}
GrScissorState fScissor;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
+
+ typedef GrBatch INHERITED;
};
#endif
#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);
class GrStrokeRectBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
GrColor fColor;
SkMatrix fViewMatrix;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
template <typename Impl>
class GrTInstanceBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
typedef typename Impl::Geometry Geometry;
static GrTInstanceBatch* Create() { return new GrTInstanceBatch; }
}
private:
- GrTInstanceBatch() {
- this->initClassID<GrTInstanceBatch<Impl>>();
-
+ GrTInstanceBatch() : INHERITED(ClassID()) {
// Push back an initial geometry
fGeoData.push_back();
}
GrPipelineOptimizations fOpts;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
class TessellatingPathBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
static GrDrawBatch* Create(const GrColor& color,
const SkPath& path,
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());
SkMatrix fViewMatrix;
SkRect fClipBounds; // in source space
GrPipelineOptimizations fPipelineInfo;
+
+ typedef GrVertexBatch INHERITED;
};
bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
}
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);
SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
BatchTracker fBatch;
+
+ typedef GrVertexBatch INHERITED;
};
#endif
#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);
public:
class Target;
- GrVertexBatch();
+ GrVertexBatch(uint32_t classID);
protected:
/** Helper for rendering instances using an instanced index index buffer. This class creates the
class DashBatch : public GrVertexBatch {
public:
+ DEFINE_BATCH_CLASS_ID
+
struct Geometry {
- GrColor fColor;
SkMatrix fViewMatrix;
SkMatrix fSrcRotInv;
SkPoint fPtsRot[2];
SkScalar fIntervals[2];
SkScalar fParallelScale;
SkScalar fPerpendicularScale;
+ GrColor fColor;
};
static GrDrawBatch* Create(const Geometry& geometry, SkPaint::Cap cap, DashAAMode aaMode,
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;
BatchTracker fBatch;
SkSTArray<1, Geometry, true> fGeoData;
+
+ typedef GrVertexBatch INHERITED;
};
static GrDrawBatch* create_batch(GrColor color, const SkMatrix& viewMatrix, const SkPoint pts[2],
}
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));
}
bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; }
void onPrepareDraws(Target*) override {};
+ typedef GrVertexBatch INHERITED;
} testLCDCoverageBatch;
GrProcOptInfo colorPOI, covPOI;