robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 GrContextPriv_DEFINED |
| 9 | #define GrContextPriv_DEFINED |
| 10 | |
| 11 | #include "GrContext.h" |
| 12 | |
| 13 | /** Class that adds methods to GrContext that are only intended for use internal to Skia. |
| 14 | This class is purely a privileged window into GrContext. It should never have additional |
| 15 | data members or virtual methods. */ |
| 16 | class GrContextPriv { |
| 17 | public: |
csmartdalton | bde96c6 | 2016-08-31 12:54:46 -0700 | [diff] [blame] | 18 | GrDrawingManager* drawingManager() { return fContext->fDrawingManager; } |
| 19 | |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 20 | // Create a drawContext that wraps an existing renderTarget |
| 21 | sk_sp<GrDrawContext> makeWrappedDrawContext(sk_sp<GrRenderTarget> rt, |
| 22 | sk_sp<SkColorSpace> colorSpace, |
| 23 | const SkSurfaceProps* = nullptr); |
| 24 | |
| 25 | sk_sp<GrDrawContext> makeBackendTextureDrawContext(const GrBackendTextureDesc& desc, |
| 26 | sk_sp<SkColorSpace> colorSpace, |
| 27 | const SkSurfaceProps* = nullptr, |
| 28 | GrWrapOwnership = kBorrow_GrWrapOwnership); |
| 29 | |
| 30 | sk_sp<GrDrawContext> makeBackendRenderTargetDrawContext(const GrBackendRenderTargetDesc& desc, |
| 31 | sk_sp<SkColorSpace> colorSpace, |
| 32 | const SkSurfaceProps* = nullptr); |
| 33 | |
| 34 | sk_sp<GrDrawContext> makeBackendTextureAsRenderTargetDrawContext( |
| 35 | const GrBackendTextureDesc& desc, |
| 36 | sk_sp<SkColorSpace> colorSpace, |
| 37 | const SkSurfaceProps* = nullptr); |
| 38 | |
| 39 | private: |
| 40 | explicit GrContextPriv(GrContext* context) : fContext(context) {} |
| 41 | GrContextPriv(const GrContextPriv&) {} // unimpl |
| 42 | GrContextPriv& operator=(const GrContextPriv&); // unimpl |
| 43 | |
| 44 | // No taking addresses of this type. |
| 45 | const GrContextPriv* operator&() const; |
| 46 | GrContextPriv* operator&(); |
| 47 | |
| 48 | GrContext* fContext; |
| 49 | |
| 50 | friend class GrContext; // to construct/copy this type. |
| 51 | }; |
| 52 | |
| 53 | inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); } |
| 54 | |
| 55 | inline const GrContextPriv GrContext::contextPriv () const { |
| 56 | return GrContextPriv(const_cast<GrContext*>(this)); |
| 57 | } |
| 58 | |
| 59 | #endif |