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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 SkCanvas* SkSurface_Gpu::onNewCanvas() { | 61 SkCanvas* SkSurface_Gpu::onNewCanvas() { |
62 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; | 62 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; |
63 flags = static_cast<SkCanvas::InitFlags>(flags | SkCanvas::kConservativeRast
erClip_InitFlag); | 63 flags = static_cast<SkCanvas::InitFlags>(flags | SkCanvas::kConservativeRast
erClip_InitFlag); |
64 | 64 |
65 return new SkCanvas(fDevice.get(), flags); | 65 return new SkCanvas(fDevice.get(), flags); |
66 } | 66 } |
67 | 67 |
68 sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { | 68 sk_sp<SkSurface> SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { |
69 int sampleCount = fDevice->accessDrawContext()->numColorSamples(); | 69 int sampleCount = fDevice->accessDrawContext()->numColorSamples(); |
| 70 GrSurfaceOrigin origin = fDevice->accessDrawContext()->origin(); |
70 // TODO: Make caller specify this (change virtual signature of onNewSurface)
. | 71 // TODO: Make caller specify this (change virtual signature of onNewSurface)
. |
71 static const SkBudgeted kBudgeted = SkBudgeted::kNo; | 72 static const SkBudgeted kBudgeted = SkBudgeted::kNo; |
72 return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, samp
leCount, | 73 return SkSurface::MakeRenderTarget(fDevice->context(), kBudgeted, info, samp
leCount, |
73 &this->props()); | 74 origin, &this->props()); |
74 } | 75 } |
75 | 76 |
76 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyM
ode forceCopyMode) { | 77 sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(SkBudgeted budgeted, ForceCopyM
ode forceCopyMode) { |
77 GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget(); | 78 GrRenderTarget* rt = fDevice->accessDrawContext()->accessRenderTarget(); |
78 SkASSERT(rt); | 79 SkASSERT(rt); |
79 GrTexture* tex = rt->asTexture(); | 80 GrTexture* tex = rt->asTexture(); |
80 SkAutoTUnref<GrTexture> copy; | 81 SkAutoTUnref<GrTexture> copy; |
81 // If the original render target is a buffer originally created by the clien
t, then we don't | 82 // If the original render target is a buffer originally created by the clien
t, then we don't |
82 // want to ever retarget the SkSurface at another buffer we create. Force a
copy now to avoid | 83 // want to ever retarget the SkSurface at another buffer we create. Force a
copy now to avoid |
83 // copy-on-write. | 84 // copy-on-write. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props, | 139 SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props, |
139 SkGpuDevice::kUninit_InitContents)); | 140 SkGpuDevice::kUninit_InitContents)); |
140 if (!device) { | 141 if (!device) { |
141 return nullptr; | 142 return nullptr; |
142 } | 143 } |
143 return sk_make_sp<SkSurface_Gpu>(std::move(device)); | 144 return sk_make_sp<SkSurface_Gpu>(std::move(device)); |
144 } | 145 } |
145 | 146 |
146 sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted
, | 147 sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted
, |
147 const SkImageInfo& info, int sample
Count, | 148 const SkImageInfo& info, int sample
Count, |
148 const SkSurfaceProps* props) { | 149 GrSurfaceOrigin origin, const SkSur
faceProps* props) { |
149 sk_sp<SkGpuDevice> device(SkGpuDevice::Make( | 150 sk_sp<SkGpuDevice> device(SkGpuDevice::Make( |
150 ctx, budgeted, info, sampleCount, props, SkGpuDevice::kClear_InitCon
tents)); | 151 ctx, budgeted, info, sampleCount, origin, props, SkGpuDevice::kClear
_InitContents)); |
151 if (!device) { | 152 if (!device) { |
152 return nullptr; | 153 return nullptr; |
153 } | 154 } |
154 return sk_make_sp<SkSurface_Gpu>(std::move(device)); | 155 return sk_make_sp<SkSurface_Gpu>(std::move(device)); |
155 } | 156 } |
156 | 157 |
157 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, | 158 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context, |
158 const GrBackendTextureDesc& d
esc, | 159 const GrBackendTextureDesc& d
esc, |
159 sk_sp<SkColorSpace> colorSpac
e, | 160 sk_sp<SkColorSpace> colorSpac
e, |
160 const SkSurfaceProps* props)
{ | 161 const SkSurfaceProps* props)
{ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 211 } |
211 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp
ace), props, | 212 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSp
ace), props, |
212 SkGpuDevice::kUninit_InitContent
s)); | 213 SkGpuDevice::kUninit_InitContent
s)); |
213 if (!device) { | 214 if (!device) { |
214 return nullptr; | 215 return nullptr; |
215 } | 216 } |
216 return sk_make_sp<SkSurface_Gpu>(std::move(device)); | 217 return sk_make_sp<SkSurface_Gpu>(std::move(device)); |
217 } | 218 } |
218 | 219 |
219 #endif | 220 #endif |
OLD | NEW |