OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkSurface_Gpu.h" | 8 #include "SkSurface_Gpu.h" |
9 | 9 |
10 #include "GrResourceProvider.h" | 10 #include "GrResourceProvider.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyM
ode forceCopyMode) { | 80 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyM
ode forceCopyMode) { |
81 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 81 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
82 SkASSERT(rt); | 82 SkASSERT(rt); |
83 GrTexture* tex = rt->asTexture(); | 83 GrTexture* tex = rt->asTexture(); |
84 SkAutoTUnref<GrTexture> copy; | 84 SkAutoTUnref<GrTexture> copy; |
85 // If the original render target is a buffer originally created by the clien
t, then we don't | 85 // If the original render target is a buffer originally created by the clien
t, then we don't |
86 // want to ever retarget the SkSurface at another buffer we create. Force a
copy now to avoid | 86 // want to ever retarget the SkSurface at another buffer we create. Force a
copy now to avoid |
87 // copy-on-write. | 87 // copy-on-write. |
88 if (kYes_ForceCopyMode == forceCopyMode || !tex || rt->resourcePriv().isExte
rnal()) { | 88 if (kYes_ForceCopyMode == forceCopyMode || !tex || rt->resourcePriv().refsWr
appedObjects()) { |
89 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); | 89 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); |
90 GrContext* ctx = fDevice->context(); | 90 GrContext* ctx = fDevice->context(); |
91 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag; | 91 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag; |
92 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); | 92 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); |
93 if (!copy) { | 93 if (!copy) { |
94 return nullptr; | 94 return nullptr; |
95 } | 95 } |
96 if (!ctx->copySurface(copy, rt)) { | 96 if (!ctx->copySurface(copy, rt)) { |
97 return nullptr; | 97 return nullptr; |
98 } | 98 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, | 209 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, |
210 SkGpuDevice::kUninit_In
itContents)); | 210 SkGpuDevice::kUninit_In
itContents)); |
211 if (!device) { | 211 if (!device) { |
212 return nullptr; | 212 return nullptr; |
213 } | 213 } |
214 return sk_make_sp<SkSurface_Gpu>(device); | 214 return sk_make_sp<SkSurface_Gpu>(device); |
215 } | 215 } |
216 | 216 |
217 #endif | 217 #endif |
OLD | NEW |