diff options
author | 2015-04-08 08:38:40 -0700 | |
---|---|---|
committer | 2015-04-08 08:38:40 -0700 | |
commit | e4579adfdfb4b9f195d162835a69d9c2a974a6ac (patch) | |
tree | 8d78d7cd7cd5a88ac9affeca0307f62a14322bcb /src/image/SkSurface_Gpu.cpp | |
parent | 95bc5f349561fef2d6fbae71adb08cf5c2eec0c9 (diff) |
Add helper for creating a SkSurface from a client created texture.
Review URL: https://codereview.chromium.org/1071603002
Diffstat (limited to 'src/image/SkSurface_Gpu.cpp')
-rw-r--r-- | src/image/SkSurface_Gpu.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index b94e4e30bd..ac2f7fe25e 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -99,4 +99,24 @@ SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, Budgeted budgeted, const S return SkNEW_ARGS(SkSurface_Gpu, (device)); } +SkSurface* SkSurface::NewWrappedRenderTarget(GrContext* context, GrBackendTextureDesc desc, + const SkSurfaceProps* props) { + if (NULL == context) { + return NULL; + } + if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) { + return NULL; + } + SkAutoTUnref<GrSurface> surface(context->wrapBackendTexture(desc)); + if (!surface) { + return NULL; + } + SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget(), props, + SkGpuDevice::kNeedClear_Flag)); + if (!device) { + return NULL; + } + return SkNEW_ARGS(SkSurface_Gpu, (device)); +} + #endif |