Home | History | Annotate | Download | only in gpu
      1 /*
      2  * Copyright 2018 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 GrContextThreadSafeProxyPriv_DEFINED
      9 #define GrContextThreadSafeProxyPriv_DEFINED
     10 
     11 #include "GrContextThreadSafeProxy.h"
     12 
     13 /**
     14  * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to
     15  * Skia. This class is purely a privileged window into GrContextThreadSafeProxy. It should never
     16  * have additional data members or virtual methods.
     17  */
     18 class GrContextThreadSafeProxyPriv {
     19 public:
     20     const GrContextOptions& contextOptions() { return fProxy->fOptions; }
     21 
     22     const GrCaps* caps() const { return fProxy->fCaps.get(); }
     23     sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
     24     uint32_t contextID() const { return fProxy->fContextID; }
     25     GrBackendApi backend() const { return fProxy->fBackend; }
     26     sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const;
     27 
     28 private:
     29     explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
     30     GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete;
     31     GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete;
     32 
     33     // No taking addresses of this type.
     34     const GrContextThreadSafeProxyPriv* operator&() const = delete;
     35     GrContextThreadSafeProxyPriv* operator&() = delete;
     36 
     37     GrContextThreadSafeProxy* fProxy;
     38 
     39     friend class GrContextThreadSafeProxy;  // to construct/copy this type.
     40 };
     41 
     42 inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() {
     43     return GrContextThreadSafeProxyPriv(this);
     44 }
     45 
     46 inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const {
     47     return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this));
     48 }
     49 
     50 #endif
     51