aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-06-12 10:11:12 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-12 14:43:03 +0000
commit7c525e62d405d57ae7a7742cf607b9770a83a0ab (patch)
tree8dabe9ed08bddd398b8fac935decaf2743f5a6f7 /gm
parent7deacf4833dcdb6c1101a18a2b46a8c516a96f9a (diff)
Plumb GrContext everywhere
There is no good way to split the monster CL up. This breaks out the GrContext plumbing but doesn't use it. Change-Id: I90856d428d372bcec3f8821e6364667b367927d4 Reviewed-on: https://skia-review.googlesource.com/133382 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/beziereffects.cpp34
-rw-r--r--gm/bigrrectaaeffect.cpp8
-rw-r--r--gm/constcolorprocessor.cpp2
-rw-r--r--gm/convexpolyeffect.cpp17
-rw-r--r--gm/rrects.cpp8
-rw-r--r--gm/texturedomaineffect.cpp2
-rw-r--r--gm/yuvtorgbeffect.cpp4
7 files changed, 57 insertions, 18 deletions
diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp
index ab9a5fdb5b..dea6150549 100644
--- a/gm/beziereffects.cpp
+++ b/gm/beziereffects.cpp
@@ -11,6 +11,7 @@
#include "sk_tool_utils.h"
#include "GrContext.h"
+#include "GrMemoryPool.h"
#include "GrOpFlushState.h"
#include "GrPathUtils.h"
#include "GrRenderTargetContextPriv.h"
@@ -75,12 +76,16 @@ public:
const char* name() const override { return "BezierCubicTestOp"; }
- static std::unique_ptr<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& rect,
+ static std::unique_ptr<GrDrawOp> Make(GrContext* context,
+ sk_sp<GrGeometryProcessor> gp,
+ const SkRect& rect,
GrColor color) {
return std::unique_ptr<GrDrawOp>(new BezierCubicTestOp(std::move(gp), rect, color));
}
private:
+ friend class ::GrOpMemoryPool; // for ctor
+
BezierCubicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color)
: INHERITED(std::move(gp), rect, color, ClassID()) {}
@@ -230,7 +235,7 @@ protected:
}
std::unique_ptr<GrDrawOp> op =
- BezierCubicTestOp::Make(std::move(gp), bounds, color);
+ BezierCubicTestOp::Make(context, std::move(gp), bounds, color);
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
}
++col;
@@ -254,13 +259,18 @@ public:
const char* name() const override { return "BezierConicTestOp"; }
- static std::unique_ptr<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& rect,
- GrColor color, const SkMatrix& klm) {
+ static std::unique_ptr<GrDrawOp> Make(GrContext* context,
+ sk_sp<GrGeometryProcessor> gp,
+ const SkRect& rect,
+ GrColor color,
+ const SkMatrix& klm) {
return std::unique_ptr<GrMeshDrawOp>(
new BezierConicTestOp(std::move(gp), rect, color, klm));
}
private:
+ friend class ::GrOpMemoryPool; // for ctor
+
BezierConicTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
const SkMatrix& klm)
: INHERITED(std::move(gp), rect, color, ClassID()), fKLM(klm) {}
@@ -406,7 +416,8 @@ protected:
boundsPaint.setStyle(SkPaint::kStroke_Style);
canvas->drawRect(bounds, boundsPaint);
- std::unique_ptr<GrDrawOp> op = BezierConicTestOp::Make(gp, bounds, color, klm);
+ std::unique_ptr<GrDrawOp> op = BezierConicTestOp::Make(context, gp, bounds,
+ color, klm);
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
}
++col;
@@ -469,12 +480,17 @@ public:
DEFINE_OP_CLASS_ID
const char* name() const override { return "BezierQuadTestOp"; }
- static std::unique_ptr<GrDrawOp> Make(sk_sp<GrGeometryProcessor> gp, const SkRect& rect,
- GrColor color, const GrPathUtils::QuadUVMatrix& devToUV) {
+ static std::unique_ptr<GrDrawOp> Make(GrContext* context,
+ sk_sp<GrGeometryProcessor> gp,
+ const SkRect& rect,
+ GrColor color,
+ const GrPathUtils::QuadUVMatrix& devToUV) {
return std::unique_ptr<GrDrawOp>(new BezierQuadTestOp(std::move(gp), rect, color, devToUV));
}
private:
+ friend class ::GrOpMemoryPool; // for ctor
+
BezierQuadTestOp(sk_sp<GrGeometryProcessor> gp, const SkRect& rect, GrColor color,
const GrPathUtils::QuadUVMatrix& devToUV)
: INHERITED(std::move(gp), rect, color, ClassID()), fDevToUV(devToUV) {}
@@ -615,8 +631,8 @@ protected:
GrPathUtils::QuadUVMatrix DevToUV(pts);
- std::unique_ptr<GrDrawOp> op =
- BezierQuadTestOp::Make(gp, bounds, color, DevToUV);
+ std::unique_ptr<GrDrawOp> op = BezierQuadTestOp::Make(context, gp,
+ bounds, color, DevToUV);
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
}
++col;
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index dee19c5547..f3f10ae317 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -56,6 +56,11 @@ protected:
return;
}
+ GrContext* context = canvas->getGrContext();
+ if (!context) {
+ return;
+ }
+
SkPaint paint;
int y = kPad;
@@ -90,7 +95,8 @@ protected:
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
renderTargetContext->priv().testingOnly_addDrawOp(
- GrRectOpFactory::MakeNonAAFill(std::move(grPaint), SkMatrix::I(),
+ GrRectOpFactory::MakeNonAAFill(context, std::move(grPaint),
+ SkMatrix::I(),
bounds, GrAAType::kNone));
}
canvas->restore();
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index 26da988aea..ffeecda047 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -108,7 +108,7 @@ protected:
grPaint.addColorFragmentProcessor(std::move(fp));
renderTargetContext->priv().testingOnly_addDrawOp(
- GrRectOpFactory::MakeNonAAFill(std::move(grPaint), viewMatrix,
+ GrRectOpFactory::MakeNonAAFill(context, std::move(grPaint), viewMatrix,
renderRect, GrAAType::kNone));
// Draw labels for the input to the processor and the processor to the right of
diff --git a/gm/convexpolyeffect.cpp b/gm/convexpolyeffect.cpp
index fa48e7bb88..8f8d1b4d50 100644
--- a/gm/convexpolyeffect.cpp
+++ b/gm/convexpolyeffect.cpp
@@ -11,6 +11,7 @@
#include "GrContext.h"
#include "GrDefaultGeoProcFactory.h"
+#include "GrMemoryPool.h"
#include "GrOpFlushState.h"
#include "GrPathUtils.h"
#include "GrRenderTargetContextPriv.h"
@@ -41,7 +42,9 @@ class PolyBoundsOp : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- static std::unique_ptr<GrDrawOp> Make(GrPaint&& paint, const SkRect& rect) {
+ static std::unique_ptr<GrDrawOp> Make(GrContext* context,
+ GrPaint&& paint,
+ const SkRect& rect) {
return std::unique_ptr<GrDrawOp>(new PolyBoundsOp(std::move(paint), rect));
}
@@ -61,6 +64,8 @@ public:
}
private:
+ friend class ::GrOpMemoryPool; // for ctor
+
PolyBoundsOp(GrPaint&& paint, const SkRect& rect)
: INHERITED(ClassID())
, fColor(paint.getColor())
@@ -181,6 +186,11 @@ protected:
return;
}
+ GrContext* context = canvas->getGrContext();
+ if (!context) {
+ return;
+ }
+
SkScalar y = 0;
constexpr SkScalar kDX = 12.f;
for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart);
@@ -206,7 +216,7 @@ protected:
grPaint.addCoverageFragmentProcessor(std::move(fp));
std::unique_ptr<GrDrawOp> op =
- PolyBoundsOp::Make(std::move(grPaint), p.getBounds());
+ PolyBoundsOp::Make(context, std::move(grPaint), p.getBounds());
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
@@ -245,7 +255,8 @@ protected:
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
grPaint.addCoverageFragmentProcessor(std::move(fp));
- std::unique_ptr<GrDrawOp> op = PolyBoundsOp::Make(std::move(grPaint), rect);
+ std::unique_ptr<GrDrawOp> op = PolyBoundsOp::Make(context, std::move(grPaint),
+ rect);
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
x += SkScalarCeilToScalar(rect.width() + kDX);
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index ff704c82a2..143fde35e7 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -69,6 +69,12 @@ protected:
return;
}
+ GrContext* context = canvas->getGrContext();
+ if (kEffect_Type == fType && !context) {
+ skiagm::GM::DrawGpuOnlyMessage(canvas);
+ return;
+ }
+
SkPaint paint;
if (kAA_Draw_Type == fType) {
paint.setAntiAlias(true);
@@ -112,7 +118,7 @@ protected:
bounds.outset(2.f, 2.f);
renderTargetContext->priv().testingOnly_addDrawOp(
- GrRectOpFactory::MakeNonAAFill(std::move(grPaint),
+ GrRectOpFactory::MakeNonAAFill(context, std::move(grPaint),
SkMatrix::I(), bounds,
GrAAType::kNone));
} else {
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 63e01111f4..5b96859637 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -132,7 +132,7 @@ protected:
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
grPaint.addColorFragmentProcessor(std::move(fp));
renderTargetContext->priv().testingOnly_addDrawOp(
- GrRectOpFactory::MakeNonAAFill(std::move(grPaint), viewMatrix,
+ GrRectOpFactory::MakeNonAAFill(context, std::move(grPaint), viewMatrix,
renderRect, GrAAType::kNone));
x += renderRect.width() + kTestPad;
}
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 7b7846d6eb..a73025502b 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -129,7 +129,7 @@ protected:
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
renderTargetContext->priv().testingOnly_addDrawOp(
- GrRectOpFactory::MakeNonAAFill(std::move(grPaint), viewMatrix,
+ GrRectOpFactory::MakeNonAAFill(context, std::move(grPaint), viewMatrix,
renderRect, GrAAType::kNone));
}
x += renderRect.width() + kTestPad;
@@ -246,7 +246,7 @@ protected:
viewMatrix.setTranslate(x, y);
grPaint.addColorFragmentProcessor(std::move(fp));
std::unique_ptr<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
- std::move(grPaint), viewMatrix, renderRect, GrAAType::kNone));
+ context, std::move(grPaint), viewMatrix, renderRect, GrAAType::kNone));
renderTargetContext->priv().testingOnly_addDrawOp(std::move(op));
}
}