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