diff options
author | 2015-05-07 15:36:17 -0700 | |
---|---|---|
committer | 2015-05-07 15:36:18 -0700 | |
commit | 8b26b99c97473f020df4b9d4ba789e074e06cedd (patch) | |
tree | 5739c495be880bebf001e5df37d6b17160f0959c /src/gpu/SkGr.cpp | |
parent | a2532d90cf3d71286276a6659db035c51b789658 (diff) |
new image from backend desc
BUG=485243
Review URL: https://codereview.chromium.org/1121813002
Diffstat (limited to 'src/gpu/SkGr.cpp')
-rw-r--r-- | src/gpu/SkGr.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 5df8c53feb..2fc0996d84 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -12,6 +12,7 @@ #include "SkConfig8888.h" #include "SkData.h" #include "SkErrorInternals.h" +#include "SkGrPixelRef.h" #include "SkMessageBus.h" #include "SkPixelRef.h" #include "SkResourceCache.h" @@ -737,3 +738,25 @@ bool SkPaint2GrPaint(GrContext* context, GrRenderTarget* rt, const SkPaint& skPa // If the shader can be seen as an effect it returns true and adds its effect to the grpaint. return SkPaint2GrPaintNoShader(context, rt, skPaint, paintColor, constantColor, grPaint); } + +SkImageInfo GrMakeInfoFromTexture(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; + if (!GrPixelConfig2ColorAndProfileType(config, &ct, NULL)) { + ct = kUnknown_SkColorType; + } + return SkImageInfo::Make(w, h, ct, at); +} + + +void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap* dst) { + const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); + dst->setInfo(info); + dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); +} |