aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkCanvas.h10
-rw-r--r--include/private/SkRecords.h11
-rw-r--r--include/utils/SkDumpCanvas.h6
-rw-r--r--include/utils/SkLuaCanvas.h6
-rw-r--r--include/utils/SkNoDrawCanvas.h5
-rw-r--r--src/core/SkCanvas.cpp25
-rw-r--r--src/core/SkDevice.cpp4
-rw-r--r--src/core/SkDevice.h3
-rw-r--r--src/core/SkLiteDL.cpp17
-rw-r--r--src/core/SkLiteDL.h1
-rw-r--r--src/core/SkLiteRecorder.cpp4
-rw-r--r--src/core/SkLiteRecorder.h1
-rw-r--r--src/core/SkPictureData.cpp33
-rw-r--r--src/core/SkPictureData.h8
-rw-r--r--src/core/SkPictureFlat.h3
-rw-r--r--src/core/SkPicturePlayback.cpp15
-rw-r--r--src/core/SkPictureRecord.cpp66
-rw-r--r--src/core/SkPictureRecord.h13
-rw-r--r--src/core/SkRecordDraw.cpp7
-rw-r--r--src/core/SkRecorder.cpp16
-rw-r--r--src/core/SkRecorder.h1
-rw-r--r--src/gpu/SkGpuDevice.cpp6
-rw-r--r--src/gpu/SkGpuDevice.h3
-rw-r--r--tools/debugger/SkDebugCanvas.h6
24 files changed, 116 insertions, 154 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 85531bb74a..81841ba2b4 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1186,9 +1186,9 @@ public:
shader. In this case the colors are combined with the texture
using mode, before being drawn using the paint.
@param paint Specifies the shader/texture if present.
+ @param flags Allows the caller to ignore colors or texs on vertices.
*/
- void drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint);
- void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint);
+ void drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint);
/**
Draw a cubic coons patch
@@ -1445,10 +1445,12 @@ protected:
virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
const SkPoint texs[], const SkColor colors[], SkBlendMode,
const uint16_t indices[], int indexCount, const SkPaint&);
- virtual void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&);
+ virtual void onDrawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode mode,
+ const SkPaint& paint, uint32_t flags);
// 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&);
+ void onDrawVerticesObjectFallback(sk_sp<SkVertices> vertices, SkBlendMode mode,
+ const SkPaint& paint, uint32_t flags);
virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int count, SkBlendMode, const SkRect* cull, const SkPaint*);
diff --git a/include/private/SkRecords.h b/include/private/SkRecords.h
index ac492ec0ea..b81bca87ee 100644
--- a/include/private/SkRecords.h
+++ b/include/private/SkRecords.h
@@ -21,7 +21,6 @@
#include "SkRSXform.h"
#include "SkString.h"
#include "SkTextBlob.h"
-#include "SkVertices.h"
// Windows.h, will pull in all of the GDI defines. GDI #defines
// DrawText to DrawTextA or DrawTextW, but SkRecord has a struct
@@ -346,8 +345,14 @@ RECORD(DrawAtlas, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag,
Optional<SkRect> cull);
RECORD(DrawVertices, kDraw_Tag|kHasPaint_Tag,
SkPaint paint;
- sk_sp<SkVertices> vertices;
- SkBlendMode bmode);
+ SkCanvas::VertexMode vmode;
+ int vertexCount;
+ PODArray<SkPoint> vertices;
+ PODArray<SkPoint> texs;
+ PODArray<SkColor> colors;
+ SkBlendMode bmode;
+ PODArray<uint16_t> indices;
+ int indexCount);
RECORD(DrawAnnotation, 0, // TODO: kDraw_Tag, skia:5548
SkRect rect;
SkString key;
diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h
index 19e5da567d..79a49bcd3b 100644
--- a/include/utils/SkDumpCanvas.h
+++ b/include/utils/SkDumpCanvas.h
@@ -117,9 +117,9 @@ protected:
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(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
+ uint32_t flags) override {
+ this->onDrawVerticesObjectFallback(std::move(vertices), mode, paint, flags);
}
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
diff --git a/include/utils/SkLuaCanvas.h b/include/utils/SkLuaCanvas.h
index a11d72f26c..ce374137c0 100644
--- a/include/utils/SkLuaCanvas.h
+++ b/include/utils/SkLuaCanvas.h
@@ -63,9 +63,9 @@ protected:
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(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
+ uint32_t flags) override {
+ this->onDrawVerticesObjectFallback(std::move(vertices), mode, paint, flags);
}
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
diff --git a/include/utils/SkNoDrawCanvas.h b/include/utils/SkNoDrawCanvas.h
index 75c15b201e..14b85549f4 100644
--- a/include/utils/SkNoDrawCanvas.h
+++ b/include/utils/SkNoDrawCanvas.h
@@ -68,7 +68,10 @@ protected:
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 onDrawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
+ uint32_t flags) override {
+ this->onDrawVerticesObjectFallback(std::move(vertices), mode, paint, flags);
+ }
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int, SkBlendMode, const SkRect*, const SkPaint*) override {}
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index ccdb71b5a0..23aed12b3b 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1799,15 +1799,10 @@ void SkCanvas::drawVertices(VertexMode vmode, int vertexCount, const SkPoint ver
indexCount, paint);
}
-void SkCanvas::drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode,
- const SkPaint& paint) {
- RETURN_ON_NULL(vertices);
- this->onDrawVerticesObject(vertices.get(), mode, paint);
-}
-
-void SkCanvas::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) {
+void SkCanvas::drawVertices(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint) {
RETURN_ON_NULL(vertices);
- this->onDrawVerticesObject(vertices, mode, paint);
+ uint32_t deprecatedFlags = 0;
+ this->onDrawVerticesObject(std::move(vertices), mode, paint, deprecatedFlags);
}
void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
@@ -2676,24 +2671,24 @@ void SkCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
LOOPER_END
}
-void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
- const SkPaint& paint) {
+void SkCanvas::onDrawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode bmode,
+ const SkPaint& paint, uint32_t flags) {
TRACE_EVENT0("disabled-by-default-skia", "SkCanvas::drawVertices()");
LOOPER_BEGIN(paint, SkDrawFilter::kPath_Type, nullptr)
while (iter.next()) {
// In the common case of one iteration we could std::move vertices here.
- iter.fDevice->drawVerticesObject(vertices, bmode, looper.paint());
+ iter.fDevice->drawVerticesObject(vertices, bmode, looper.paint(), flags);
}
LOOPER_END
}
-void SkCanvas::devolveSkVerticesToRaw(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint) {
+void SkCanvas::onDrawVerticesObjectFallback(sk_sp<SkVertices> vertices, SkBlendMode mode,
+ const SkPaint& paint, uint32_t deprecatedFlags) {
this->onDrawVertices(vertices->mode(), vertices->vertexCount(), vertices->positions(),
- vertices->texCoords(), vertices->colors(), mode,
- vertices->indices(), vertices->indexCount(), paint);
+ 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 44c9dfb75c..eb507d402b 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -276,8 +276,8 @@ void SkBaseDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
}
}
-void SkBaseDevice::drawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& 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/core/SkDevice.h b/src/core/SkDevice.h
index 6267b4451d..a8a68b6016 100644
--- a/src/core/SkDevice.h
+++ b/src/core/SkDevice.h
@@ -238,7 +238,8 @@ protected:
const SkColor colors[], SkBlendMode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) = 0;
- virtual void drawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&);
+ virtual void drawVerticesObject(sk_sp<SkVertices>, SkBlendMode, const SkPaint&,
+ uint32_t flags);
// default implementation unrolls the blob runs.
virtual void drawTextBlob(const SkTextBlob*, SkScalar x, SkScalar y,
const SkPaint& paint, SkDrawFilter* drawFilter);
diff --git a/src/core/SkLiteDL.cpp b/src/core/SkLiteDL.cpp
index 2da6eb5ef6..b990c70b1a 100644
--- a/src/core/SkLiteDL.cpp
+++ b/src/core/SkLiteDL.cpp
@@ -15,7 +15,6 @@
#include "SkRegion.h"
#include "SkRSXform.h"
#include "SkTextBlob.h"
-#include "SkVertices.h"
#ifndef SKLITEDL_PAGE
#define SKLITEDL_PAGE 4096
@@ -55,7 +54,7 @@ namespace {
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) };
@@ -503,17 +502,6 @@ namespace {
indices, nindices, paint);
}
};
- struct DrawVerticesObject final : Op {
- static const auto kType = Type::DrawVerticesObject;
- DrawVerticesObject(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;
- SkPaint paint;
- void draw(SkCanvas* c, const SkMatrix&) {
- c->drawVertices(vertices, mode, paint);
- }
- };
struct DrawAtlas final : Op {
static const auto kType = Type::DrawAtlas;
DrawAtlas(const SkImage* atlas, int count, SkBlendMode xfermode,
@@ -726,9 +714,6 @@ void SkLiteDL::drawVertices(SkCanvas::VertexMode mode, int count, const SkPoint
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);
-}
void SkLiteDL::drawAtlas(const SkImage* atlas, const SkRSXform xforms[], const SkRect texs[],
const SkColor colors[], int count, SkBlendMode xfermode,
const SkRect* cull, const SkPaint* paint) {
diff --git a/src/core/SkLiteDL.h b/src/core/SkLiteDL.h
index bc5f4e701e..2e1b8cce5d 100644
--- a/src/core/SkLiteDL.h
+++ b/src/core/SkLiteDL.h
@@ -76,7 +76,6 @@ public:
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*);
diff --git a/src/core/SkLiteRecorder.cpp b/src/core/SkLiteRecorder.cpp
index a01ac655e7..b3314b0c2a 100644
--- a/src/core/SkLiteRecorder.cpp
+++ b/src/core/SkLiteRecorder.cpp
@@ -187,10 +187,6 @@ void SkLiteRecorder::onDrawVertices(SkCanvas::VertexMode mode,
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 SkLiteRecorder::onDrawAtlas(const SkImage* atlas,
const SkRSXform xforms[],
const SkRect texs[],
diff --git a/src/core/SkLiteRecorder.h b/src/core/SkLiteRecorder.h
index 82aeca385a..4de978943f 100644
--- a/src/core/SkLiteRecorder.h
+++ b/src/core/SkLiteRecorder.h
@@ -76,7 +76,6 @@ public:
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;
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 69ff736fcf..9780b7d104 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -87,15 +87,6 @@ SkPictureData::SkPictureData(const SkPictureRecord& record,
}
}
- const SkTDArray<const SkVertices*>& verts = record.getVerticesRefs();
- fVerticesCount = verts.count();
- if (fVerticesCount > 0) {
- fVerticesRefs = new const SkVertices* [fVerticesCount];
- for (int i = 0; i < fVerticesCount; ++i) {
- fVerticesRefs[i] = SkRef(verts[i]);
- }
- }
-
const SkTDArray<const SkImage*>& imgs = record.getImageRefs();
fImageCount = imgs.count();
if (fImageCount > 0) {
@@ -113,8 +104,6 @@ void SkPictureData::init() {
fDrawableCount = 0;
fTextBlobRefs = nullptr;
fTextBlobCount = 0;
- fVerticesRefs = nullptr;
- fVerticesCount = 0;
fImageRefs = nullptr;
fImageCount = 0;
fFactoryPlayback = nullptr;
@@ -139,11 +128,6 @@ SkPictureData::~SkPictureData() {
}
delete[] fTextBlobRefs;
- for (int i = 0; i < fVerticesCount; i++) {
- fVerticesRefs[i]->unref();
- }
- delete[] fVerticesRefs;
-
for (int i = 0; i < fImageCount; i++) {
fImageRefs[i]->unref();
}
@@ -263,13 +247,6 @@ void SkPictureData::flattenToBuffer(SkWriteBuffer& buffer) const {
}
}
- if (fVerticesCount > 0) {
- write_tag_size(buffer, SK_PICT_VERTICES_BUFFER_TAG, fVerticesCount);
- for (i = 0; i < fVerticesCount; ++i) {
- buffer.writeDataAsByteArray(fVerticesRefs[i]->encode().get());
- }
- }
-
if (fImageCount > 0) {
write_tag_size(buffer, SK_PICT_IMAGE_BUFFER_TAG, fImageCount);
for (i = 0; i < fImageCount; ++i) {
@@ -487,10 +464,6 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
static const SkImage* create_image_from_buffer(SkReadBuffer& buffer) {
return buffer.readImage().release();
}
-static const SkVertices* create_vertices_from_buffer(SkReadBuffer& buffer) {
- auto data = buffer.readByteArrayAsData();
- return data ? SkVertices::Decode(data->data(), data->size()).release() : nullptr;
-}
static const SkImage* create_bitmap_image_from_buffer(SkReadBuffer& buffer) {
return buffer.readBitmapAsImage().release();
@@ -576,12 +549,6 @@ bool SkPictureData::parseBufferTag(SkReadBuffer& buffer, uint32_t tag, uint32_t
return false;
}
break;
- case SK_PICT_VERTICES_BUFFER_TAG:
- if (!new_array_from_buffer(buffer, size, &fVerticesRefs, &fVerticesCount,
- create_vertices_from_buffer)) {
- return false;
- }
- break;
case SK_PICT_IMAGE_BUFFER_TAG:
if (!new_array_from_buffer(buffer, size, &fImageRefs, &fImageCount,
create_image_from_buffer)) {
diff --git a/src/core/SkPictureData.h b/src/core/SkPictureData.h
index 37a02373be..332b799638 100644
--- a/src/core/SkPictureData.h
+++ b/src/core/SkPictureData.h
@@ -68,7 +68,6 @@ public:
#define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ')
#define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ')
#define SK_PICT_TEXTBLOB_BUFFER_TAG SkSetFourByteTag('b', 'l', 'o', 'b')
-#define SK_PICT_VERTICES_BUFFER_TAG SkSetFourByteTag('v', 'e', 'r', 't')
#define SK_PICT_IMAGE_BUFFER_TAG SkSetFourByteTag('i', 'm', 'a', 'g')
// Always write this guy last (with no length field afterwards)
@@ -144,11 +143,6 @@ public:
return reader->validateIndex(index, fTextBlobCount) ? fTextBlobRefs[index] : nullptr;
}
- const SkVertices* getVertices(SkReadBuffer* reader) const {
- const int index = reader->readInt() - 1;
- return reader->validateIndex(index, fVerticesCount) ? fVerticesRefs[index] : nullptr;
- }
-
#if SK_SUPPORT_GPU
/**
* sampleCount is the number of samples-per-pixel or zero if non-MSAA.
@@ -191,8 +185,6 @@ private:
int fDrawableCount;
const SkTextBlob** fTextBlobRefs;
int fTextBlobCount;
- const SkVertices** fVerticesRefs;
- int fVerticesCount;
const SkImage** fImageRefs;
int fImageCount;
const SkImage** fBitmapImageRefs;
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index ac1483d4a1..f5b20ca66c 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -93,9 +93,8 @@ enum DrawType {
DRAW_IMAGE_LATTICE,
DRAW_ARC,
DRAW_REGION,
- DRAW_VERTICES_OBJECT,
- LAST_DRAWTYPE_ENUM = DRAW_VERTICES_OBJECT
+ LAST_DRAWTYPE_ENUM = DRAW_REGION
};
// In the 'match' method, this constant will match any flavor of DRAW_BITMAP*
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 26dc38bef8..be2e5dbe04 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -678,19 +678,8 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
BREAK_ON_READ_ERROR(reader);
if (paint) {
- canvas->drawVertices(SkVertices::MakeCopy(vmode, vCount, verts, texs, colors,
- iCount, indices), bmode, *paint);
- }
- } break;
- case DRAW_VERTICES_OBJECT: {
- const SkPaint* paint = fPictureData->getPaint(reader);
- const SkVertices* vertices = fPictureData->getVertices(reader);
- SkBlendMode bmode = static_cast<SkBlendMode>(reader->readInt());
-
- BREAK_ON_READ_ERROR(reader);
-
- if (paint && vertices) {
- canvas->drawVertices(vertices, bmode, *paint);
+ canvas->drawVertices(vmode, vCount, verts, texs, colors,
+ bmode, indices, iCount, *paint);
}
} break;
case RESTORE:
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 1639cff863..98677dd5eb 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -722,26 +722,59 @@ void SkPictureRecord::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matri
}
void SkPictureRecord::onDrawVertices(VertexMode vmode, int vertexCount,
- const SkPoint pos[], const SkPoint texs[],
- const SkColor cols[], SkBlendMode bmode,
+ const SkPoint vertices[], const SkPoint texs[],
+ const SkColor colors[], 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);
+ uint32_t flags = 0;
+ if (texs) {
+ flags |= DRAW_VERTICES_HAS_TEXS;
+ }
+ if (colors) {
+ flags |= DRAW_VERTICES_HAS_COLORS;
+ }
+ if (indexCount > 0) {
+ flags |= DRAW_VERTICES_HAS_INDICES;
+ }
+ if (SkBlendMode::kModulate != bmode) {
+ flags |= DRAW_VERTICES_HAS_XFER;
}
-}
-void SkPictureRecord::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint) {
- // op + paint index + vertices index + mode
- size_t size = 4 * kUInt32Size;
- size_t initialOffset = this->addDraw(DRAW_VERTICES_OBJECT, &size);
+ // op + paint index + flags + vmode + vCount + vertices
+ size_t size = 5 * kUInt32Size + vertexCount * sizeof(SkPoint);
+ if (flags & DRAW_VERTICES_HAS_TEXS) {
+ size += vertexCount * sizeof(SkPoint); // + uvs
+ }
+ if (flags & DRAW_VERTICES_HAS_COLORS) {
+ size += vertexCount * sizeof(SkColor); // + vert colors
+ }
+ if (flags & DRAW_VERTICES_HAS_INDICES) {
+ // + num indices + indices
+ size += 1 * kUInt32Size + SkAlign4(indexCount * sizeof(uint16_t));
+ }
+ if (flags & DRAW_VERTICES_HAS_XFER) {
+ size += kUInt32Size; // mode enum
+ }
+ size_t initialOffset = this->addDraw(DRAW_VERTICES, &size);
this->addPaint(paint);
- this->addVertices(vertices);
- this->addInt(static_cast<uint32_t>(mode));
-
+ this->addInt(flags);
+ this->addInt(vmode);
+ this->addInt(vertexCount);
+ this->addPoints(vertices, vertexCount);
+ if (flags & DRAW_VERTICES_HAS_TEXS) {
+ this->addPoints(texs, vertexCount);
+ }
+ if (flags & DRAW_VERTICES_HAS_COLORS) {
+ fWriter.writeMul4(colors, vertexCount * sizeof(SkColor));
+ }
+ if (flags & DRAW_VERTICES_HAS_INDICES) {
+ this->addInt(indexCount);
+ fWriter.writePad(indices, indexCount * sizeof(uint16_t));
+ }
+ if (flags & DRAW_VERTICES_HAS_XFER) {
+ this->addInt((int)bmode);
+ }
this->validate(initialOffset, size);
}
@@ -951,9 +984,4 @@ void SkPictureRecord::addTextBlob(const SkTextBlob* blob) {
this->addInt(find_or_append_uniqueID(fTextBlobRefs, blob) + 1);
}
-void SkPictureRecord::addVertices(const SkVertices* vertices) {
- // follow the convention of recording a 1-based index
- this->addInt(find_or_append_uniqueID(fVerticesRefs, vertices) + 1);
-}
-
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 197684e347..587233c298 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -44,11 +44,7 @@ public:
return fTextBlobRefs;
}
- const SkTDArray<const SkVertices* >& getVerticesRefs() const {
- return fVerticesRefs;
- }
-
- const SkTDArray<const SkImage* >& getImageRefs() const {
+ const SkTDArray<const SkImage* >& getImageRefs() const {
return fImageRefs;
}
@@ -145,7 +141,6 @@ private:
void addRegion(const SkRegion& region);
void addText(const void* text, size_t byteLength);
void addTextBlob(const SkTextBlob* blob);
- void addVertices(const SkVertices*);
int find(const SkBitmap& bitmap);
@@ -209,7 +204,10 @@ protected:
const SkColor colors[], SkBlendMode,
const uint16_t indices[], int indexCount,
const SkPaint&) override;
- void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
+ void onDrawVerticesObject(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
+ uint32_t flags) override {
+ this->onDrawVerticesObjectFallback(std::move(vertices), mode, paint, flags);
+ }
void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
@@ -279,7 +277,6 @@ private:
SkTDArray<const SkPicture*> fPictureRefs;
SkTDArray<SkDrawable*> fDrawableRefs;
SkTDArray<const SkTextBlob*> fTextBlobRefs;
- SkTDArray<const SkVertices*> fVerticesRefs;
uint32_t fRecordFlags;
int fInitialSaveCount;
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 21f9de956b..8ca3f06513 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -134,7 +134,8 @@ DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.p
DRAW(DrawTextRSXform, drawTextRSXform(r.text, r.byteLength, r.xforms, r.cull, r.paint));
DRAW(DrawAtlas, drawAtlas(r.atlas.get(),
r.xforms, r.texs, r.colors, r.count, r.mode, r.cull, r.paint));
-DRAW(DrawVertices, drawVertices(r.vertices, r.bmode, r.paint));
+DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
+ r.bmode, r.indices, r.indexCount, r.paint));
DRAW(DrawAnnotation, drawAnnotation(r.rect, r.key.c_str(), r.value.get()));
#undef DRAW
@@ -453,7 +454,9 @@ private:
return this->adjustAndMap(dst, &op.paint);
}
Bounds bounds(const DrawVertices& op) const {
- return this->adjustAndMap(op.vertices->bounds(), &op.paint);
+ SkRect dst;
+ dst.set(op.vertices, op.vertexCount);
+ return this->adjustAndMap(dst, &op.paint);
}
Bounds bounds(const DrawAtlas& op) const {
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 9b38bcd2b3..fb0bda7e0b 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -331,13 +331,15 @@ void SkRecorder::onDrawVertices(VertexMode vmode,
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);
+ APPEND(DrawVertices, paint,
+ vmode,
+ vertexCount,
+ this->copy(vertices, vertexCount),
+ texs ? this->copy(texs, vertexCount) : nullptr,
+ colors ? this->copy(colors, vertexCount) : nullptr,
+ bmode,
+ this->copy(indices, indexCount),
+ indexCount);
}
void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index c13344227e..b5a79039d7 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -129,7 +129,6 @@ public:
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;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 55f0f17b2f..637077764c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1664,8 +1664,8 @@ void SkGpuDevice::drawVertices(SkCanvas::VertexMode vmode,
GrRenderTargetContext::ColorArrayType::kSkColor);
}
-void SkGpuDevice::drawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
- const SkPaint& paint) {
+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());
@@ -1685,7 +1685,7 @@ void SkGpuDevice::drawVerticesObject(const SkVertices* vertices, SkBlendMode mod
return;
}
fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(),
- sk_ref_sp(const_cast<SkVertices*>(vertices)));
+ std::move(vertices));
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index ed101f9bcf..01bded4ffc 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -92,7 +92,8 @@ public:
void drawVertices(SkCanvas::VertexMode, int vertexCount, const SkPoint verts[],
const SkPoint texs[], const SkColor colors[], SkBlendMode,
const uint16_t indices[], int indexCount, const SkPaint&) override;
- void drawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
+ void drawVerticesObject(sk_sp<SkVertices>, SkBlendMode, const SkPaint&,
+ uint32_t flags) override;
void drawAtlas(const SkImage* atlas, const SkRSXform[], const SkRect[],
const SkColor[], int count, SkBlendMode, const SkPaint&) override;
void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override;
diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h
index 2b15bbaf90..d25fe40274 100644
--- a/tools/debugger/SkDebugCanvas.h
+++ b/tools/debugger/SkDebugCanvas.h
@@ -230,9 +230,9 @@ protected:
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(sk_sp<SkVertices> vertices, SkBlendMode mode, const SkPaint& paint,
+ uint32_t flags) override {
+ this->onDrawVerticesObjectFallback(std::move(vertices), mode, paint, flags);
}
void onDrawPath(const SkPath&, const SkPaint&) override;
void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top, const SkPaint*) override;