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

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

Issue 2176333002: Remove SkSurface::MakeRenderTargetDirect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 4 years, 4 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
« src/gpu/SkGpuDevice.h ('K') | « src/image/SkSurface.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 "GrContextPriv.h"
10 #include "GrResourceProvider.h" 11 #include "GrResourceProvider.h"
11 #include "SkCanvas.h" 12 #include "SkCanvas.h"
12 #include "SkGpuDevice.h" 13 #include "SkGpuDevice.h"
13 #include "SkImage_Base.h" 14 #include "SkImage_Base.h"
14 #include "SkImage_Gpu.h" 15 #include "SkImage_Gpu.h"
15 #include "SkImagePriv.h" 16 #include "SkImagePriv.h"
16 #include "SkSurface_Base.h" 17 #include "SkSurface_Base.h"
17 18
18 #if SK_SUPPORT_GPU 19 #if SK_SUPPORT_GPU
19 20
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 void SkSurface_Gpu::onDiscard() { 126 void SkSurface_Gpu::onDiscard() {
126 fDevice->accessDrawContext()->discard(); 127 fDevice->accessDrawContext()->discard();
127 } 128 }
128 129
129 void SkSurface_Gpu::onPrepareForExternalIO() { 130 void SkSurface_Gpu::onPrepareForExternalIO() {
130 fDevice->flush(); 131 fDevice->flush();
131 } 132 }
132 133
133 /////////////////////////////////////////////////////////////////////////////// 134 ///////////////////////////////////////////////////////////////////////////////
134 135
135 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target,
136 sk_sp<SkColorSpace> colorSpac e,
137 const SkSurfaceProps* props) {
138 sk_sp<SkGpuDevice> device(
139 SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props,
140 SkGpuDevice::kUninit_InitContents));
141 if (!device) {
142 return nullptr;
143 }
144 return sk_make_sp<SkSurface_Gpu>(std::move(device));
145 }
146
147 sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted , 136 sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted ,
148 const SkImageInfo& info, int sample Count, 137 const SkImageInfo& info, int sample Count,
149 GrSurfaceOrigin origin, const SkSur faceProps* props) { 138 GrSurfaceOrigin origin, const SkSur faceProps* props) {
150 sk_sp<SkGpuDevice> device(SkGpuDevice::Make( 139 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(
151 ctx, budgeted, info, sampleCount, origin, props, SkGpuDevice::kClear _InitContents)); 140 ctx, budgeted, info, sampleCount, origin, props, SkGpuDevice::kClear _InitContents));
152 if (!device) { 141 if (!device) {
153 return nullptr; 142 return nullptr;
154 } 143 }
155 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 144 return sk_make_sp<SkSurface_Gpu>(std::move(device));
156 } 145 }
157 146
158 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, 147 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
159 const GrBackendTextureDesc& d esc, 148 const GrBackendTextureDesc& d esc,
160 sk_sp<SkColorSpace> colorSpac e, 149 sk_sp<SkColorSpace> colorSpac e,
161 const SkSurfaceProps* props) { 150 const SkSurfaceProps* props) {
162 if (nullptr == context) { 151 if (!context) {
163 return nullptr; 152 return nullptr;
164 } 153 }
165 if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) { 154 if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) {
166 return nullptr; 155 return nullptr;
167 } 156 }
168 SkAutoTUnref<GrSurface> surface(context->textureProvider()->wrapBackendTextu re(desc, 157
169 kBorrow_GrWrapOwnership)); 158 sk_sp<GrDrawContext> dc(context->contextPriv().makeBackendTextureDrawContext (
170 if (!surface) { 159 desc,
160 std::move(co lorSpace),
161 props,
162 kBorrow_GrWr apOwnership));
163 if (!dc) {
171 return nullptr; 164 return nullptr;
172 } 165 }
173 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(sk_ref_sp(surface->asRenderTarge t()), 166
174 std::move(colorSpace), props, 167 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc .fHeight,
175 SkGpuDevice::kUninit_InitContent s)); 168 SkGpuDevice::kUninit_InitContent s));
176 if (!device) { 169 if (!device) {
177 return nullptr; 170 return nullptr;
178 } 171 }
179 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 172 return sk_make_sp<SkSurface_Gpu>(std::move(device));
180 } 173 }
181 174
182 sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, 175 sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
183 const GrBackendRenderTar getDesc& desc, 176 const GrBackendRenderTar getDesc& desc,
184 sk_sp<SkColorSpace> colo rSpace, 177 sk_sp<SkColorSpace> colo rSpace,
185 const SkSurfaceProps* pr ops) { 178 const SkSurfaceProps* pr ops) {
186 if (!context) { 179 if (!context) {
187 return nullptr; 180 return nullptr;
188 } 181 }
189 sk_sp<GrRenderTarget> rt(context->textureProvider()->wrapBackendRenderTarget (desc)); 182
190 if (!rt) { 183 sk_sp<GrDrawContext> dc(context->contextPriv().makeBackendRenderTargetDrawCo ntext(
184 desc ,
185 std: :move(colorSpace),
186 prop s));
187 if (!dc) {
191 return nullptr; 188 return nullptr;
192 } 189 }
193 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp ace), props, 190
191 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc .fHeight,
194 SkGpuDevice::kUninit_InitContent s)); 192 SkGpuDevice::kUninit_InitContent s));
195 if (!device) { 193 if (!device) {
196 return nullptr; 194 return nullptr;
197 } 195 }
196
198 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 197 return sk_make_sp<SkSurface_Gpu>(std::move(device));
199 } 198 }
200 199
201 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont ext, 200 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont ext,
202 const GrBackend TextureDesc& desc, 201 const GrBackend TextureDesc& desc,
203 sk_sp<SkColorSp ace> colorSpace, 202 sk_sp<SkColorSp ace> colorSpace,
204 const SkSurface Props* props) { 203 const SkSurface Props* props) {
205 if (!context) { 204 if (!context) {
206 return nullptr; 205 return nullptr;
207 } 206 }
208 sk_sp<GrRenderTarget> rt(context->resourceProvider()->wrapBackendTextureAsRe nderTarget(desc)); 207
209 if (!rt) { 208 sk_sp<GrDrawContext> dc(context->contextPriv().makeBackendTextureAsRenderTar getDrawContext(
209 desc ,
210 std: :move(colorSpace),
211 prop s));
212 if (!dc) {
210 return nullptr; 213 return nullptr;
211 } 214 }
212 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp ace), props, 215
216 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(dc), desc.fWidth, desc .fHeight,
213 SkGpuDevice::kUninit_InitContent s)); 217 SkGpuDevice::kUninit_InitContent s));
214 if (!device) { 218 if (!device) {
215 return nullptr; 219 return nullptr;
216 } 220 }
217 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 221 return sk_make_sp<SkSurface_Gpu>(std::move(device));
218 } 222 }
219 223
220 #endif 224 #endif
OLDNEW
« src/gpu/SkGpuDevice.h ('K') | « src/image/SkSurface.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698