2 * Copyright 2019 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrBaseContextPriv_DEFINED
9 #define GrBaseContextPriv_DEFINED
11 #include "include/gpu/GrContextOptions.h"
12 #include "include/private/gpu/ganesh/GrContext_Base.h"
14 /** Class that exposes methods on GrContext_Base that are only intended for use internal to Skia.
15 This class is purely a privileged window into GrContext_Base. It should never have
16 additional data members or virtual methods. */
17 class GrBaseContextPriv {
19 GrContext_Base* context() { return fContext; }
20 const GrContext_Base* context() const { return fContext; }
22 uint32_t contextID() const { return this->context()->contextID(); }
24 bool matches(GrContext_Base* candidate) const { return this->context()->matches(candidate); }
26 const GrContextOptions& options() const { return this->context()->options(); }
28 const GrCaps* caps() const { return this->context()->caps(); }
29 sk_sp<const GrCaps> refCaps() const;
31 GrImageContext* asImageContext() { return this->context()->asImageContext(); }
32 GrRecordingContext* asRecordingContext() { return this->context()->asRecordingContext(); }
33 GrDirectContext* asDirectContext() { return this->context()->asDirectContext(); }
35 GrContextOptions::ShaderErrorHandler* getShaderErrorHandler() const;
38 explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}
40 GrContext_Base* fContext;
43 GrBaseContextPriv& operator=(const GrBaseContextPriv&) = delete;
45 // No taking addresses of this type.
46 const GrBaseContextPriv* operator&() const;
47 GrBaseContextPriv* operator&();
49 friend class GrContext_Base; // to construct/copy this type.
52 inline GrBaseContextPriv GrContext_Base::priv() { return GrBaseContextPriv(this); }
54 inline const GrBaseContextPriv GrContext_Base::priv () const { // NOLINT(readability-const-return-type)
55 return GrBaseContextPriv(const_cast<GrContext_Base*>(this));