diff options
author | Robert Phillips <robertphillips@google.com> | 2019-01-25 15:11:04 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2019-01-29 14:03:47 +0000 |
commit | f8397f2b3f00ca17da3c028a287097b5d79cd315 (patch) | |
tree | d98f46567f738227951beea7c3a3e88fdff39e0f /src/gpu | |
parent | a09731e5cf3e946e960482102f636a84d7018c39 (diff) | |
download | skqp-f8397f2b3f00ca17da3c028a287097b5d79cd315.tar.gz |
Split GrContextThreadSafeProxy into its own files
This just shuffles stuff around.
Change-Id: Ieab35f50945efe87512d7077cb994132f0e0b6ef
Reviewed-on: https://skia-review.googlesource.com/c/186874
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrContext.cpp | 72 | ||||
-rw-r--r-- | src/gpu/GrContextPriv.h | 4 | ||||
-rw-r--r-- | src/gpu/GrContextThreadSafeProxy.cpp | 94 | ||||
-rw-r--r-- | src/gpu/GrContextThreadSafeProxyPriv.h | 4 | ||||
-rw-r--r-- | src/gpu/GrDDLContext.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrDirectContext.cpp | 1 |
6 files changed, 101 insertions, 75 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index d122a4d891..657b7dac70 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -169,76 +169,6 @@ GrContext::~GrContext() { ////////////////////////////////////////////////////////////////////////////// -GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID, - GrBackendApi backend, - const GrContextOptions& options, - sk_sp<GrSkSLFPFactoryCache> cache) - : fCaps(std::move(caps)) - , fContextUniqueID(uniqueID) - , fBackend(backend) - , fOptions(options) - , fFPFactoryCache(std::move(cache)) {} - -GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default; - -sk_sp<GrContextThreadSafeProxy> GrContext::threadSafeProxy() { - return fThreadSafeProxy; -} - -SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization( - size_t cacheMaxResourceBytes, - const SkImageInfo& ii, const GrBackendFormat& backendFormat, - int sampleCnt, GrSurfaceOrigin origin, - const SkSurfaceProps& surfaceProps, - bool isMipMapped, bool willUseGLFBO0) { - if (!backendFormat.isValid()) { - return SkSurfaceCharacterization(); // return an invalid characterization - } - - if (GrBackendApi::kOpenGL != backendFormat.backend() && willUseGLFBO0) { - // The willUseGLFBO0 flags can only be used for a GL backend. - return SkSurfaceCharacterization(); // return an invalid characterization - } - - if (!fCaps->mipMapSupport()) { - isMipMapped = false; - } - - GrPixelConfig config = fCaps->getConfigFromBackendFormat(backendFormat, ii.colorType()); - if (config == kUnknown_GrPixelConfig) { - return SkSurfaceCharacterization(); // return an invalid characterization - } - - if (!SkSurface_Gpu::Valid(fCaps.get(), config, ii.colorSpace())) { - return SkSurfaceCharacterization(); // return an invalid characterization - } - - sampleCnt = fCaps->getRenderTargetSampleCount(sampleCnt, config); - if (!sampleCnt) { - return SkSurfaceCharacterization(); // return an invalid characterization - } - - GrFSAAType FSAAType = GrFSAAType::kNone; - if (sampleCnt > 1) { - FSAAType = fCaps->usesMixedSamples() ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA; - } - - // This surface characterization factory assumes that the resulting characterization is - // textureable. - if (!fCaps->isConfigTexturable(config)) { - return SkSurfaceCharacterization(); // return an invalid characterization - } - - return SkSurfaceCharacterization(sk_ref_sp<GrContextThreadSafeProxy>(this), - cacheMaxResourceBytes, ii, - origin, config, FSAAType, sampleCnt, - SkSurfaceCharacterization::Textureable(true), - SkSurfaceCharacterization::MipMapped(isMipMapped), - SkSurfaceCharacterization::UsesGLFBO0(willUseGLFBO0), - SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false), - surfaceProps); -} - void GrContext::abandonContext() { ASSERT_SINGLE_OWNER @@ -1140,6 +1070,8 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext( return renderTargetContext; } +sk_sp<GrSkSLFPFactoryCache> GrContextPriv::getFPFactoryCache() { return fContext->fFPFactoryCache; } + std::unique_ptr<GrFragmentProcessor> GrContext::createPMToUPMEffect( std::unique_ptr<GrFragmentProcessor> fp) { ASSERT_SINGLE_OWNER diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h index 468a599b8b..24309ec99b 100644 --- a/src/gpu/GrContextPriv.h +++ b/src/gpu/GrContextPriv.h @@ -279,9 +279,7 @@ public: GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; } - sk_sp<GrSkSLFPFactoryCache> getFPFactoryCache() { - return fContext->fFPFactoryCache; - } + sk_sp<GrSkSLFPFactoryCache> getFPFactoryCache(); /** This is only useful for debug purposes */ SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fContext->fSingleOwner; } ) diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp new file mode 100644 index 0000000000..cfa4b33f9f --- /dev/null +++ b/src/gpu/GrContextThreadSafeProxy.cpp @@ -0,0 +1,94 @@ +/* + * Copyright 2019 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrContextThreadSafeProxy.h" +#include "GrContextThreadSafeProxyPriv.h" + +#include "GrCaps.h" +#include "GrContext.h" +#include "GrSkSLFPFactoryCache.h" +#include "SkSurface_Gpu.h" +#include "SkSurfaceCharacterization.h" + +GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID, + GrBackendApi backend, + const GrContextOptions& options, + sk_sp<GrSkSLFPFactoryCache> cache) + : fCaps(std::move(caps)) + , fContextUniqueID(uniqueID) + , fBackend(backend) + , fOptions(options) + , fFPFactoryCache(std::move(cache)) {} + +GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default; + +sk_sp<GrContextThreadSafeProxy> GrContext::threadSafeProxy() { + return fThreadSafeProxy; +} + +bool GrContextThreadSafeProxy::matches(GrContext* context) const { + return context->uniqueID() == fContextUniqueID; +} + +SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization( + size_t cacheMaxResourceBytes, + const SkImageInfo& ii, const GrBackendFormat& backendFormat, + int sampleCnt, GrSurfaceOrigin origin, + const SkSurfaceProps& surfaceProps, + bool isMipMapped, bool willUseGLFBO0) { + if (!backendFormat.isValid()) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + if (GrBackendApi::kOpenGL != backendFormat.backend() && willUseGLFBO0) { + // The willUseGLFBO0 flags can only be used for a GL backend. + return SkSurfaceCharacterization(); // return an invalid characterization + } + + if (!fCaps->mipMapSupport()) { + isMipMapped = false; + } + + GrPixelConfig config = fCaps->getConfigFromBackendFormat(backendFormat, ii.colorType()); + if (config == kUnknown_GrPixelConfig) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + if (!SkSurface_Gpu::Valid(fCaps.get(), config, ii.colorSpace())) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + sampleCnt = fCaps->getRenderTargetSampleCount(sampleCnt, config); + if (!sampleCnt) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + GrFSAAType FSAAType = GrFSAAType::kNone; + if (sampleCnt > 1) { + FSAAType = fCaps->usesMixedSamples() ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA; + } + + // This surface characterization factory assumes that the resulting characterization is + // textureable. + if (!fCaps->isConfigTexturable(config)) { + return SkSurfaceCharacterization(); // return an invalid characterization + } + + return SkSurfaceCharacterization(sk_ref_sp<GrContextThreadSafeProxy>(this), + cacheMaxResourceBytes, ii, + origin, config, FSAAType, sampleCnt, + SkSurfaceCharacterization::Textureable(true), + SkSurfaceCharacterization::MipMapped(isMipMapped), + SkSurfaceCharacterization::UsesGLFBO0(willUseGLFBO0), + SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false), + surfaceProps); +} + +//////////////////////////////////////////////////////////////////////////////// +sk_sp<GrSkSLFPFactoryCache> GrContextThreadSafeProxyPriv::fpFactoryCache() const { + return fProxy->fFPFactoryCache; +} diff --git a/src/gpu/GrContextThreadSafeProxyPriv.h b/src/gpu/GrContextThreadSafeProxyPriv.h index 1d251e46c3..298ad783cf 100644 --- a/src/gpu/GrContextThreadSafeProxyPriv.h +++ b/src/gpu/GrContextThreadSafeProxyPriv.h @@ -8,7 +8,7 @@ #ifndef GrContextThreadSafeProxyPriv_DEFINED #define GrContextThreadSafeProxyPriv_DEFINED -#include "GrContext.h" +#include "GrContextThreadSafeProxy.h" /** * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to @@ -23,7 +23,7 @@ public: sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; } uint32_t contextUniqueID() const { return fProxy->fContextUniqueID; } GrBackendApi backend() const { return fProxy->fBackend; } - sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const { return fProxy->fFPFactoryCache; } + sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const; private: explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {} diff --git a/src/gpu/GrDDLContext.cpp b/src/gpu/GrDDLContext.cpp index eb5ed29e6b..5461bd98f1 100644 --- a/src/gpu/GrDDLContext.cpp +++ b/src/gpu/GrDDLContext.cpp @@ -9,6 +9,7 @@ #include "GrCaps.h" #include "GrContextPriv.h" #include "GrContextThreadSafeProxyPriv.h" +#include "GrSkSLFPFactoryCache.h" /** * The DDL Context is the one in effect during DDL Recording. It isn't backed by a GrGPU and diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp index c46d84e909..9e6075c436 100644 --- a/src/gpu/GrDirectContext.cpp +++ b/src/gpu/GrDirectContext.cpp @@ -9,6 +9,7 @@ #include "GrContext.h" #include "GrContextPriv.h" +#include "GrContextThreadSafeProxy.h" #include "GrGpu.h" #include "effects/GrSkSLFP.h" |