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

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

Issue 1694943002: When a surface is backed by an external render target force a copy on image snap (Closed) Base URL: https://skia.googlesource.com/skia.git@imgcopy
Patch Set: test git config branch.nollvm.skip-deps-uploads True Created 4 years, 9 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/GrResourceCache.cpp ('k') | tests/SurfaceTest.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 static const SkBudgeted kBudgeted = SkBudgeted::kNo; 75 static const SkBudgeted kBudgeted = SkBudgeted::kNo;
76 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl eCount, 76 return SkSurface::NewRenderTarget(fDevice->context(), kBudgeted, info, sampl eCount,
77 &this->props()); 77 &this->props());
78 } 78 }
79 79
80 SkImage* SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode fo rceCopyMode) { 80 SkImage* SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyMode fo rceCopyMode) {
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 // TODO: Force a copy when the rt is an external resource. 85 // If the original render target is a buffer originally created by the clien t, then we don't
86 if (kYes_ForceCopyMode == forceCopyMode || !tex) { 86 // want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid
87 // copy-on-write.
88 if (kYes_ForceCopyMode == forceCopyMode || !tex || rt->resourcePriv().isExte rnal()) {
87 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc(); 89 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc();
88 GrContext* ctx = fDevice->context(); 90 GrContext* ctx = fDevice->context();
89 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag; 91 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag;
90 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); 92 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted));
91 if (!copy) { 93 if (!copy) {
92 return nullptr; 94 return nullptr;
93 } 95 }
94 if (!ctx->copySurface(copy, rt)) { 96 if (!ctx->copySurface(copy, rt)) {
95 return nullptr; 97 return nullptr;
96 } 98 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 207 }
206 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, 208 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props,
207 SkGpuDevice::kUninit_In itContents)); 209 SkGpuDevice::kUninit_In itContents));
208 if (!device) { 210 if (!device) {
209 return nullptr; 211 return nullptr;
210 } 212 }
211 return new SkSurface_Gpu(device); 213 return new SkSurface_Gpu(device);
212 } 214 }
213 215
214 #endif 216 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrResourceCache.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698