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

Unified Diff: src/core/SkDevice.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/core/SkCanvas.cpp ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDevice.cpp
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 15cd7eef3b53f66c76e46dd6e804da079346890a..8f7f50c86368ce0639501e0b902a3f33abd4068c 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkColorFilter.h"
#include "SkDevice.h"
#include "SkDraw.h"
#include "SkDrawFilter.h"
@@ -13,6 +14,7 @@
#include "SkPatchUtils.h"
#include "SkPathMeasure.h"
#include "SkRasterClip.h"
+#include "SkRSXform.h"
#include "SkShader.h"
#include "SkTextBlob.h"
#include "SkTextToPathIter.h"
@@ -159,6 +161,37 @@ void SkBaseDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const
}
}
+void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRSXform xform[],
+ const SkRect tex[], const SkColor colors[], int count,
+ SkXfermode::Mode mode, const SkPaint& paint) {
+ SkPath path;
+ path.setIsVolatile(true);
+
+ for (int i = 0; i < count; ++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());
+
+ SkPaint pnt(paint);
+ pnt.setShader(atlas->newShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode,
+ &localM))->unref();
+ if (colors && colors[i] != SK_ColorWHITE) {
+ SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(colors[i], mode));
+ pnt.setColorFilter(cf);
+ }
+
+ path.rewind();
+ path.addPoly(quad, 4, true);
+ path.setConvexity(SkPath::kConvex_Convexity);
+ this->drawPath(draw, path, pnt, NULL, true);
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
bool SkBaseDevice::readPixels(const SkImageInfo& info, void* dstP, size_t rowBytes, int x, int y) {
#ifdef SK_DEBUG
SkASSERT(info.width() > 0 && info.height() > 0);
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698