| Index: src/core/SkDevice.cpp
|
| diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
|
| index dd55aad0ce42379d502fa5f6b6e573114ad983d8..a6f609b4869f9b1bb3b75ae92d0ef3db57702ae6 100644
|
| --- a/src/core/SkDevice.cpp
|
| +++ b/src/core/SkDevice.cpp
|
| @@ -10,6 +10,7 @@
|
| #include "SkDraw.h"
|
| #include "SkDrawFilter.h"
|
| #include "SkImage_Base.h"
|
| +#include "SkLightingShader.h"
|
| #include "SkMetaData.h"
|
| #include "SkNinePatchIter.h"
|
| #include "SkPatchUtils.h"
|
| @@ -212,6 +213,69 @@ void SkBaseDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkR
|
| }
|
| }
|
|
|
| +#include "SkGr.h"
|
| +
|
| +static bool wrap_as_bm(const SkImage* image, SkBitmap* bm) {
|
| + GrTexture* tex = as_IB(image)->getTexture();
|
| + if (tex) {
|
| + GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpaque(), bm);
|
| + return true;
|
| + } else {
|
| + return as_IB(image)->getROPixels(bm);
|
| + }
|
| +}
|
| +
|
| +void SkBaseDevice::drawLitAtlas(const SkDraw& draw, const SkImage* atlas, const SkRSXform xform[],
|
| + const SkRect diffTex[], const SkRect normTex[],
|
| + const SkColor colors[], int count, SkXfermode::Mode mode,
|
| + const SkPaint& paint,
|
| + const SkLight lights[], int numLights) {
|
| + SkPath path;
|
| + path.setIsVolatile(true);
|
| +
|
| + SkBitmap bm;
|
| + if (!wrap_as_bm(atlas, &bm)) {
|
| + return;
|
| + }
|
| +
|
| + SkLightingShader::Lights::Builder builder(lights, numLights);
|
| + SkAutoTUnref<const SkLightingShader::Lights> lights2(builder.finish());
|
| +
|
| + for (int i = 0; i < count; ++i) {
|
| + SkASSERT(diffTex[i].width() == normTex[i].width() &&
|
| + diffTex[i].height() == normTex[i].height());
|
| +
|
| + SkPoint quad[4];
|
| + xform[i].toQuad(diffTex[i].width(), diffTex[i].height(), quad);
|
| +
|
| + SkMatrix diffLocalM;
|
| + diffLocalM.setRSXform(xform[i]);
|
| + diffLocalM.preTranslate(-diffTex[i].left(), -diffTex[i].top());
|
| +
|
| + SkMatrix normLocalM;
|
| + normLocalM.setRSXform(xform[i]);
|
| + normLocalM.preTranslate(diffTex[i].left()-normTex[i].left(),
|
| + diffTex[i].top()-normTex[i].top());
|
| + normLocalM.preTranslate(-diffTex[i].left(), -diffTex[i].top());
|
| +
|
| + SkPaint pnt(paint);
|
| +
|
| + pnt.setShader(SkLightingShader::Create(bm, bm,
|
| + lights2,
|
| + xform[i], &diffLocalM, &normLocalM));
|
| +
|
| + 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) {
|
|
|