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

Unified Diff: include/core/SkCanvas.h

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 | « gyp/SampleApp.gyp ('k') | include/core/SkDevice.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkCanvas.h
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 42627daf51b9899c7df36fa88db5f2d29c5f79ce..7bdb6d219ca4bb5f89d1b57bfcc6127810fdd052 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -28,6 +28,7 @@ class SkImage;
class SkMetaData;
class SkPicture;
class SkRRect;
+struct SkRSXform;
class SkSurface;
class SkSurface_Base;
class SkTextBlob;
@@ -1024,6 +1025,32 @@ public:
const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint);
/**
+ * Draw a set of sprites from the atlas. Each is specified by a tex rectangle in the
+ * coordinate space of the atlas, and a corresponding xform which transforms the tex rectangle
+ * into a quad.
+ *
+ * xform maps [0, 0, tex.width, tex.height] -> quad
+ *
+ * The color array is optional. When specified, each color modulates the pixels in its
+ * corresponding quad (via the specified SkXfermode::Mode).
+ *
+ * The cullRect is optional. When specified, it must be a conservative bounds of all of the
+ * resulting transformed quads, allowing the canvas to skip drawing if the cullRect does not
+ * intersect the current clip.
+ *
+ * The paint is optional. If specified, its antialiasing, alpha, color-filter, image-filter
+ * and xfermode are used to affect each of the quads.
+ */
+ void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
+ const SkColor colors[], int count, SkXfermode::Mode, const SkRect* cullRect,
+ const SkPaint* paint);
+
+ void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
+ const SkRect* cullRect, const SkPaint* paint) {
+ this->drawAtlas(atlas, xform, tex, NULL, count, SkXfermode::kDst_Mode, cullRect, paint);
+ }
+
+ /**
* Draw the contents of this drawable into the canvas. If the canvas is async
* (e.g. it is recording into a picture) then the drawable will be referenced instead,
* to have its draw() method called when the picture is finalized.
@@ -1197,6 +1224,9 @@ protected:
virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
const SkPoint texs[], const SkColor colors[], SkXfermode*,
const uint16_t indices[], int indexCount, const SkPaint&);
+
+ virtual void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
+ int count, SkXfermode::Mode, const SkRect* cull, const SkPaint*);
virtual void onDrawPath(const SkPath&, const SkPaint&);
virtual void onDrawImage(const SkImage*, SkScalar dx, SkScalar dy, const SkPaint*);
virtual void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*);
« no previous file with comments | « gyp/SampleApp.gyp ('k') | include/core/SkDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698