blob: 212ea0a0490a5da2b0a52b42e174fa4873dbdbae [file] [log] [blame]
Robert Phillips84a81202016-11-04 11:59:10 -04001/*
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
11// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
12// GrRenderTargetProxy) so its constructor must be explicitly called.
13GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
14 const GrSurfaceDesc& desc,
15 SkBackingFit fit,
16 SkBudgeted budgeted)
17 : GrSurfaceProxy(desc, fit, budgeted)
18 , GrTextureProxy(desc, fit, budgeted, nullptr, 0) // 4 now textures w/ data are always wrapped
19 , GrRenderTargetProxy(caps, desc, fit, budgeted) {
20}
21
22// Wrapped version
23// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
24// GrRenderTargetProxy) so its constructor must be explicitly called.
Robert Phillips37430132016-11-09 06:50:43 -050025GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf)
26 : GrSurfaceProxy(surf, SkBackingFit::kExact)
27 , GrTextureProxy(sk_ref_sp(surf->asTexture()))
28 , GrRenderTargetProxy(sk_ref_sp(surf->asRenderTarget())) {
29 SkASSERT(surf->asTexture());
30 SkASSERT(surf->asRenderTarget());
Robert Phillips84a81202016-11-04 11:59:10 -040031}
32
33size_t GrTextureRenderTargetProxy::onGpuMemorySize() const {
34 if (fTarget) {
35 return fTarget->gpuMemorySize();
36 }
37
38 // TODO: do we have enough information to improve this worst case estimate?
Robert Phillipsb4460882016-11-17 14:43:51 -050039 return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, true, SkBackingFit::kApprox == fFit);
Robert Phillips84a81202016-11-04 11:59:10 -040040}
41