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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 void SkSurface_Gpu::onDiscard() { | 124 void SkSurface_Gpu::onDiscard() { |
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 bool SkSurface_Gpu::onBlitWithGamma(SkImage* image, SkScalar gamma) { |
| 133 GrRenderTarget* dst = fDevice->accessDrawContext()->accessRenderTarget(); |
| 134 if (GrTexture* src = as_IB(image)->asTextureRef(dst->getContext(), |
| 135 GrTextureParams::ClampNoFilt
er(), |
| 136 SkSourceGammaTreatment::kRes
pect)) { |
| 137 fDevice.get()->context()->applyGamma(dst, src, gamma); |
| 138 return true; |
| 139 } |
| 140 return false; |
| 141 } |
| 142 |
132 /////////////////////////////////////////////////////////////////////////////// | 143 /////////////////////////////////////////////////////////////////////////////// |
133 | 144 |
134 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target, | 145 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target, |
135 sk_sp<SkColorSpace> colorSpac
e, | 146 sk_sp<SkColorSpace> colorSpac
e, |
136 const SkSurfaceProps* props)
{ | 147 const SkSurfaceProps* props)
{ |
137 sk_sp<SkGpuDevice> device( | 148 sk_sp<SkGpuDevice> device( |
138 SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props, | 149 SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props, |
139 SkGpuDevice::kUninit_InitContents)); | 150 SkGpuDevice::kUninit_InitContents)); |
140 if (!device) { | 151 if (!device) { |
141 return nullptr; | 152 return nullptr; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 221 } |
211 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp
ace), props, | 222 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp
ace), props, |
212 SkGpuDevice::kUninit_InitContent
s)); | 223 SkGpuDevice::kUninit_InitContent
s)); |
213 if (!device) { | 224 if (!device) { |
214 return nullptr; | 225 return nullptr; |
215 } | 226 } |
216 return sk_make_sp<SkSurface_Gpu>(std::move(device)); | 227 return sk_make_sp<SkSurface_Gpu>(std::move(device)); |
217 } | 228 } |
218 | 229 |
219 #endif | 230 #endif |
OLD | NEW |