2019-01-30 18:08:28 +00:00
|
|
|
/*
|
|
|
|
* 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 GrRecordingContext_DEFINED
|
|
|
|
#define GrRecordingContext_DEFINED
|
|
|
|
|
2019-02-08 15:29:20 +00:00
|
|
|
#include "GrAuditTrail.h"
|
2019-01-30 18:08:28 +00:00
|
|
|
#include "GrImageContext.h"
|
2019-02-22 16:16:30 +00:00
|
|
|
#include "SkRefCnt.h"
|
2019-01-30 18:08:28 +00:00
|
|
|
|
2019-02-12 20:24:12 +00:00
|
|
|
class GrDrawingManager;
|
2019-02-15 17:52:59 +00:00
|
|
|
class GrOnFlushCallbackObject;
|
2019-02-08 15:29:20 +00:00
|
|
|
class GrOpMemoryPool;
|
2019-01-30 18:08:28 +00:00
|
|
|
class GrRecordingContextPriv;
|
2019-02-21 21:11:41 +00:00
|
|
|
class GrStrikeCache;
|
|
|
|
class GrTextBlobCache;
|
2019-01-30 18:08:28 +00:00
|
|
|
|
|
|
|
class SK_API GrRecordingContext : public GrImageContext {
|
|
|
|
public:
|
|
|
|
~GrRecordingContext() override;
|
|
|
|
|
|
|
|
// Provides access to functions that aren't part of the public API.
|
|
|
|
GrRecordingContextPriv priv();
|
|
|
|
const GrRecordingContextPriv priv() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class GrRecordingContextPriv; // for hidden functions
|
|
|
|
|
2019-02-07 15:44:10 +00:00
|
|
|
GrRecordingContext(GrBackendApi, const GrContextOptions&, uint32_t contextID);
|
2019-02-14 19:49:02 +00:00
|
|
|
bool init(sk_sp<const GrCaps>, sk_sp<GrSkSLFPFactoryCache>) override;
|
2019-03-12 16:28:59 +00:00
|
|
|
void setupDrawingManager(bool explicitlyAllocate, bool sortOpLists);
|
2019-01-30 18:08:28 +00:00
|
|
|
|
2019-02-11 19:12:03 +00:00
|
|
|
void abandonContext() override;
|
|
|
|
|
2019-02-22 16:16:30 +00:00
|
|
|
GrDrawingManager* drawingManager();
|
2019-02-12 20:24:12 +00:00
|
|
|
|
2019-02-08 15:29:20 +00:00
|
|
|
sk_sp<GrOpMemoryPool> refOpMemoryPool();
|
|
|
|
GrOpMemoryPool* opMemoryPool();
|
|
|
|
|
2019-03-04 22:10:01 +00:00
|
|
|
GrStrikeCache* getGrStrikeCache() { return fStrikeCache.get(); }
|
2019-02-21 21:11:41 +00:00
|
|
|
GrTextBlobCache* getTextBlobCache();
|
|
|
|
const GrTextBlobCache* getTextBlobCache() const;
|
|
|
|
|
2019-02-15 17:52:59 +00:00
|
|
|
/**
|
|
|
|
* 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*);
|
|
|
|
|
2019-02-14 19:49:02 +00:00
|
|
|
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);
|
|
|
|
|
2019-02-12 20:24:12 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
2019-02-13 16:02:28 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
|
2019-02-08 15:29:20 +00:00
|
|
|
GrAuditTrail* auditTrail() { return &fAuditTrail; }
|
|
|
|
|
2019-01-30 18:08:28 +00:00
|
|
|
GrRecordingContext* asRecordingContext() override { return this; }
|
|
|
|
|
|
|
|
private:
|
2019-02-22 16:16:30 +00:00
|
|
|
std::unique_ptr<GrDrawingManager> fDrawingManager;
|
2019-02-08 15:29:20 +00:00
|
|
|
// All the GrOp-derived classes use this pool.
|
2019-02-21 21:11:41 +00:00
|
|
|
sk_sp<GrOpMemoryPool> fOpMemoryPool;
|
|
|
|
|
2019-03-04 22:10:01 +00:00
|
|
|
std::unique_ptr<GrStrikeCache> fStrikeCache;
|
2019-02-21 21:11:41 +00:00
|
|
|
std::unique_ptr<GrTextBlobCache> fTextBlobCache;
|
|
|
|
|
|
|
|
GrAuditTrail fAuditTrail;
|
2019-02-08 15:29:20 +00:00
|
|
|
|
2019-01-30 18:08:28 +00:00
|
|
|
typedef GrImageContext INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|