Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrTextureRenderTargetProxy.h" |
| 9 | |
| 10 | // Deferred version |
Robert Phillips | c787e49 | 2017-02-28 11:26:32 -0500 | [diff] [blame^] | 11 | // This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 12 | // GrRenderTargetProxy) so its constructor must be explicitly called. |
| 13 | GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps, |
| 14 | const GrSurfaceDesc& desc, |
| 15 | SkBackingFit fit, |
Robert Phillips | c787e49 | 2017-02-28 11:26:32 -0500 | [diff] [blame^] | 16 | SkBudgeted budgeted, |
| 17 | uint32_t flags) |
| 18 | : GrSurfaceProxy(desc, fit, budgeted, flags) |
| 19 | // for now textures w/ data are always wrapped |
| 20 | , GrTextureProxy(desc, fit, budgeted, nullptr, 0, flags) |
| 21 | , GrRenderTargetProxy(caps, desc, fit, budgeted, flags) { |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | // Wrapped version |
Robert Phillips | c787e49 | 2017-02-28 11:26:32 -0500 | [diff] [blame^] | 25 | // This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 26 | // GrRenderTargetProxy) so its constructor must be explicitly called. |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 27 | GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf) |
| 28 | : GrSurfaceProxy(surf, SkBackingFit::kExact) |
| 29 | , GrTextureProxy(sk_ref_sp(surf->asTexture())) |
| 30 | , GrRenderTargetProxy(sk_ref_sp(surf->asRenderTarget())) { |
| 31 | SkASSERT(surf->asTexture()); |
| 32 | SkASSERT(surf->asRenderTarget()); |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | size_t GrTextureRenderTargetProxy::onGpuMemorySize() const { |
| 36 | if (fTarget) { |
| 37 | return fTarget->gpuMemorySize(); |
| 38 | } |
| 39 | |
| 40 | // TODO: do we have enough information to improve this worst case estimate? |
Robert Phillips | b446088 | 2016-11-17 14:43:51 -0500 | [diff] [blame] | 41 | return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, true, SkBackingFit::kApprox == fFit); |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 42 | } |
| 43 | |