1*c8dee2aaSAndroid Build Coastguard Worker /* 2*c8dee2aaSAndroid Build Coastguard Worker * Copyright 2019 Google Inc. 3*c8dee2aaSAndroid Build Coastguard Worker * 4*c8dee2aaSAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license that can be 5*c8dee2aaSAndroid Build Coastguard Worker * found in the LICENSE file. 6*c8dee2aaSAndroid Build Coastguard Worker */ 7*c8dee2aaSAndroid Build Coastguard Worker 8*c8dee2aaSAndroid Build Coastguard Worker #ifndef GrBaseContextPriv_DEFINED 9*c8dee2aaSAndroid Build Coastguard Worker #define GrBaseContextPriv_DEFINED 10*c8dee2aaSAndroid Build Coastguard Worker 11*c8dee2aaSAndroid Build Coastguard Worker #include "include/core/SkRefCnt.h" 12*c8dee2aaSAndroid Build Coastguard Worker #include "include/gpu/ganesh/GrContextOptions.h" 13*c8dee2aaSAndroid Build Coastguard Worker #include "include/private/gpu/ganesh/GrContext_Base.h" 14*c8dee2aaSAndroid Build Coastguard Worker 15*c8dee2aaSAndroid Build Coastguard Worker #include <cstdint> 16*c8dee2aaSAndroid Build Coastguard Worker 17*c8dee2aaSAndroid Build Coastguard Worker class GrCaps; 18*c8dee2aaSAndroid Build Coastguard Worker class GrDirectContext; 19*c8dee2aaSAndroid Build Coastguard Worker class GrImageContext; 20*c8dee2aaSAndroid Build Coastguard Worker class GrRecordingContext; 21*c8dee2aaSAndroid Build Coastguard Worker 22*c8dee2aaSAndroid Build Coastguard Worker /** Class that exposes methods on GrContext_Base that are only intended for use internal to Skia. 23*c8dee2aaSAndroid Build Coastguard Worker This class is purely a privileged window into GrContext_Base. It should never have 24*c8dee2aaSAndroid Build Coastguard Worker additional data members or virtual methods. */ 25*c8dee2aaSAndroid Build Coastguard Worker class GrBaseContextPriv { 26*c8dee2aaSAndroid Build Coastguard Worker public: context()27*c8dee2aaSAndroid Build Coastguard Worker GrContext_Base* context() { return fContext; } context()28*c8dee2aaSAndroid Build Coastguard Worker const GrContext_Base* context() const { return fContext; } 29*c8dee2aaSAndroid Build Coastguard Worker contextID()30*c8dee2aaSAndroid Build Coastguard Worker uint32_t contextID() const { return this->context()->contextID(); } 31*c8dee2aaSAndroid Build Coastguard Worker matches(GrContext_Base * candidate)32*c8dee2aaSAndroid Build Coastguard Worker bool matches(GrContext_Base* candidate) const { return this->context()->matches(candidate); } 33*c8dee2aaSAndroid Build Coastguard Worker options()34*c8dee2aaSAndroid Build Coastguard Worker const GrContextOptions& options() const { return this->context()->options(); } 35*c8dee2aaSAndroid Build Coastguard Worker caps()36*c8dee2aaSAndroid Build Coastguard Worker const GrCaps* caps() const { return this->context()->caps(); } 37*c8dee2aaSAndroid Build Coastguard Worker sk_sp<const GrCaps> refCaps() const; 38*c8dee2aaSAndroid Build Coastguard Worker asImageContext()39*c8dee2aaSAndroid Build Coastguard Worker GrImageContext* asImageContext() { return this->context()->asImageContext(); } asRecordingContext()40*c8dee2aaSAndroid Build Coastguard Worker GrRecordingContext* asRecordingContext() { return this->context()->asRecordingContext(); } asDirectContext()41*c8dee2aaSAndroid Build Coastguard Worker GrDirectContext* asDirectContext() { return this->context()->asDirectContext(); } 42*c8dee2aaSAndroid Build Coastguard Worker 43*c8dee2aaSAndroid Build Coastguard Worker GrContextOptions::ShaderErrorHandler* getShaderErrorHandler() const; 44*c8dee2aaSAndroid Build Coastguard Worker 45*c8dee2aaSAndroid Build Coastguard Worker protected: GrBaseContextPriv(GrContext_Base * context)46*c8dee2aaSAndroid Build Coastguard Worker explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {} 47*c8dee2aaSAndroid Build Coastguard Worker 48*c8dee2aaSAndroid Build Coastguard Worker GrContext_Base* fContext; 49*c8dee2aaSAndroid Build Coastguard Worker 50*c8dee2aaSAndroid Build Coastguard Worker private: 51*c8dee2aaSAndroid Build Coastguard Worker GrBaseContextPriv& operator=(const GrBaseContextPriv&) = delete; 52*c8dee2aaSAndroid Build Coastguard Worker 53*c8dee2aaSAndroid Build Coastguard Worker // No taking addresses of this type. 54*c8dee2aaSAndroid Build Coastguard Worker const GrBaseContextPriv* operator&() const; 55*c8dee2aaSAndroid Build Coastguard Worker GrBaseContextPriv* operator&(); 56*c8dee2aaSAndroid Build Coastguard Worker 57*c8dee2aaSAndroid Build Coastguard Worker friend class GrContext_Base; // to construct/copy this type. 58*c8dee2aaSAndroid Build Coastguard Worker }; 59*c8dee2aaSAndroid Build Coastguard Worker priv()60*c8dee2aaSAndroid Build Coastguard Workerinline GrBaseContextPriv GrContext_Base::priv() { return GrBaseContextPriv(this); } 61*c8dee2aaSAndroid Build Coastguard Worker priv()62*c8dee2aaSAndroid Build Coastguard Workerinline const GrBaseContextPriv GrContext_Base::priv () const { // NOLINT(readability-const-return-type) 63*c8dee2aaSAndroid Build Coastguard Worker return GrBaseContextPriv(const_cast<GrContext_Base*>(this)); 64*c8dee2aaSAndroid Build Coastguard Worker } 65*c8dee2aaSAndroid Build Coastguard Worker 66*c8dee2aaSAndroid Build Coastguard Worker #endif 67