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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted, ForceCopyMode forc
eCopyMode) { | 79 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted, ForceCopyMode forc
eCopyMode) { |
80 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 80 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
81 SkASSERT(rt); | 81 SkASSERT(rt); |
82 GrTexture* tex = rt->asTexture(); | 82 GrTexture* tex = rt->asTexture(); |
83 SkAutoTUnref<GrTexture> copy; | 83 SkAutoTUnref<GrTexture> copy; |
84 // TODO: Force a copy when the rt is an external resource. | 84 // TODO: Force a copy when the rt is an external resource. |
85 if (kYes_ForceCopyMode == forceCopyMode || !tex) { | 85 if (kYes_ForceCopyMode == forceCopyMode || !tex) { |
86 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); | 86 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); |
87 GrContext* ctx = fDevice->context(); | 87 GrContext* ctx = fDevice->context(); |
88 desc.fFlags = desc.fFlags & !kRenderTarget_GrSurfaceFlag; | 88 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag; |
89 copy.reset(ctx->textureProvider()->createTexture(desc, kYes_Budgeted ==
budgeted)); | 89 copy.reset(ctx->textureProvider()->createTexture(desc, kYes_Budgeted ==
budgeted)); |
90 if (!copy) { | 90 if (!copy) { |
91 return nullptr; | 91 return nullptr; |
92 } | 92 } |
93 if (!ctx->copySurface(copy, rt)) { | 93 if (!ctx->copySurface(copy, rt)) { |
94 return nullptr; | 94 return nullptr; |
95 } | 95 } |
96 tex = copy; | 96 tex = copy; |
97 } | 97 } |
98 const SkImageInfo info = fDevice->imageInfo(); | 98 const SkImageInfo info = fDevice->imageInfo(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, | 182 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, |
183 SkGpuDevice::kUninit_In
itContents)); | 183 SkGpuDevice::kUninit_In
itContents)); |
184 if (!device) { | 184 if (!device) { |
185 return nullptr; | 185 return nullptr; |
186 } | 186 } |
187 return new SkSurface_Gpu(device); | 187 return new SkSurface_Gpu(device); |
188 } | 188 } |
189 | 189 |
190 #endif | 190 #endif |
OLD | NEW |