Move GrContextOptions to GrContext_Base and make GrContextThreadSafeProxy be derived from GrContext_Base

The main thrust of this CL is to bring the GrContextThreadSafeProxy into the fold.

Change-Id: I8f457d5b75c69f89beac3a0035b1c05ba5d3b931
Reviewed-on: https://skia-review.googlesource.com/c/188622
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-02-04 12:05:37 -05:00 committed by Skia Commit-Bot
parent 69da42f188
commit c1541ae25f
24 changed files with 97 additions and 84 deletions

View File

@ -280,10 +280,10 @@ public:
void storeVkPipelineCacheData(); void storeVkPipelineCacheData();
protected: protected:
GrContext(GrBackendApi, int32_t id = SK_InvalidGenID); GrContext(GrBackendApi, const GrContextOptions& options, int32_t id = SK_InvalidGenID);
bool initCommon(const GrContextOptions&); bool initCommon();
virtual bool init(const GrContextOptions&) = 0; // must be called after the ctor! virtual bool init() = 0; // must be called after the ctor!
virtual GrAtlasManager* onGetAtlasManager() = 0; virtual GrAtlasManager* onGetAtlasManager() = 0;
@ -308,8 +308,6 @@ private:
GrStrikeCache* fGlyphCache; GrStrikeCache* fGlyphCache;
std::unique_ptr<GrTextBlobCache> fTextBlobCache; std::unique_ptr<GrTextBlobCache> fTextBlobCache;
bool fDisableGpuYUVConversion;
bool fSharpenMipmappedTextures;
bool fDidTestPMConversions; bool fDidTestPMConversions;
// true if the PM/UPM conversion succeeded; false otherwise // true if the PM/UPM conversion succeeded; false otherwise
bool fPMUPMConversionsRoundTrip; bool fPMUPMConversionsRoundTrip;

View File

@ -10,6 +10,7 @@
#include "GrContextOptions.h" #include "GrContextOptions.h"
#include "SkRefCnt.h" #include "SkRefCnt.h"
#include "../private/GrContext_Base.h"
class GrBackendFormat; class GrBackendFormat;
class GrCaps; class GrCaps;
@ -24,7 +25,7 @@ class SkSurfaceCharacterization;
* Can be used to perform actions related to the generating GrContext in a thread safe manner. The * Can be used to perform actions related to the generating GrContext in a thread safe manner. The
* proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrContext. * proxy does not access the 3D API (e.g. OpenGL) that backs the generating GrContext.
*/ */
class SK_API GrContextThreadSafeProxy : public SkRefCnt { class SK_API GrContextThreadSafeProxy : public GrContext_Base {
public: public:
~GrContextThreadSafeProxy() override; ~GrContextThreadSafeProxy() override;
@ -72,7 +73,7 @@ public:
bool operator==(const GrContextThreadSafeProxy& that) const { bool operator==(const GrContextThreadSafeProxy& that) const {
// Each GrContext should only ever have a single thread-safe proxy. // Each GrContext should only ever have a single thread-safe proxy.
SkASSERT((this == &that) == (fContextID == that.fContextID)); SkASSERT((this == &that) == (this->contextID() == that.contextID()));
return this == &that; return this == &that;
} }
@ -91,15 +92,12 @@ private:
sk_sp<GrSkSLFPFactoryCache> cache); sk_sp<GrSkSLFPFactoryCache> cache);
sk_sp<const GrCaps> fCaps; sk_sp<const GrCaps> fCaps;
const uint32_t fContextID;
const GrBackendApi fBackend;
const GrContextOptions fOptions;
sk_sp<GrSkSLFPFactoryCache> fFPFactoryCache; sk_sp<GrSkSLFPFactoryCache> fFPFactoryCache;
friend class GrDirectContext; // To construct this object friend class GrDirectContext; // To construct this object
friend class GrContextThreadSafeProxyPriv; friend class GrContextThreadSafeProxyPriv;
typedef SkRefCnt INHERITED; typedef GrContext_Base INHERITED;
}; };
#endif #endif

View File

