aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkSurface_Gpu.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-04-08 08:38:40 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-08 08:38:40 -0700
commite4579adfdfb4b9f195d162835a69d9c2a974a6ac (patch)
tree8d78d7cd7cd5a88ac9affeca0307f62a14322bcb /src/image/SkSurface_Gpu.cpp
parent95bc5f349561fef2d6fbae71adb08cf5c2eec0c9 (diff)
Add helper for creating a SkSurface from a client created texture.
Diffstat (limited to 'src/image/SkSurface_Gpu.cpp')
-rw-r--r--src/image/SkSurface_Gpu.cpp20
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