aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextureProxyCacheAccess.h
blob: 7db7150b7f97d8df698b93bedfa54fcaf6c5f878 (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
/*
 * Copyright 2017 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrTextureProxyCacheAccess_DEFINED
#define GrTextureProxyCacheAccess_DEFINED

#include "GrTextureProxy.h"

/**
 * This class allows GrResourceCache increased privileged access to GrTextureProxy objects.
 */
class GrTextureProxy::CacheAccess {
private:
    void setUniqueKey(GrProxyProvider* proxyProvider, const GrUniqueKey& key) {
        fTextureProxy->setUniqueKey(proxyProvider, key);
    }

    void clearUniqueKey() {
        fTextureProxy->clearUniqueKey();
    }

    explicit CacheAccess(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
    CacheAccess(const CacheAccess&) {} // unimpl
    CacheAccess& operator=(const CacheAccess&); // unimpl

    // No taking addresses of this type.
    const CacheAccess* operator&() const;
    CacheAccess* operator&();

    GrTextureProxy* fTextureProxy;

    friend class GrTextureProxy;  // to construct/copy this type.
    friend class GrProxyProvider; // to use this type
};

inline GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() { return CacheAccess(this); }

inline const GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess() const {
    return CacheAccess(const_cast<GrTextureProxy*>(this));
}

#endif