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

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

Issue 1954103002: Revert of Retract GrRenderTarget a bit within SkGpuDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/SkGpuDevice.cpp ('k') | no next file » | 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 SkCanvas* SkSurface_Gpu::onNewCanvas() { 63 SkCanvas* SkSurface_Gpu::onNewCanvas() {
64 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; 64 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
65 flags = static_cast<SkCanvas::InitFlags>(flags | SkCanvas::kConservativeRast erClip_InitFlag); 65 flags = static_cast<SkCanvas::InitFlags>(flags | SkCanvas::kConservativeRast erClip_InitFlag);
66 66
67 return new SkCanvas(fDevice.get(), flags); 67 return new SkCanvas(fDevice.get(), flags);
68 } 68 }
69 69
70 sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { 70 sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
71 int sampleCount = fDevice->accessDrawContext()->numColorSamples(); 71 GrRenderTarget* rt = fDevice->accessRenderTarget();
72 int sampleCount = rt->numColorSamples();
72 // TODO: Make caller specify this (change virtual signature of onNewSurface) . 73 // TODO: Make caller specify this (change virtual signature of onNewSurface) .
73 static const SkBudgeted kBudgeted = SkBudgeted::kNo; 74 static const SkBudgeted kBudgeted = SkBudgeted::kNo;
74 return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, samp leCount, 75 return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, samp leCount,
75 &this->props()); 76 &this->props());
76 } 77 }
77 78
78 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyM ode forceCopyMode) { 79 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyM ode forceCopyMode) {
79 GrRenderTarget* rt = fDevice->accessRenderTarget(); 80 GrRenderTarget* rt = fDevice->accessRenderTarget();
80 SkASSERT(rt); 81 SkASSERT(rt);
81 GrTexture* tex = rt->asTexture(); 82 GrTexture* tex = rt->asTexture();
82 SkAutoTUnref<GrTexture> copy; 83 SkAutoTUnref<GrTexture> copy;
83 // If the original render target is a buffer originally created by the clien t, then we don't 84 // If the original render target is a buffer originally created by the clien t, then we don't
84 // want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid 85 // want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid
85 // copy-on-write. 86 // copy-on-write.
86 if (kYes_ForceCopyMode == forceCopyMode || !tex || rt->resourcePriv().refsWr appedObjects()) { 87 if (kYes_ForceCopyMode == forceCopyMode || !tex || rt->resourcePriv().refsWr appedObjects()) {
87 GrSurfaceDesc desc = fDevice->accessDrawContext()->desc(); 88 GrSurfaceDesc desc = fDevice->accessRenderTarget()->desc();
88 GrContext* ctx = fDevice->context(); 89 GrContext* ctx = fDevice->context();
89 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag; 90 desc.fFlags = desc.fFlags & ~kRenderTarget_GrSurfaceFlag;
90 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted)); 91 copy.reset(ctx->textureProvider()->createTexture(desc, budgeted));
91 if (!copy) { 92 if (!copy) {
92 return nullptr; 93 return nullptr;
93 } 94 }
94 if (!ctx->copySurface(copy, rt)) { 95 if (!ctx->copySurface(copy, rt)) {
95 return nullptr; 96 return nullptr;
96 } 97 }
97 tex = copy; 98 tex = copy;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 206 }
206 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props, 207 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props,
207 SkGpuDevice::kUninit_InitContent s)); 208 SkGpuDevice::kUninit_InitContent s));
208 if (!device) { 209 if (!device) {
209 return nullptr; 210 return nullptr;
210 } 211 }
211 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 212 return sk_make_sp<SkSurface_Gpu>(std::move(device));
212 } 213 }
213 214
214 #endif 215 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698