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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // Create a new render target and, if necessary, copy the contents of the old | 108 // Create a new render target and, if necessary, copy the contents of the old |
109 // render target into it. Note that this flushes the SkGpuDevice but | 109 // render target into it. Note that this flushes the SkGpuDevice but |
110 // doesn't force an OpenGL flush. | 110 // doesn't force an OpenGL flush. |
111 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { | 111 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { |
112 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 112 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
113 // are we sharing our render target with the image? Note this call should ne
ver create a new | 113 // are we sharing our render target with the image? Note this call should ne
ver create a new |
114 // image because onCopyOnWrite is only called when there is a cached image. | 114 // image because onCopyOnWrite is only called when there is a cached image. |
115 sk_sp<SkImage> image(this->refCachedImage(SkBudgeted::kNo, kNo_ForceUnique))
; | 115 sk_sp<SkImage> image(this->refCachedImage(SkBudgeted::kNo, kNo_ForceUnique))
; |
116 SkASSERT(image); | 116 SkASSERT(image); |
117 if (rt->asTexture() == as_IB(image)->peekTexture()) { | 117 if (rt->asTexture() == as_IB(image)->peekTexture()) { |
118 this->fDevice->replaceRenderTarget(SkSurface::kRetain_ContentChangeMode
== mode); | 118 this->fDevice->replaceDrawContext(SkSurface::kRetain_ContentChangeMode =
= mode); |
119 SkTextureImageApplyBudgetedDecision(image.get()); | 119 SkTextureImageApplyBudgetedDecision(image.get()); |
120 } else if (kDiscard_ContentChangeMode == mode) { | 120 } else if (kDiscard_ContentChangeMode == mode) { |
121 this->SkSurface_Gpu::onDiscard(); | 121 this->SkSurface_Gpu::onDiscard(); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 void SkSurface_Gpu::onDiscard() { | 125 void SkSurface_Gpu::onDiscard() { |
126 fDevice->accessRenderTarget()->discard(); | 126 fDevice->accessDrawContext()->discard(); |
127 } | 127 } |
128 | 128 |
129 void SkSurface_Gpu::onPrepareForExternalIO() { | 129 void SkSurface_Gpu::onPrepareForExternalIO() { |
130 fDevice->accessRenderTarget()->prepareForExternalIO(); | 130 fDevice->accessRenderTarget()->prepareForExternalIO(); |
131 } | 131 } |
132 | 132 |
133 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
134 | 134 |
135 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target, | 135 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target, |
136 const SkSurfaceProps* props)
{ | 136 const SkSurfaceProps* props)
{ |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 205 } |
206 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props, | 206 sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props, |
207 SkGpuDevice::kUninit_InitContent
s)); | 207 SkGpuDevice::kUninit_InitContent
s)); |
208 if (!device) { | 208 if (!device) { |
209 return nullptr; | 209 return nullptr; |
210 } | 210 } |
211 return sk_make_sp<SkSurface_Gpu>(std::move(device)); | 211 return sk_make_sp<SkSurface_Gpu>(std::move(device)); |
212 } | 212 } |
213 | 213 |
214 #endif | 214 #endif |
OLD | NEW |