aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/GrTextureProxy.h
blob: e68ef8896a85777d4880cef8a86babc7f8a78e5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrTextureProxy_DEFINED
#define GrTextureProxy_DEFINED

#include "GrSurfaceProxy.h"
#include "GrTexture.h"

class GrCaps;
class GrTextureProvider;

// This class delays the acquisition of textures until they are actually required
class GrTextureProxy : virtual public GrSurfaceProxy {
public:
    // TODO: need to refine ownership semantics of 'srcData' if we're in completely
    // deferred mode
    static sk_sp<GrTextureProxy> Make(const GrCaps&, GrTextureProvider*, const GrSurfaceDesc&,
                                      SkBackingFit, SkBudgeted,
                                      const void* srcData = nullptr, size_t rowBytes = 0);
    static sk_sp<GrTextureProxy> Make(sk_sp<GrTexture>);

    // TODO: add asRenderTargetProxy variants
    GrTextureProxy* asTextureProxy() override { return this; }
    const GrTextureProxy* asTextureProxy() const override { return this; }

    // Actually instantiate the backing texture, if necessary
    GrTexture* instantiate(GrTextureProvider*);

protected:
    // Deferred version
    GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted,
                   const void* srcData, size_t srcRowBytes);
    // Wrapped version
    GrTextureProxy(sk_sp<GrTexture> tex);

private:
    size_t onGpuMemorySize() const override;

    // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy.
    // For deferred proxies that pointer will be filled n when we need to instantiate
    // the deferred resource

    typedef GrSurfaceProxy INHERITED;
};

#endif