Chromium Code Reviews| Index: src/gpu/SkGpuDevice.cpp |
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
| index 6ff0538ee2ca833bfbfcc145d8dbd0ba605fef4c..5fcc4355cdb9be4af20e908e19e5f4f5b5e868ea 100644 |
| --- a/src/gpu/SkGpuDevice.cpp |
| +++ b/src/gpu/SkGpuDevice.cpp |
| @@ -1730,6 +1730,49 @@ bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, |
| filter, ctx, result, offset); |
| } |
|
robertphillips
2015/05/05 18:47:56
Move up ?
reed1
2015/05/05 19:45:15
Done.
|
| +#include "SkImage_Base.h" |
| + |
| +static SkImageInfo make_info(GrTexture* tex, int w, int h, bool isOpaque) { |
| + const GrPixelConfig config = tex->config(); |
| + SkColorType ct; |
| + SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| + if (!GrPixelConfig2ColorAndProfileType(config, &ct, NULL)) { |
| + ct = kUnknown_SkColorType; |
| + } |
| + return SkImageInfo::Make(w, h, ct, at); |
| +} |
| + |
| +static bool wrap_as_bm(const SkImage* image, SkBitmap* bm) { |
| + GrTexture* tex = image->getTexture(); |
| + if (tex) { |
| + // TODO: handle the GrTexture directly, and skip GrPixelRef |
| + const SkImageInfo info = make_info(tex, image->width(), image->height(), image->isOpaque()); |
| + bm->setInfo(info); |
| + bm->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, tex)))->unref(); |
| + } else { |
| + if (!as_IB(image)->getROPixels(bm)) { |
| + return false; |
| + } |
| + } |
| + return true; |
| +} |
| + |
| +void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y, |
| + const SkPaint& paint) { |
| + SkBitmap bm; |
| + if (wrap_as_bm(image, &bm)) { |
| + this->drawBitmap(draw, bm, SkMatrix::MakeTrans(x, y), paint); |
| + } |
| +} |
| + |
| +void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const SkRect* src, |
| + const SkRect& dst, const SkPaint& paint) { |
| + SkBitmap bm; |
| + if (wrap_as_bm(image, &bm)) { |
|
robertphillips
2015/05/05 18:47:56
kNone_DrawBitmapRectFlag ?
reed1
2015/05/05 19:45:15
Done.
|
| + this->drawBitmapRect(draw, bm, src, dst, paint, SkCanvas::DrawBitmapRectFlags(0)); |
| + } |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| // must be in SkCanvas::VertexMode order |