remove unused VerticesFlags
Deferring removing the flags parameter from the virtuals until a
later CL (as it collides with another related CL)
BUG=skia:6366
Change-Id: I817fae3df03ecebe5ec3532f691ed06deab890e6
Reviewed-on: https://skia-review.googlesource.com/9739
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp
index 32ff3ff..33b932b 100644
--- a/fuzz/FuzzCanvas.cpp
+++ b/fuzz/FuzzCanvas.cpp
@@ -1750,13 +1750,11 @@
blendMode, indexCount > 0 ? indices : nullptr, indexCount,
paint);
} else {
- uint32_t flags;
- fuzz->nextRange(&flags, 0, 3);
canvas->drawVertices(SkVertices::MakeCopy(vertexMode, vertexCount, vertices,
useTexs ? texs : nullptr,
useColors ? colors : nullptr,
indexCount, indices),
- blendMode, paint, flags);
+ blendMode, paint);
}
break;
}
diff --git a/gm/vertices.cpp b/gm/vertices.cpp
index 0d79827..4bf9f87 100644
--- a/gm/vertices.cpp
+++ b/gm/vertices.cpp
@@ -89,7 +89,6 @@
sk_sp<SkShader> fShader1;
sk_sp<SkShader> fShader2;
sk_sp<SkColorFilter> fColorFilter;
- sk_sp<SkVertices> fVertices;
bool fUseObject;
SkScalar fShaderScale;
@@ -104,10 +103,6 @@
fShader1 = make_shader1(fShaderScale);
fShader2 = make_shader2();
fColorFilter = make_color_filter();
- if (fUseObject) {
- fVertices = SkVertices::MakeCopy(SkCanvas::kTriangleFan_VertexMode, kMeshVertexCnt,
- fPts, fTexs, fColors, kMeshIndexCnt, kMeshFan);
- }
}
SkString onShortName() override {
@@ -175,16 +170,15 @@
paint.setShader(shader);
paint.setColorFilter(cf);
paint.setAlpha(alpha);
+
+ const SkColor* colors = attrs.fHasColors ? fColors : nullptr;
+ const SkPoint* texs = attrs.fHasTexs ? fTexs : nullptr;
if (fUseObject) {
- uint32_t flags = 0;
- flags |=
- attrs.fHasColors ? 0 : SkCanvas::kIgnoreColors_VerticesFlag;
- flags |= attrs.fHasTexs ? 0
- : SkCanvas::kIgnoreTexCoords_VerticesFlag;
- canvas->drawVertices(fVertices, mode, paint, flags);
+ auto v = SkVertices::MakeCopy(SkCanvas::kTriangleFan_VertexMode,
+ kMeshVertexCnt, fPts, texs, colors,
+ kMeshIndexCnt, kMeshFan);
+ canvas->drawVertices(v, mode, paint);
} else {
- const SkColor* colors = attrs.fHasColors ? fColors : nullptr;
- const SkPoint* texs = attrs.fHasTexs ? fTexs : nullptr;
canvas->drawVertices(SkCanvas::kTriangleFan_VertexMode,
kMeshVertexCnt, fPts, texs, colors, mode,
kMeshFan, kMeshIndexCnt, paint);
@@ -240,10 +234,6 @@
}
- sk_sp<SkVertices> vertices;
- if (useObject) {
- vertices = builder.detach();
- }
canvas->save();
canvas->translate(10, 10);
for (bool useShader : {false, true}) {
@@ -253,11 +243,13 @@
canvas->concat(m);
SkPaint paint;
paint.setShader(useShader ? shader : nullptr);
+
+ const SkPoint* t = useTex ? texs : nullptr;
if (useObject) {
- uint32_t flags = useTex ? 0 : SkCanvas::kIgnoreTexCoords_VerticesFlag;
- canvas->drawVertices(vertices, SkBlendMode::kModulate, paint, flags);
+ auto v = SkVertices::MakeCopy(SkCanvas::kTriangles_VertexMode, kMeshVertexCnt,
+ pts, t, colors, kNumTris * 3, indices);
+ canvas->drawVertices(v, SkBlendMode::kModulate, paint);
} else {
- const SkPoint* t = useTex ? texs : nullptr;
canvas->drawVertices(SkCanvas::kTriangles_VertexMode, kMeshVertexCnt, pts,
t, colors, indices, kNumTris * 3, paint);
}
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 3ce4bae..81841ba 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1178,12 +1178,7 @@
this->drawVertices(vmode, vertexCount, vertices, texs, colors, SkBlendMode::kModulate,
indices, indexCount, paint);
}
- enum VerticesFlags {
- /** Ignore the vertices' colors and instead use the paint color. */
- kIgnoreColors_VerticesFlag = 0x1,
- /** Ignore the vertices' tex coords (and any shader on the paint). */
- kIgnoreTexCoords_VerticesFlag = 0x2
- };
+
/** Draw vertices from an immutable SkVertices object.
@param vertices The mesh to draw.
@@ -1193,8 +1188,7 @@
@param paint Specifies the shader/texture if present.
@param flags Allows the caller to ignore colors or texs on vertices.
*/
- void drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
- uint32_t flags = 0);
+ void drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint);
/**
Draw a cubic coons patch
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 150caa4..23aed12 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1799,10 +1799,10 @@
indexCount, paint);
}
-void SkCanvas::drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
- uint32_t flags) {
+void SkCanvas::drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint) {
RETURN_ON_NULL(vertices);
- this->onDrawVerticesObject(std::move(vertices), mode, paint, flags);
+ uint32_t deprecatedFlags = 0;
+ this->onDrawVerticesObject(std::move(vertices), mode, paint, deprecatedFlags);
}
void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
@@ -2685,12 +2685,10 @@
}
void SkCanvas::onDrawVerticesObjectFallback(sk_sp<SkVertices> vertices, SkBlendMode mode,
- const SkPaint& paint, uint32_t flags) {
- const SkPoint* texs =
- (flags & SkCanvas::kIgnoreTexCoords_VerticesFlag) ? nullptr : vertices->texCoords();
- const SkColor* colors = (flags & kIgnoreColors_VerticesFlag) ? nullptr : vertices->colors();
- this->onDrawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(), texs,
- colors, mode, vertices->indices(), vertices->indexCount(), paint);
+ const SkPaint& paint, uint32_t deprecatedFlags) {
+ this->onDrawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(),
+ vertices->texCoords(), vertices->colors(), mode, vertices->indices(),
+ vertices->indexCount(), paint);
}
void SkCanvas::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 7c5c2bf..eb507d4 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -276,14 +276,11 @@
}
}
-void SkBaseDevice::drawVerticesObject(sk_sp<SkVertices> vertices,
- SkBlendMode mode, const SkPaint& paint, uint32_t flags) {
- const SkPoint* texs =
- (flags & SkCanvas::kIgnoreTexCoords_VerticesFlag) ? nullptr : vertices->texCoords();
- const SkColor* colors =
- (flags & SkCanvas::kIgnoreColors_VerticesFlag) ? nullptr : vertices->colors();
- this->drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(), texs,
- colors, mode, vertices->indices(), vertices->indexCount(), paint);
+void SkBaseDevice::drawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode mode,
+ const SkPaint& paint, uint32_t deprecatedFlags) {
+ this->drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(),
+ vertices->texCoords(), vertices->colors(), mode, vertices->indices(),
+ vertices->indexCount(), paint);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 8cc383d..bd73c8b 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -951,8 +951,7 @@
void GrRenderTargetContext::drawVertices(const GrClip& clip,
GrPaint&& paint,
const SkMatrix& viewMatrix,
- sk_sp<SkVertices> vertices,
- uint32_t flags) {
+ sk_sp<SkVertices> vertices) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
@@ -962,7 +961,7 @@
SkASSERT(vertices);
std::unique_ptr<GrMeshDrawOp> op =
- GrDrawVerticesOp::Make(paint.getColor(), std::move(vertices), viewMatrix, flags);
+ GrDrawVerticesOp::Make(paint.getColor(), std::move(vertices), viewMatrix);
if (!op) {
return;
}
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index c6793d3..fc2fc0e 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -245,8 +245,7 @@
void drawVertices(const GrClip&,
GrPaint&& paint,
const SkMatrix& viewMatrix,
- sk_sp<SkVertices> vertices,
- uint32_t flags);
+ sk_sp<SkVertices> vertices);
/**
* Draws textured sprites from an atlas with a paint. This currently does not support AA for the
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 597d272..6370777 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1664,16 +1664,16 @@
GrRenderTargetContext::ColorArrayType::kSkColor);
}
-void SkGpuDevice::drawVerticesObject(sk_sp<SkVertices> vertices,
- SkBlendMode mode, const SkPaint& paint, uint32_t flags) {
+void SkGpuDevice::drawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode mode,
+ const SkPaint& paint, uint32_t deprecatedFlags) {
ASSERT_SINGLE_OWNER
CHECK_SHOULD_DRAW();
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawVerticesObject", fContext.get());
SkASSERT(vertices);
GrPaint grPaint;
- bool hasColors = vertices->hasColors() && !(SkCanvas::kIgnoreColors_VerticesFlag & flags);
- bool hasTexs = vertices->hasTexCoords() & !(SkCanvas::kIgnoreTexCoords_VerticesFlag & flags);
+ bool hasColors = vertices->hasColors();
+ bool hasTexs = vertices->hasTexCoords();
if (!hasTexs && !hasColors) {
// The dreaded wireframe mode. Fallback to drawVertices and go so slooooooow.
this->drawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(),
@@ -1685,7 +1685,7 @@
return;
}
fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(),
- std::move(vertices), flags);
+ std::move(vertices));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index aa13cae..7c59d61 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -32,12 +32,12 @@
}
std::unique_ptr<GrMeshDrawOp> GrDrawVerticesOp::Make(GrColor color, sk_sp<SkVertices> vertices,
- const SkMatrix& viewMatrix, uint32_t flags) {
+ const SkMatrix& viewMatrix) {
SkASSERT(vertices);
GrPrimitiveType primType = SkVertexModeToGrPrimitiveType(vertices->mode());
return std::unique_ptr<GrMeshDrawOp>(new GrDrawVerticesOp(
std::move(vertices), primType, color, GrRenderTargetContext::ColorArrayType::kSkColor,
- viewMatrix, flags));
+ viewMatrix));
}
GrDrawVerticesOp::GrDrawVerticesOp(sk_sp<SkVertices> vertices, GrPrimitiveType primitiveType,
@@ -89,14 +89,14 @@
GrColor overrideColor;
if (optimizations.getOverrideColorIfSet(&overrideColor)) {
fMeshes[0].fColor = overrideColor;
- fMeshes[0].fFlags |= SkCanvas::kIgnoreColors_VerticesFlag;
+ fMeshes[0].fFlags |= kIgnoreColors_VerticesFlag;
fFlags &= ~kRequiresPerVertexColors_Flag;
fColorArrayType = GrRenderTargetContext::ColorArrayType::kPremulGrColor;
}
if (optimizations.readsLocalCoords()) {
fFlags |= kPipelineRequiresLocalCoords_Flag;
} else {
- fFlags |= SkCanvas::kIgnoreTexCoords_VerticesFlag;
+ fFlags |= kIgnoreTexCoords_VerticesFlag;
fFlags &= ~kAnyMeshHasExplicitLocalCoords;
}
}
diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h
index eddf201..f881d61 100644
--- a/src/gpu/ops/GrDrawVerticesOp.h
+++ b/src/gpu/ops/GrDrawVerticesOp.h
@@ -25,6 +25,11 @@
public:
DEFINE_OP_CLASS_ID
+ enum {
+ kIgnoreTexCoords_VerticesFlag = 1 << 0,
+ kIgnoreColors_VerticesFlag = 1 << 1,
+ };
+
/**
* The 'color' param is used if the 'colors' array is null. 'bounds' is the bounds of the
* 'positions' array (in local space prior to application of 'viewMatrix'). If 'indices' is null
@@ -47,7 +52,7 @@
* that they should be ignored then the vertex positions are used as local coords.
*/
static std::unique_ptr<GrMeshDrawOp> Make(GrColor color, sk_sp<SkVertices>,
- const SkMatrix& viewMatrix, uint32_t flags);
+ const SkMatrix& viewMatrix);
const char* name() const override { return "DrawVerticesOp"; }
@@ -87,11 +92,11 @@
uint32_t fFlags;
bool hasExplicitLocalCoords() const {
- return fVertices->hasTexCoords() && !(SkCanvas::kIgnoreTexCoords_VerticesFlag & fFlags);
+ return fVertices->hasTexCoords() && !(kIgnoreTexCoords_VerticesFlag & fFlags);
}
bool hasPerVertexColors() const {
- return fVertices->hasColors() && !(SkCanvas::kIgnoreColors_VerticesFlag & fFlags);
+ return fVertices->hasColors() && !(kIgnoreColors_VerticesFlag & fFlags);
}
};