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" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 12 | #include "GrSurfaceContext.h" |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 13 | |
| 14 | /** Class that adds methods to GrContext that are only intended for use internal to Skia. |
| 15 | This class is purely a privileged window into GrContext. It should never have additional |
| 16 | data members or virtual methods. */ |
| 17 | class GrContextPriv { |
| 18 | public: |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 19 | GrDrawingManager* drawingManager() { return fContext->fDrawingManager.get(); } |
csmartdalton | bde96c6 | 2016-08-31 12:54:46 -0700 | [diff] [blame] | 20 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 21 | // Create a renderTargetContext that wraps an existing renderTarget |
| 22 | sk_sp<GrRenderTargetContext> makeWrappedRenderTargetContext(sk_sp<GrRenderTarget> rt, |
| 23 | sk_sp<SkColorSpace> colorSpace, |
| 24 | const SkSurfaceProps* = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 25 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 26 | // Create a surfaceContext that wraps an existing texture or renderTarget |
| 27 | sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurface> tex); |
| 28 | |
Robert Phillips | 31c2608 | 2016-12-14 15:12:15 -0500 | [diff] [blame^] | 29 | sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy); |
| 30 | |
Robert Phillips | e305cc1f | 2016-12-14 12:19:05 -0500 | [diff] [blame] | 31 | sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc, |
| 32 | SkBackingFit dstFit, |
| 33 | SkBudgeted isDstBudgeted); |
| 34 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 35 | sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext( |
| 36 | const GrBackendTextureDesc& desc, |
| 37 | sk_sp<SkColorSpace> colorSpace, |
| 38 | const SkSurfaceProps* = nullptr, |
| 39 | GrWrapOwnership = kBorrow_GrWrapOwnership); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 40 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 41 | sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext( |
| 42 | const GrBackendRenderTargetDesc& desc, |
| 43 | sk_sp<SkColorSpace> colorSpace, |
| 44 | const SkSurfaceProps* = nullptr); |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 45 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 46 | sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext( |
robertphillips | 4fd74ae | 2016-08-03 14:26:53 -0700 | [diff] [blame] | 47 | const GrBackendTextureDesc& desc, |
| 48 | sk_sp<SkColorSpace> colorSpace, |
| 49 | const SkSurfaceProps* = nullptr); |
| 50 | |
| 51 | private: |
| 52 | explicit GrContextPriv(GrContext* context) : fContext(context) {} |
| 53 | GrContextPriv(const GrContextPriv&) {} // unimpl |
| 54 | GrContextPriv& operator=(const GrContextPriv&); // unimpl |
| 55 | |
| 56 | // No taking addresses of this type. |
| 57 | const GrContextPriv* operator&() const; |
| 58 | GrContextPriv* operator&(); |
| 59 | |
| 60 | GrContext* fContext; |
| 61 | |
| 62 | friend class GrContext; // to construct/copy this type. |
| 63 | }; |
| 64 | |
| 65 | inline GrContextPriv GrContext::contextPriv() { return GrContextPriv(this); } |
| 66 | |
| 67 | inline const GrContextPriv GrContext::contextPriv () const { |
| 68 | return GrContextPriv(const_cast<GrContext*>(this)); |
| 69 | } |
| 70 | |
| 71 | #endif |