/* * 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 "include/private/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(); } const GrCaps* caps() const { return fContext->caps(); } sk_sp refCaps() const; sk_sp 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 GrDrawingManager* drawingManager() { return fContext->drawingManager(); } sk_sp refOpMemoryPool(); GrOpMemoryPool* opMemoryPool() { return fContext->opMemoryPool(); } GrStrikeCache* getGrStrikeCache() { return fContext->getGrStrikeCache(); } 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 makeWrappedSurfaceContext(sk_sp, GrColorType, SkAlphaType, sk_sp = nullptr, const SkSurfaceProps* = nullptr); /** Create a new texture context backed by a deferred-style GrTextureProxy. */ sk_sp makeDeferredTextureContext( SkBackingFit, int width, int height, GrColorType, SkAlphaType, sk_sp, GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin = kTopLeft_GrSurfaceOrigin, SkBudgeted = SkBudgeted::kYes, GrProtected = GrProtected::kNo); /* * 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 makeDeferredRenderTargetContext( SkBackingFit fit, int width, int height, GrColorType, sk_sp colorSpace, int sampleCnt = 1, GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, const SkSurfaceProps* surfaceProps = nullptr, SkBudgeted = SkBudgeted::kYes, GrProtected isProtected = GrProtected::kNo); /* * 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 makeDeferredRenderTargetContextWithFallback( SkBackingFit fit, int width, int height, GrColorType, sk_sp colorSpace, int sampleCnt = 1, GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, const SkSurfaceProps* surfaceProps = nullptr, SkBudgeted budgeted = SkBudgeted::kYes, GrProtected isProtected = GrProtected::kNo); 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(this)); } #endif