| 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 GrImageContextPriv_DEFINED |
| 9 | #define GrImageContextPriv_DEFINED |
| 10 | |
| 11 | #include "include/private/GrImageContext.h" |
| 12 | |
| 13 | /** Class that exposes methods on GrImageContext that are only intended for use internal to Skia. |
| 14 | This class is purely a privileged window into GrImageContext. It should never have |
| 15 | additional data members or virtual methods. */ |
| 16 | class GrImageContextPriv { |
| 17 | public: |
| 18 | // from GrContext_Base |
| 19 | uint32_t contextID() const { return fContext->contextID(); } |
| 20 | |
| 21 | bool matches(GrContext_Base* candidate) const { return fContext->matches(candidate); } |
| 22 | |
| 23 | const GrContextOptions& options() const { return fContext->options(); } |
| 24 | |
| 25 | const GrCaps* caps() const { return fContext->caps(); } |
| 26 | sk_sp<const GrCaps> refCaps() const; |
| 27 | |
| 28 | GrImageContext* asImageContext() { return fContext->asImageContext(); } |
| 29 | GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); } |
| 30 | GrContext* asDirectContext() { return fContext->asDirectContext(); } |
| 31 | |
| 32 | // from GrImageContext |
| 33 | GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); } |
| 34 | const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); } |
| 35 | |
| 36 | bool abandoned() const { return fContext->abandoned(); } |
| 37 | |
| 38 | /** This is only useful for debug purposes */ |
| 39 | SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } ) |
| 40 | |
| 41 | private: |
| 42 | explicit GrImageContextPriv(GrImageContext* context) : fContext(context) {} |
| 43 | GrImageContextPriv(const GrImageContextPriv&); // unimpl |
| 44 | GrImageContextPriv& operator=(const GrImageContextPriv&); // unimpl |
| 45 | |
| 46 | // No taking addresses of this type. |
| 47 | const GrImageContextPriv* operator&() const; |
| 48 | GrImageContextPriv* operator&(); |
| 49 | |
| 50 | GrImageContext* fContext; |
| 51 | |
| 52 | friend class GrImageContext; // to construct/copy this type. |
| 53 | }; |
| 54 | |
| 55 | inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); } |
| 56 | |
| 57 | inline const GrImageContextPriv GrImageContext::priv () const { |
| 58 | return GrImageContextPriv(const_cast<GrImageContext*>(this)); |
| 59 | } |
| 60 | |
| 61 | #endif |
| 62 |