Bring sk_sp to oval GrDrawOps and rename batch->op

Change-Id: Ic0e95a29f1e2479d3d79b7d175290cb20422b585
Reviewed-on: https://skia-review.googlesource.com/6082
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Salomon 2016-12-14 15:52:56 -05:00 committed by Skia Commit-Bot
parent 222e9ad98b
commit 289e3d8dd7
6 changed files with 572 additions and 614 deletions

View File

@ -121,8 +121,6 @@ skia_gpu_sources = [
"$_src/gpu/GrOpFlushState.h",
"$_src/gpu/GrOpList.cpp",
"$_src/gpu/GrOpList.h",
"$_src/gpu/GrOvalRenderer.cpp",
"$_src/gpu/GrOvalRenderer.h",
"$_src/gpu/GrPaint.cpp",
"$_src/gpu/GrPath.cpp",
"$_src/gpu/GrPath.h",
@ -273,6 +271,8 @@ skia_gpu_sources = [
"$_src/gpu/batches/GrNinePatch.h",
"$_src/gpu/batches/GrOp.cpp",
"$_src/gpu/batches/GrOp.h",
"$_src/gpu/batches/GrOvalOpFactory.cpp",
"$_src/gpu/batches/GrOvalOpFactory.h",
"$_src/gpu/batches/GrPLSPathRenderer.cpp",
"$_src/gpu/batches/GrPLSPathRenderer.h",
"$_src/gpu/batches/GrRectOpFactory.h",

View File

@ -20,12 +20,12 @@ DRAW_BATCH_TEST_EXTERN(AAStrokeRectOp);
DRAW_BATCH_TEST_EXTERN(AnalyticRectOp);
DRAW_BATCH_TEST_EXTERN(DashBatch);
DRAW_BATCH_TEST_EXTERN(DefaultPathBatch);
DRAW_BATCH_TEST_EXTERN(CircleBatch);
DRAW_BATCH_TEST_EXTERN(DIEllipseBatch);
DRAW_BATCH_TEST_EXTERN(EllipseBatch);
DRAW_BATCH_TEST_EXTERN(CircleOp);
DRAW_BATCH_TEST_EXTERN(DIEllipseOp);
DRAW_BATCH_TEST_EXTERN(EllipseOp);
DRAW_BATCH_TEST_EXTERN(GrDrawAtlasBatch);
DRAW_BATCH_TEST_EXTERN(NonAAStrokeRectOp);
DRAW_BATCH_TEST_EXTERN(RRectBatch);
DRAW_BATCH_TEST_EXTERN(RRectOp);
DRAW_BATCH_TEST_EXTERN(TesselatingPathBatch);
DRAW_BATCH_TEST_EXTERN(TextBlobBatch);
DRAW_BATCH_TEST_EXTERN(VerticesBatch);
@ -40,12 +40,12 @@ static BatchTestFunc gTestBatches[] = {
DRAW_BATCH_TEST_ENTRY(AnalyticRectOp),
DRAW_BATCH_TEST_ENTRY(DashBatch),
DRAW_BATCH_TEST_ENTRY(DefaultPathBatch),
DRAW_BATCH_TEST_ENTRY(CircleBatch),
DRAW_BATCH_TEST_ENTRY(DIEllipseBatch),
DRAW_BATCH_TEST_ENTRY(EllipseBatch),
DRAW_BATCH_TEST_ENTRY(CircleOp),
DRAW_BATCH_TEST_ENTRY(DIEllipseOp),
DRAW_BATCH_TEST_ENTRY(EllipseOp),
DRAW_BATCH_TEST_ENTRY(GrDrawAtlasBatch),
DRAW_BATCH_TEST_ENTRY(NonAAStrokeRectOp),
DRAW_BATCH_TEST_ENTRY(RRectBatch),
DRAW_BATCH_TEST_ENTRY(RRectOp),
DRAW_BATCH_TEST_ENTRY(TesselatingPathBatch),
DRAW_BATCH_TEST_ENTRY(TextBlobBatch),
DRAW_BATCH_TEST_ENTRY(VerticesBatch)

View File

@ -1,48 +0,0 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrOvalRenderer_DEFINED
#define GrOvalRenderer_DEFINED
#include "GrColor.h"
class GrDrawOp;
class GrShaderCaps;
class GrStyle;
class SkMatrix;
struct SkRect;
class SkRRect;
class SkStrokeRec;
/*
* This class wraps helper functions that draw ovals and roundrects (filled & stroked)
*/
class GrOvalRenderer {
public:
static GrDrawOp* CreateOvalBatch(GrColor,
const SkMatrix& viewMatrix,
const SkRect& oval,
const SkStrokeRec& stroke,
const GrShaderCaps* shaderCaps);
static GrDrawOp* CreateRRectBatch(GrColor,
bool needsDistance,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const SkStrokeRec& stroke,
const GrShaderCaps* shaderCaps);
static GrDrawOp* CreateArcBatch(GrColor,
const SkMatrix& viewMatrix,
const SkRect& oval,
SkScalar startAngle,
SkScalar sweepAngle,
bool useCenter,
const GrStyle&,
const GrShaderCaps* shaderCaps);
};
#endif // GrOvalRenderer_DEFINED

View File

@ -12,7 +12,6 @@
#include "GrDrawingManager.h"
#include "GrFixedClip.h"
#include "GrGpuResourcePriv.h"
#include "GrOvalRenderer.h"
#include "GrPathRenderer.h"
#include "GrPipelineBuilder.h"
#include "GrRenderTarget.h"
@ -25,6 +24,7 @@
#include "batches/GrDrawVerticesBatch.h"
#include "batches/GrNinePatch.h" // TODO Factory
#include "batches/GrOp.h"
#include "batches/GrOvalOpFactory.h"
#include "batches/GrRectOpFactory.h"
#include "batches/GrRegionBatch.h"
#include "batches/GrShadowRRectBatch.h"
@ -926,12 +926,12 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip,
aaType = this->decideAAType(aa);
if (GrAAType::kCoverage == aaType) {
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawOp> op(GrOvalRenderer::CreateRRectBatch(paint.getColor(),
paint.usesDistanceVectorField(),
viewMatrix,
rrect,
stroke,
shaderCaps));
sk_sp<GrDrawOp> op = GrOvalOpFactory::MakeRRectOp(paint.getColor(),
paint.usesDistanceVectorField(),
viewMatrix,
rrect,
stroke,
shaderCaps);
if (op) {
GrPipelineBuilder pipelineBuilder(paint, aaType);
this->getOpList()->addDrawOp(pipelineBuilder, this, *clip, std::move(op));
@ -1159,11 +1159,8 @@ void GrRenderTargetContext::drawOval(const GrClip& clip,
aaType = this->decideAAType(aa);
if (GrAAType::kCoverage == aaType) {
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawOp> op(GrOvalRenderer::CreateOvalBatch(paint.getColor(),
viewMatrix,
oval,
stroke,
shaderCaps));
sk_sp<GrDrawOp> op =
GrOvalOpFactory::MakeOvalOp(paint.getColor(), viewMatrix, oval, stroke, shaderCaps);
if (op) {
GrPipelineBuilder pipelineBuilder(paint, aaType);
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op));
@ -1189,14 +1186,14 @@ void GrRenderTargetContext::drawArc(const GrClip& clip,
GrAAType aaType = this->decideAAType(aa);
if (GrAAType::kCoverage == aaType) {
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawOp> op(GrOvalRenderer::CreateArcBatch(paint.getColor(),
viewMatrix,
oval,
startAngle,
sweepAngle,
useCenter,
style,
shaderCaps));
sk_sp<GrDrawOp> op = GrOvalOpFactory::MakeArcOp(paint.getColor(),
viewMatrix,
oval,
startAngle,
sweepAngle,
useCenter,
style,
shaderCaps);
if (op) {
GrPipelineBuilder pipelineBuilder(paint, aaType);
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op));
@ -1401,11 +1398,8 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
if (isOval && !path.isInverseFillType()) {
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
sk_sp<GrDrawOp> op(GrOvalRenderer::CreateOvalBatch(paint.getColor(),
viewMatrix,
ovalRect,
style.strokeRec(),
shaderCaps));
sk_sp<GrDrawOp> op = GrOvalOpFactory::MakeOvalOp(
paint.getColor(), viewMatrix, ovalRect, style.strokeRec(), shaderCaps);
if (op) {
GrPipelineBuilder pipelineBuilder(paint, aaType);
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op));

View File

@ -0,0 +1,49 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrOvalOpFactory_DEFINED
#define GrOvalOpFactory_DEFINED
#include "GrColor.h"
#include "SkRefCnt.h"
class GrDrawOp;
class GrShaderCaps;
class GrStyle;
class SkMatrix;
struct SkRect;
class SkRRect;
class SkStrokeRec;
/*
* This namespace wraps helper functions that draw ovals, rrects, and arcs (filled & stroked)
*/
class GrOvalOpFactory {
public:
static sk_sp<GrDrawOp> MakeOvalOp(GrColor,
const SkMatrix& viewMatrix,
const SkRect& oval,
const SkStrokeRec& stroke,
const GrShaderCaps* shaderCaps);
static sk_sp<GrDrawOp> MakeRRectOp(GrColor,
bool needsDistance,
const SkMatrix& viewMatrix,
const SkRRect& rrect,
const SkStrokeRec& stroke,
const GrShaderCaps* shaderCaps);
static sk_sp<GrDrawOp> MakeArcOp(GrColor,
const SkMatrix& viewMatrix,
const SkRect& oval,
SkScalar startAngle,
SkScalar sweepAngle,
bool useCenter,
const GrStyle&,
const GrShaderCaps* shaderCaps);
};
#endif // GrOvalOpFactory_DEFINED