Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / GrBaseContextPriv.h
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 "include/gpu/GrContextOptions.h"
12 #include "include/private/gpu/ganesh/GrContext_Base.h"
13
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 {
18 public:
19     GrContext_Base* context() { return fContext; }
20     const GrContext_Base* context() const { return fContext; }
21
22     uint32_t contextID() const { return this->context()->contextID(); }
23
24     bool matches(GrContext_Base* candidate) const { return this->context()->matches(candidate); }
25
26     const GrContextOptions& options() const { return this->context()->options(); }
27
28     const GrCaps* caps() const { return this->context()->caps(); }
29     sk_sp<const GrCaps> refCaps() const;
30
31     GrImageContext* asImageContext() { return this->context()->asImageContext(); }
32     GrRecordingContext* asRecordingContext() { return this->context()->asRecordingContext(); }
33     GrDirectContext* asDirectContext() { return this->context()->asDirectContext(); }
34
35     GrContextOptions::ShaderErrorHandler* getShaderErrorHandler() const;
36
37 protected:
38     explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}
39
40     GrContext_Base* fContext;
41
42 private:
43     GrBaseContextPriv& operator=(const GrBaseContextPriv&) = delete;
44
45     // No taking addresses of this type.
46     const GrBaseContextPriv* operator&() const;
47     GrBaseContextPriv* operator&();
48
49     friend class GrContext_Base; // to construct/copy this type.
50 };
51
52 inline GrBaseContextPriv GrContext_Base::priv() { return GrBaseContextPriv(this); }
53
54 inline const GrBaseContextPriv GrContext_Base::priv () const {  // NOLINT(readability-const-return-type)
55     return GrBaseContextPriv(const_cast<GrContext_Base*>(this));
56 }
57
58 #endif