Rename GrTestBatch and subclasses to Op

Change-Id: Ideab66b7ca227057a767be48aba3ea69a0a19115
Reviewed-on: https://skia-review.googlesource.com/6161
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Salomon 2016-12-16 09:35:49 -05:00 committed by Skia Commit-Bot
parent 99ad164886
commit 6b316e9e20
5 changed files with 47 additions and 40 deletions

View File

@ -18,7 +18,7 @@
#include "SkColorPriv.h"
#include "SkGeometry.h"
#include "batches/GrTestBatch.h"
#include "batches/GrTestMeshDrawOp.h"
#include "effects/GrBezierEffect.h"
@ -28,24 +28,26 @@ static inline SkScalar eval_line(const SkPoint& p, const SkScalar lineEq[3], SkS
namespace skiagm {
class BezierCubicOrConicTestBatch : public GrTestBatch {
class BezierCubicOrConicTestOp : public GrTestMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
const char* name() const override { return "BezierCubicOrConicTestBatch"; }
const char* name() const override { return "BezierCubicOrConicTestOp"; }
BezierCubicOrConicTestBatch(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds,
GrColor color, const SkScalar klmEqs[9], SkScalar sign)
: INHERITED(ClassID(), bounds, color)
, fGeometryProcessor(std::move(gp)) {
static sk_sp<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
const SkScalar klmEqs[9], SkScalar sign) {
return sk_sp<GrDrawOp>(new BezierCubicOrConicTestOp(gp, bounds, color, klmEqs, sign));
}
private:
BezierCubicOrConicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
const SkScalar klmEqs[9], SkScalar sign)
: INHERITED(ClassID(), bounds, color), fGeometryProcessor(std::move(gp)) {
for (int i = 0; i < 9; i++) {
fKlmEqs[i] = klmEqs[i];
}
fSign = sign;
}
private:
struct Vertex {
SkPoint fPosition;
float fKLM[4]; // The last value is ignored. The effect expects a vec4f.
@ -77,7 +79,7 @@ private:
static constexpr int kVertsPerCubic = 4;
static constexpr int kIndicesPerCubic = 6;
typedef GrTestBatch INHERITED;
typedef GrTestMeshDrawOp INHERITED;
};
/**
@ -192,9 +194,8 @@ protected:
GrPaint grPaint;
grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc));
sk_sp<GrDrawOp> op = sk_make_sp<BezierCubicOrConicTestBatch>(gp, bounds, color,
klmEqs,
klmSigns[c]);
sk_sp<GrDrawOp> op =
BezierCubicOrConicTestOp::Make(gp, bounds, color, klmEqs, klmSigns[c]);
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
@ -326,8 +327,8 @@ protected:
GrPaint grPaint;
grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc));
sk_sp<GrDrawOp> op(new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs,
1.f));
sk_sp<GrDrawOp> op =
BezierCubicOrConicTestOp::Make(gp, bounds, color, klmEqs, 1.f);
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
@ -387,19 +388,22 @@ private:
//////////////////////////////////////////////////////////////////////////////
class BezierQuadTestBatch : public GrTestBatch {
class BezierQuadTestOp : public GrTestMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
const char* name() const override { return "BezierQuadTestBatch"; }
const char* name() const override { return "BezierQuadTestOp"; }
BezierQuadTestBatch(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
const GrPathUtils::QuadUVMatrix& devToUV)
: INHERITED(ClassID(), bounds, color)
, fDevToUV(devToUV)
, fGeometryProcessor(std::move(gp)) {
static sk_sp<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
const GrPathUtils::QuadUVMatrix& devToUV) {
return sk_sp<GrDrawOp>(new BezierQuadTestOp(gp, bounds, color, devToUV));
}
private:
BezierQuadTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& bounds, GrColor color,
const GrPathUtils::QuadUVMatrix& devToUV)
: INHERITED(ClassID(), bounds, color)
, fDevToUV(devToUV)
, fGeometryProcessor(std::move(gp)) {}
struct Vertex {
SkPoint fPosition;
@ -427,7 +431,7 @@ private:
static constexpr int kVertsPerCubic = 4;
static constexpr int kIndicesPerCubic = 6;
typedef GrTestBatch INHERITED;
typedef GrTestMeshDrawOp INHERITED;
};
/**
@ -539,7 +543,7 @@ protected:
GrPathUtils::QuadUVMatrix DevToUV(pts);
sk_sp<GrDrawOp> op(new BezierQuadTestBatch(gp, bounds, color, DevToUV));
sk_sp<GrDrawOp> op = BezierQuadTestOp::Make(gp, bounds, color, DevToUV);
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));

View File

@ -21,7 +21,7 @@
#include "SkTLList.h"
#include "batches/GrMeshDrawOp.h"
#include "batches/GrTestBatch.h"
#include "batches/GrTestMeshDrawOp.h"
#include "effects/GrConvexPolyEffect.h"
@ -40,18 +40,20 @@ static SkRect sorted_rect(const SkRect& unsorted) {
}
namespace skiagm {
class PolyBoundsBatch : public GrTestBatch {
class PolyBoundsOp : public GrTestMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
const char* name() const override { return "PolyBoundsBatch"; }
const char* name() const override { return "PolyBoundsOp"; }
PolyBoundsBatch(const SkRect& rect, GrColor color)
: INHERITED(ClassID(), outset(sorted_rect(rect)), color)
, fRect(outset(rect)) {
static sk_sp<GrDrawOp> Make(const SkRect& rect, GrColor color) {
return sk_sp<GrDrawOp>(new PolyBoundsOp(rect, color));
}
private:
PolyBoundsOp(const SkRect& rect, GrColor color)
: INHERITED(ClassID(), outset(sorted_rect(rect)), color), fRect(outset(rect)) {}
void onPrepareDraws(Target* target) const override {
using namespace GrDefaultGeoProcFactory;
@ -76,7 +78,7 @@ private:
SkRect fRect;
typedef GrTestBatch INHERITED;
typedef GrTestMeshDrawOp INHERITED;
};
/**
@ -183,7 +185,7 @@ protected:
grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
sk_sp<GrDrawOp> op(new PolyBoundsBatch(p.getBounds(), 0xff000000));
sk_sp<GrDrawOp> op = PolyBoundsOp::Make(p.getBounds(), 0xff000000);
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
@ -223,7 +225,7 @@ protected:
grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
sk_sp<GrDrawOp> op(new PolyBoundsBatch(rect, 0xff000000));
sk_sp<GrDrawOp> op = PolyBoundsOp::Make(rect, 0xff000000);
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));

View File

@ -288,6 +288,7 @@ skia_gpu_sources = [
"$_src/gpu/batches/GrStencilPathOp.h",
"$_src/gpu/batches/GrTessellatingPathRenderer.cpp",
"$_src/gpu/batches/GrTessellatingPathRenderer.h",
"$_src/gpu/batches/GrTestMeshDrawOp.h",
"$_src/gpu/batches/GrMeshDrawOp.cpp",
"$_src/gpu/batches/GrMeshDrawOp.h",

View File

@ -12,6 +12,7 @@
#include "GrTypesPriv.h"
#include "SkPathEffect.h"
class GrClip;
class GrDrawOp;
class GrStyle;

View File

@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
#ifndef GrTestBatch_DEFINED
#define GrTestBatch_DEFINED
#ifndef GrTestMeshDrawOp_DEFINED
#define GrTestMeshDrawOp_DEFINED
#include "GrGeometryProcessor.h"
#include "GrOpFlushState.h"
@ -17,7 +17,7 @@
* A simple solid color batch only for testing purposes which actually doesn't batch at all. It
* saves having to fill out some boiler plate methods.
*/
class GrTestBatch : public GrMeshDrawOp {
class GrTestMeshDrawOp : public GrMeshDrawOp {
public:
virtual const char* name() const override = 0;
@ -38,9 +38,8 @@ public:
}
protected:
GrTestBatch(uint32_t classID, const SkRect& bounds, GrColor color)
: INHERITED(classID)
, fColor(color) {
GrTestMeshDrawOp(uint32_t classID, const SkRect& bounds, GrColor color)
: INHERITED(classID), fColor(color) {
// Choose some conservative values for aa bloat and zero area.
this->setBounds(bounds, HasAABloat::kYes, IsZeroArea::kYes);
}