@ -9,6 +9,7 @@
#define GrContext_Base_DEFINED #define GrContext_Base_DEFINED
#include "SkRefCnt.h" #include "SkRefCnt.h"
#include "GrContextOptions.h"
#include "GrTypes.h" #include "GrTypes.h"
class GrBaseContextPriv; class GrBaseContextPriv;
@ -32,7 +33,7 @@ public:
protected: protected:
friend class GrBaseContextPriv; // for hidden functions friend class GrBaseContextPriv; // for hidden functions
GrContext_Base(GrBackendApi backend, uint32_t uniqueID); GrContext_Base(GrBackendApi backend, const GrContextOptions& options, uint32_t uniqueID);
/** /**
* An identifier for this context. The id is used by all compatible contexts. For example, * An identifier for this context. The id is used by all compatible contexts. For example,
@ -43,14 +44,20 @@ protected:
*/ */
uint32_t contextID() const { return fContextID; } uint32_t contextID() const { return fContextID; }
/*
* The options in effect for this context
*/
const GrContextOptions& options() const { return fOptions; }
GrContext_Base* asBaseContext() { return this; } GrContext_Base* asBaseContext() { return this; }
virtual GrImageContext* asImageContext() { return nullptr; } virtual GrImageContext* asImageContext() { return nullptr; }
virtual GrRecordingContext* asRecordingContext() { return nullptr; } virtual GrRecordingContext* asRecordingContext() { return nullptr; }
virtual GrContext* asDirectContext() { return nullptr; } virtual GrContext* asDirectContext() { return nullptr; }
private: private:
const GrBackendApi fBackend; const GrBackendApi fBackend;
const uint32_t fContextID; const GrContextOptions fOptions;
const uint32_t fContextID;
typedef SkRefCnt INHERITED; typedef SkRefCnt INHERITED;
}; };

View File

@ -23,7 +23,7 @@ public:
protected: protected:
friend class GrImageContextPriv; // for hidden functions friend class GrImageContextPriv; // for hidden functions
GrImageContext(GrBackendApi backend, uint32_t uniqueID); GrImageContext(GrBackendApi, const GrContextOptions&, uint32_t uniqueID);
GrImageContext* asImageContext() override { return this; } GrImageContext* asImageContext() override { return this; }

View File

@ -23,7 +23,7 @@ public:
protected: protected:
friend class GrRecordingContextPriv; // for hidden functions friend class GrRecordingContextPriv; // for hidden functions
GrRecordingContext(GrBackendApi backend, uint32_t uniqueID); GrRecordingContext(GrBackendApi, const GrContextOptions&, uint32_t uniqueID);
GrRecordingContext* asRecordingContext() override { return this; } GrRecordingContext* asRecordingContext() override { return this; }

View File

@ -18,6 +18,8 @@ public:
// from GrContext_Base // from GrContext_Base
uint32_t contextID() const { return fContext->contextID(); } uint32_t contextID() const { return fContext->contextID(); }
const GrContextOptions& options() const { return fContext->options(); }
private: private:
explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {} explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}
GrBaseContextPriv(const GrBaseContextPriv&); // unimpl GrBaseContextPriv(const GrBaseContextPriv&); // unimpl

View File

