Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: src/image/SkSurface_Gpu.cpp

Issue 1862043002: Refactor to separate backend object lifecycle and GpuResource budget decision (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unrelated GrBuffer::onGpuMemorySize() lack of override keyword compile error Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkVertexBuffer.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkVertexBuffer.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698