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;
}
sk_sp<SkShader> fShader1;
sk_sp<SkShader> fShader2;
sk_sp<SkColorFilter> fColorFilter;
- sk_sp<SkVertices> fVertices;
bool fUseObject;
SkScalar fShaderScale;
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 {
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);
}
- sk_sp<SkVertices> vertices;
- if (useObject) {
- vertices = builder.detach();
- }
canvas->save();
canvas->translate(10, 10);
for (bool useShader : {false, true}) {
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);
}
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.
@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
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) {
}
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],
}
}
-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);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
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();)
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;
}
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
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(),
return;
}
fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(),
- std::move(vertices), flags);
+ std::move(vertices));
}
///////////////////////////////////////////////////////////////////////////////
}
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,
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;
}
}
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
* 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"; }
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);
}
};