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

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

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