| 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 GrImageContext_DEFINED | 
| 9 | #define GrImageContext_DEFINED | 
| 10 | |
| 11 | #include "include/private/GrContext_Base.h" | 
| 12 | #include "include/private/GrSingleOwner.h" | 
| 13 | |
| 14 | class GrImageContextPriv; | 
| 15 | class GrProxyProvider; | 
| 16 | |
| 17 | class GrImageContext : public GrContext_Base { | 
| 18 | public: | 
| 19 | ~GrImageContext() override; | 
| 20 | |
| 21 | SK_API GrBackendFormat defaultBackendFormat(SkColorType ct, GrRenderable renderable) const { | 
| 22 | return INHERITED::defaultBackendFormat(ct, renderable); | 
| 23 | } | 
| 24 | |
| 25 | // Provides access to functions that aren't part of the public API. | 
| 26 | GrImageContextPriv priv(); | 
| 27 | const GrImageContextPriv priv() const; | 
| 28 | |
| 29 | protected: | 
| 30 | friend class GrImageContextPriv; // for hidden functions | 
| 31 | |
| 32 | GrImageContext(GrBackendApi, const GrContextOptions&, uint32_t contextID); | 
| 33 | |
| 34 | SK_API virtual void abandonContext(); | 
| 35 | SK_API virtual bool abandoned(); | 
| 36 | |
| 37 | GrProxyProvider* proxyProvider() { return fProxyProvider.get(); } | 
| 38 | const GrProxyProvider* proxyProvider() const { return fProxyProvider.get(); } | 
| 39 | |
| 40 | /** This is only useful for debug purposes */ | 
| 41 | GrSingleOwner* singleOwner() const { return &fSingleOwner; } | 
| 42 | |
| 43 | GrImageContext* asImageContext() override { return this; } | 
| 44 | |
| 45 | private: | 
| 46 | std::unique_ptr<GrProxyProvider> fProxyProvider; | 
| 47 | bool fAbandoned = false; | 
| 48 | |
| 49 | // In debug builds we guard against improper thread handling | 
| 50 | // This guard is passed to the GrDrawingManager and, from there to all the | 
| 51 | // GrRenderTargetContexts. It is also passed to the GrResourceProvider and SkGpuDevice. | 
| 52 | mutable GrSingleOwner fSingleOwner; | 
| 53 | |
| 54 | typedef GrContext_Base INHERITED; | 
| 55 | }; | 
| 56 | |
| 57 | #endif | 
| 58 | 
