huangcm
2024-12-18 9d29be7f7249789d6ffd0440067187a9f040c2cd
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
/*
 * Copyright 2019 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
 
#ifndef GrBaseContextPriv_DEFINED
#define GrBaseContextPriv_DEFINED
 
#include "GrContext_Base.h"
 
/** Class that exposes methods on GrContext_Base that are only intended for use internal to Skia.
    This class is purely a privileged window into GrContext_Base. It should never have
    additional data members or virtual methods. */
class GrBaseContextPriv {
public:
    // from GrContext_Base
    uint32_t contextID() const { return fContext->contextID(); }
 
private:
    explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}
    GrBaseContextPriv(const GrBaseContextPriv&); // unimpl
    GrBaseContextPriv& operator=(const GrBaseContextPriv&); // unimpl
 
    // No taking addresses of this type.
    const GrBaseContextPriv* operator&() const;
    GrBaseContextPriv* operator&();
 
    GrContext_Base* fContext;
 
    friend class GrContext_Base; // to construct/copy this type.
};
 
inline GrBaseContextPriv GrContext_Base::priv() { return GrBaseContextPriv(this); }
 
inline const GrBaseContextPriv GrContext_Base::priv () const {
    return GrBaseContextPriv(const_cast<GrContext_Base*>(this));
}
 
#endif