@ -59,15 +59,15 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
GrContext::GrContext(GrBackendApi backend, int32_t id) GrContext::GrContext(GrBackendApi backend, const GrContextOptions& options, int32_t id)
: INHERITED(backend, id) { : INHERITED(backend, options, id) {
fResourceCache = nullptr; fResourceCache = nullptr;
fResourceProvider = nullptr; fResourceProvider = nullptr;
fProxyProvider = nullptr; fProxyProvider = nullptr;
fGlyphCache = nullptr; fGlyphCache = nullptr;
} }
bool GrContext::initCommon(const GrContextOptions& options) { bool GrContext::initCommon() {
ASSERT_SINGLE_OWNER ASSERT_SINGLE_OWNER
SkASSERT(fCaps); // needs to have been initialized by derived classes SkASSERT(fCaps); // needs to have been initialized by derived classes
SkASSERT(fThreadSafeProxy); // needs to have been initialized by derived classes SkASSERT(fThreadSafeProxy); // needs to have been initialized by derived classes
@ -76,7 +76,7 @@ bool GrContext::initCommon(const GrContextOptions& options) {
fCaps = fGpu->refCaps(); fCaps = fGpu->refCaps();
fResourceCache = new GrResourceCache(fCaps.get(), &fSingleOwner, this->contextID()); fResourceCache = new GrResourceCache(fCaps.get(), &fSingleOwner, this->contextID());
fResourceProvider = new GrResourceProvider(fGpu.get(), fResourceCache, &fSingleOwner, fResourceProvider = new GrResourceProvider(fGpu.get(), fResourceCache, &fSingleOwner,
options.fExplicitlyAllocateGPUResources); this->options().fExplicitlyAllocateGPUResources);
fProxyProvider = fProxyProvider =
new GrProxyProvider(fResourceProvider, fResourceCache, fCaps, &fSingleOwner); new GrProxyProvider(fResourceProvider, fResourceCache, fCaps, &fSingleOwner);
} else { } else {
@ -87,19 +87,17 @@ bool GrContext::initCommon(const GrContextOptions& options) {
fResourceCache->setProxyProvider(fProxyProvider); fResourceCache->setProxyProvider(fProxyProvider);
} }
fDisableGpuYUVConversion = options.fDisableGpuYUVConversion;
fSharpenMipmappedTextures = options.fSharpenMipmappedTextures;
fDidTestPMConversions = false; fDidTestPMConversions = false;
GrPathRendererChain::Options prcOptions; GrPathRendererChain::Options prcOptions;
prcOptions.fAllowPathMaskCaching = options.fAllowPathMaskCaching; prcOptions.fAllowPathMaskCaching = this->options().fAllowPathMaskCaching;
#if GR_TEST_UTILS #if GR_TEST_UTILS
prcOptions.fGpuPathRenderers = options.fGpuPathRenderers; prcOptions.fGpuPathRenderers = this->options().fGpuPathRenderers;
#endif #endif
if (options.fDisableCoverageCountingPaths) { if (this->options().fDisableCoverageCountingPaths) {
prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kCoverageCounting; prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kCoverageCounting;
} }
if (options.fDisableDistanceFieldPaths) { if (this->options().fDisableDistanceFieldPaths) {
prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kSmall; prcOptions.fGpuPathRenderers &= ~GpuPathRenderers::kSmall;
} }
@ -112,11 +110,11 @@ bool GrContext::initCommon(const GrContextOptions& options) {
} }
GrTextContext::Options textContextOptions; GrTextContext::Options textContextOptions;
textContextOptions.fMaxDistanceFieldFontSize = options.fGlyphsAsPathsFontSize; textContextOptions.fMaxDistanceFieldFontSize = this->options().fGlyphsAsPathsFontSize;
textContextOptions.fMinDistanceFieldFontSize = options.fMinDistanceFieldFontSize; textContextOptions.fMinDistanceFieldFontSize = this->options().fMinDistanceFieldFontSize;
textContextOptions.fDistanceFieldVerticesAlwaysHaveW = false; textContextOptions.fDistanceFieldVerticesAlwaysHaveW = false;
#if SK_SUPPORT_ATLAS_TEXT #if SK_SUPPORT_ATLAS_TEXT
if (GrContextOptions::Enable::kYes == options.fDistanceFieldGlyphVerticesAlwaysHaveW) { if (GrContextOptions::Enable::kYes == this->options().fDistanceFieldGlyphVerticesAlwaysHaveW) {
textContextOptions.fDistanceFieldVerticesAlwaysHaveW = true; textContextOptions.fDistanceFieldVerticesAlwaysHaveW = true;
} }
#endif #endif
@ -126,20 +124,20 @@ bool GrContext::initCommon(const GrContextOptions& options) {
: false; : false;
fDrawingManager.reset(new GrDrawingManager(this, prcOptions, textContextOptions, fDrawingManager.reset(new GrDrawingManager(this, prcOptions, textContextOptions,
&fSingleOwner, explicitlyAllocatingResources, &fSingleOwner, explicitlyAllocatingResources,
options.fSortRenderTargets, this->options().fSortRenderTargets,
options.fReduceOpListSplitting)); this->options().fReduceOpListSplitting));
fGlyphCache = new GrStrikeCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes); fGlyphCache = new GrStrikeCache(fCaps.get(), this->options().fGlyphCacheTextureMaximumBytes);
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this, this->contextID())); fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this, this->contextID()));
// DDL TODO: we need to think through how the task group & persistent cache // DDL TODO: we need to think through how the task group & persistent cache
// get passed on to/shared between all the DDLRecorders created with this context. // get passed on to/shared between all the DDLRecorders created with this context.
if (options.fExecutor) { if (this->options().fExecutor) {
fTaskGroup = skstd::make_unique<SkTaskGroup>(*options.fExecutor); fTaskGroup = skstd::make_unique<SkTaskGroup>(*this->options().fExecutor);
} }
fPersistentCache = options.fPersistentCache; fPersistentCache = this->options().fPersistentCache;
return true; return true;
} }

