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

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

Issue 2164363002: Add SkColorSpace to GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 fDevice->accessDrawContext()->discard(); 127 fDevice->accessDrawContext()->discard();
128 } 128 }
129 129
130 void SkSurface_Gpu::onPrepareForExternalIO() { 130 void SkSurface_Gpu::onPrepareForExternalIO() {
131 fDevice->flush(); 131 fDevice->flush();
132 } 132 }
133 133
134 /////////////////////////////////////////////////////////////////////////////// 134 ///////////////////////////////////////////////////////////////////////////////
135 135
136 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target, 136 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target,
137 sk_sp<SkColorSpace> colorSpac e,
137 const SkSurfaceProps* props) { 138 const SkSurfaceProps* props) {
138 sk_sp<SkGpuDevice> device( 139 sk_sp<SkGpuDevice> device(
139 SkGpuDevice::Make(sk_ref_sp(target), props, SkGpuDevice::kUninit_InitCon tents)); 140 SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props,
141 SkGpuDevice::kUninit_InitContents));
140 if (!device) { 142 if (!device) {
141 return nullptr; 143 return nullptr;
142 } 144 }
143 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 145 return sk_make_sp<SkSurface_Gpu>(std::move(device));
144 } 146 }
145 147
146 sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted , 148 sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted ,
147 const SkImageInfo& info, int sample Count, 149 const SkImageInfo& info, int sample Count,
148 const SkSurfaceProps* props) { 150 const SkSurfaceProps* props) {
149 sk_sp<SkGpuDevice> device(SkGpuDevice::Make( 151 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(
150 ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitCon tents)); 152 ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitCon tents));
151 if (!device) { 153 if (!device) {
152 return nullptr; 154 return nullptr;
153 } 155 }
154 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 156 return sk_make_sp<SkSurface_Gpu>(std::move(device));
155 } 157 }
156 158
157 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, 159 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
158 const GrBackendTextureDesc& d esc, 160 const GrBackendTextureDesc& d esc,
161 sk_sp<SkColorSpace> colorSpac e,
159 const SkSurfaceProps* props) { 162 const SkSurfaceProps* props) {
160 if (nullptr == context) { 163 if (nullptr == context) {
161 return nullptr; 164 return nullptr;
162 } 165 }
163 if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) { 166 if (!SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) {
164 return nullptr; 167 return nullptr;
165 } 168 }
166 SkAutoTUnref<GrSurface> surface(context->textureProvider()->wrapBackendTextu re(desc, 169 SkAutoTUnref<GrSurface> surface(context->textureProvider()->wrapBackendTextu re(desc,
167 kBorrow_GrWrapOwnership)); 170 kBorrow_GrWrapOwnership));
168 if (!surface) { 171 if (!surface) {
169 return nullptr; 172 return nullptr;
170 } 173 }
171 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(sk_ref_sp(surface->asRenderTarge t()), props, 174 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(sk_ref_sp(surface->asRenderTarge t()),
175 std::move(colorSpace), props,
172 SkGpuDevice::kUninit_InitContent s)); 176 SkGpuDevice::kUninit_InitContent s));
173 if (!device) { 177 if (!device) {
174 return nullptr; 178 return nullptr;
175 } 179 }
176 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 180 return sk_make_sp<SkSurface_Gpu>(std::move(device));
177 } 181 }
178 182
179 sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context, 183 sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
180 const GrBackendRenderTar getDesc& desc, 184 const GrBackendRenderTar getDesc& desc,
185 sk_sp<SkColorSpace> colo rSpace,
181 const SkSurfaceProps* pr ops) { 186 const SkSurfaceProps* pr ops) {
182 if (!context) { 187 if (!context) {
183 return nullptr; 188 return nullptr;
184 } 189 }
185 sk_sp<GrRenderTarget> rt(context->textureProvider()->wrapBackendRenderTarget (desc)); 190 sk_sp<GrRenderTarget> rt(context->textureProvider()->wrapBackendRenderTarget (desc));
186 if (!rt) { 191 if (!rt) {
187 return nullptr; 192 return nullptr;
188 } 193 }
189 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props, 194 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp ace), props,
190 SkGpuDevice::kUninit_InitContent s)); 195 SkGpuDevice::kUninit_InitContent s));
191 if (!device) { 196 if (!device) {
192 return nullptr; 197 return nullptr;
193 } 198 }
194 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 199 return sk_make_sp<SkSurface_Gpu>(std::move(device));
195 } 200 }
196 201
197 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont ext, 202 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont ext,
198 const GrBackend TextureDesc& desc, 203 const GrBackend TextureDesc& desc,
204 sk_sp<SkColorSp ace> colorSpace,
199 const SkSurface Props* props) { 205 const SkSurface Props* props) {
200 if (!context) { 206 if (!context) {
201 return nullptr; 207 return nullptr;
202 } 208 }
203 sk_sp<GrRenderTarget> rt(context->resourceProvider()->wrapBackendTextureAsRe nderTarget(desc)); 209 sk_sp<GrRenderTarget> rt(context->resourceProvider()->wrapBackendTextureAsRe nderTarget(desc));
204 if (!rt) { 210 if (!rt) {
205 return nullptr; 211 return nullptr;
206 } 212 }
207 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props, 213 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp ace), props,
208 SkGpuDevice::kUninit_InitContent s)); 214 SkGpuDevice::kUninit_InitContent s));
209 if (!device) { 215 if (!device) {
210 return nullptr; 216 return nullptr;
211 } 217 }
212 return sk_make_sp<SkSurface_Gpu>(std::move(device)); 218 return sk_make_sp<SkSurface_Gpu>(std::move(device));
213 } 219 }
214 220
215 #endif 221 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698