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