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

Unified Diff: src/core/SkCanvas.cpp

Issue 1181913003: add SkCanvas::drawAtlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add virtuals for device and picture 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
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 14372611f8cfbed8a667a0a3b9eeedaf853aa17f..1b92db6b6f591567a60771d52644e3b8cc890fe5 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1801,6 +1801,39 @@ void SkCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, const SkPai
this->onDrawSprite(bitmap, left, top, paint);
}
+#include "SkRSXform.h"
+void SkCanvas::drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
+ const SkColor colors[], int n, const SkRect* cull, const SkPaint* paint) {
+// this->drawImage(atlas, 0, 0, paint);
+
+ SkPaint pnt;
+ if (paint) {
+ pnt = *paint;
+ }
+// pnt.setStyle(SkPaint::kStroke_Style);
+
+ SkPath path;
+ for (int i = 0; i < n; ++i) {
+ SkPoint quad[4];
+ xform[i].toQuad(tex[i].width(), tex[i].height(), quad);
+
+ SkMatrix localM;
+ localM.setRSXform(xform[i]);
+ localM.preTranslate(-tex[i].left(), -tex[i].top());
+
+ pnt.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode,
+ &localM))->unref();
+ if (colors) {
+ pnt.setColorFilter(SkColorFilter::CreateModeFilter(colors[i],
+ SkXfermode::kModulate_Mode))->unref();
+ }
+
+ path.rewind();
+ path.addPoly(quad, 4, true);
+ this->drawPath(path, pnt);
+ }
+}
+
//////////////////////////////////////////////////////////////////////////////
// These are the virtual drawing methods
//////////////////////////////////////////////////////////////////////////////
@@ -2449,6 +2482,25 @@ void SkCanvas::onDrawDrawable(SkDrawable* dr) {
dr->draw(this);
}
+void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
mtklein 2015/06/15 20:55:18 Am I crazy or is this never called?
reed1 2015/06/15 20:59:17 I'm crazy. Will fix.
+ const SkColor colors[], int count, const SkRect* cull,
+ const SkPaint* paint) {
+ if (cull && this->quickReject(*cull)) {
+ return;
+ }
+
+ SkPaint pnt;
+ if (paint) {
+ pnt = *paint;
+ }
+
+ LOOPER_BEGIN(pnt, SkDrawFilter::kPath_Type, NULL)
+ while (iter.next()) {
+ iter.fDevice->drawAtlas(iter, atlas, xform, tex, colors, count, pnt);
+ }
+ LOOPER_END
+}
+
//////////////////////////////////////////////////////////////////////////////
// These methods are NOT virtual, and therefore must call back into virtual
// methods, rather than actually drawing themselves.

Powered by Google App Engine
This is Rietveld 408576698