123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- /*
- * 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<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
- GrDrawingManager* drawingManager() { return fContext->drawingManager(); }
- sk_sp<GrOpMemoryPool> 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<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
- GrColorType,
- SkAlphaType,
- sk_sp<SkColorSpace> = nullptr,
- const SkSurfaceProps* = nullptr);
- /** Create a new texture context backed by a deferred-style GrTextureProxy. */
- sk_sp<GrTextureContext> makeDeferredTextureContext(
- SkBackingFit,
- int width,
- int height,
- GrColorType,
- SkAlphaType,
- sk_sp<SkColorSpace>,
- 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<GrRenderTargetContext> makeDeferredRenderTargetContext(
- SkBackingFit fit,
- int width,
- int height,
- GrColorType,
- sk_sp<SkColorSpace> 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<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- SkBackingFit fit,
- int width,
- int height,
- GrColorType,
- sk_sp<SkColorSpace> 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<GrRecordingContext*>(this));
- }
- #endif
|