1*c8dee2aaSAndroid Build Coastguard Worker /* 2*c8dee2aaSAndroid Build Coastguard Worker * Copyright 2018 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 GrResourceProviderPriv_DEFINED 9*c8dee2aaSAndroid Build Coastguard Worker #define GrResourceProviderPriv_DEFINED 10*c8dee2aaSAndroid Build Coastguard Worker 11*c8dee2aaSAndroid Build Coastguard Worker #include "src/gpu/ganesh/GrResourceProvider.h" 12*c8dee2aaSAndroid Build Coastguard Worker 13*c8dee2aaSAndroid Build Coastguard Worker /** Class that adds methods to GrResourceProvider that are only intended for use internal to Skia. 14*c8dee2aaSAndroid Build Coastguard Worker This class is purely a privileged window into GrResourceProvider. It should never have 15*c8dee2aaSAndroid Build Coastguard Worker additional data members or virtual methods. */ 16*c8dee2aaSAndroid Build Coastguard Worker class GrResourceProviderPriv { 17*c8dee2aaSAndroid Build Coastguard Worker public: gpu()18*c8dee2aaSAndroid Build Coastguard Worker GrGpu* gpu() { return fResourceProvider->gpu(); } 19*c8dee2aaSAndroid Build Coastguard Worker 20*c8dee2aaSAndroid Build Coastguard Worker private: GrResourceProviderPriv(GrResourceProvider * provider)21*c8dee2aaSAndroid Build Coastguard Worker explicit GrResourceProviderPriv(GrResourceProvider* provider) : fResourceProvider(provider) {} 22*c8dee2aaSAndroid Build Coastguard Worker GrResourceProviderPriv& operator=(const GrResourceProviderPriv&) = delete; 23*c8dee2aaSAndroid Build Coastguard Worker 24*c8dee2aaSAndroid Build Coastguard Worker // No taking addresses of this type. 25*c8dee2aaSAndroid Build Coastguard Worker const GrResourceProviderPriv* operator&() const; 26*c8dee2aaSAndroid Build Coastguard Worker GrResourceProviderPriv* operator&(); 27*c8dee2aaSAndroid Build Coastguard Worker 28*c8dee2aaSAndroid Build Coastguard Worker GrResourceProvider* fResourceProvider; 29*c8dee2aaSAndroid Build Coastguard Worker friend class GrResourceProvider; // to construct/copy this type 30*c8dee2aaSAndroid Build Coastguard Worker }; 31*c8dee2aaSAndroid Build Coastguard Worker priv()32*c8dee2aaSAndroid Build Coastguard Workerinline GrResourceProviderPriv GrResourceProvider::priv() { return GrResourceProviderPriv(this); } 33*c8dee2aaSAndroid Build Coastguard Worker priv()34*c8dee2aaSAndroid Build Coastguard Workerinline const GrResourceProviderPriv GrResourceProvider::priv() const { // NOLINT(readability-const-return-type) 35*c8dee2aaSAndroid Build Coastguard Worker return GrResourceProviderPriv(const_cast<GrResourceProvider*>(this)); 36*c8dee2aaSAndroid Build Coastguard Worker } 37*c8dee2aaSAndroid Build Coastguard Worker 38*c8dee2aaSAndroid Build Coastguard Worker #endif 39