View File

@ -32,6 +32,8 @@ public:
// from GrContext_Base // from GrContext_Base
uint32_t contextID() const { return fContext->contextID(); } uint32_t contextID() const { return fContext->contextID(); }
const GrContextOptions& options() const { return fContext->options(); }
// from GrImageContext // from GrImageContext
// from GrRecordingContext // from GrRecordingContext
@ -88,9 +90,6 @@ public:
sk_sp<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext( sk_sp<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext(
const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr); const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr);
bool disableGpuYUVConversion() const { return fContext->fDisableGpuYUVConversion; }
bool sharpenMipmappedTextures() const { return fContext->fSharpenMipmappedTextures; }
/** /**
* Call to ensure all drawing to the context has been issued to the * Call to ensure all drawing to the context has been issued to the
* underlying 3D API. * underlying 3D API.

View File

@ -19,16 +19,14 @@ GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uin
GrBackendApi backend, GrBackendApi backend,
const GrContextOptions& options, const GrContextOptions& options,
sk_sp<GrSkSLFPFactoryCache> cache) sk_sp<GrSkSLFPFactoryCache> cache)
: fCaps(std::move(caps)) : INHERITED(backend, options, contextID)
, fContextID(contextID) , fCaps(std::move(caps))
, fBackend(backend)
, fOptions(options)
, fFPFactoryCache(std::move(cache)) {} , fFPFactoryCache(std::move(cache)) {}
GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default; GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default;
bool GrContextThreadSafeProxy::matches(GrContext_Base* context) const { bool GrContextThreadSafeProxy::matches(GrContext_Base* context) const {
return context->priv().contextID() == fContextID; return context->priv().contextID() == this->contextID();
} }
SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization( SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(

View File

@ -17,12 +17,15 @@
*/ */
class GrContextThreadSafeProxyPriv { class GrContextThreadSafeProxyPriv {
public: public:
const GrContextOptions& contextOptions() { return fProxy->fOptions; } // from GrContext_Base
uint32_t contextID() const { return fProxy->contextID(); }
const GrContextOptions& options() const { return fProxy->options(); }
//
const GrCaps* caps() const { return fProxy->fCaps.get(); } const GrCaps* caps() const { return fProxy->fCaps.get(); }
sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; } sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
uint32_t contextID() const { return fProxy->fContextID; }
GrBackendApi backend() const { return fProxy->fBackend; }
sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const; sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const;
private: private:

View File

@ -17,12 +17,13 @@ static int32_t next_id() {
} }
GrContext_Base::GrContext_Base(GrBackendApi backend, GrContext_Base::GrContext_Base(GrBackendApi backend,
const GrContextOptions& options,
uint32_t contextID) uint32_t contextID)
: fBackend(backend) : fBackend(backend)
, fOptions(options)
, fContextID(SK_InvalidGenID == contextID ? next_id() : contextID) { , fContextID(SK_InvalidGenID == contextID ? next_id() : contextID) {
} }
GrContext_Base::~GrContext_Base() { GrContext_Base::~GrContext_Base() { }
}

View File

