Index: src/core/SkDevice.cpp |
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp |
index 14784a25d657bf9b1c9f862a274b28ecd8128407..970b8ec8bee4db1dbcb784888dc397ad707c3a54 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 "SkDeviceProperties.h" |
#include "SkDraw.h" |
@@ -14,6 +15,7 @@ |
#include "SkPatchUtils.h" |
#include "SkPathMeasure.h" |
#include "SkRasterClip.h" |
+#include "SkRSXform.h" |
#include "SkShader.h" |
#include "SkTextBlob.h" |
#include "SkTextToPathIter.h" |
@@ -180,6 +182,35 @@ 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, |
+ const SkPaint& paint) { |
+ SkPath path; |
+ 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) { |
+ SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(colors[i], |
+ SkXfermode::kModulate_Mode)); |
+ pnt.setColorFilter(cf); |
+ } |
+ |
+ path.rewind(); |
+ path.addPoly(quad, 4, true); |
+ 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); |