| /* |
| * Copyright 2019 Google Inc. |
| * |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| */ |
| |
| #ifndef GrRecordingContextPriv_DEFINED |
| #define GrRecordingContextPriv_DEFINED |
| |
| #include "GrRecordingContext.h" |
| |
| /** Class that exposes methods to GrRecordingContext that are only intended for use internal to |
| Skia. This class is purely a privileged window into GrRecordingContext. It should never have |
| additional data members or virtual methods. */ |
| class GrRecordingContextPriv { |
| public: |
| // from GrContext_Base |
| uint32_t contextID() const { return fContext->contextID(); } |
| |
| bool matches(GrContext_Base* candidate) const { return fContext->matches(candidate); } |
| |
| const GrContextOptions& options() const { return fContext->options(); } |
| |
| bool explicitlyAllocateGPUResources() const { |
| return fContext->explicitlyAllocateGPUResources(); |
| } |
| |
| const GrCaps* caps() const { return fContext->caps(); } |
| sk_sp<const GrCaps> refCaps() const; |
| |
| sk_sp<GrSkSLFPFactoryCache> fpFactoryCache(); |
| |
| GrImageContext* asImageContext() { return fContext->asImageContext(); } |
| GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); } |
| GrContext* asDirectContext() { return fContext->asDirectContext(); } |
| |
| // from GrImageContext |
| GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); } |
| const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); } |
| |
| bool abandoned() const { return fContext->abandoned(); } |
| |
| /** This is only useful for debug purposes */ |
| SkDEBUGCODE(GrSingleOwner* singleOwner() const { return fContext->singleOwner(); } ) |
| |
| // from GrRecordingContext |
| |
| // CONTEXT TODO: move GrDrawingManager to GrRecordingContext for real |
| GrDrawingManager* drawingManager() { return fContext->drawingManager(); } |
| |
| sk_sp<GrOpMemoryPool> refOpMemoryPool(); |
| GrOpMemoryPool* opMemoryPool() { return fContext->opMemoryPool(); } |
| |
| GrStrikeCache* getGlyphCache() { return fContext->getGlyphCache(); } |
| GrTextBlobCache* getTextBlobCache() { return fContext->getTextBlobCache(); } |
| |
| /** |
| * Registers an object for flush-related callbacks. (See GrOnFlushCallbackObject.) |
| * |
| * NOTE: the drawing manager tracks this object as a raw pointer; it is up to the caller to |
| * ensure its lifetime is tied to that of the context. |
| */ |
| void addOnFlushCallbackObject(GrOnFlushCallbackObject*); |
| |
| sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>, |
| sk_sp<SkColorSpace> = nullptr, |
| const SkSurfaceProps* = nullptr); |
| |
| sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrBackendFormat&, |
| const GrSurfaceDesc&, |
| GrSurfaceOrigin, |
| GrMipMapped, |
| SkBackingFit, |
| SkBudgeted, |
| sk_sp<SkColorSpace> colorSpace = nullptr, |
| const SkSurfaceProps* = nullptr); |
| |
| /* |
| * Create a new render target context backed by a deferred-style |
| * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for |
| * renderTargetContexts created via this entry point. |
| */ |
| sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext( |
| const GrBackendFormat& format, |
| SkBackingFit fit, |
| int width, int height, |
| GrPixelConfig config, |
| sk_sp<SkColorSpace> colorSpace, |
| int sampleCnt = 1, |
| GrMipMapped = GrMipMapped::kNo, |
| GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| const SkSurfaceProps* surfaceProps = nullptr, |
| SkBudgeted = SkBudgeted::kYes); |
| |
| /* |
| * This method will attempt to create a renderTargetContext that has, at least, the number of |
| * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be |
| * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA). |
| * SRGB-ness will be preserved. |
| */ |
| sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback( |
| const GrBackendFormat& format, |
| SkBackingFit fit, |
| int width, int height, |
| GrPixelConfig config, |
| sk_sp<SkColorSpace> colorSpace, |
| int sampleCnt = 1, |
| GrMipMapped = GrMipMapped::kNo, |
| GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, |
| const SkSurfaceProps* surfaceProps = nullptr, |
| SkBudgeted budgeted = SkBudgeted::kYes); |
| |
| GrAuditTrail* auditTrail() { return fContext->auditTrail(); } |
| |
| // CONTEXT TODO: remove this backdoor |
| // In order to make progress we temporarily need a way to break CL impasses. |
| GrContext* backdoor(); |
| |
| private: |
| explicit GrRecordingContextPriv(GrRecordingContext* context) : fContext(context) {} |
| GrRecordingContextPriv(const GrRecordingContextPriv&); // unimpl |
| GrRecordingContextPriv& operator=(const GrRecordingContextPriv&); // unimpl |
| |
| // No taking addresses of this type. |
| const GrRecordingContextPriv* operator&() const; |
| GrRecordingContextPriv* operator&(); |
| |
| GrRecordingContext* fContext; |
| |
| friend class GrRecordingContext; // to construct/copy this type. |
| }; |
| |
| inline GrRecordingContextPriv GrRecordingContext::priv() { return GrRecordingContextPriv(this); } |
| |
| inline const GrRecordingContextPriv GrRecordingContext::priv () const { |
| return GrRecordingContextPriv(const_cast<GrRecordingContext*>(this)); |
| } |
| |
| #endif |