Line data Source code
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
11 : // This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
12 : // GrRenderTargetProxy) so its constructor must be explicitly called.
13 0 : GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
14 : const GrSurfaceDesc& desc,
15 : SkBackingFit fit,
16 : SkBudgeted budgeted,
17 0 : 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 0 : , GrRenderTargetProxy(caps, desc, fit, budgeted, flags) {
22 0 : }
23 :
24 : // Wrapped version
25 : // This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
26 : // GrRenderTargetProxy) so its constructor must be explicitly called.
27 0 : GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(sk_sp<GrSurface> surf)
28 : : GrSurfaceProxy(surf, SkBackingFit::kExact)
29 0 : , GrTextureProxy(sk_ref_sp(surf->asTexture()))
30 0 : , GrRenderTargetProxy(sk_ref_sp(surf->asRenderTarget())) {
31 0 : SkASSERT(surf->asTexture());
32 0 : SkASSERT(surf->asRenderTarget());
33 0 : }
34 :
35 0 : size_t GrTextureRenderTargetProxy::onGpuMemorySize() const {
36 0 : if (fTarget) {
37 0 : return fTarget->gpuMemorySize();
38 : }
39 :
40 : // TODO: do we have enough information to improve this worst case estimate?
41 0 : return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, true, SkBackingFit::kApprox == fFit);
42 : }
43 :
|