const SkPaint&);
virtual void onDrawRRect(const SkRRect&, const SkPaint&);
virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&);
+
+#ifdef SK_SUPPORT_LEGACY_DRAWVERTICES_VIRTUAL
virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
const SkPoint texs[], const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount, const SkPaint&);
+ const uint16_t indices[], int indexCount, const SkPaint&) {}
+#endif
+
virtual void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&);
- // Subclasses can use this put the vertices object call on the regular draw vertices code path.
- // This is temporary until we teach recording and other SkCanvas classes about SkVertices.
- void devolveSkVerticesToRaw(const SkVertices*, SkBlendMode, const SkPaint&);
virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int count, SkBlendMode, const SkRect* cull, const SkPaint*);
const SkPaint*, SrcRectConstraint) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
- void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint) override {
- this->devolveSkVerticesToRaw(vertices, mode, paint);
- }
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
const SkPaint*, SrcRectConstraint) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
- void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint) override {
- this->devolveSkVerticesToRaw(vertices, mode, paint);
- }
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
const SkPaint*, SrcRectConstraint) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
const SkPaint*) override {}
void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
const SkPaint*) override {}
- void onDrawVertices(VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
- SkBlendMode, const uint16_t[], int, const SkPaint&) override {}
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override {}
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int, SkBlendMode, const SkRect*, const SkPaint*) override {}
const SkPaint*, SrcRectConstraint) override;
void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkBlendMode,
const SkPaint& paint) override;
this->onDrawPoints(mode, count, pts, paint);
}
-void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[],
+void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, const SkPoint positions[],
const SkPoint texs[], const SkColor colors[], SkBlendMode bmode,
const uint16_t indices[], int indexCount, const SkPaint& paint) {
- this->onDrawVertices(vmode, vertexCount, std::move(vertices), texs, colors, bmode, indices,
- indexCount, paint);
+ auto vertices = SkVertices::MakeCopy(vmode, vertexCount, positions, texs, colors,
+ indexCount, indices);
+ if (vertices) {
+ this->onDrawVerticesObject(vertices.get(), bmode, paint);
+ }
}
void SkCanvas::drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode,
this->onDrawTextBlob(blob, x, y, paint);
}
-void SkCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint verts[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
- TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawVertices()");
- LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr)
-
- while (iter.next()) {
- iter.fDevice->drawVertices(vmode, vertexCount, verts, texs,
- colors, bmode, indices, indexCount,
- looper.paint());
- }
-
- LOOPER_END
-}
-
void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
const SkPaint& paint) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawVertices()");
LOOPER_END
}
-void SkCanvas::devolveSkVerticesToRaw(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint) {
- 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],
const SkPoint texCoords[4], SkBlendMode bmode,
const SkPaint& paint) {
SkTLazy<SkPaint> lazy;
fTarget->drawPoints(mode, count, pts, this->xform(paint, &lazy));
}
- void onDrawVertices(VertexMode vmode, int count,
- const SkPoint* verts, const SkPoint* texs, const SkColor* colors,
- SkBlendMode mode,
- const uint16_t* indices, int indexCount, const SkPaint& paint) override {
- SkSTArray<8, SkColor> xformed;
- if (colors) {
- xformed.reset(count);
- this->xform(xformed.begin(), colors, count);
- colors = xformed.begin();
+ void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
+ const SkPaint& paint) override {
+ sk_sp<SkVertices> copy;
+ if (vertices->hasColors()) {
+ int count = vertices->vertexCount();
+ SkSTArray<8, SkColor> xformed(count);
+ this->xform(xformed.begin(), vertices->colors(), count);
+ copy = SkVertices::MakeCopy(vertices->mode(), count, vertices->positions(),
+ vertices->texCoords(), xformed.begin(),
+ vertices->indexCount(), vertices->indices());
+ vertices = copy.get();
}
SkTLazy<SkPaint> lazy;
- fTarget->drawVertices(vmode, count, verts, texs, colors, mode, indices, indexCount,
- this->xform(paint, &lazy));
+ fTarget->drawVertices(vertices, mode, this->xform(paint, &lazy));
}
void onDrawText(const void* ptr, size_t len,
M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice) \
M(DrawText) M(DrawPosText) M(DrawPosTextH) \
M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob) \
- M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawVerticesObject) M(DrawAtlas)
+ M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas)
#define M(T) T,
enum class Type : uint8_t { TYPES(M) };
};
struct DrawVertices final : Op {
static const auto kType = Type::DrawVertices;
- DrawVertices(SkCanvas::VertexMode mode, int count, SkBlendMode bmode, int nindices,
- const SkPaint& paint, bool has_texs, bool has_colors, bool has_indices)
- : mode(mode), count(count), xfermode(bmode), nindices(nindices)
- , paint(paint), has_texs(has_texs), has_colors(has_colors), has_indices(has_indices) {}
- SkCanvas::VertexMode mode;
- int count;
- SkBlendMode xfermode;
- int nindices;
- SkPaint paint;
- bool has_texs;
- bool has_colors;
- bool has_indices;
- void draw(SkCanvas* c, const SkMatrix&) {
- SkPoint* vertices = pod<SkPoint>(this, 0);
- size_t offset = count*sizeof(SkPoint);
-
- SkPoint* texs = nullptr;
- if (has_texs) {
- texs = pod<SkPoint>(this, offset);
- offset += count*sizeof(SkPoint);
- }
-
- SkColor* colors = nullptr;
- if (has_colors) {
- colors = pod<SkColor>(this, offset);
- offset += count*sizeof(SkColor);
- }
-
- uint16_t* indices = nullptr;
- if (has_indices) {
- indices = pod<uint16_t>(this, offset);
- }
- c->drawVertices(mode, count, vertices, texs, colors, xfermode,
- indices, nindices, paint);
- }
- };
- struct DrawVerticesObject final : Op {
- static const auto kType = Type::DrawVerticesObject;
- DrawVerticesObject(const SkVertices* v, SkBlendMode m, const SkPaint& p)
+ DrawVertices(const SkVertices* v, SkBlendMode m, const SkPaint& p)
: vertices(sk_ref_sp(const_cast<SkVertices*>(v))), mode(m), paint(p) {}
sk_sp<SkVertices> vertices;
SkBlendMode mode;
void* pod = this->push<DrawPoints>(count*sizeof(SkPoint), mode, count, paint);
copy_v(pod, points,count);
}
-void SkLiteDL::drawVertices(SkCanvas::VertexMode mode, int count, const SkPoint vertices[],
- const SkPoint texs[], const SkColor colors[], SkBlendMode xfermode,
- const uint16_t indices[], int nindices, const SkPaint& paint) {
- size_t bytes = count * sizeof(SkPoint);
- if (texs ) { bytes += count * sizeof(SkPoint); }
- if (colors) { bytes += count * sizeof(SkColor); }
- if (indices) { bytes += nindices * sizeof(uint16_t); }
- void* pod = this->push<DrawVertices>(bytes, mode, count, xfermode, nindices, paint,
- texs != nullptr, colors != nullptr, indices != nullptr);
- copy_v(pod, vertices, count,
- texs, texs ? count : 0,
- colors, colors ? count : 0,
- indices, indices ? nindices : 0);
-}
void SkLiteDL::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) {
- this->push<DrawVerticesObject>(0, vertices, mode, paint);
+ this->push<DrawVertices>(0, vertices, mode, paint);
}
void SkLiteDL::drawAtlas(const SkImage* atlas, const SkRSXform xforms[], const SkRect texs[],
const SkColor colors[], int count, SkBlendMode xfermode,
void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4],
SkBlendMode, const SkPaint&);
void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&);
- void drawVertices(SkCanvas::VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
- SkBlendMode, const uint16_t[], int, const SkPaint&);
void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&);
void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
SkBlendMode, const SkRect*, const SkPaint*);
const SkPaint& paint) {
fDL->drawPoints(mode, count, pts, paint);
}
-void SkLiteRecorder::onDrawVertices(SkCanvas::VertexMode mode,
- int count, const SkPoint vertices[],
- const SkPoint texs[], const SkColor colors[],
- SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
- fDL->drawVertices(mode, count, vertices, texs, colors, bmode, indices, indexCount, paint);
-}
void SkLiteRecorder::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
const SkPaint& paint) {
fDL->drawVertices(vertices, mode, paint);
void onDrawPatch(const SkPoint[12], const SkColor[4],
const SkPoint[4], SkBlendMode, const SkPaint&) override;
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
- void onDrawVertices(VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
- SkBlendMode, const uint16_t[], int, const SkPaint&) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int, SkBlendMode, const SkRect*, const SkPaint*) override;
fList[0]->onDrawPoints(mode, count, points, this->overdrawPaint(paint));
}
-void SkOverdrawCanvas::onDrawVertices(VertexMode vertexMode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode blendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
- fList[0]->onDrawVertices(vertexMode, vertexCount, vertices, texs, colors, blendMode, indices,
- indexCount, this->overdrawPaint(paint));
+void SkOverdrawCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode blendMode,
+ const SkPaint& paint) {
+ fList[0]->onDrawVerticesObject(vertices, blendMode, this->overdrawPaint(paint));
}
void SkOverdrawCanvas::onDrawAtlas(const SkImage* image, const SkRSXform xform[],
void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
void onDrawRRect(const SkRRect&, const SkPaint&) override;
void onDrawPoints(PointMode, size_t, const SkPoint[], const SkPaint&) override;
- void onDrawVertices(VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[],
- SkBlendMode, const uint16_t[], int, const SkPaint&) override;
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int, SkBlendMode, const SkRect*, const SkPaint*) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
this->validate(initialOffset, size);
}
-void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint pos[], const SkPoint texs[],
- const SkColor cols[], SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
- auto vertices = SkVertices::MakeCopy(vmode, vertexCount, pos, texs, cols, indexCount, indices);
- if (vertices) {
- this->onDrawVerticesObject(vertices.get(), bmode, paint);
- }
-}
-
void SkPictureRecord::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
const SkPaint& paint) {
// op + paint index + vertices index + mode
const SkPaint*) override;
void onDrawImageLattice(const SkImage*, const SkCanvas::Lattice& lattice, const SkRect& dst,
const SkPaint*) override;
-
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
}
-void SkRecorder::onDrawVertices(VertexMode vmode,
- int vertexCount, const SkPoint vertices[],
- const SkPoint texs[], const SkColor colors[],
- SkBlendMode bmode,
- const uint16_t indices[], int indexCount, const SkPaint& paint) {
- this->onDrawVerticesObject(SkVertices::MakeCopy(vmode, vertexCount, vertices, texs, colors,
- indexCount, indices).get(), bmode, paint);
-}
-
void SkRecorder::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
const SkPaint& paint) {
APPEND(DrawVertices, paint, sk_ref_sp(const_cast<SkVertices*>(vertices)), bmode);
const SkPaint*) override;
void onDrawBitmapLattice(const SkBitmap&, const Lattice& lattice, const SkRect& dst,
const SkPaint*) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int count, SkBlendMode, const SkRect* cull, const SkPaint*) override;
write_paint(writer, paint, kGeometry_PaintUsage);
}
-void SkPipeCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
- SkASSERT(vertexCount > 0);
-
- unsigned extra = 0;
- if (vertexCount <= kVCount_DrawVerticesMask) {
- extra |= vertexCount;
- }
- extra |= (unsigned)vmode << kVMode_DrawVerticesShift;
- extra |= (unsigned)bmode << kXMode_DrawVerticesShift;
-
- if (texs) {
- extra |= kHasTex_DrawVerticesMask;
- }
- if (colors) {
- extra |= kHasColors_DrawVerticesMask;
- }
- if (indexCount > 0) {
- extra |= kHasIndices_DrawVerticesMask;
- }
+void SkPipeCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+ const SkPaint& paint) {
+ unsigned extra = static_cast<unsigned>(bmode);
SkPipeWriter writer(this);
writer.write32(pack_verb(SkPipeVerb::kDrawVertices, extra));
- if (vertexCount > kVCount_DrawVerticesMask) {
- writer.write32(vertexCount);
- }
- writer.write(vertices, vertexCount * sizeof(SkPoint));
- if (texs) {
- writer.write(texs, vertexCount * sizeof(SkPoint));
- }
- if (colors) {
- writer.write(colors, vertexCount * sizeof(SkColor));
- }
- if (indexCount > 0) {
- writer.write32(indexCount);
- SkASSERT(SkIsAlign2(indexCount));
- writer.write(indices, indexCount * sizeof(uint16_t));
- }
+ // TODO: dedup vertices?
+ writer.writeDataAsByteArray(vertices->encode().get());
write_paint(writer, paint, kVertices_PaintUsage);
}
const SkPaint*) override;
void onDrawImageLattice(const SkImage*, const Lattice& lattice, const SkRect& dst,
const SkPaint*) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
fCanvas->drawAtlas(image, xform, rects, colors, count, bmode, cull, paint);
}
-void SkDeferredCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
+void SkDeferredCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+ const SkPaint& paint) {
this->flush_before_saves();
- fCanvas->drawVertices(vmode, vertexCount, vertices, texs, colors, bmode,
- indices, indexCount, paint);
+ fCanvas->drawVertices(vertices, bmode, paint);
}
void SkDeferredCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
void onDrawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
const SkPaint*, SrcRectConstraint) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawAtlas(const SkImage* image, const SkRSXform xform[],
const SkRect rects[], const SkColor colors[],
int count, SkBlendMode, const SkRect* cull, const SkPaint* paint) override;
picture->cullRect().fRight, picture->cullRect().fBottom);
}
-void SkDumpCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
- this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] %g %g ...)",
- toString(vmode), vertexCount, SkScalarToFloat(vertices[0].fX),
- SkScalarToFloat(vertices[0].fY));
+void SkDumpCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode,
+ const SkPaint& paint) {
+ this->dump(kDrawVertices_Verb, &paint, "drawVertices(%s [%d] ...)",
+ toString(vertices->mode()), vertices->vertexCount());
}
void SkDumpCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
}
}
-void SkNWayCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
+void SkNWayCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+ const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
- iter->drawVertices(vmode, vertexCount, vertices, texs, colors, bmode,
- indices, indexCount, paint);
+ iter->drawVertices(vertices, bmode, paint);
}
}
}
}
-void SkPaintFilterCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
+void SkPaintFilterCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+ const SkPaint& paint) {
AutoPaintFilter apf(this, kVertices_Type, paint);
if (apf.shouldDraw()) {
- this->INHERITED::onDrawVertices(vmode, vertexCount, vertices, texs, colors, bmode, indices,
- indexCount, *apf.paint());
+ this->INHERITED::onDrawVerticesObject(vertices, bmode, *apf.paint());
}
}
this->addDrawCommand(new SkDrawPatchCommand(cubics, colors, texCoords, bmode, paint));
}
-void SkDebugCanvas::onDrawVertices(VertexMode vmode, int vertexCount, const SkPoint vertices[],
- const SkPoint texs[], const SkColor colors[],
- SkBlendMode bmode, const uint16_t indices[], int indexCount,
- const SkPaint& paint) {
- this->addDrawCommand(new SkDrawVerticesCommand(vmode, vertexCount, vertices,
- texs, colors, bmode, indices, indexCount, paint));
+void SkDebugCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
+ const SkPaint& paint) {
+ this->addDrawCommand(new SkDrawVerticesCommand(sk_ref_sp(const_cast<SkVertices*>(vertices)),
+ bmode, paint));
}
void SkDebugCanvas::willRestore() {
void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
void onDrawRRect(const SkRRect&, const SkPaint&) override;
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
- void onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint&) override;
- void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint) override {
- this->devolveSkVerticesToRaw(vertices, mode, paint);
- }
+ void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;
void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst, const SkPaint*,
///////////////////////////////////////////////////////////////////////////////////////////////////
-SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode bmode,
- const uint16_t indices[], int indexCount,
+SkDrawVerticesCommand::SkDrawVerticesCommand(sk_sp<SkVertices> vertices, SkBlendMode bmode,
const SkPaint& paint)
: INHERITED(kDrawVertices_OpType)
+ , fVertices(std::move(vertices))
, fBlendMode(bmode)
+ , fPaint(paint)
{
- fVmode = vmode;
-
- fVertexCount = vertexCount;
-
- fVertices = new SkPoint[vertexCount];
- memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint));
-
- if (texs) {
- fTexs = new SkPoint[vertexCount];
- memcpy(fTexs, texs, vertexCount * sizeof(SkPoint));
- } else {
- fTexs = nullptr;
- }
-
- if (colors) {
- fColors = new SkColor[vertexCount];
- memcpy(fColors, colors, vertexCount * sizeof(SkColor));
- } else {
- fColors = nullptr;
- }
-
- if (indexCount > 0) {
- fIndices = new uint16_t[indexCount];
- memcpy(fIndices, indices, indexCount * sizeof(uint16_t));
- } else {
- fIndices = nullptr;
- }
-
- fIndexCount = indexCount;
- fPaint = paint;
-
// TODO(chudy)
fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
fInfo.push(SkObjectParser::PaintToString(paint));
}
-SkDrawVerticesCommand::~SkDrawVerticesCommand() {
- delete [] fVertices;
- delete [] fTexs;
- delete [] fColors;
- delete [] fIndices;
-}
-
void SkDrawVerticesCommand::execute(SkCanvas* canvas) const {
- canvas->drawVertices(fVmode, fVertexCount, fVertices,
- fTexs, fColors, fBlendMode, fIndices,
- fIndexCount, fPaint);
+ canvas->drawVertices(fVertices, fBlendMode, fPaint);
}
SkRestoreCommand::SkRestoreCommand()
#include "SkRSXform.h"
#include "SkString.h"
#include "SkTDArray.h"
+#include "SkVertices.h"
#include "SkJSONCPP.h"
#include "UrlDataManager.h"
class SkDrawVerticesCommand : public SkDrawCommand {
public:
- SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
- const SkPoint vertices[], const SkPoint texs[],
- const SkColor colors[], SkBlendMode,
- const uint16_t indices[], int indexCount,
- const SkPaint& paint);
- virtual ~SkDrawVerticesCommand();
+ SkDrawVerticesCommand(sk_sp<SkVertices>, SkBlendMode, const SkPaint&);
+
void execute(SkCanvas* canvas) const override;
private:
- SkCanvas::VertexMode fVmode;
- int fVertexCount;
- SkPoint* fVertices;
- SkPoint* fTexs;
- SkColor* fColors;
- SkBlendMode fBlendMode;
- uint16_t* fIndices;
- int fIndexCount;
- SkPaint fPaint;
+ sk_sp<SkVertices> fVertices;
+ SkBlendMode fBlendMode;
+ SkPaint fPaint;
typedef SkDrawCommand INHERITED;
};