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

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 1121813002: new image from backend desc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 9518600e9948cd681e1bf9f4fb587bc046ccce1c..6e051ac992e3ec869273ac2aab06f31d904f6577 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1732,6 +1732,11 @@ bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src,
}
static SkImageInfo make_info(GrTexture* tex, int w, int h, bool isOpaque) {
+#ifdef SK_DEBUG
+ const GrSurfaceDesc& desc = tex->desc();
+ SkASSERT(w <= desc.fWidth);
+ SkASSERT(h <= desc.fHeight);
+#endif
const GrPixelConfig config = tex->config();
SkColorType ct;
SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
@@ -1741,19 +1746,22 @@ static SkImageInfo make_info(GrTexture* tex, int w, int h, bool isOpaque) {
return SkImageInfo::Make(w, h, ct, at);
}
+void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap* dst) {
bsalomon 2015/05/07 17:05:56 This code should maybe move to SkGr.h/cpp where th
reed1 2015/05/07 17:49:11 Done.
+ const SkImageInfo info = make_info(src, w, h, isOpaque);
+ dst->setInfo(info);
+ dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref();
+}
+
robertphillips 2015/05/07 16:50:03 Move the #include up ? Do we even need this ?
reed1 2015/05/07 17:49:11 Done.
+#include "SkImage_Base.h"
+
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();
+ GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpaque(), bm);
+ return true;
} else {
- if (!as_IB(image)->getROPixels(bm)) {
- return false;
- }
+ return as_IB(image)->getROPixels(bm);
}
- return true;
}
void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x, SkScalar y,
« no previous file with comments | « src/gpu/SkGpuDevice.h ('k') | src/image/SkImage.cpp » ('j') | src/image/SkImage_Gpu.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698