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