• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 #ifndef GrBaseContextPriv_DEFINED
9 #define GrBaseContextPriv_DEFINED
10 
11 #include "GrContext_Base.h"
12 
13 /** Class that exposes methods on GrContext_Base that are only intended for use internal to Skia.
14     This class is purely a privileged window into GrContext_Base. It should never have
15     additional data members or virtual methods. */
16 class GrBaseContextPriv {
17 public:
18     // from GrContext_Base
contextID()19     uint32_t contextID() const { return fContext->contextID(); }
20 
21 private:
GrBaseContextPriv(GrContext_Base * context)22     explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}
23     GrBaseContextPriv(const GrBaseContextPriv&); // unimpl
24     GrBaseContextPriv& operator=(const GrBaseContextPriv&); // unimpl
25 
26     // No taking addresses of this type.
27     const GrBaseContextPriv* operator&() const;
28     GrBaseContextPriv* operator&();
29 
30     GrContext_Base* fContext;
31 
32     friend class GrContext_Base; // to construct/copy this type.
33 };
34 
priv()35 inline GrBaseContextPriv GrContext_Base::priv() { return GrBaseContextPriv(this); }
36 
priv()37 inline const GrBaseContextPriv GrContext_Base::priv () const {
38     return GrBaseContextPriv(const_cast<GrContext_Base*>(this));
39 }
40 
41 #endif
42