Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/private/GrImageContext.h" |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 12 | |
Adlai Holler | dced31f | 2021-02-19 12:33:46 -0500 | [diff] [blame^] | 13 | #include "include/gpu/GrContextThreadSafeProxy.h" |
| 14 | |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 15 | /** Class that exposes methods on GrImageContext that are only intended for use internal to Skia. |
| 16 | This class is purely a privileged window into GrImageContext. It should never have |
| 17 | additional data members or virtual methods. */ |
| 18 | class GrImageContextPriv { |
| 19 | public: |
| 20 | // from GrContext_Base |
Robert Phillips | fd0d970 | 2019-02-01 10:19:42 -0500 | [diff] [blame] | 21 | uint32_t contextID() const { return fContext->contextID(); } |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 22 | |
Robert Phillips | fe0963c | 2019-02-07 13:25:07 -0500 | [diff] [blame] | 23 | bool matches(GrContext_Base* candidate) const { return fContext->matches(candidate); } |
| 24 | |
Robert Phillips | c1541ae | 2019-02-04 12:05:37 -0500 | [diff] [blame] | 25 | const GrContextOptions& options() const { return fContext->options(); } |
| 26 | |
Robert Phillips | bb60677 | 2019-02-04 17:50:57 -0500 | [diff] [blame] | 27 | const GrCaps* caps() const { return fContext->caps(); } |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 28 | sk_sp<const GrCaps> refCaps() const; |
Robert Phillips | bb60677 | 2019-02-04 17:50:57 -0500 | [diff] [blame] | 29 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 30 | GrImageContext* asImageContext() { return fContext->asImageContext(); } |
| 31 | GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); } |
Robert Phillips | bb60677 | 2019-02-04 17:50:57 -0500 | [diff] [blame] | 32 | |
Robert Phillips | a9162df | 2019-02-11 14:12:03 -0500 | [diff] [blame] | 33 | bool abandoned() const { return fContext->abandoned(); } |
| 34 | |
Adlai Holler | dced31f | 2021-02-19 12:33:46 -0500 | [diff] [blame^] | 35 | static sk_sp<GrImageContext> MakeForPromiseImage(sk_sp<GrContextThreadSafeProxy> tsp) { |
| 36 | return GrImageContext::MakeForPromiseImage(std::move(tsp)); |
| 37 | } |
| 38 | |
Robert Phillips | a41c685 | 2019-02-07 10:44:10 -0500 | [diff] [blame] | 39 | /** This is only useful for debug purposes */ |
| 40 | SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } ) |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | explicit GrImageContextPriv(GrImageContext* context) : fContext(context) {} |
John Stiles | b35c3b8 | 2020-08-06 19:58:52 -0400 | [diff] [blame] | 44 | GrImageContextPriv(const GrImageContextPriv&) = delete; |
| 45 | GrImageContextPriv& operator=(const GrImageContextPriv&) = delete; |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 46 | |
| 47 | // No taking addresses of this type. |
| 48 | const GrImageContextPriv* operator&() const; |
| 49 | GrImageContextPriv* operator&(); |
| 50 | |
| 51 | GrImageContext* fContext; |
| 52 | |
| 53 | friend class GrImageContext; // to construct/copy this type. |
| 54 | }; |
| 55 | |
| 56 | inline GrImageContextPriv GrImageContext::priv() { return GrImageContextPriv(this); } |
| 57 | |
John Stiles | ec9b4aa | 2020-08-07 13:05:14 -0400 | [diff] [blame] | 58 | inline const GrImageContextPriv GrImageContext::priv () const { // NOLINT(readability-const-return-type) |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 59 | return GrImageContextPriv(const_cast<GrImageContext*>(this)); |
| 60 | } |
| 61 | |
| 62 | #endif |