@ -18,16 +18,14 @@
class SK_API GrDDLContext : public GrContext { class SK_API GrDDLContext : public GrContext {
public: public:
GrDDLContext(sk_sp<GrContextThreadSafeProxy> proxy) GrDDLContext(sk_sp<GrContextThreadSafeProxy> proxy)
: INHERITED(proxy->priv().backend(), proxy->priv().contextID()) { : INHERITED(proxy->backend(), proxy->priv().options(), proxy->priv().contextID()) {
fCaps = proxy->priv().refCaps(); fCaps = proxy->priv().refCaps();
fFPFactoryCache = proxy->priv().fpFactoryCache(); fFPFactoryCache = proxy->priv().fpFactoryCache();
SkASSERT(fFPFactoryCache); SkASSERT(fFPFactoryCache);
fThreadSafeProxy = std::move(proxy); fThreadSafeProxy = std::move(proxy);
} }
~GrDDLContext() override { ~GrDDLContext() override { }
// The GrDDLContext doesn't actually own the fRestrictedAtlasManager so don't delete it
}
void abandonContext() override { void abandonContext() override {
SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense SkASSERT(0); // abandoning in a DDL Recorder doesn't make a whole lot of sense
@ -45,11 +43,11 @@ public:
} }
protected: protected:
bool init(const GrContextOptions& options) override { bool init() override {
SkASSERT(fCaps); // should've been set in ctor SkASSERT(fCaps); // should've been set in ctor
SkASSERT(fThreadSafeProxy); // should've been set in the ctor SkASSERT(fThreadSafeProxy); // should've been set in the ctor
if (!INHERITED::initCommon(options)) { if (!INHERITED::initCommon()) {
return false; return false;
} }
@ -70,7 +68,7 @@ sk_sp<GrContext> GrContextPriv::MakeDDL(const sk_sp<GrContextThreadSafeProxy>& p
// Note: we aren't creating a Gpu here. This causes the resource provider & cache to // Note: we aren't creating a Gpu here. This causes the resource provider & cache to
// also not be created // also not be created
if (!context->init(proxy->priv().contextOptions())) { if (!context->init()) {
return nullptr; return nullptr;
} }
return context; return context;

View File

@ -25,8 +25,8 @@
class SK_API GrDirectContext : public GrContext { class SK_API GrDirectContext : public GrContext {
public: public:
GrDirectContext(GrBackendApi backend) GrDirectContext(GrBackendApi backend, const GrContextOptions& options)
: INHERITED(backend) : INHERITED(backend, options)
, fAtlasManager(nullptr) { , fAtlasManager(nullptr) {
} }
@ -58,21 +58,21 @@ public:
} }
protected: protected:
bool init(const GrContextOptions& options) override { bool init() override {
SkASSERT(fCaps); // should've been set in ctor SkASSERT(fCaps); // should've been set in ctor
SkASSERT(!fThreadSafeProxy); SkASSERT(!fThreadSafeProxy);
SkASSERT(!fFPFactoryCache); SkASSERT(!fFPFactoryCache);
fFPFactoryCache.reset(new GrSkSLFPFactoryCache()); fFPFactoryCache.reset(new GrSkSLFPFactoryCache());
fThreadSafeProxy.reset(new GrContextThreadSafeProxy(fCaps, this->contextID(), fThreadSafeProxy.reset(new GrContextThreadSafeProxy(fCaps, this->contextID(),
this->backend(), this->backend(),
options, fFPFactoryCache)); this->options(), fFPFactoryCache));
if (!INHERITED::initCommon(options)) { if (!INHERITED::initCommon()) {
return false; return false;
} }
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing; GrDrawOpAtlas::AllowMultitexturing allowMultitexturing;
if (GrContextOptions::Enable::kNo == options.fAllowMultipleGlyphCacheTextures || if (GrContextOptions::Enable::kNo == this->options().fAllowMultipleGlyphCacheTextures ||
// multitexturing supported only if range can represent the index + texcoords fully // multitexturing supported only if range can represent the index + texcoords fully
!(fCaps->shaderCaps()->floatIs32Bits() || fCaps->shaderCaps()->integerSupport())) { !(fCaps->shaderCaps()->floatIs32Bits() || fCaps->shaderCaps()->integerSupport())) {
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo; allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kNo;
@ -84,7 +84,7 @@ protected:
GrProxyProvider* proxyProvider = this->contextPriv().proxyProvider(); GrProxyProvider* proxyProvider = this->contextPriv().proxyProvider();
fAtlasManager = new GrAtlasManager(proxyProvider, glyphCache, fAtlasManager = new GrAtlasManager(proxyProvider, glyphCache,
options.fGlyphCacheTextureMaximumBytes, this->options().fGlyphCacheTextureMaximumBytes,
allowMultitexturing); allowMultitexturing);
this->contextPriv().addOnFlushCallbackObject(fAtlasManager); this->contextPriv().addOnFlushCallbackObject(fAtlasManager);
@ -115,7 +115,7 @@ sk_sp<GrContext> GrContext::MakeGL() {
sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface, sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface,
const GrContextOptions& options) { const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kOpenGL)); sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kOpenGL, options));
context->fGpu = GrGLGpu::Make(std::move(interface), options, context.get()); context->fGpu = GrGLGpu::Make(std::move(interface), options, context.get());
if (!context->fGpu) { if (!context->fGpu) {
@ -123,7 +123,7 @@ sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface,
} }
context->fCaps = context->fGpu->refCaps(); context->fCaps = context->fGpu->refCaps();
if (!context->init(options)) { if (!context->init()) {
return nullptr; return nullptr;
} }
return context; return context;
@ -136,7 +136,7 @@ sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions) {
sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions, sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
const GrContextOptions& options) { const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kMock)); sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kMock, options));
context->fGpu = GrMockGpu::Make(mockOptions, options, context.get()); context->fGpu = GrMockGpu::Make(mockOptions, options, context.get());
if (!context->fGpu) { if (!context->fGpu) {
@ -144,7 +144,7 @@ sk_sp<GrContext> GrContext::MakeMock(const GrMockOptions* mockOptions,
} }
context->fCaps = context->fGpu->refCaps(); context->fCaps = context->fGpu->refCaps();
if (!context->init(options)) { if (!context->init()) {
return nullptr; return nullptr;
} }
return context; return context;
@ -163,7 +163,7 @@ sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext,
const GrContextOptions& options) { const GrContextOptions& options) {
#ifdef SK_VULKAN #ifdef SK_VULKAN
GrContextOptions defaultOptions; GrContextOptions defaultOptions;
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kVulkan)); sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kVulkan, options));
context->fGpu = GrVkGpu::Make(backendContext, options, context.get()); context->fGpu = GrVkGpu::Make(backendContext, options, context.get());
if (!context->fGpu) { if (!context->fGpu) {
@ -171,7 +171,7 @@ sk_sp<GrContext> GrContext::MakeVulkan(const GrVkBackendContext& backendContext,
} }
context->fCaps = context->fGpu->refCaps(); context->fCaps = context->fGpu->refCaps();
if (!context->init(options)) { if (!context->init()) {
return nullptr; return nullptr;
} }
return context; return context;
@ -187,7 +187,7 @@ sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue) {
} }
sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) { sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContextOptions& options) {
sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kMetal)); sk_sp<GrContext> context(new GrDirectContext(GrBackendApi::kMetal, options));
context->fGpu = GrMtlTrampoline::MakeGpu(context.get(), options, device, queue); context->fGpu = GrMtlTrampoline::MakeGpu(context.get(), options, device, queue);
if (!context->fGpu) { if (!context->fGpu) {
@ -195,7 +195,7 @@ sk_sp<GrContext> GrContext::MakeMetal(void* device, void* queue, const GrContext
} }
context->fCaps = context->fGpu->refCaps(); context->fCaps = context->fGpu->refCaps();
if (!context->init(options)) { if (!context->init()) {
return nullptr; return nullptr;
} }
return context; return context;

View File

@ -7,8 +7,10 @@
#include "GrImageContext.h" #include "GrImageContext.h"
GrImageContext::GrImageContext(GrBackendApi backend, uint32_t uniqueID) GrImageContext::GrImageContext(GrBackendApi backend,
: INHERITED(backend, uniqueID) { const GrContextOptions& options,
uint32_t uniqueID)
: INHERITED(backend, options, uniqueID) {
} }
GrImageContext::~GrImageContext() {} GrImageContext::~GrImageContext() {}

View File

@ -18,6 +18,8 @@ public:
// from GrContext_Base // from GrContext_Base
uint32_t contextID() const { return fContext->contextID(); } uint32_t contextID() const { return fContext->contextID(); }
const GrContextOptions& options() const { return fContext->options(); }
// from GrImageContext // from GrImageContext
private: private:

View File

@ -7,8 +7,10 @@
#include "GrRecordingContext.h" #include "GrRecordingContext.h"
GrRecordingContext::GrRecordingContext(GrBackendApi backend, uint32_t uniqueID) GrRecordingContext::GrRecordingContext(GrBackendApi backend,
: INHERITED(backend, uniqueID) { const GrContextOptions& options,
uint32_t uniqueID)
: INHERITED(backend, options, uniqueID) {
} }
GrRecordingContext::~GrRecordingContext() { } GrRecordingContext::~GrRecordingContext() { }

View File

@ -18,6 +18,8 @@ public:
// from GrContext_Base // from GrContext_Base
uint32_t contextID() const { return fContext->contextID(); } uint32_t contextID() const { return fContext->contextID(); }
const GrContextOptions& options() const { return fContext->options(); }
// from GrImageContext // from GrImageContext
// from GrRecordingContext // from GrRecordingContext

View File

@ -769,8 +769,8 @@ bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr
GrSamplerState samplerState; GrSamplerState samplerState;
bool doBicubic; bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode( GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
quality, viewMatrix, srcToDstRect, fContext->contextPriv().sharpenMipmappedTextures(), quality, viewMatrix, srcToDstRect,
&doBicubic); fContext->contextPriv().options().fSharpenMipmappedTextures, &doBicubic);
int tileFilterPad; int tileFilterPad;
if (doBicubic) { if (doBicubic) {
@ -821,7 +821,7 @@ void SkGpuDevice::drawBitmap(const SkBitmap& bitmap,
bool doBicubic; bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode( GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
paint.getFilterQuality(), viewMatrix, SkMatrix::I(), paint.getFilterQuality(), viewMatrix, SkMatrix::I(),
fContext->contextPriv().sharpenMipmappedTextures(), &doBicubic); fContext->contextPriv().options().fSharpenMipmappedTextures, &doBicubic);
int tileFilterPad; int tileFilterPad;
@ -1180,7 +1180,7 @@ void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap,
bool doBicubic; bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode( GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
paint.getFilterQuality(), this->ctm(), srcToDstMatrix, paint.getFilterQuality(), this->ctm(), srcToDstMatrix,
fContext->contextPriv().sharpenMipmappedTextures(), &doBicubic); fContext->contextPriv().options().fSharpenMipmappedTextures, &doBicubic);
int tileFilterPad; int tileFilterPad;

View File

@ -251,7 +251,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
bool doBicubic; bool doBicubic;
GrSamplerState::Filter fm = GrSkFilterQualityToGrFilterMode( GrSamplerState::Filter fm = GrSkFilterQualityToGrFilterMode(
paint.getFilterQuality(), viewMatrix, srcToDstMatrix, paint.getFilterQuality(), viewMatrix, srcToDstMatrix,
fContext->contextPriv().sharpenMipmappedTextures(), &doBicubic); fContext->contextPriv().options().fSharpenMipmappedTextures, &doBicubic);
const GrSamplerState::Filter* filterMode = doBicubic ? nullptr : &fm; const GrSamplerState::Filter* filterMode = doBicubic ? nullptr : &fm;
GrTextureProducer::FilterConstraint constraintMode; GrTextureProducer::FilterConstraint constraintMode;

View File

@ -231,7 +231,8 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
SkSL::Program::Settings settings; SkSL::Program::Settings settings;
settings.fCaps = this->gpu()->glCaps().shaderCaps(); settings.fCaps = this->gpu()->glCaps().shaderCaps();
settings.fFlipY = this->origin() != kTopLeft_GrSurfaceOrigin; settings.fFlipY = this->origin() != kTopLeft_GrSurfaceOrigin;
settings.fSharpenTextures = this->gpu()->getContext()->contextPriv().sharpenMipmappedTextures(); settings.fSharpenTextures =
this->gpu()->getContext()->contextPriv().options().fSharpenMipmappedTextures;
settings.fFragColorIsInOut = this->fragColorIsInOut(); settings.fFragColorIsInOut = this->fragColorIsInOut();
SkSL::Program::Inputs inputs; SkSL::Program::Inputs inputs;

View File

@ -319,7 +319,8 @@ GrMtlPipelineState* GrMtlPipelineStateBuilder::finalize(const GrPrimitiveProcess
SkSL::Program::Settings settings; SkSL::Program::Settings settings;
settings.fCaps = this->caps()->shaderCaps(); settings.fCaps = this->caps()->shaderCaps();
settings.fFlipY = this->origin() != kTopLeft_GrSurfaceOrigin; settings.fFlipY = this->origin() != kTopLeft_GrSurfaceOrigin;
settings.fSharpenTextures = fGpu->getContext()->contextPriv().sharpenMipmappedTextures(); settings.fSharpenTextures =
fGpu->getContext()->contextPriv().options().fSharpenMipmappedTextures;
SkASSERT(!this->fragColorIsInOut()); SkASSERT(!this->fragColorIsInOut());
id<MTLLibrary> vertexLibrary = nil; id<MTLLibrary> vertexLibrary = nil;

View File

@ -276,7 +276,8 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrStencilSettings& s
SkSL::Program::Settings settings; SkSL::Program::Settings settings;
settings.fCaps = this->caps()->shaderCaps(); settings.fCaps = this->caps()->shaderCaps();
settings.fFlipY = this->origin() != kTopLeft_GrSurfaceOrigin; settings.fFlipY = this->origin() != kTopLeft_GrSurfaceOrigin;
settings.fSharpenTextures = this->gpu()->getContext()->contextPriv().sharpenMipmappedTextures(); settings.fSharpenTextures =
this->gpu()->getContext()->contextPriv().options().fSharpenMipmappedTextures;
SkASSERT(!this->fragColorIsInOut()); SkASSERT(!this->fragColorIsInOut());
sk_sp<SkData> cached; sk_sp<SkData> cached;

View File

@ -425,7 +425,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(
// 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping // 3. Ask the generator to return YUV planes, which the GPU can convert. If we will be mipping
// the texture we fall through here and have the CPU generate the mip maps for us. // the texture we fall through here and have the CPU generate the mip maps for us.
if (!proxy && !willBeMipped && !ctx->contextPriv().disableGpuYUVConversion()) { if (!proxy && !willBeMipped && !ctx->contextPriv().options().fDisableGpuYUVConversion) {
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo); const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo);
SkColorType colorType = fInfo.colorType(); SkColorType colorType = fInfo.colorType();

View File

@ -214,7 +214,7 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
bool doBicubic; bool doBicubic;
GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode( GrSamplerState::Filter textureFilterMode = GrSkFilterQualityToGrFilterMode(
args.fFilterQuality, *args.fViewMatrix, *lm, args.fFilterQuality, *args.fViewMatrix, *lm,
args.fContext->contextPriv().sharpenMipmappedTextures(), &doBicubic); args.fContext->contextPriv().options().fSharpenMipmappedTextures, &doBicubic);
GrSamplerState samplerState(wrapModes, textureFilterMode); GrSamplerState samplerState(wrapModes, textureFilterMode);
SkScalar scaleAdjust[2] = { 1.0f, 1.0f }; SkScalar scaleAdjust[2] = { 1.0f, 1.0f };
sk_sp<GrTextureProxy> proxy(as_IB(fImage)->asTextureProxyRef(args.fContext, samplerState, sk_sp<GrTextureProxy> proxy(as_IB(fImage)->asTextureProxyRef(args.fContext, samplerState,