diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkSurfaceCharacterization.cpp | 21 | ||||
-rw-r--r-- | src/gpu/GrContextThreadSafeProxyPriv.h | 49 | ||||
-rw-r--r-- | src/gpu/GrDDLContext.cpp | 8 |
3 files changed, 73 insertions, 5 deletions
diff --git a/src/core/SkSurfaceCharacterization.cpp b/src/core/SkSurfaceCharacterization.cpp index 930e96fc39..74160d2b94 100644 --- a/src/core/SkSurfaceCharacterization.cpp +++ b/src/core/SkSurfaceCharacterization.cpp @@ -8,12 +8,14 @@ #include "SkSurfaceCharacterization.h" #if SK_SUPPORT_GPU +#include "GrContextThreadSafeProxyPriv.h" + bool SkSurfaceCharacterization::operator==(const SkSurfaceCharacterization& other) const { if (!this->isValid() || !other.isValid()) { return false; } - if (fContextInfo->fContextUniqueID != other.fContextInfo->fContextUniqueID) { + if (fContextInfo != other.fContextInfo) { return false; } @@ -29,4 +31,21 @@ bool SkSurfaceCharacterization::operator==(const SkSurfaceCharacterization& othe fSurfaceProps == other.fSurfaceProps; } +SkSurfaceCharacterization SkSurfaceCharacterization::createResized(int width, int height) const { + const GrCaps* caps = fContextInfo->priv().caps(); + if (!caps) { + return SkSurfaceCharacterization(); + } + + if (width <= 0 || height <= 0 || width > caps->maxRenderTargetSize() || + height > caps->maxRenderTargetSize()) { + return SkSurfaceCharacterization(); + } + + return SkSurfaceCharacterization(fContextInfo, fCacheMaxResourceBytes, + fImageInfo.makeWH(width, height), fOrigin, fConfig, fFSAAType, + fStencilCnt, fIsTextureable, fIsMipMapped, fUsesGLFBO0, + fSurfaceProps); +} + #endif diff --git a/src/gpu/GrContextThreadSafeProxyPriv.h b/src/gpu/GrContextThreadSafeProxyPriv.h new file mode 100644 index 0000000000..8e299c8180 --- /dev/null +++ b/src/gpu/GrContextThreadSafeProxyPriv.h @@ -0,0 +1,49 @@ +/* + * Copyright 2018 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrContextThreadSafeProxyPriv_DEFINED +#define GrContextThreadSafeProxyPriv_DEFINED + +#include "GrContext.h" + +/** + * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to + * Skia. This class is purely a privileged window into GrContextThreadSafeProxy. It should never + * have additional data members or virtual methods. + */ +class GrContextThreadSafeProxyPriv { +public: + const GrContextOptions& contextOptions() { return fProxy->fOptions; } + + const GrCaps* caps() const { return fProxy->fCaps.get(); } + sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; } + uint32_t contextUniqueID() const { return fProxy->fContextUniqueID; } + GrBackend backend() const { return fProxy->fBackend; } + +private: + explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {} + GrContextThreadSafeProxyPriv(const GrContextThreadSafeProxy&) = delete; + GrContextThreadSafeProxyPriv& operator=(const GrContextThreadSafeProxyPriv&) = delete; + + // No taking addresses of this type. + const GrContextThreadSafeProxyPriv* operator&() const = delete; + GrContextThreadSafeProxyPriv* operator&() = delete; + + GrContextThreadSafeProxy* fProxy; + + friend class GrContextThreadSafeProxy; // to construct/copy this type. +}; + +inline GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() { + return GrContextThreadSafeProxyPriv(this); +} + +inline const GrContextThreadSafeProxyPriv GrContextThreadSafeProxy::priv() const { + return GrContextThreadSafeProxyPriv(const_cast<GrContextThreadSafeProxy*>(this)); +} + +#endif diff --git a/src/gpu/GrDDLContext.cpp b/src/gpu/GrDDLContext.cpp index 9a91ab8526..5ed65ea5f0 100644 --- a/src/gpu/GrDDLContext.cpp +++ b/src/gpu/GrDDLContext.cpp @@ -6,8 +6,8 @@ */ #include "GrContext.h" - #include "GrContextPriv.h" +#include "GrContextThreadSafeProxyPriv.h" /** * The DDL Context is the one in effect during DDL Recording. It isn't backed by a GrGPU and @@ -16,8 +16,8 @@ class SK_API GrDDLContext : public GrContext { public: GrDDLContext(sk_sp<GrContextThreadSafeProxy> proxy) - : INHERITED(proxy->fBackend, proxy->fContextUniqueID) { - fCaps = proxy->fCaps; + : INHERITED(proxy->priv().backend(), proxy->priv().contextUniqueID()) { + fCaps = proxy->priv().refCaps(); fThreadSafeProxy = std::move(proxy); } @@ -66,7 +66,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 // also not be created - if (!context->init(proxy->fOptions)) { + if (!context->init(proxy->priv().contextOptions())) { return nullptr; } return context; |