Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(901)

Unified Diff: src/pipe/SkGPipeWrite.cpp

Issue 1181913003: add SkCanvas::drawAtlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warnings Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pipe/SkGPipeWrite.cpp
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 2c11c414442223e3462fe0e20d3dc1e1f13f395c..f2aaaae216a738695185798029b4ceb5255a20b2 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -16,6 +16,7 @@
#include "SkGPipePriv.h"
#include "SkImageFilter.h"
#include "SkMaskFilter.h"
+#include "SkRSXform.h"
#include "SkWriteBuffer.h"
#include "SkPaint.h"
#include "SkPatchUtils.h"
@@ -287,6 +288,8 @@ protected:
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint&) override;
+ void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
+ int count, SkXfermode::Mode, const SkRect* cull, const SkPaint*) override;
void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
@@ -1096,6 +1099,48 @@ void SkGPipeCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
}
}
+void SkGPipeCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
+ const SkColor colors[], int count, SkXfermode::Mode mode,
+ const SkRect* cull, const SkPaint* paint) {
+ NOTIFY_SETUP(this);
+ unsigned flags = 0; // packs with the op, so needs no extra space
+
+ if (paint) {
+ flags |= kDrawAtlas_HasPaint_DrawOpFlag;
+ this->writePaint(*paint);
+ }
+
+ size_t size = 4; // image-slot
+ size += 4; // count
+ size += 4; // mode
+ size += count * sizeof(SkRSXform); // xform
+ size += count * sizeof(SkRect); // tex
+ if (colors) {
+ flags |= kDrawAtlas_HasColors_DrawOpFlag;
+ size += count * sizeof(SkColor); // colors
+ }
+ if (cull) {
+ flags |= kDrawAtlas_HasCull_DrawOpFlag;
+ size += sizeof(SkRect); // cull
+ }
+
+ if (this->needOpBytes(size)) {
+ this->writeOp(kDrawAtlas_DrawOp, flags, 0);
+ int32_t slot = fImageHeap->insert(atlas);
+ fWriter.write32(slot);
+ fWriter.write32(count);
+ fWriter.write32(mode);
+ fWriter.write(xform, count * sizeof(SkRSXform));
+ fWriter.write(tex, count * sizeof(SkRect));
+ if (colors) {
+ fWriter.write(colors, count * sizeof(SkColor));
+ }
+ if (cull) {
+ fWriter.writeRect(*cull);
+ }
+ }
+}
+
void SkGPipeCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkXfermode* xmode,
const SkPaint& paint) {
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698