aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-12-14 11:08:17 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-14 19:27:40 +0000
commit6a639040bc3ee5369d86c9cb5b9047208beb5206 (patch)
tree8498b5e6ce910868b3c9943ec708406219c8fcca
parentb7ce80b7149209dfcdb8757d39a627e8dcccefea (diff)
Update rect ops to use "op" in their name and return sk_sp.
Change-Id: I757c33d1cd17a7a7dda858f0fc5ab1094e3c2472 Reviewed-on: https://skia-review.googlesource.com/5985 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
-rw-r--r--gm/bigrrectaaeffect.cpp7
-rw-r--r--gm/constcolorprocessor.cpp7
-rw-r--r--gm/rrects.cpp7
-rw-r--r--gm/texturedomaineffect.cpp9
-rw-r--r--gm/yuvtorgbeffect.cpp11
-rw-r--r--gn/gpu.gni26
-rw-r--r--src/gpu/GrBatchTest.cpp20
-rw-r--r--src/gpu/GrRenderTargetContext.cpp31
-rw-r--r--src/gpu/GrRenderTargetOpList.cpp2
-rw-r--r--src/gpu/GrSWMaskHelper.cpp6
-rw-r--r--src/gpu/GrSoftwarePathRenderer.cpp8
-rw-r--r--src/gpu/SkGpuDevice.cpp6
-rw-r--r--src/gpu/batches/GrAAFillRectBatch.h41
-rw-r--r--src/gpu/batches/GrAAFillRectOp.cpp (renamed from src/gpu/batches/GrAAFillRectBatch.cpp)161
-rw-r--r--src/gpu/batches/GrAAFillRectOp.h41
-rw-r--r--src/gpu/batches/GrAAStrokeRectBatch.h33
-rw-r--r--src/gpu/batches/GrAAStrokeRectOp.cpp (renamed from src/gpu/batches/GrAAStrokeRectBatch.cpp)230
-rw-r--r--src/gpu/batches/GrAAStrokeRectOp.h32
-rw-r--r--src/gpu/batches/GrAnalyticRectOp.cpp (renamed from src/gpu/batches/GrAnalyticRectBatch.cpp)131
-rw-r--r--src/gpu/batches/GrAnalyticRectOp.h (renamed from src/gpu/batches/GrAnalyticRectBatch.h)19
-rw-r--r--src/gpu/batches/GrDefaultPathRenderer.cpp6
-rw-r--r--src/gpu/batches/GrMSAAPathRenderer.cpp6
-rw-r--r--src/gpu/batches/GrNonAAFillRectBatch.h33
-rw-r--r--src/gpu/batches/GrNonAAFillRectOp.cpp (renamed from src/gpu/batches/GrNonAAFillRectBatch.cpp)74
-rw-r--r--src/gpu/batches/GrNonAAFillRectOp.h33
-rw-r--r--src/gpu/batches/GrNonAAFillRectPerspectiveOp.cpp (renamed from src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp)79
-rw-r--r--src/gpu/batches/GrNonAAStrokeRectBatch.h30
-rw-r--r--src/gpu/batches/GrNonAAStrokeRectOp.cpp (renamed from src/gpu/batches/GrNonAAStrokeRectBatch.cpp)69
-rw-r--r--src/gpu/batches/GrNonAAStrokeRectOp.h28
-rw-r--r--src/gpu/batches/GrRectBatchFactory.h83
-rw-r--r--src/gpu/batches/GrRectOpFactory.cpp (renamed from src/gpu/batches/GrRectBatchFactory.cpp)17
-rw-r--r--src/gpu/batches/GrRectOpFactory.h82
-rw-r--r--src/gpu/batches/GrStencilAndCoverPathRenderer.cpp9
33 files changed, 674 insertions, 703 deletions
diff --git a/gm/bigrrectaaeffect.cpp b/gm/bigrrectaaeffect.cpp
index 8921a1477e..3b4ffe2f79 100644
--- a/gm/bigrrectaaeffect.cpp
+++ b/gm/bigrrectaaeffect.cpp
@@ -11,7 +11,7 @@
#include "GrRenderTargetContextPriv.h"
#include "SkRRect.h"
#include "batches/GrDrawOp.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "effects/GrRRectEffect.h"
namespace skiagm {
@@ -87,9 +87,8 @@ protected:
SkRect bounds = testBounds;
bounds.offset(SkIntToScalar(x), SkIntToScalar(y));
- sk_sp<GrDrawOp> op(
- GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), bounds,
- nullptr, nullptr));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(0xff000000, SkMatrix::I(),
+ bounds, nullptr, nullptr));
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
}
diff --git a/gm/constcolorprocessor.cpp b/gm/constcolorprocessor.cpp
index 60f90a590a..11883d2fa3 100644
--- a/gm/constcolorprocessor.cpp
+++ b/gm/constcolorprocessor.cpp
@@ -16,7 +16,7 @@
#include "SkGrPriv.h"
#include "SkGradientShader.h"
#include "batches/GrDrawOp.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "effects/GrConstColorProcessor.h"
namespace skiagm {
@@ -109,9 +109,8 @@ protected:
grPaint.addColorFragmentProcessor(std::move(fp));
- sk_sp<GrDrawOp> op(
- GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix,
- renderRect, nullptr, nullptr));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
+ grPaint.getColor(), viewMatrix, renderRect, nullptr, nullptr));
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
diff --git a/gm/rrects.cpp b/gm/rrects.cpp
index 43b06eb473..0810f274de 100644
--- a/gm/rrects.cpp
+++ b/gm/rrects.cpp
@@ -10,7 +10,7 @@
#include "GrContext.h"
#include "GrRenderTargetContextPriv.h"
#include "batches/GrDrawOp.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "effects/GrRRectEffect.h"
#endif
#include "SkRRect.h"
@@ -115,9 +115,8 @@ protected:
SkRect bounds = rrect.getBounds();
bounds.outset(2.f, 2.f);
- sk_sp<GrDrawOp> op(
- GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(),
- bounds, nullptr, nullptr));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
+ 0xff000000, SkMatrix::I(), bounds, nullptr, nullptr));
renderTargetContext->priv().testingOnly_addDrawOp(grPaint,
GrAAType::kNone,
std::move(op));
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 882f14d89b..417d99a3a4 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -11,13 +11,13 @@
#if SK_SUPPORT_GPU
-#include "GrRenderTargetContextPriv.h"
#include "GrContext.h"
+#include "GrRenderTargetContextPriv.h"
#include "SkBitmap.h"
#include "SkGr.h"
#include "SkGradientShader.h"
#include "batches/GrDrawOp.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "effects/GrTextureDomain.h"
namespace skiagm {
@@ -126,9 +126,8 @@ protected:
const SkMatrix viewMatrix = SkMatrix::MakeTrans(x, y);
grPaint.addColorFragmentProcessor(std::move(fp));
- sk_sp<GrDrawOp> op(
- GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
- renderRect, nullptr, nullptr));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
+ GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
x += renderRect.width() + kTestPad;
diff --git a/gm/yuvtorgbeffect.cpp b/gm/yuvtorgbeffect.cpp
index 168571c914..ac96303940 100644
--- a/gm/yuvtorgbeffect.cpp
+++ b/gm/yuvtorgbeffect.cpp
@@ -17,7 +17,7 @@
#include "SkGr.h"
#include "SkGradientShader.h"
#include "batches/GrDrawOp.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "effects/GrYUVEffect.h"
#define YSIZE 8
@@ -123,9 +123,8 @@ protected:
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
grPaint.addColorFragmentProcessor(std::move(fp));
- sk_sp<GrDrawOp> op(
- GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
- renderRect, nullptr, nullptr));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(
+ GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
}
@@ -237,8 +236,8 @@ protected:
SkMatrix viewMatrix;
viewMatrix.setTranslate(x, y);
grPaint.addColorFragmentProcessor(fp);
- sk_sp<GrDrawOp> op(GrRectBatchFactory::CreateNonAAFill(
- GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(GrColor_WHITE, viewMatrix,
+ renderRect, nullptr, nullptr));
renderTargetContext->priv().testingOnly_addDrawOp(grPaint, GrAAType::kNone,
std::move(op));
}
diff --git a/gn/gpu.gni b/gn/gpu.gni
index b8306f3de5..be77f11302 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -237,12 +237,12 @@ skia_gpu_sources = [
"$_src/gpu/batches/GrAADistanceFieldPathRenderer.h",
"$_src/gpu/batches/GrAAConvexPathRenderer.cpp",
"$_src/gpu/batches/GrAAConvexPathRenderer.h",
- "$_src/gpu/batches/GrAAFillRectBatch.cpp",
- "$_src/gpu/batches/GrAAFillRectBatch.h",
- "$_src/gpu/batches/GrAAStrokeRectBatch.cpp",
- "$_src/gpu/batches/GrAAStrokeRectBatch.h",
- "$_src/gpu/batches/GrAnalyticRectBatch.cpp",
- "$_src/gpu/batches/GrAnalyticRectBatch.h",
+ "$_src/gpu/batches/GrAAFillRectOp.cpp",
+ "$_src/gpu/batches/GrAAFillRectOp.h",
+ "$_src/gpu/batches/GrAAStrokeRectOp.cpp",
+ "$_src/gpu/batches/GrAAStrokeRectOp.h",
+ "$_src/gpu/batches/GrAnalyticRectOp.cpp",
+ "$_src/gpu/batches/GrAnalyticRectOp.h",
"$_src/gpu/batches/GrAtlasTextBatch.cpp",
"$_src/gpu/batches/GrAtlasTextBatch.h",
"$_src/gpu/batches/GrClearBatch.h",
@@ -264,19 +264,19 @@ skia_gpu_sources = [
"$_src/gpu/batches/GrDrawVerticesBatch.h",
"$_src/gpu/batches/GrMSAAPathRenderer.cpp",
"$_src/gpu/batches/GrMSAAPathRenderer.h",
- "$_src/gpu/batches/GrNonAAFillRectBatch.h",
- "$_src/gpu/batches/GrNonAAFillRectBatch.cpp",
- "$_src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp",
- "$_src/gpu/batches/GrNonAAStrokeRectBatch.cpp",
- "$_src/gpu/batches/GrNonAAStrokeRectBatch.h",
+ "$_src/gpu/batches/GrNonAAFillRectOp.h",
+ "$_src/gpu/batches/GrNonAAFillRectOp.cpp",
+ "$_src/gpu/batches/GrNonAAFillRectPerspectiveOp.cpp",
+ "$_src/gpu/batches/GrNonAAStrokeRectOp.cpp",
+ "$_src/gpu/batches/GrNonAAStrokeRectOp.h",
"$_src/gpu/batches/GrNinePatch.cpp",
"$_src/gpu/batches/GrNinePatch.h",
"$_src/gpu/batches/GrOp.cpp",
"$_src/gpu/batches/GrOp.h",
"$_src/gpu/batches/GrPLSPathRenderer.cpp",
"$_src/gpu/batches/GrPLSPathRenderer.h",
- "$_src/gpu/batches/GrRectBatchFactory.h",
- "$_src/gpu/batches/GrRectBatchFactory.cpp",
+ "$_src/gpu/batches/GrRectOpFactory.h",
+ "$_src/gpu/batches/GrRectOpFactory.cpp",
"$_src/gpu/batches/GrRegionBatch.cpp",
"$_src/gpu/batches/GrRegionBatch.h",
"$_src/gpu/batches/GrShadowRRectBatch.cpp",
diff --git a/src/gpu/GrBatchTest.cpp b/src/gpu/GrBatchTest.cpp
index 40a88b7538..09ed7b4c92 100644
--- a/src/gpu/GrBatchTest.cpp
+++ b/src/gpu/GrBatchTest.cpp
@@ -13,18 +13,18 @@
DRAW_BATCH_TEST_EXTERN(AAConvexPathBatch);
DRAW_BATCH_TEST_EXTERN(AADistanceFieldPathBatch);
-DRAW_BATCH_TEST_EXTERN(AAFillRectBatch);
-DRAW_BATCH_TEST_EXTERN(AAFillRectBatchLocalMatrix);
+DRAW_BATCH_TEST_EXTERN(AAFillRectOp);
+DRAW_BATCH_TEST_EXTERN(AAFillRectOpLocalMatrix);
DRAW_BATCH_TEST_EXTERN(AAHairlineBatch);
-DRAW_BATCH_TEST_EXTERN(AAStrokeRectBatch);
-DRAW_BATCH_TEST_EXTERN(AnalyticRectBatch);
+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(GrDrawAtlasBatch);
-DRAW_BATCH_TEST_EXTERN(NonAAStrokeRectBatch);
+DRAW_BATCH_TEST_EXTERN(NonAAStrokeRectOp);
DRAW_BATCH_TEST_EXTERN(RRectBatch);
DRAW_BATCH_TEST_EXTERN(TesselatingPathBatch);
DRAW_BATCH_TEST_EXTERN(TextBlobBatch);
@@ -33,18 +33,18 @@ DRAW_BATCH_TEST_EXTERN(VerticesBatch);
static BatchTestFunc gTestBatches[] = {
DRAW_BATCH_TEST_ENTRY(AAConvexPathBatch),
DRAW_BATCH_TEST_ENTRY(AADistanceFieldPathBatch),
- DRAW_BATCH_TEST_ENTRY(AAFillRectBatch),
- DRAW_BATCH_TEST_ENTRY(AAFillRectBatchLocalMatrix),
+ DRAW_BATCH_TEST_ENTRY(AAFillRectOp),
+ DRAW_BATCH_TEST_ENTRY(AAFillRectOpLocalMatrix),
DRAW_BATCH_TEST_ENTRY(AAHairlineBatch),
- DRAW_BATCH_TEST_ENTRY(AAStrokeRectBatch),
- DRAW_BATCH_TEST_ENTRY(AnalyticRectBatch),
+ DRAW_BATCH_TEST_ENTRY(AAStrokeRectOp),
+ 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(GrDrawAtlasBatch),
- DRAW_BATCH_TEST_ENTRY(NonAAStrokeRectBatch),
+ DRAW_BATCH_TEST_ENTRY(NonAAStrokeRectOp),
DRAW_BATCH_TEST_ENTRY(RRectBatch),
DRAW_BATCH_TEST_ENTRY(TesselatingPathBatch),
DRAW_BATCH_TEST_ENTRY(TextBlobBatch),
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 1a1f6a5835..0ded922c64 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -20,12 +20,12 @@
#include "GrResourceProvider.h"
#include "SkSurfacePriv.h"
-#include "batches/GrOp.h"
#include "batches/GrClearBatch.h"
#include "batches/GrDrawAtlasBatch.h"
#include "batches/GrDrawVerticesBatch.h"
-#include "batches/GrRectBatchFactory.h"
-#include "batches/GrNinePatch.h" // TODO Factory
+#include "batches/GrNinePatch.h" // TODO Factory
+#include "batches/GrOp.h"
+#include "batches/GrRectOpFactory.h"
#include "batches/GrRegionBatch.h"
#include "batches/GrShadowRRectBatch.h"
@@ -480,8 +480,7 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
SkRect devBoundRect;
viewMatrix.mapRect(&devBoundRect, croppedRect);
- op.reset(GrRectBatchFactory::CreateAAFill(paint, viewMatrix, rect, croppedRect,
- devBoundRect));
+ op = GrRectOpFactory::MakeAAFill(paint, viewMatrix, rect, croppedRect, devBoundRect);
if (op) {
GrPipelineBuilder pipelineBuilder(paint, aaType);
if (ss) {
@@ -594,7 +593,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
if (GrAAType::kCoverage == aaType) {
// The stroke path needs the rect to remain axis aligned (no rotation or skew).
if (viewMatrix.rectStaysRect()) {
- op.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, stroke));
+ op = GrRectOpFactory::MakeAAStroke(color, viewMatrix, rect, stroke);
}
} else {
// Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of
@@ -602,8 +601,8 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
// when MSAA is enabled because it can cause ugly artifacts.
snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Style &&
!fRenderTargetProxy->isUnifiedMultisampled();
- op.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect,
- stroke, snapToPixelCenters));
+ op = GrRectOpFactory::MakeNonAAStroke(color, viewMatrix, rect, stroke,
+ snapToPixelCenters);
}
if (op) {
@@ -741,8 +740,8 @@ void GrRenderTargetContext::fillRectToRect(const GrClip& clip,
}
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
- sk_sp<GrDrawOp> op(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix,
- croppedRect, croppedLocalRect));
+ sk_sp<GrDrawOp> op = GrAAFillRectOp::MakeWithLocalRect(paint.getColor(), viewMatrix,
+ croppedRect, croppedLocalRect);
GrPipelineBuilder pipelineBuilder(paint, aaType);
this->addDrawOp(pipelineBuilder, clip, std::move(op));
return;
@@ -799,8 +798,8 @@ void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip,
}
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
- sk_sp<GrDrawOp> op(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, localMatrix,
- croppedRect));
+ sk_sp<GrDrawOp> op =
+ GrAAFillRectOp::Make(paint.getColor(), viewMatrix, localMatrix, croppedRect);
GrPipelineBuilder pipelineBuilder(paint, aaType);
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op));
return;
@@ -1259,8 +1258,8 @@ void GrRenderTargetContext::drawNonAAFilledRect(const GrClip& clip,
GrAAType hwOrNoneAAType) {
SkASSERT(GrAAType::kCoverage != hwOrNoneAAType);
SkASSERT(hwOrNoneAAType == GrAAType::kNone || this->isStencilBufferMultisampled());
- sk_sp<GrDrawOp> op( GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect,
- localRect, localMatrix));
+ sk_sp<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, rect,
+ localRect, localMatrix);
GrPipelineBuilder pipelineBuilder(paint, hwOrNoneAAType);
if (ss) {
pipelineBuilder.setUserStencil(ss);
@@ -1388,8 +1387,8 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
SkRect rects[2];
if (fills_as_nested_rects(viewMatrix, path, rects)) {
- sk_sp<GrDrawOp> op(GrRectBatchFactory::CreateAAFillNestedRects(
- paint.getColor(), viewMatrix, rects));
+ sk_sp<GrDrawOp> op =
+ GrRectOpFactory::MakeAAFillNestedRects(paint.getColor(), viewMatrix, rects);
if (op) {
GrPipelineBuilder pipelineBuilder(paint, aaType);
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, std::move(op));
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 15d7b75d12..fafbd7cb0f 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -33,7 +33,7 @@
#include "batches/GrDiscardBatch.h"
#include "batches/GrDrawOp.h"
#include "batches/GrDrawPathBatch.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "batches/GrStencilPathBatch.h"
#include "instanced/InstancedRendering.h"
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 00653908fc..caa244860b 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -19,7 +19,7 @@
#include "SkDistanceFieldGen.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
/*
* Convert a boolean operation into a transfer mode code
@@ -190,7 +190,7 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture,
maskMatrix,
GrSamplerParams::kNone_FilterMode));
- sk_sp<GrDrawOp> op(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), SkMatrix::I(), dstRect,
- nullptr, &invert));
+ sk_sp<GrDrawOp> op = GrRectOpFactory::MakeNonAAFill(paint.getColor(), SkMatrix::I(), dstRect,
+ nullptr, &invert);
renderTargetContext->addDrawOp(pipelineBuilder, clip, std::move(op));
}
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 12a753df73..dac88d4d68 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -8,12 +8,12 @@
#include "GrSoftwarePathRenderer.h"
#include "GrAuditTrail.h"
#include "GrClip.h"
-#include "GrPipelineBuilder.h"
#include "GrGpuResourcePriv.h"
+#include "GrPipelineBuilder.h"
#include "GrSWMaskHelper.h"
#include "GrSurfaceContextPriv.h"
#include "GrTextureProvider.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
////////////////////////////////////////////////////////////////////////////////
bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
@@ -69,8 +69,8 @@ void GrSoftwarePathRenderer::DrawNonAARect(GrRenderTargetContext* renderTargetCo
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkMatrix& localMatrix) {
- sk_sp<GrDrawOp> op(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect,
- nullptr, &localMatrix));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewMatrix, rect, nullptr,
+ &localMatrix));
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
pipelineBuilder.setUserStencil(&userStencilSettings);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 3cdc34e982..8549b0ccf1 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -22,17 +22,17 @@
#include "SkGlyphCache.h"
#include "SkGr.h"
#include "SkGrPriv.h"
-#include "SkImage_Base.h"
#include "SkImageCacherator.h"
#include "SkImageFilter.h"
#include "SkImageFilterCache.h"
+#include "SkImage_Base.h"
#include "SkLatticeIter.h"
#include "SkMaskFilter.h"
#include "SkPathEffect.h"
#include "SkPicture.h"
#include "SkPictureData.h"
-#include "SkRasterClip.h"
#include "SkRRect.h"
+#include "SkRasterClip.h"
#include "SkRecord.h"
#include "SkSpecialImage.h"
#include "SkStroke.h"
@@ -41,7 +41,7 @@
#include "SkTLazy.h"
#include "SkUtils.h"
#include "SkVertState.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "effects/GrBicubicEffect.h"
#include "effects/GrDashingEffect.h"
#include "effects/GrSimpleTextureEffect.h"
diff --git a/src/gpu/batches/GrAAFillRectBatch.h b/src/gpu/batches/GrAAFillRectBatch.h
deleted file mode 100644
index 62940d2ec2..0000000000
--- a/src/gpu/batches/GrAAFillRectBatch.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrAAFillRectBatch_DEFINED
-#define GrAAFillRectBatch_DEFINED
-
-#include "GrColor.h"
-
-class GrDrawOp;
-class SkMatrix;
-class GrOp;
-struct SkRect;
-
-namespace GrAAFillRectBatch {
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect);
-
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect);
-
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const SkRect& devRect);
-
-GrDrawOp* CreateWithLocalRect(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& localRect);
-};
-
-#endif
diff --git a/src/gpu/batches/GrAAFillRectBatch.cpp b/src/gpu/batches/GrAAFillRectOp.cpp
index cad896e5e5..9f7b0e0205 100644
--- a/src/gpu/batches/GrAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrAAFillRectOp.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrAAFillRectBatch.h"
+#include "GrAAFillRectOp.h"
#include "GrColor.h"
#include "GrDefaultGeoProcFactory.h"
@@ -19,10 +19,8 @@
GR_DECLARE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
-static void set_inset_fan(SkPoint* pts, size_t stride,
- const SkRect& r, SkScalar dx, SkScalar dy) {
- pts->setRectFan(r.fLeft + dx, r.fTop + dy,
- r.fRight - dx, r.fBottom - dy, stride);
+static void set_inset_fan(SkPoint* pts, size_t stride, const SkRect& r, SkScalar dx, SkScalar dy) {
+ pts->setRectFan(r.fLeft + dx, r.fTop + dy, r.fRight - dx, r.fBottom - dy, stride);
}
static const int kNumAAFillRectsInIndexBuffer = 256;
@@ -32,6 +30,7 @@ static const int kIndicesPerAAFillRect = 30;
const GrBuffer* get_index_buffer(GrResourceProvider* resourceProvider) {
GR_DEFINE_STATIC_UNIQUE_KEY(gAAFillRectIndexBufferKey);
+ // clang-format off
static const uint16_t gFillAARectIdx[] = {
0, 1, 5, 5, 4, 0,
1, 2, 6, 6, 5, 1,
@@ -39,10 +38,12 @@ const GrBuffer* get_index_buffer(GrResourceProvider* resourceProvider) {
3, 0, 4, 4, 7, 3,
4, 5, 6, 6, 7, 4,
};
+ // clang-format on
+
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gFillAARectIdx) == kIndicesPerAAFillRect);
- return resourceProvider->findOrCreateInstancedIndexBuffer(gFillAARectIdx,
- kIndicesPerAAFillRect, kNumAAFillRectsInIndexBuffer, kVertsPerAAFillRect,
- gAAFillRectIndexBufferKey);
+ return resourceProvider->findOrCreateInstancedIndexBuffer(
+ gFillAARectIdx, kIndicesPerAAFillRect, kNumAAFillRectsInIndexBuffer,
+ kVertsPerAAFillRect, gAAFillRectIndexBufferKey);
}
static void generate_aa_fill_rect_geometry(intptr_t verts,
@@ -63,13 +64,11 @@ static void generate_aa_fill_rect_geometry(intptr_t verts,
inset = SK_ScalarHalf * SkMinScalar(inset, devRect.height());
set_inset_fan(fan0Pos, vertexStride, devRect, -SK_ScalarHalf, -SK_ScalarHalf);
- set_inset_fan(fan1Pos, vertexStride, devRect, inset, inset);
+ set_inset_fan(fan1Pos, vertexStride, devRect, inset, inset);
} else {
// compute transformed (1, 0) and (0, 1) vectors
- SkVector vec[2] = {
- { viewMatrix[SkMatrix::kMScaleX], viewMatrix[SkMatrix::kMSkewY] },
- { viewMatrix[SkMatrix::kMSkewX], viewMatrix[SkMatrix::kMScaleY] }
- };
+ SkVector vec[2] = {{viewMatrix[SkMatrix::kMScaleX], viewMatrix[SkMatrix::kMSkewY]},
+ {viewMatrix[SkMatrix::kMSkewX], viewMatrix[SkMatrix::kMScaleY]}};
SkScalar len1 = SkPoint::Normalize(&vec[0]);
vec[0].scale(SK_ScalarHalf);
@@ -80,8 +79,7 @@ static void generate_aa_fill_rect_geometry(intptr_t verts,
inset = SK_ScalarHalf * SkMinScalar(inset, len2 * rect.height());
// create the rotated rect
- fan0Pos->setRectFan(rect.fLeft, rect.fTop,
- rect.fRight, rect.fBottom, vertexStride);
+ fan0Pos->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
viewMatrix.mapPointsWithStride(fan0Pos, vertexStride, 4);
// Now create the inset points and then outset the original
@@ -89,19 +87,19 @@ static void generate_aa_fill_rect_geometry(intptr_t verts,
// TL
*((SkPoint*)((intptr_t)fan1Pos + 0 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) + vec[0] + vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) + vec[0] + vec[1];
*((SkPoint*)((intptr_t)fan0Pos + 0 * vertexStride)) -= vec[0] + vec[1];
// BL
*((SkPoint*)((intptr_t)fan1Pos + 1 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 1 * vertexStride)) + vec[0] - vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 1 * vertexStride)) + vec[0] - vec[1];
*((SkPoint*)((intptr_t)fan0Pos + 1 * vertexStride)) -= vec[0] - vec[1];
// BR
*((SkPoint*)((intptr_t)fan1Pos + 2 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 2 * vertexStride)) - vec[0] - vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 2 * vertexStride)) - vec[0] - vec[1];
*((SkPoint*)((intptr_t)fan0Pos + 2 * vertexStride)) += vec[0] + vec[1];
// TR
*((SkPoint*)((intptr_t)fan1Pos + 3 * vertexStride)) =
- *((SkPoint*)((intptr_t)fan0Pos + 3 * vertexStride)) - vec[0] + vec[1];
+ *((SkPoint*)((intptr_t)fan0Pos + 3 * vertexStride)) - vec[0] + vec[1];
*((SkPoint*)((intptr_t)fan0Pos + 3 * vertexStride)) += vec[0] - vec[1];
}
@@ -152,20 +150,21 @@ static void generate_aa_fill_rect_geometry(intptr_t verts,
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
} else {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
- *reinterpret_cast<float*>(verts + i * vertexStride +
- coverageOffset) = innerCoverage;
+ *reinterpret_cast<float*>(verts + i * vertexStride + coverageOffset) = innerCoverage;
}
}
}
-class AAFillRectBatch final : public GrMeshDrawOp {
+
+class AAFillRectOp final: public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- AAFillRectBatch(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect,
- const SkMatrix* localMatrix) : INHERITED(ClassID()) {
+ AAFillRectOp(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect,
+ const SkMatrix* localMatrix)
+ : INHERITED(ClassID()) {
if (localMatrix) {
void* mem = fRectData.push_back_n(sizeof(RectWithLocalMatrixInfo));
new (mem) RectWithLocalMatrixInfo(color, viewMatrix, rect, devRect, *localMatrix);
@@ -173,13 +172,13 @@ public:
void* mem = fRectData.push_back_n(sizeof(RectInfo));
new (mem) RectInfo(color, viewMatrix, rect, devRect);
}
- IsZeroArea zeroArea = (!rect.width() || !rect.height()) ? IsZeroArea::kYes
- : IsZeroArea::kNo;
+ IsZeroArea zeroArea =
+ (!rect.width() || !rect.height()) ? IsZeroArea::kYes : IsZeroArea::kNo;
this->setBounds(devRect, HasAABloat::kYes, zeroArea);
fRectCnt = 1;
}
- const char* name() const override { return "AAFillRectBatch"; }
+ const char* name() const override { return "AAFillRectOp"; }
SkString dumpInfo() const override {
SkString str;
@@ -187,8 +186,8 @@ public:
const RectInfo* info = this->first();
for (int i = 0; i < fRectCnt; ++i) {
const SkRect& rect = info->rect();
- str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
- i, info->color(), rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
+ str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", i,
+ info->color(), rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
info = this->next(info);
}
str.append(DumpPipelineInfo(*this->pipeline()));
@@ -199,7 +198,7 @@ public:
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
- // When this is called on a batch, there is only one rect
+ // When this is called there is only one rect
color->setKnownFourComponents(this->first()->color());
coverage->setUnknownSingleComponent();
}
@@ -225,10 +224,10 @@ private:
coverageType = Coverage::kAttribute_Type;
}
Coverage coverage(coverageType);
- LocalCoords lc = needLocalCoords ? LocalCoords::kHasExplicit_Type
- : LocalCoords::kUnused_Type;
- sk_sp<GrGeometryProcessor> gp = GrDefaultGeoProcFactory::Make(color, coverage, lc,
- SkMatrix::I());
+ LocalCoords lc =
+ needLocalCoords ? LocalCoords::kHasExplicit_Type : LocalCoords::kUnused_Type;
+ sk_sp<GrGeometryProcessor> gp =
+ GrDefaultGeoProcFactory::Make(color, coverage, lc, SkMatrix::I());
if (!gp) {
SkDebugf("Couldn't create GrGeometryProcessor\n");
return;
@@ -238,9 +237,9 @@ private:
sk_sp<const GrBuffer> indexBuffer(get_index_buffer(target->resourceProvider()));
InstancedHelper helper;
- void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
- indexBuffer.get(), kVertsPerAAFillRect,
- kIndicesPerAAFillRect, fRectCnt);
+ void* vertices =
+ helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexBuffer.get(),
+ kVertsPerAAFillRect, kIndicesPerAAFillRect, fRectCnt);
if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
@@ -249,8 +248,8 @@ private:
const RectInfo* info = this->first();
const SkMatrix* localMatrix = nullptr;
for (int i = 0; i < fRectCnt; i++) {
- intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
- i * kVertsPerAAFillRect * vertexStride;
+ intptr_t verts =
+ reinterpret_cast<intptr_t>(vertices) + i * kVertsPerAAFillRect * vertexStride;
if (needLocalCoords) {
if (info->hasLocalMatrix()) {
localMatrix = &static_cast<const RectWithLocalMatrixInfo*>(info)->localMatrix();
@@ -258,23 +257,22 @@ private:
localMatrix = &SkMatrix::I();
}
}
- generate_aa_fill_rect_geometry(verts, vertexStride, info->color(),
- info->viewMatrix(), info->rect(),
- info->devRect(), fOverrides, localMatrix);
+ generate_aa_fill_rect_geometry(verts, vertexStride, info->color(), info->viewMatrix(),
+ info->rect(), info->devRect(), fOverrides, localMatrix);
info = this->next(info);
}
helper.recordDraw(target, gp.get());
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
- AAFillRectBatch* that = t->cast<AAFillRectBatch>();
+ AAFillRectOp* that = t->cast<AAFillRectOp>();
if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
that->bounds(), caps)) {
return false;
}
- // In the event of two batches, one who can tweak, one who cannot, we just fall back to
- // not tweaking
+ // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
+ // tweaking.
if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakAlphaForCoverage()) {
fOverrides = that->fOverrides;
}
@@ -289,7 +287,7 @@ private:
public:
RectInfo(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
const SkRect& devRect)
- : RectInfo(color, viewMatrix, rect, devRect, HasLocalMatrix::kNo) {}
+ : RectInfo(color, viewMatrix, rect, devRect, HasLocalMatrix::kNo) {}
bool hasLocalMatrix() const { return HasLocalMatrix::kYes == fHasLocalMatrix; }
GrColor color() const { return fColor; }
const SkMatrix& viewMatrix() const { return fViewMatrix; }
@@ -297,6 +295,7 @@ private:
const SkRect& devRect() const { return fDevRect; }
void setColor(GrColor color) { fColor = color; }
+
protected:
enum class HasLocalMatrix : uint32_t { kNo, kYes };
@@ -319,9 +318,10 @@ private:
public:
RectWithLocalMatrixInfo(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
const SkRect& devRect, const SkMatrix& localMatrix)
- : RectInfo(color, viewMatrix, rect, devRect, HasLocalMatrix::kYes)
- , fLocalMatrix(localMatrix) {}
+ : RectInfo(color, viewMatrix, rect, devRect, HasLocalMatrix::kYes)
+ , fLocalMatrix(localMatrix) {}
const SkMatrix& localMatrix() const { return fLocalMatrix; }
+
private:
SkMatrix fLocalMatrix;
};
@@ -329,9 +329,9 @@ private:
RectInfo* first() { return reinterpret_cast<RectInfo*>(fRectData.begin()); }
const RectInfo* first() const { return reinterpret_cast<const RectInfo*>(fRectData.begin()); }
const RectInfo* next(const RectInfo* prev) const {
- intptr_t next = reinterpret_cast<intptr_t>(prev) +
- (prev->hasLocalMatrix() ? sizeof(RectWithLocalMatrixInfo)
- : sizeof(RectInfo));
+ intptr_t next =
+ reinterpret_cast<intptr_t>(prev) +
+ (prev->hasLocalMatrix() ? sizeof(RectWithLocalMatrixInfo) : sizeof(RectInfo));
return reinterpret_cast<const RectInfo*>(next);
}
@@ -342,45 +342,44 @@ private:
typedef GrMeshDrawOp INHERITED;
};
-namespace GrAAFillRectBatch {
+namespace GrAAFillRectOp {
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
- return new AAFillRectBatch(color, viewMatrix, rect, devRect, nullptr);
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect) {
+ return sk_sp<GrDrawOp>(new AAFillRectOp(color, viewMatrix, rect, devRect, nullptr));
}
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
- return new AAFillRectBatch(color, viewMatrix, rect, devRect, &localMatrix);
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ const SkRect& rect,
+ const SkRect& devRect) {
+ return sk_sp<GrDrawOp>(new AAFillRectOp(color, viewMatrix, rect, devRect, &localMatrix));
}
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect) {
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ const SkRect& rect) {
SkRect devRect;
viewMatrix.mapRect(&devRect, rect);
- return Create(color, viewMatrix, localMatrix, rect, devRect);
+ return Make(color, viewMatrix, localMatrix, rect, devRect);
}
-GrDrawOp* CreateWithLocalRect(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& localRect) {
+sk_sp<GrDrawOp> MakeWithLocalRect(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& localRect) {
SkRect devRect;
viewMatrix.mapRect(&devRect, rect);
SkMatrix localMatrix;
if (!localMatrix.setRectToRect(rect, localRect, SkMatrix::kFill_ScaleToFit)) {
return nullptr;
}
- return Create(color, viewMatrix, localMatrix, rect, devRect);
+ return Make(color, viewMatrix, localMatrix, rect, devRect);
}
-
};
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -389,21 +388,21 @@ GrDrawOp* CreateWithLocalRect(GrColor color,
#include "GrBatchTest.h"
-DRAW_BATCH_TEST_DEFINE(AAFillRectBatch) {
+DRAW_BATCH_TEST_DEFINE(AAFillRectOp) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
SkRect rect = GrTest::TestRect(random);
SkRect devRect = GrTest::TestRect(random);
- return GrAAFillRectBatch::Create(color, viewMatrix, rect, devRect);
+ return GrAAFillRectOp::Make(color, viewMatrix, rect, devRect).release();
}
-DRAW_BATCH_TEST_DEFINE(AAFillRectBatchLocalMatrix) {
+DRAW_BATCH_TEST_DEFINE(AAFillRectOpLocalMatrix) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
SkMatrix localMatrix = GrTest::TestMatrix(random);
SkRect rect = GrTest::TestRect(random);
SkRect devRect = GrTest::TestRect(random);
- return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRect);
+ return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect).release();
}
#endif
diff --git a/src/gpu/batches/GrAAFillRectOp.h b/src/gpu/batches/GrAAFillRectOp.h
new file mode 100644
index 0000000000..b611ff98f8
--- /dev/null
+++ b/src/gpu/batches/GrAAFillRectOp.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrAAFillRectOp_DEFINED
+#define GrAAFillRectOp_DEFINED
+
+#include "GrColor.h"
+#include "SkRefCnt.h"
+
+class GrDrawOp;
+class SkMatrix;
+struct SkRect;
+
+namespace GrAAFillRectOp {
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& devRect);
+
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ const SkRect& rect);
+
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ const SkRect& rect,
+ const SkRect& devRect);
+
+sk_sp<GrDrawOp> MakeWithLocalRect(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& localRect);
+};
+
+#endif
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.h b/src/gpu/batches/GrAAStrokeRectBatch.h
deleted file mode 100644
index f29efb8d80..0000000000
--- a/src/gpu/batches/GrAAStrokeRectBatch.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrAAStrokeRectBatch_DEFINED
-#define GrAAStrokeRectBatch_DEFINED
-
-#include "GrColor.h"
-
-class GrDrawOp;
-class GrResourceProvider;
-class SkMatrix;
-struct SkRect;
-class SkStrokeRec;
-
-namespace GrAAStrokeRectBatch {
-
-GrDrawOp* CreateFillBetweenRects(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& devOutside,
- const SkRect& devInside);
-
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkStrokeRec& stroke);
-
-}
-
-#endif
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.cpp b/src/gpu/batches/GrAAStrokeRectOp.cpp
index 785cefe897..2b68636dee 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrAAStrokeRectOp.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrAAStrokeRectBatch.h"
+#include "GrAAStrokeRectOp.h"
#include "GrDefaultGeoProcFactory.h"
#include "GrOpFlushState.h"
@@ -15,10 +15,8 @@
GR_DECLARE_STATIC_UNIQUE_KEY(gMiterIndexBufferKey);
GR_DECLARE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey);
-static void set_inset_fan(SkPoint* pts, size_t stride,
- const SkRect& r, SkScalar dx, SkScalar dy) {
- pts->setRectFan(r.fLeft + dx, r.fTop + dy,
- r.fRight - dx, r.fBottom - dy, stride);
+static void set_inset_fan(SkPoint* pts, size_t stride, const SkRect& r, SkScalar dx, SkScalar dy) {
+ pts->setRectFan(r.fLeft + dx, r.fTop + dy, r.fRight - dx, r.fBottom - dy, stride);
}
// We support all hairlines, bevels, and miters, but not round joins. Also, check whether the miter
@@ -111,19 +109,18 @@ static sk_sp<GrGeometryProcessor> create_stroke_rect_gp(bool tweakAlphaForCovera
coverageType = Coverage::kAttribute_Type;
}
Coverage coverage(coverageType);
- LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type :
- LocalCoords::kUnused_Type);
+ LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type
+ : LocalCoords::kUnused_Type);
return MakeForDeviceSpace(color, coverage, localCoords, viewMatrix);
}
-class AAStrokeRectBatch final : public GrMeshDrawOp {
+class AAStrokeRectOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- AAStrokeRectBatch(GrColor color, const SkMatrix& viewMatrix,
- const SkRect& devOutside, const SkRect& devInside)
- : INHERITED(ClassID())
- , fViewMatrix(viewMatrix) {
+ AAStrokeRectOp(GrColor color, const SkMatrix& viewMatrix, const SkRect& devOutside,
+ const SkRect& devInside)
+ : INHERITED(ClassID()), fViewMatrix(viewMatrix) {
SkASSERT(!devOutside.isEmpty());
SkASSERT(!devInside.isEmpty());
@@ -132,22 +129,22 @@ public:
fMiterStroke = true;
}
- static GrDrawOp* Create(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
- const SkStrokeRec& stroke) {
+ static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
+ const SkStrokeRec& stroke) {
bool isMiter;
if (!allowed_stroke(stroke, &isMiter)) {
return nullptr;
}
- AAStrokeRectBatch* batch = new AAStrokeRectBatch();
- batch->fMiterStroke = isMiter;
- Geometry& geo = batch->fGeoData.push_back();
+ AAStrokeRectOp* op = new AAStrokeRectOp();
+ op->fMiterStroke = isMiter;
+ Geometry& geo = op->fGeoData.push_back();
compute_rects(&geo.fDevOutside, &geo.fDevOutsideAssist, &geo.fDevInside, &geo.fDegenerate,
viewMatrix, rect, stroke.getWidth(), isMiter);
geo.fColor = color;
- batch->setBounds(geo.fDevOutside, HasAABloat::kYes, IsZeroArea::kNo);
- batch->fViewMatrix = viewMatrix;
- return batch;
+ op->setBounds(geo.fDevOutside, HasAABloat::kYes, IsZeroArea::kNo);
+ op->fViewMatrix = viewMatrix;
+ return sk_sp<GrDrawOp>(op);
}
const char* name() const override { return "AAStrokeRect"; }
@@ -155,17 +152,15 @@ public:
SkString dumpInfo() const override {
SkString string;
for (const auto& geo : fGeoData) {
- string.appendf("Color: 0x%08x, ORect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], "
- "AssistORect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], "
- "IRect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], Degen: %d",
- geo.fColor,
- geo.fDevOutside.fLeft, geo.fDevOutside.fTop,
- geo.fDevOutside.fRight, geo.fDevOutside.fBottom,
- geo.fDevOutsideAssist.fLeft, geo.fDevOutsideAssist.fTop,
- geo.fDevOutsideAssist.fRight, geo.fDevOutsideAssist.fBottom,
- geo.fDevInside.fLeft, geo.fDevInside.fTop,
- geo.fDevInside.fRight, geo.fDevInside.fBottom,
- geo.fDegenerate);
+ string.appendf(
+ "Color: 0x%08x, ORect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], "
+ "AssistORect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], "
+ "IRect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], Degen: %d",
+ geo.fColor, geo.fDevOutside.fLeft, geo.fDevOutside.fTop, geo.fDevOutside.fRight,
+ geo.fDevOutside.fBottom, geo.fDevOutsideAssist.fLeft,
+ geo.fDevOutsideAssist.fTop, geo.fDevOutsideAssist.fRight,
+ geo.fDevOutsideAssist.fBottom, geo.fDevInside.fLeft, geo.fDevInside.fTop,
+ geo.fDevInside.fRight, geo.fDevInside.fBottom, geo.fDegenerate);
}
string.append(DumpPipelineInfo(*this->pipeline()));
string.append(INHERITED::dumpInfo());
@@ -175,13 +170,13 @@ public:
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
- // When this is called on a batch, there is only one geometry bundle
+ // When this is called there is only one rect.
color->setKnownFourComponents(fGeoData[0].fColor);
coverage->setUnknownSingleComponent();
}
private:
- AAStrokeRectBatch() : INHERITED(ClassID()) {}
+ AAStrokeRectOp() : INHERITED(ClassID()) {}
void onPrepareDraws(Target*) const override;
void initBatchTracker(const GrXPOverridesForBatch&) override;
@@ -244,7 +239,7 @@ private:
typedef GrMeshDrawOp INHERITED;
};
-void AAStrokeRectBatch::initBatchTracker(const GrXPOverridesForBatch& overrides) {
+void AAStrokeRectOp::initBatchTracker(const GrXPOverridesForBatch& overrides) {
// Handle any color overrides
if (!overrides.readsColor()) {
fGeoData[0].fColor = GrColor_ILLEGAL;
@@ -259,7 +254,7 @@ void AAStrokeRectBatch::initBatchTracker(const GrXPOverridesForBatch& overrides)
fBatch.fCanTweakAlphaForCoverage = overrides.canTweakAlphaForCoverage();
}
-void AAStrokeRectBatch::onPrepareDraws(Target* target) const {
+void AAStrokeRectOp::onPrepareDraws(Target* target) const {
bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();
sk_sp<GrGeometryProcessor> gp(create_stroke_rect_gp(canTweakAlphaForCoverage,
@@ -273,9 +268,9 @@ void AAStrokeRectBatch::onPrepareDraws(Target* target) const {
size_t vertexStride = gp->getVertexStride();
- SkASSERT(canTweakAlphaForCoverage ?
- vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) :
- vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
+ SkASSERT(canTweakAlphaForCoverage
+ ? vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr)
+ : vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
int innerVertexNum = 4;
int outerVertexNum = this->miterStroke() ? 4 : 8;
int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2;
@@ -283,15 +278,15 @@ void AAStrokeRectBatch::onPrepareDraws(Target* target) const {
int instanceCount = fGeoData.count();
const sk_sp<const GrBuffer> indexBuffer(
- GetIndexBuffer(target->resourceProvider(), this->miterStroke()));
+ GetIndexBuffer(target->resourceProvider(), this->miterStroke()));
InstancedHelper helper;
- void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
- indexBuffer.get(), verticesPerInstance, indicesPerInstance,
- instanceCount);
+ void* vertices =
+ helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexBuffer.get(),
+ verticesPerInstance, indicesPerInstance, instanceCount);
if (!vertices || !indexBuffer) {
- SkDebugf("Could not allocate vertices\n");
- return;
- }
+ SkDebugf("Could not allocate vertices\n");
+ return;
+ }
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
@@ -311,10 +306,10 @@ void AAStrokeRectBatch::onPrepareDraws(Target* target) const {
helper.recordDraw(target, gp.get());
}
-const GrBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resourceProvider,
- bool miterStroke) {
-
+const GrBuffer* AAStrokeRectOp::GetIndexBuffer(GrResourceProvider* resourceProvider,
+ bool miterStroke) {
if (miterStroke) {
+ // clang-format off
static const uint16_t gMiterIndices[] = {
0 + 0, 1 + 0, 5 + 0, 5 + 0, 4 + 0, 0 + 0,
1 + 0, 2 + 0, 6 + 0, 6 + 0, 5 + 0, 1 + 0,
@@ -331,11 +326,12 @@ const GrBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resourcePr
2 + 8, 3 + 8, 7 + 8, 7 + 8, 6 + 8, 2 + 8,
3 + 8, 0 + 8, 4 + 8, 4 + 8, 7 + 8, 3 + 8,
};
+ // clang-format on
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gMiterIndices) == kMiterIndexCnt);
GR_DEFINE_STATIC_UNIQUE_KEY(gMiterIndexBufferKey);
- return resourceProvider->findOrCreateInstancedIndexBuffer(gMiterIndices,
- kMiterIndexCnt, kNumMiterRectsInIndexBuffer, kMiterVertexCnt,
- gMiterIndexBufferKey);
+ return resourceProvider->findOrCreateInstancedIndexBuffer(
+ gMiterIndices, kMiterIndexCnt, kNumMiterRectsInIndexBuffer, kMiterVertexCnt,
+ gMiterIndexBufferKey);
} else {
/**
* As in miter-stroke, index = a + b, and a is the current index, b is the shift
@@ -366,6 +362,7 @@ const GrBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resourcePr
* **********************************
* 5 6
*/
+ // clang-format off
static const uint16_t gBevelIndices[] = {
// Draw outer AA, from outer AA line to outer edge, shift is 0.
0 + 0, 1 + 0, 9 + 0, 9 + 0, 8 + 0, 0 + 0,
@@ -393,17 +390,18 @@ const GrBuffer* AAStrokeRectBatch::GetIndexBuffer(GrResourceProvider* resourcePr
2 + 16, 3 + 16, 7 + 16, 7 + 16, 6 + 16, 2 + 16,
3 + 16, 0 + 16, 4 + 16, 4 + 16, 7 + 16, 3 + 16,
};
+ // clang-format on
GR_STATIC_ASSERT(SK_ARRAY_COUNT(gBevelIndices) == kBevelIndexCnt);
GR_DEFINE_STATIC_UNIQUE_KEY(gBevelIndexBufferKey);
- return resourceProvider->findOrCreateInstancedIndexBuffer(gBevelIndices,
- kBevelIndexCnt, kNumBevelRectsInIndexBuffer, kBevelVertexCnt,
- gBevelIndexBufferKey);
+ return resourceProvider->findOrCreateInstancedIndexBuffer(
+ gBevelIndices, kBevelIndexCnt, kNumBevelRectsInIndexBuffer, kBevelVertexCnt,
+ gBevelIndexBufferKey);
}
}
-bool AAStrokeRectBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
- AAStrokeRectBatch* that = t->cast<AAStrokeRectBatch>();
+bool AAStrokeRectOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
+ AAStrokeRectOp* that = t->cast<AAStrokeRectOp>();
if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
that->bounds(), caps)) {
@@ -422,8 +420,8 @@ bool AAStrokeRectBatch::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
return false;
}
- // In the event of two batches, one who can tweak, one who cannot, we just fall back to
- // not tweaking
+ // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
+ // tweaking.
if (this->canTweakAlphaForCoverage() != that->canTweakAlphaForCoverage()) {
fBatch.fCanTweakAlphaForCoverage = false;
}
@@ -445,18 +443,18 @@ static void setup_scale(int* scale, SkScalar inset) {
}
}
-void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
- size_t offset,
- size_t vertexStride,
- int outerVertexNum,
- int innerVertexNum,
- GrColor color,
- const SkRect& devOutside,
- const SkRect& devOutsideAssist,
- const SkRect& devInside,
- bool miterStroke,
- bool degenerate,
- bool tweakAlphaForCoverage) const {
+void AAStrokeRectOp::generateAAStrokeRectGeometry(void* vertices,
+ size_t offset,
+ size_t vertexStride,
+ int outerVertexNum,
+ int innerVertexNum,
+ GrColor color,
+ const SkRect& devOutside,
+ const SkRect& devOutsideAssist,
+ const SkRect& devInside,
+ bool miterStroke,
+ bool degenerate,
+ bool tweakAlphaForCoverage) const {
intptr_t verts = reinterpret_cast<intptr_t>(vertices) + offset;
// We create vertices for four nested rectangles. There are two ramps from 0 to full
@@ -465,9 +463,8 @@ void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vertexStride);
SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * vertexStride);
- SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts +
- (2 * outerVertexNum + innerVertexNum) *
- vertexStride);
+ SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(
+ verts + (2 * outerVertexNum + innerVertexNum) * vertexStride);
#ifndef SK_IGNORE_THIN_STROKED_RECT_FIX
// TODO: this only really works if the X & Y margins are the same all around
@@ -480,15 +477,15 @@ void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
if (miterStroke) {
inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom);
} else {
- inset = SK_ScalarHalf * SkMinScalar(inset, devOutsideAssist.fBottom -
- devInside.fBottom);
+ inset = SK_ScalarHalf *
+ SkMinScalar(inset, devOutsideAssist.fBottom - devInside.fBottom);
}
SkASSERT(inset >= 0);
} else {
// TODO use real devRect here
inset = SkMinScalar(devOutside.width(), SK_Scalar1);
- inset = SK_ScalarHalf * SkMinScalar(inset, SkTMax(devOutside.height(),
- devOutsideAssist.height()));
+ inset = SK_ScalarHalf *
+ SkMinScalar(inset, SkTMax(devOutside.height(), devOutsideAssist.height()));
}
#else
SkScalar inset;
@@ -497,8 +494,8 @@ void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
} else {
// TODO use real devRect here
inset = SkMinScalar(devOutside.width(), SK_Scalar1);
- inset = SK_ScalarHalf * SkMinScalar(inset, SkTMax(devOutside.height(),
- devOutsideAssist.height()));
+ inset = SK_ScalarHalf *
+ SkMinScalar(inset, SkTMax(devOutside.height(), devOutsideAssist.height()));
}
#endif
@@ -506,45 +503,42 @@ void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
// outermost
set_inset_fan(fan0Pos, vertexStride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
// inner two
- set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
+ set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
if (!degenerate) {
- set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
+ set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
// innermost
- set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
+ set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
} else {
// When the interior rect has become degenerate we smoosh to a single point
- SkASSERT(devInside.fLeft == devInside.fRight &&
- devInside.fTop == devInside.fBottom);
- fan2Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
- fan3Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
+ SkASSERT(devInside.fLeft == devInside.fRight && devInside.fTop == devInside.fBottom);
+ fan2Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
+ devInside.fBottom, vertexStride);
+ fan3Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
+ devInside.fBottom, vertexStride);
}
} else {
SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
- SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(verts +
- (outerVertexNum + 4) *
- vertexStride);
+ SkPoint* fan1AssistPos =
+ reinterpret_cast<SkPoint*>(verts + (outerVertexNum + 4) * vertexStride);
// outermost
set_inset_fan(fan0Pos, vertexStride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
set_inset_fan(fan0AssistPos, vertexStride, devOutsideAssist, -SK_ScalarHalf,
-SK_ScalarHalf);
// outer one of the inner two
- set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
- set_inset_fan(fan1AssistPos, vertexStride, devOutsideAssist, inset, inset);
+ set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
+ set_inset_fan(fan1AssistPos, vertexStride, devOutsideAssist, inset, inset);
if (!degenerate) {
// inner one of the inner two
- set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
+ set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
// innermost
- set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
+ set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
} else {
// When the interior rect has become degenerate we smoosh to a single point
- SkASSERT(devInside.fLeft == devInside.fRight &&
- devInside.fTop == devInside.fBottom);
- fan2Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
- fan3Pos->setRectFan(devInside.fLeft, devInside.fTop,
- devInside.fRight, devInside.fBottom, vertexStride);
+ SkASSERT(devInside.fLeft == devInside.fRight && devInside.fTop == devInside.fBottom);
+ fan2Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
+ devInside.fBottom, vertexStride);
+ fan3Pos->setRectFan(devInside.fLeft, devInside.fTop, devInside.fRight,
+ devInside.fBottom, vertexStride);
}
}
@@ -595,22 +589,21 @@ void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
}
}
-namespace GrAAStrokeRectBatch {
+namespace GrAAStrokeRectOp {
-GrDrawOp* CreateFillBetweenRects(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& devOutside,
- const SkRect& devInside) {
- return new AAStrokeRectBatch(color, viewMatrix, devOutside, devInside);
+sk_sp<GrDrawOp> MakeFillBetweenRects(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& devOutside,
+ const SkRect& devInside) {
+ return sk_sp<GrDrawOp>(new AAStrokeRectOp(color, viewMatrix, devOutside, devInside));
}
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkStrokeRec& stroke) {
- return AAStrokeRectBatch::Create(color, viewMatrix, rect, stroke);
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkStrokeRec& stroke) {
+ return AAStrokeRectOp::Make(color, viewMatrix, rect, stroke);
}
-
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -619,12 +612,12 @@ GrDrawOp* Create(GrColor color,
#include "GrBatchTest.h"
-DRAW_BATCH_TEST_DEFINE(AAStrokeRectBatch) {
+DRAW_BATCH_TEST_DEFINE(AAStrokeRectOp) {
bool miterStroke = random->nextBool();
// Create either a empty rect or a non-empty rect.
- SkRect rect = random->nextBool() ? SkRect::MakeXYWH(10, 10, 50, 40) :
- SkRect::MakeXYWH(6, 7, 0, 0);
+ SkRect rect =
+ random->nextBool() ? SkRect::MakeXYWH(10, 10, 50, 40) : SkRect::MakeXYWH(6, 7, 0, 0);
SkScalar minDim = SkMinScalar(rect.width(), rect.height());
SkScalar strokeWidth = random->nextUScalar1() * minDim;
@@ -633,10 +626,9 @@ DRAW_BATCH_TEST_DEFINE(AAStrokeRectBatch) {
SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
rec.setStrokeStyle(strokeWidth);
rec.setStrokeParams(SkPaint::kButt_Cap,
- miterStroke ? SkPaint::kMiter_Join : SkPaint::kBevel_Join,
- 1.f);
+ miterStroke ? SkPaint::kMiter_Join : SkPaint::kBevel_Join, 1.f);
SkMatrix matrix = GrTest::TestMatrixRectStaysRect(random);
- return GrAAStrokeRectBatch::Create(color, matrix, rect, rec);
+ return GrAAStrokeRectOp::Make(color, matrix, rect, rec).release();
}
#endif
diff --git a/src/gpu/batches/GrAAStrokeRectOp.h b/src/gpu/batches/GrAAStrokeRectOp.h
new file mode 100644
index 0000000000..fe8f55c00a
--- /dev/null
+++ b/src/gpu/batches/GrAAStrokeRectOp.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrAAStrokeRectOp_DEFINED
+#define GrAAStrokeRectOp_DEFINED
+
+#include "GrColor.h"
+#include "SkRefCnt.h"
+
+class GrDrawOp;
+class SkMatrix;
+struct SkRect;
+class SkStrokeRec;
+
+namespace GrAAStrokeRectOp {
+
+sk_sp<GrDrawOp> MakeFillBetweenRects(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& devOutside,
+ const SkRect& devInside);
+
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkStrokeRec& stroke);
+}
+
+#endif
diff --git a/src/gpu/batches/GrAnalyticRectBatch.cpp b/src/gpu/batches/GrAnalyticRectOp.cpp
index 16c1382e8f..c71fb58ea8 100644
--- a/src/gpu/batches/GrAnalyticRectBatch.cpp
+++ b/src/gpu/batches/GrAnalyticRectOp.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrAnalyticRectBatch.h"
+#include "GrAnalyticRectOp.h"
#include "GrBatchTest.h"
#include "GrGeometryProcessor.h"
@@ -27,14 +27,13 @@
namespace {
struct RectVertex {
- SkPoint fPos;
- GrColor fColor;
- SkPoint fCenter;
+ SkPoint fPos;
+ GrColor fColor;
+ SkPoint fCenter;
SkVector fDownDir;
SkScalar fHalfWidth;
SkScalar fHalfHeight;
};
-
}
///////////////////////////////////////////////////////////////////////////////
@@ -55,18 +54,18 @@ class RectGeometryProcessor : public GrGeometryProcessor {
public:
RectGeometryProcessor(const SkMatrix& localMatrix) : fLocalMatrix(localMatrix) {
this->initClassID<RectGeometryProcessor>();
- fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType,
- kHigh_GrSLPrecision);
- fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType);
- fInRectEdge = &this->addVertexAttrib("inRectEdge", kVec4f_GrVertexAttribType);
+ fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType,
+ kHigh_GrSLPrecision);
+ fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType);
+ fInRectEdge = &this->addVertexAttrib("inRectEdge", kVec4f_GrVertexAttribType);
fInWidthHeight = &this->addVertexAttrib("inWidthHeight", kVec2f_GrVertexAttribType);
}
bool implementsDistanceVector() const override { return true; }
- const Attribute* inPosition() const { return fInPosition; }
- const Attribute* inColor() const { return fInColor; }
- const Attribute* inRectEdge() const { return fInRectEdge; }
+ const Attribute* inPosition() const { return fInPosition; }
+ const Attribute* inColor() const { return fInColor; }
+ const Attribute* inRectEdge() const { return fInRectEdge; }
const Attribute* inWidthHeight() const { return fInWidthHeight; }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
@@ -79,7 +78,7 @@ public:
public:
GLSLProcessor() {}
- void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
+ void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const RectGeometryProcessor& rgp = args.fGP.cast<RectGeometryProcessor>();
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
@@ -102,8 +101,8 @@ public:
// setup the varying for the width/2+.5 and height/2+.5
GrGLSLVertToFrag widthHeightVary(kVec2f_GrSLType);
varyingHandler->addVarying("WidthHeight", &widthHeightVary);
- vertBuilder->codeAppendf("%s = %s;",
- widthHeightVary.vsOut(), rgp.inWidthHeight()->fName);
+ vertBuilder->codeAppendf("%s = %s;", widthHeightVary.vsOut(),
+ rgp.inWidthHeight()->fName);
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -138,8 +137,8 @@ public:
fragBuilder->codeAppend("float scaleW = min(1.0, 2.0*insetW/spanW);");
fragBuilder->codeAppend("float scaleH = min(1.0, 2.0*insetH/spanH);");
// Compute the coverage for the rect's width
- fragBuilder->codeAppendf("vec2 offset = %s.xy - %s.xy;",
- positionVary.fsIn(), rectEdgeVary.fsIn());
+ fragBuilder->codeAppendf("vec2 offset = %s.xy - %s.xy;", positionVary.fsIn(),
+ rectEdgeVary.fsIn());
fragBuilder->codeAppendf("float perpDot = abs(offset.x * %s.w - offset.y * %s.z);",
rectEdgeVary.fsIn(), rectEdgeVary.fsIn());
@@ -152,8 +151,7 @@ public:
"float coverage = scaleW*clamp((%s.x-perpDot)/spanW, 0.0, 1.0);",
widthHeightVary.fsIn());
// Compute the coverage for the rect's height and merge with the width
- fragBuilder->codeAppendf("perpDot = abs(dot(offset, %s.zw));",
- rectEdgeVary.fsIn());
+ fragBuilder->codeAppendf("perpDot = abs(dot(offset, %s.zw));", rectEdgeVary.fsIn());
if (args.fDistanceVectorName) {
fragBuilder->codeAppendf("float heightDistance = %s.y - perpDot;",
@@ -167,23 +165,22 @@ public:
fragBuilder->codeAppendf("%s = vec4(coverage);", args.fOutputCoverage);
if (args.fDistanceVectorName) {
- fragBuilder->codeAppend( "// Calculating distance vector\n");
- fragBuilder->codeAppend( "vec2 dvAxis;");
- fragBuilder->codeAppend( "float dvLength;");
+ fragBuilder->codeAppend("// Calculating distance vector\n");
+ fragBuilder->codeAppend("vec2 dvAxis;");
+ fragBuilder->codeAppend("float dvLength;");
- fragBuilder->codeAppend( "if (heightDistance < widthDistance) {");
+ fragBuilder->codeAppend("if (heightDistance < widthDistance) {");
fragBuilder->codeAppendf(" dvAxis = %s.zw;", rectEdgeVary.fsIn());
- fragBuilder->codeAppend( " dvLength = heightDistance;");
- fragBuilder->codeAppend( "} else {");
- fragBuilder->codeAppendf(" dvAxis = vec2(-%s.w, %s.z);",
- rectEdgeVary.fsIn(), rectEdgeVary.fsIn());
- fragBuilder->codeAppend( " dvLength = widthDistance;");
- fragBuilder->codeAppend( "}");
-
- fragBuilder->codeAppend( "float dvSign = sign(dot(offset, dvAxis));");
+ fragBuilder->codeAppend(" dvLength = heightDistance;");
+ fragBuilder->codeAppend("} else {");
+ fragBuilder->codeAppendf(" dvAxis = vec2(-%s.w, %s.z);", rectEdgeVary.fsIn(),
+ rectEdgeVary.fsIn());
+ fragBuilder->codeAppend(" dvLength = widthDistance;");
+ fragBuilder->codeAppend("}");
+
+ fragBuilder->codeAppend("float dvSign = sign(dot(offset, dvAxis));");
fragBuilder->codeAppendf("%s = vec4(dvSign * dvAxis, dvLength, 0.0);",
args.fDistanceVectorName);
-
}
}
@@ -196,7 +193,7 @@ public:
void setData(const GrGLSLProgramDataManager& pdman, const GrPrimitiveProcessor& primProc,
FPCoordTransformIter&& transformIter) override {
const RectGeometryProcessor& rgp = primProc.cast<RectGeometryProcessor>();
- this->setTransformDataHelper(rgp.fLocalMatrix, pdman,&transformIter);
+ this->setTransformDataHelper(rgp.fLocalMatrix, pdman, &transformIter);
}
private:
@@ -212,7 +209,7 @@ public:
}
private:
- SkMatrix fLocalMatrix;
+ SkMatrix fLocalMatrix;
const Attribute* fInPosition;
const Attribute* fInColor;
@@ -227,20 +224,18 @@ private:
GR_DEFINE_GEOMETRY_PROCESSOR_TEST(RectGeometryProcessor);
sk_sp<GrGeometryProcessor> RectGeometryProcessor::TestCreate(GrProcessorTestData* d) {
- return sk_sp<GrGeometryProcessor>(
- new RectGeometryProcessor(GrTest::TestMatrix(d->fRandom)));
+ return sk_sp<GrGeometryProcessor>(new RectGeometryProcessor(GrTest::TestMatrix(d->fRandom)));
}
///////////////////////////////////////////////////////////////////////////////
-class AnalyticRectBatch final : public GrMeshDrawOp {
+class AnalyticRectOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- AnalyticRectBatch(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
- const SkRect& croppedRect, const SkRect& bounds)
- : INHERITED(ClassID())
- , fViewMatrixIfUsingLocalCoords(viewMatrix) {
+ AnalyticRectOp(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
+ const SkRect& croppedRect, const SkRect& bounds)
+ : INHERITED(ClassID()), fViewMatrixIfUsingLocalCoords(viewMatrix) {
SkPoint center = SkPoint::Make(rect.centerX(), rect.centerY());
viewMatrix.mapPoints(&center, 1);
SkScalar halfWidth = viewMatrix.mapRadius(SkScalarHalf(rect.width()));
@@ -251,8 +246,8 @@ public:
SkRect deviceSpaceCroppedRect = croppedRect;
viewMatrix.mapRect(&deviceSpaceCroppedRect);
- fGeoData.emplace_back(Geometry {color, center, downDir, halfWidth, halfHeight,
- deviceSpaceCroppedRect});
+ fGeoData.emplace_back(
+ Geometry{color, center, downDir, halfWidth, halfHeight, deviceSpaceCroppedRect});
this->setBounds(bounds, HasAABloat::kYes, IsZeroArea::kNo);
}
@@ -263,11 +258,9 @@ public:
SkString string;
for (int i = 0; i < fGeoData.count(); ++i) {
string.appendf("Color: 0x%08x Rect [C:(%.2f, %.2f) D:<%.2f,%.3f> W/2:%.2f H/2:%.2f]\n",
- fGeoData[i].fColor,
- fGeoData[i].fCenter.x(), fGeoData[i].fCenter.y(),
+ fGeoData[i].fColor, fGeoData[i].fCenter.x(), fGeoData[i].fCenter.y(),
fGeoData[i].fDownDir.x(), fGeoData[i].fDownDir.y(),
- fGeoData[i].fHalfWidth,
- fGeoData[i].fHalfHeight);
+ fGeoData[i].fHalfWidth, fGeoData[i].fHalfHeight);
}
string.append(DumpPipelineInfo(*this->pipeline()));
string.append(INHERITED::dumpInfo());
@@ -277,7 +270,7 @@ public:
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
- // When this is called on a batch, there is only one geometry bundle
+ // When this is called there is only one rect.
color->setKnownFourComponents(fGeoData[0].fColor);
coverage->setUnknownSingleComponent();
}
@@ -304,8 +297,8 @@ private:
size_t vertexStride = gp->getVertexStride();
SkASSERT(vertexStride == sizeof(RectVertex));
QuadHelper helper;
- RectVertex* verts = reinterpret_cast<RectVertex*>(helper.init(target, vertexStride,
- instanceCount));
+ RectVertex* verts =
+ reinterpret_cast<RectVertex*>(helper.init(target, vertexStride, instanceCount));
if (!verts) {
return;
}
@@ -313,12 +306,12 @@ private:
for (int i = 0; i < instanceCount; i++) {
const Geometry& geom = fGeoData[i];
- GrColor color = geom.fColor;
- SkPoint center = geom.fCenter;
- SkVector downDir = geom.fDownDir;
- SkScalar halfWidth = geom.fHalfWidth;
- SkScalar halfHeight = geom.fHalfHeight;
- SkRect croppedRect = geom.fCroppedRect;
+ GrColor color = geom.fColor;
+ SkPoint center = geom.fCenter;
+ SkVector downDir = geom.fDownDir;
+ SkScalar halfWidth = geom.fHalfWidth;
+ SkScalar halfHeight = geom.fHalfHeight;
+ SkRect croppedRect = geom.fCroppedRect;
SkVector rightDir;
downDir.rotateCCW(&rightDir);
@@ -357,7 +350,7 @@ private:
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
- AnalyticRectBatch* that = t->cast<AnalyticRectBatch>();
+ AnalyticRectOp* that = t->cast<AnalyticRectOp>();
if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
that->bounds(), caps)) {
return false;
@@ -373,37 +366,37 @@ private:
}
struct Geometry {
- GrColor fColor;
- SkPoint fCenter;
+ GrColor fColor;
+ SkPoint fCenter;
SkVector fDownDir;
SkScalar fHalfWidth;
SkScalar fHalfHeight;
- SkRect fCroppedRect;
+ SkRect fCroppedRect;
};
- SkMatrix fViewMatrixIfUsingLocalCoords;
+ SkMatrix fViewMatrixIfUsingLocalCoords;
SkSTArray<1, Geometry, true> fGeoData;
typedef GrMeshDrawOp INHERITED;
};
-GrDrawOp* GrAnalyticRectBatch::CreateAnalyticRectBatch(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& croppedRect,
- const SkRect& bounds) {
- return new AnalyticRectBatch(color, viewMatrix, rect, croppedRect, bounds);
+sk_sp<GrDrawOp> GrAnalyticRectOp::Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& croppedRect,
+ const SkRect& bounds) {
+ return sk_sp<GrDrawOp>(new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds));
}
#ifdef GR_TEST_UTILS
-DRAW_BATCH_TEST_DEFINE(AnalyticRectBatch) {
+DRAW_BATCH_TEST_DEFINE(AnalyticRectOp) {
SkMatrix viewMatrix = GrTest::TestMatrix(random);
GrColor color = GrRandomColor(random);
SkRect rect = GrTest::TestSquare(random);
SkRect croppedRect = GrTest::TestSquare(random);
SkRect bounds = GrTest::TestSquare(random);
- return new AnalyticRectBatch(color, viewMatrix, rect, croppedRect, bounds);
+ return new AnalyticRectOp(color, viewMatrix, rect, croppedRect, bounds);
}
#endif
diff --git a/src/gpu/batches/GrAnalyticRectBatch.h b/src/gpu/batches/GrAnalyticRectOp.h
index 0c07c2a9c6..77d17ed7c7 100644
--- a/src/gpu/batches/GrAnalyticRectBatch.h
+++ b/src/gpu/batches/GrAnalyticRectOp.h
@@ -5,10 +5,11 @@
* found in the LICENSE file.
*/
-#ifndef GrAnalyticRectBatch_DEFINED
-#define GrAnalyticRectBatch_DEFINED
+#ifndef GrAnalyticRectOp_DEFINED
+#define GrAnalyticRectOp_DEFINED
#include "GrColor.h"
+#include "SkRefCnt.h"
class GrDrawOp;
class SkMatrix;
@@ -24,13 +25,13 @@ struct SkRect;
* @param croppedRect the shape in device space, clipped to the device's bounds
* @param bounds the axis aligned bounds of the shape in device space
*/
-class GrAnalyticRectBatch {
+class GrAnalyticRectOp {
public:
- static GrDrawOp* CreateAnalyticRectBatch(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& croppedRect,
- const SkRect& bounds);
+ static sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& croppedRect,
+ const SkRect& bounds);
};
-#endif // GrAnalyticRectBatch_DEFINED
+#endif // GrAnalyticRectOp_DEFINED
diff --git a/src/gpu/batches/GrDefaultPathRenderer.cpp b/src/gpu/batches/GrDefaultPathRenderer.cpp
index 07eee5460f..dc8024ce39 100644
--- a/src/gpu/batches/GrDefaultPathRenderer.cpp
+++ b/src/gpu/batches/GrDefaultPathRenderer.cpp
@@ -22,7 +22,7 @@
#include "SkTraceEvent.h"
#include "batches/GrMeshDrawOp.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport,
bool stencilWrapOpsSupport)
@@ -564,8 +564,8 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget
}
const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() :
viewMatrix;
- sk_sp<GrDrawOp> op(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds,
- nullptr, &localMatrix));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewM, bounds,
+ nullptr, &localMatrix));
SkASSERT(GrDrawFace::kBoth == drawFace[p]);
GrPipelineBuilder pipelineBuilder(paint, aaType);
diff --git a/src/gpu/batches/GrMSAAPathRenderer.cpp b/src/gpu/batches/GrMSAAPathRenderer.cpp
index dca7500f43..d1b461f5fb 100644
--- a/src/gpu/batches/GrMSAAPathRenderer.cpp
+++ b/src/gpu/batches/GrMSAAPathRenderer.cpp
@@ -19,7 +19,7 @@
#include "SkGeometry.h"
#include "SkTraceEvent.h"
#include "batches/GrMeshDrawOp.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
#include "gl/GrGLVaryingHandler.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
@@ -659,8 +659,8 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon
}
const SkMatrix& viewM = (reverse && viewMatrix.hasPerspective()) ? SkMatrix::I() :
viewMatrix;
- sk_sp<GrDrawOp> op(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds,
- nullptr, &localMatrix));
+ sk_sp<GrDrawOp> op(GrRectOpFactory::MakeNonAAFill(paint.getColor(), viewM, bounds,
+ nullptr, &localMatrix));
GrPipelineBuilder pipelineBuilder(paint, aaType);
pipelineBuilder.setUserStencil(passes[p]);
diff --git a/src/gpu/batches/GrNonAAFillRectBatch.h b/src/gpu/batches/GrNonAAFillRectBatch.h
deleted file mode 100644
index 6cf7cc310e..0000000000
--- a/src/gpu/batches/GrNonAAFillRectBatch.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrNonAAFillRectBatch_DEFINED
-#define GrNonAAFillRectBatch_DEFINED
-
-#include "GrColor.h"
-
-class GrDrawOp;
-class SkMatrix;
-struct SkRect;
-
-namespace GrNonAAFillRectBatch {
-
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix);
-
-GrDrawOp* CreateWithPerspective(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix);
-
-};
-
-#endif
diff --git a/src/gpu/batches/GrNonAAFillRectBatch.cpp b/src/gpu/batches/GrNonAAFillRectOp.cpp
index 2dbced3b17..de000e2ce7 100644
--- a/src/gpu/batches/GrNonAAFillRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAFillRectOp.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrNonAAFillRectBatch.h"
+#include "GrNonAAFillRectOp.h"
#include "GrColor.h"
#include "GrDefaultGeoProcFactory.h"
@@ -45,8 +45,7 @@ static void tesselate(intptr_t vertices,
const GrQuad* localQuad) {
SkPoint* positions = reinterpret_cast<SkPoint*>(vertices);
- positions->setRectFan(rect.fLeft, rect.fTop,
- rect.fRight, rect.fBottom, vertexStride);
+ positions->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
if (viewMatrix) {
SkMatrixPriv::MapPointsWithStride(*viewMatrix, positions, vertexStride, kVertsPerInstance);
@@ -57,8 +56,8 @@ static void tesselate(intptr_t vertices,
if (localQuad) {
static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
for (int i = 0; i < kVertsPerInstance; i++) {
- SkPoint* coords = reinterpret_cast<SkPoint*>(vertices + kLocalOffset +
- i * vertexStride);
+ SkPoint* coords =
+ reinterpret_cast<SkPoint*>(vertices + kLocalOffset + i * vertexStride);
*coords = localQuad->point(i);
}
}
@@ -67,19 +66,18 @@ static void tesselate(intptr_t vertices,
GrColor* vertColor = reinterpret_cast<GrColor*>(vertices + kColorOffset);
for (int j = 0; j < 4; ++j) {
*vertColor = color;
- vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
+ vertColor = (GrColor*)((intptr_t)vertColor + vertexStride);
}
}
-class NonAAFillRectBatch final : public GrMeshDrawOp {
+class NonAAFillRectOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- NonAAFillRectBatch(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
- const SkRect* localRect, const SkMatrix* localMatrix)
+ NonAAFillRectOp(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
+ const SkRect* localRect, const SkMatrix* localMatrix)
: INHERITED(ClassID()) {
- SkASSERT(!viewMatrix.hasPerspective() && (!localMatrix ||
- !localMatrix->hasPerspective()));
+ SkASSERT(!viewMatrix.hasPerspective() && (!localMatrix || !localMatrix->hasPerspective()));
RectInfo& info = fRects.push_back();
info.fColor = color;
info.fViewMatrix = viewMatrix;
@@ -96,16 +94,16 @@ public:
this->setTransformedBounds(fRects[0].fRect, viewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
}
- const char* name() const override { return "NonAAFillRectBatch"; }
+ const char* name() const override { return "NonAAFillRectOp"; }
SkString dumpInfo() const override {
SkString str;
str.appendf("# batched: %d\n", fRects.count());
for (int i = 0; i < fRects.count(); ++i) {
const RectInfo& info = fRects[i];
- str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
- i, info.fColor,
- info.fRect.fLeft, info.fRect.fTop, info.fRect.fRight, info.fRect.fBottom);
+ str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", i,
+ info.fColor, info.fRect.fLeft, info.fRect.fTop, info.fRect.fRight,
+ info.fRect.fBottom);
}
str.append(DumpPipelineInfo(*this->pipeline()));
str.append(INHERITED::dumpInfo());
@@ -115,7 +113,7 @@ public:
void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
- // When this is called on a batch, there is only one geometry bundle
+ // When this is called there is only one rect.
color->setKnownFourComponents(fRects[0].fColor);
coverage->setKnownSingleComponent(0xff);
}
@@ -126,7 +124,7 @@ public:
}
private:
- NonAAFillRectBatch() : INHERITED(ClassID()) {}
+ NonAAFillRectOp() : INHERITED(ClassID()) {}
void onPrepareDraws(Target* target) const override {
sk_sp<GrGeometryProcessor> gp = make_gp(fOverrides.readsCoverage());
@@ -142,17 +140,17 @@ private:
sk_sp<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
InstancedHelper helper;
- void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
- indexBuffer.get(), kVertsPerInstance,
- kIndicesPerInstance, instanceCount);
+ void* vertices =
+ helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexBuffer.get(),
+ kVertsPerInstance, kIndicesPerInstance, instanceCount);
if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
}
for (int i = 0; i < instanceCount; i++) {
- intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
- i * kVertsPerInstance * vertexStride;
+ intptr_t verts =
+ reinterpret_cast<intptr_t>(vertices) + i * kVertsPerInstance * vertexStride;
tesselate(verts, vertexStride, fRects[i].fColor, &fRects[i].fViewMatrix,
fRects[i].fRect, &fRects[i].fLocalQuad);
}
@@ -160,14 +158,14 @@ private:
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
- NonAAFillRectBatch* that = t->cast<NonAAFillRectBatch>();
+ NonAAFillRectOp* that = t->cast<NonAAFillRectOp>();
if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
that->bounds(), caps)) {
return false;
}
- // In the event of two batches, one who can tweak, one who cannot, we just fall back to
- // not tweaking
+ // In the event of two ops, one who can tweak, one who cannot, we just fall back to not
+ // tweaking.
if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakAlphaForCoverage()) {
fOverrides = that->fOverrides;
}
@@ -190,16 +188,15 @@ private:
typedef GrMeshDrawOp INHERITED;
};
-namespace GrNonAAFillRectBatch {
+namespace GrNonAAFillRectOp {
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
- return new NonAAFillRectBatch(color, viewMatrix, rect, localRect, localMatrix);
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
+ return sk_sp<GrDrawOp>(new NonAAFillRectOp(color, viewMatrix, rect, localRect, localMatrix));
}
-
};
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -208,7 +205,7 @@ GrDrawOp* Create(GrColor color,
#include "GrBatchTest.h"
-DRAW_BATCH_TEST_DEFINE(RectBatch) {
+DRAW_BATCH_TEST_DEFINE(NonAAFillRectOp) {
GrColor color = GrRandomColor(random);
SkRect rect = GrTest::TestRect(random);
SkRect localRect = GrTest::TestRect(random);
@@ -217,9 +214,12 @@ DRAW_BATCH_TEST_DEFINE(RectBatch) {
bool hasLocalRect = random->nextBool();
bool hasLocalMatrix = random->nextBool();
- return GrNonAAFillRectBatch::Create(color, viewMatrix, rect,
- hasLocalRect ? &localRect : nullptr,
- hasLocalMatrix ? &localMatrix : nullptr);
+ return GrNonAAFillRectOp::Make(color,
+ viewMatrix,
+ rect,
+ hasLocalRect ? &localRect : nullptr,
+ hasLocalMatrix ? &localMatrix : nullptr)
+ .release();
}
#endif
diff --git a/src/gpu/batches/GrNonAAFillRectOp.h b/src/gpu/batches/GrNonAAFillRectOp.h
new file mode 100644
index 0000000000..3d983e15f1
--- /dev/null
+++ b/src/gpu/batches/GrNonAAFillRectOp.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrNonAAFillRectOp_DEFINED
+#define GrNonAAFillRectOp_DEFINED
+
+#include "GrColor.h"
+#include "SkRefCnt.h"
+
+class GrDrawOp;
+class SkMatrix;
+struct SkRect;
+
+namespace GrNonAAFillRectOp {
+
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix);
+
+sk_sp<GrDrawOp> MakeWithPerspective(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix);
+};
+
+#endif
diff --git a/src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp b/src/gpu/batches/GrNonAAFillRectPerspectiveOp.cpp
index 094c5aeb24..443c511ec4 100644
--- a/src/gpu/batches/GrNonAAFillRectPerspectiveBatch.cpp
+++ b/src/gpu/batches/GrNonAAFillRectPerspectiveOp.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrNonAAFillRectBatch.h"
+#include "GrNonAAFillRectOp.h"
#include "GrColor.h"
#include "GrDefaultGeoProcFactory.h"
@@ -41,8 +41,8 @@ static sk_sp<GrGeometryProcessor> make_persp_gp(const SkMatrix& viewMatrix,
// Otherwise, if we have a local rect, then we apply the localMatrix directly to the localRect
// to generate vertex local coords
if (viewMatrix.hasPerspective()) {
- LocalCoords localCoords(hasExplicitLocalCoords ? LocalCoords::kHasExplicit_Type :
- LocalCoords::kUsePosition_Type,
+ LocalCoords localCoords(hasExplicitLocalCoords ? LocalCoords::kHasExplicit_Type
+ : LocalCoords::kUsePosition_Type,
localMatrix);
return GrDefaultGeoProcFactory::Make(color, coverage, localCoords, viewMatrix);
} else if (hasExplicitLocalCoords) {
@@ -63,8 +63,7 @@ static void tesselate(intptr_t vertices,
const GrQuad* localQuad) {
SkPoint* positions = reinterpret_cast<SkPoint*>(vertices);
- positions->setRectFan(rect.fLeft, rect.fTop,
- rect.fRight, rect.fBottom, vertexStride);
+ positions->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, vertexStride);
if (viewMatrix) {
viewMatrix->mapPointsWithStride(positions, vertexStride, kVertsPerInstance);
@@ -75,8 +74,8 @@ static void tesselate(intptr_t vertices,
if (localQuad) {
static const int kLocalOffset = sizeof(SkPoint) + sizeof(GrColor);
for (int i = 0; i < kVertsPerInstance; i++) {
- SkPoint* coords = reinterpret_cast<SkPoint*>(vertices + kLocalOffset +
- i * vertexStride);
+ SkPoint* coords =
+ reinterpret_cast<SkPoint*>(vertices + kLocalOffset + i * vertexStride);
*coords = localQuad->point(i);
}
}
@@ -85,21 +84,19 @@ static void tesselate(intptr_t vertices,
GrColor* vertColor = reinterpret_cast<GrColor*>(vertices + kColorOffset);
for (int j = 0; j < 4; ++j) {
*vertColor = color;
- vertColor = (GrColor*) ((intptr_t) vertColor + vertexStride);
+ vertColor = (GrColor*)((intptr_t)vertColor + vertexStride);
}
}
// We handle perspective in the local matrix or viewmatrix with special batches
-class GrNonAAFillRectPerspectiveBatch final : public GrMeshDrawOp {
+class NonAAFillRectPerspectiveOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
- GrNonAAFillRectPerspectiveBatch(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
- const SkRect* localRect, const SkMatrix* localMatrix)
- : INHERITED(ClassID())
- , fViewMatrix(viewMatrix) {
- SkASSERT(viewMatrix.hasPerspective() || (localMatrix &&
- localMatrix->hasPerspective()));
+ NonAAFillRectPerspectiveOp(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
+ const SkRect* localRect, const SkMatrix* localMatrix)
+ : INHERITED(ClassID()), fViewMatrix(viewMatrix) {
+ SkASSERT(viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective()));
RectInfo& info = fRects.push_back();
info.fColor = color;
info.fRect = rect;
@@ -121,9 +118,9 @@ public:
str.appendf("# batched: %d\n", fRects.count());
for (int i = 0; i < fRects.count(); ++i) {
const RectInfo& geo = fRects[0];
- str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n",
- i, geo.fColor,
- geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect.fBottom);
+ str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", i,
+ geo.fColor, geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight,
+ geo.fRect.fBottom);
}
str.append(DumpPipelineInfo(*this->pipeline()));
str.append(INHERITED::dumpInfo());
@@ -144,7 +141,7 @@ public:
}
private:
- GrNonAAFillRectPerspectiveBatch() : INHERITED(ClassID()) {}
+ NonAAFillRectPerspectiveOp() : INHERITED(ClassID()) {}
void onPrepareDraws(Target* target) const override {
sk_sp<GrGeometryProcessor> gp = make_persp_gp(fViewMatrix,
@@ -156,18 +153,19 @@ private:
return;
}
SkASSERT(fHasLocalRect
- ? gp->getVertexStride() ==
- sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr)
- : gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
+ ? gp->getVertexStride() ==
+ sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr)
+ : gp->getVertexStride() ==
+ sizeof(GrDefaultGeoProcFactory::PositionColorAttr));
size_t vertexStride = gp->getVertexStride();
int instanceCount = fRects.count();
sk_sp<const GrBuffer> indexBuffer(target->resourceProvider()->refQuadIndexBuffer());
InstancedHelper helper;
- void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexStride,
- indexBuffer.get(), kVertsPerInstance,
- kIndicesPerInstance, instanceCount);
+ void* vertices =
+ helper.init(target, kTriangles_GrPrimitiveType, vertexStride, indexBuffer.get(),
+ kVertsPerInstance, kIndicesPerInstance, instanceCount);
if (!vertices || !indexBuffer) {
SkDebugf("Could not allocate vertices\n");
return;
@@ -175,8 +173,8 @@ private:
for (int i = 0; i < instanceCount; i++) {
const RectInfo& info = fRects[i];
- intptr_t verts = reinterpret_cast<intptr_t>(vertices) +
- i * kVertsPerInstance * vertexStride;
+ intptr_t verts =
+ reinterpret_cast<intptr_t>(vertices) + i * kVertsPerInstance * vertexStride;
if (fHasLocalRect) {
GrQuad quad(info.fLocalRect);
tesselate(verts, vertexStride, info.fColor, nullptr, info.fRect, &quad);
@@ -188,7 +186,7 @@ private:
}
bool onCombineIfPossible(GrOp* t, const GrCaps& caps) override {
- GrNonAAFillRectPerspectiveBatch* that = t->cast<GrNonAAFillRectPerspectiveBatch>();
+ NonAAFillRectPerspectiveOp* that = t->cast<NonAAFillRectPerspectiveOp>();
if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pipeline(),
that->bounds(), caps)) {
return false;
@@ -232,16 +230,16 @@ private:
typedef GrMeshDrawOp INHERITED;
};
-namespace GrNonAAFillRectBatch {
+namespace GrNonAAFillRectOp {
-GrDrawOp* CreateWithPerspective(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
- return new GrNonAAFillRectPerspectiveBatch(color, viewMatrix, rect, localRect, localMatrix);
+sk_sp<GrDrawOp> MakeWithPerspective(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
+ return sk_sp<GrDrawOp>(
+ new NonAAFillRectPerspectiveOp(color, viewMatrix, rect, localRect, localMatrix));
}
-
};
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -250,7 +248,7 @@ GrDrawOp* CreateWithPerspective(GrColor color,
#include "GrBatchTest.h"
-DRAW_BATCH_TEST_DEFINE(PerspRectBatch) {
+DRAW_BATCH_TEST_DEFINE(NonAAFillRectPerspectiveOp) {
GrColor color = GrRandomColor(random);
SkRect rect = GrTest::TestRect(random);
SkRect localRect = GrTest::TestRect(random);
@@ -263,9 +261,10 @@ DRAW_BATCH_TEST_DEFINE(PerspRectBatch) {
}
bool hasLocalRect = random->nextBool();
- return GrNonAAFillRectBatch::CreateWithPerspective(color, viewMatrix, rect,
- hasLocalRect ? &localRect : nullptr,
- hasLocalMatrix ? &localMatrix : nullptr);
+ return GrNonAAFillRectOp::MakeWithPerspective(color, viewMatrix, rect,
+ hasLocalRect ? &localRect : nullptr,
+ hasLocalMatrix ? &localMatrix : nullptr)
+ .release();
}
#endif
diff --git a/src/gpu/batches/GrNonAAStrokeRectBatch.h b/src/gpu/batches/GrNonAAStrokeRectBatch.h
deleted file mode 100644
index b05e530397..0000000000
--- a/src/gpu/batches/GrNonAAStrokeRectBatch.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrNonAAStrokeRectBatch_DEFINED
-#define GrNonAAStrokeRectBatch_DEFINED
-
-#include "GrColor.h"
-
-#include "SkTypes.h"
-
-class GrDrawOp;
-struct SkRect;
-class SkStrokeRec;
-class SkMatrix;
-
-namespace GrNonAAStrokeRectBatch {
-
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkStrokeRec&,
- bool snapToPixelCenters);
-
-}
-
-#endif
diff --git a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp b/src/gpu/batches/GrNonAAStrokeRectOp.cpp
index b706465f72..b74cd502c8 100644
--- a/src/gpu/batches/GrNonAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrNonAAStrokeRectOp.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrNonAAStrokeRectBatch.h"
+#include "GrNonAAStrokeRectOp.h"
#include "GrBatchTest.h"
#include "GrColor.h"
@@ -23,7 +23,7 @@ static void init_stroke_rect_strip(SkPoint verts[10], const SkRect& rect, SkScal
const SkScalar rad = SkScalarHalf(width);
// TODO we should be able to enable this assert, but we'd have to filter these draws
// this is a bug
- //SkASSERT(rad < rect.width() / 2 && rad < rect.height() / 2);
+ // SkASSERT(rad < rect.width() / 2 && rad < rect.height() / 2);
verts[0].set(rect.fLeft + rad, rect.fTop + rad);
verts[1].set(rect.fLeft - rad, rect.fTop - rad);
@@ -45,7 +45,7 @@ inline static bool allowed_stroke(const SkStrokeRec& stroke) {
(stroke.getJoin() == SkPaint::kMiter_Join && stroke.getMiter() > SK_ScalarSqrt2);
}
-class NonAAStrokeRectBatch final : public GrMeshDrawOp {
+class NonAAStrokeRectOp final : public GrMeshDrawOp {
public:
DEFINE_OP_CLASS_ID
@@ -53,10 +53,10 @@ public:
SkString dumpInfo() const override {
SkString string;
- string.appendf("Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], "
- "StrokeWidth: %.2f\n",
- fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom,
- fStrokeWidth);
+ string.appendf(
+ "Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f], "
+ "StrokeWidth: %.2f\n",
+ fColor, fRect.fLeft, fRect.fTop, fRect.fRight, fRect.fBottom, fStrokeWidth);
string.append(DumpPipelineInfo(*this->pipeline()));
string.append(INHERITED::dumpInfo());
return string;
@@ -70,20 +70,20 @@ public:
coverage->setKnownSingleComponent(0xff);
}
- static GrDrawOp* Create(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
- const SkStrokeRec& stroke, bool snapToPixelCenters) {
+ static sk_sp<GrDrawOp> Make(GrColor color, const SkMatrix& viewMatrix, const SkRect& rect,
+ const SkStrokeRec& stroke, bool snapToPixelCenters) {
if (!allowed_stroke(stroke)) {
return nullptr;
}
- NonAAStrokeRectBatch* batch = new NonAAStrokeRectBatch();
- batch->fColor = color;
- batch->fViewMatrix = viewMatrix;
- batch->fRect = rect;
+ NonAAStrokeRectOp* op = new NonAAStrokeRectOp();
+ op->fColor = color;
+ op->fViewMatrix = viewMatrix;
+ op->fRect = rect;
// Sort the rect for hairlines
- batch->fRect.sort();
- batch->fStrokeWidth = stroke.getWidth();
+ op->fRect.sort();
+ op->fStrokeWidth = stroke.getWidth();
- SkScalar rad = SkScalarHalf(batch->fStrokeWidth);
+ SkScalar rad = SkScalarHalf(op->fStrokeWidth);
SkRect bounds = rect;
bounds.outset(rad, rad);
@@ -98,16 +98,15 @@ public:
SkScalarFloorToScalar(bounds.fRight),
SkScalarFloorToScalar(bounds.fBottom));
bounds.offset(0.5f, 0.5f);
- batch->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
+ op->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo);
} else {
- batch->setTransformedBounds(bounds, batch->fViewMatrix, HasAABloat ::kNo,
- IsZeroArea::kNo);
+ op->setTransformedBounds(bounds, op->fViewMatrix, HasAABloat::kNo, IsZeroArea::kNo);
}
- return batch;
+ return sk_sp<GrDrawOp>(op);
}
private:
- NonAAStrokeRectBatch() : INHERITED(ClassID()) {}
+ NonAAStrokeRectOp() : INHERITED(ClassID()) {}
void onPrepareDraws(Target* target) const override {
sk_sp<GrGeometryProcessor> gp;
@@ -116,8 +115,8 @@ private:
Color color(fColor);
Coverage coverage(fOverrides.readsCoverage() ? Coverage::kSolid_Type
: Coverage::kNone_Type);
- LocalCoords localCoords(fOverrides.readsLocalCoords() ? LocalCoords::kUsePosition_Type :
- LocalCoords::kUnused_Type);
+ LocalCoords localCoords(fOverrides.readsLocalCoords() ? LocalCoords::kUsePosition_Type
+ : LocalCoords::kUnused_Type);
gp = GrDefaultGeoProcFactory::Make(color, coverage, localCoords, fViewMatrix);
}
@@ -133,8 +132,8 @@ private:
const GrBuffer* vertexBuffer;
int firstVertex;
- void* verts = target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer,
- &firstVertex);
+ void* verts =
+ target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex);
if (!verts) {
SkDebugf("Could not allocate vertices\n");
@@ -186,21 +185,20 @@ private:
typedef GrMeshDrawOp INHERITED;
};
-namespace GrNonAAStrokeRectBatch {
+namespace GrNonAAStrokeRectOp {
-GrDrawOp* Create(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkStrokeRec& stroke,
- bool snapToPixelCenters) {
- return NonAAStrokeRectBatch::Create(color, viewMatrix, rect, stroke, snapToPixelCenters);
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkStrokeRec& stroke,
+ bool snapToPixelCenters) {
+ return NonAAStrokeRectOp::Make(color, viewMatrix, rect, stroke, snapToPixelCenters);
}
-
}
#ifdef GR_TEST_UTILS
-DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) {
+DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectOp) {
SkMatrix viewMatrix = GrTest::TestMatrix(random);
GrColor color = GrRandomColor(random);
SkRect rect = GrTest::TestRect(random);
@@ -210,7 +208,8 @@ DRAW_BATCH_TEST_DEFINE(NonAAStrokeRectBatch) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeJoin(SkPaint::kMiter_Join);
SkStrokeRec strokeRec(paint);
- return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeRec, random->nextBool());
+ return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, random->nextBool())
+ .release();
}
#endif
diff --git a/src/gpu/batches/GrNonAAStrokeRectOp.h b/src/gpu/batches/GrNonAAStrokeRectOp.h
new file mode 100644
index 0000000000..1e067fa9ea
--- /dev/null
+++ b/src/gpu/batches/GrNonAAStrokeRectOp.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrNonAAStrokeRectOp_DEFINED
+#define GrNonAAStrokeRectOp_DEFINED
+
+#include "GrColor.h"
+#include "SkRefCnt.h"
+
+class GrDrawOp;
+struct SkRect;
+class SkStrokeRec;
+class SkMatrix;
+
+namespace GrNonAAStrokeRectOp {
+
+sk_sp<GrDrawOp> Make(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkStrokeRec&,
+ bool snapToPixelCenters);
+}
+
+#endif
diff --git a/src/gpu/batches/GrRectBatchFactory.h b/src/gpu/batches/GrRectBatchFactory.h
deleted file mode 100644
index df1d60f998..0000000000
--- a/src/gpu/batches/GrRectBatchFactory.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrRectBatchFactory_DEFINED
-#define GrRectBatchFactory_DEFINED
-
-#include "GrAAFillRectBatch.h"
-#include "GrAAStrokeRectBatch.h"
-#include "GrAnalyticRectBatch.h"
-#include "GrColor.h"
-#include "GrNonAAFillRectBatch.h"
-#include "GrNonAAStrokeRectBatch.h"
-#include "GrPaint.h"
-#include "SkMatrix.h"
-
-class GrOp;
-struct SkRect;
-class SkStrokeRec;
-
-/*
- * A factory for returning batches which can draw rectangles.
- */
-namespace GrRectBatchFactory {
-
-inline GrDrawOp* CreateNonAAFill(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect* localRect,
- const SkMatrix* localMatrix) {
- if (viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective())) {
- return GrNonAAFillRectBatch::CreateWithPerspective(color, viewMatrix, rect, localRect,
- localMatrix);
- } else {
- return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, localRect, localMatrix);
- }
-}
-
-inline GrDrawOp* CreateAAFill(const GrPaint& paint,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkRect& croppedRect,
- const SkRect& devRect) {
- if (!paint.usesDistanceVectorField()) {
- return GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, croppedRect, devRect);
- } else {
- return GrAnalyticRectBatch::CreateAnalyticRectBatch(paint.getColor(), viewMatrix, rect,
- croppedRect, devRect);
- }
-}
-
-inline GrDrawOp* CreateAAFill(GrColor color,
- const SkMatrix& viewMatrix,
- const SkMatrix& localMatrix,
- const SkRect& rect,
- const SkRect& devRect) {
- return GrAAFillRectBatch::Create(color, viewMatrix, localMatrix, rect, devRect);
-}
-
-inline GrDrawOp* CreateNonAAStroke(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkStrokeRec& strokeRec,
- bool snapToPixelCenters) {
- return GrNonAAStrokeRectBatch::Create(color, viewMatrix, rect, strokeRec, snapToPixelCenters);
-}
-
-inline GrDrawOp* CreateAAStroke(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkStrokeRec& stroke) {
- return GrAAStrokeRectBatch::Create(color, viewMatrix, rect, stroke);
-}
-
-// First rect is outer; second rect is inner
-GrDrawOp* CreateAAFillNestedRects(GrColor, const SkMatrix& viewMatrix, const SkRect rects[2]);
-
-};
-
-#endif
diff --git a/src/gpu/batches/GrRectBatchFactory.cpp b/src/gpu/batches/GrRectOpFactory.cpp
index 7bef91770c..fd73624254 100644
--- a/src/gpu/batches/GrRectBatchFactory.cpp
+++ b/src/gpu/batches/GrRectOpFactory.cpp
@@ -5,17 +5,17 @@
* found in the LICENSE file.
*/
-#include "GrRectBatchFactory.h"
+#include "GrRectOpFactory.h"
-#include "GrAAStrokeRectBatch.h"
+#include "GrAAStrokeRectOp.h"
#include "SkStrokeRec.h"
-namespace GrRectBatchFactory {
+namespace GrRectOpFactory {
-GrDrawOp* CreateAAFillNestedRects(GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect rects[2]) {
+sk_sp<GrDrawOp> MakeAAFillNestedRects(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect rects[2]) {
SkASSERT(viewMatrix.rectStaysRect());
SkASSERT(!rects[0].isEmpty() && !rects[1].isEmpty());
@@ -26,10 +26,9 @@ GrDrawOp* CreateAAFillNestedRects(GrColor color,
if (devOutside.isEmpty()) {
return nullptr;
}
- return GrAAFillRectBatch::Create(color, viewMatrix, devOutside, devOutside);
+ return GrAAFillRectOp::Make(color, viewMatrix, devOutside, devOutside);
}
- return GrAAStrokeRectBatch::CreateFillBetweenRects(color, viewMatrix, devOutside, devInside);
+ return GrAAStrokeRectOp::MakeFillBetweenRects(color, viewMatrix, devOutside, devInside);
}
-
};
diff --git a/src/gpu/batches/GrRectOpFactory.h b/src/gpu/batches/GrRectOpFactory.h
new file mode 100644
index 0000000000..6a54f96c92
--- /dev/null
+++ b/src/gpu/batches/GrRectOpFactory.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrRectOpFactory_DEFINED
+#define GrRectOpFactory_DEFINED
+
+#include "GrAAFillRectOp.h"
+#include "GrAAStrokeRectOp.h"
+#include "GrAnalyticRectOp.h"
+#include "GrColor.h"
+#include "GrNonAAFillRectOp.h"
+#include "GrNonAAStrokeRectOp.h"
+#include "GrPaint.h"
+#include "SkMatrix.h"
+#include "SkRefCnt.h"
+#include "batches/GrDrawOp.h"
+
+struct SkRect;
+class SkStrokeRec;
+
+/**
+ * A factory for returning batches which can draw rectangles.
+ */
+namespace GrRectOpFactory {
+
+inline sk_sp<GrDrawOp> MakeNonAAFill(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect* localRect,
+ const SkMatrix* localMatrix) {
+ if (viewMatrix.hasPerspective() || (localMatrix && localMatrix->hasPerspective())) {
+ return GrNonAAFillRectOp::MakeWithPerspective(color, viewMatrix, rect, localRect,
+ localMatrix);
+ } else {
+ return GrNonAAFillRectOp::Make(color, viewMatrix, rect, localRect, localMatrix);
+ }
+}
+
+inline sk_sp<GrDrawOp> MakeAAFill(const GrPaint& paint,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkRect& croppedRect,
+ const SkRect& devRect) {
+ if (!paint.usesDistanceVectorField()) {
+ return GrAAFillRectOp::Make(paint.getColor(), viewMatrix, croppedRect, devRect);
+ } else {
+ return GrAnalyticRectOp::Make(paint.getColor(), viewMatrix, rect, croppedRect, devRect);
+ }
+}
+
+inline sk_sp<GrDrawOp> MakeAAFill(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkMatrix& localMatrix,
+ const SkRect& rect,
+ const SkRect& devRect) {
+ return GrAAFillRectOp::Make(color, viewMatrix, localMatrix, rect, devRect);
+}
+
+inline sk_sp<GrDrawOp> MakeNonAAStroke(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkStrokeRec& strokeRec,
+ bool snapToPixelCenters) {
+ return GrNonAAStrokeRectOp::Make(color, viewMatrix, rect, strokeRec, snapToPixelCenters);
+}
+
+inline sk_sp<GrDrawOp> MakeAAStroke(GrColor color,
+ const SkMatrix& viewMatrix,
+ const SkRect& rect,
+ const SkStrokeRec& stroke) {
+ return GrAAStrokeRectOp::Make(color, viewMatrix, rect, stroke);
+}
+
+// First rect is outer; second rect is inner
+sk_sp<GrDrawOp> MakeAAFillNestedRects(GrColor, const SkMatrix& viewMatrix, const SkRect rects[2]);
+};
+
+#endif
diff --git a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
index a4318b741a..0e5771bdc3 100644
--- a/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
@@ -5,21 +5,20 @@
* found in the LICENSE file.
*/
-
#include "GrStencilAndCoverPathRenderer.h"
#include "GrCaps.h"
#include "GrContext.h"
-#include "GrRenderTargetContextPriv.h"
#include "GrDrawPathBatch.h"
#include "GrFixedClip.h"
#include "GrGpu.h"
#include "GrPath.h"
#include "GrPipelineBuilder.h"
#include "GrRenderTarget.h"
+#include "GrRenderTargetContextPriv.h"
#include "GrResourceProvider.h"
#include "GrStencilPathBatch.h"
#include "GrStyle.h"
-#include "batches/GrRectBatchFactory.h"
+#include "batches/GrRectOpFactory.h"
GrPathRenderer* GrStencilAndCoverPathRenderer::Create(GrResourceProvider* resourceProvider,
const GrCaps& caps) {
@@ -113,8 +112,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
}
const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix;
- sk_sp<GrDrawOp> coverOp(GrRectBatchFactory::CreateNonAAFill(args.fPaint->getColor(), viewM,
- bounds, nullptr, &invert));
+ sk_sp<GrDrawOp> coverOp(GrRectOpFactory::MakeNonAAFill(args.fPaint->getColor(), viewM,
+ bounds, nullptr, &invert));
// fake inverse with a stencil and cover
args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fAAType, viewMatrix,