Rename GrContext::uniqueID to contextID and hide it
The GrContext's ID isn't really unique any more (since it can be shared among a family of contexts). Change its name to reflect the new reality. Additionally, no client seems to be using it so make it private. Change-Id: Ibb9004d699fe6ca7876b3be94142e612b5b9efbd Reviewed-on: https://skia-review.googlesource.com/c/188308 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
e6e72bcbfa
commit
fd0d97092b
@ -14,6 +14,7 @@
|
|||||||
class GrBackendFormat;
|
class GrBackendFormat;
|
||||||
class GrCaps;
|
class GrCaps;
|
||||||
class GrContext;
|
class GrContext;
|
||||||
|
class GrContext_Base;
|
||||||
class GrContextThreadSafeProxyPriv;
|
class GrContextThreadSafeProxyPriv;
|
||||||
class GrSkSLFPFactoryCache;
|
class GrSkSLFPFactoryCache;
|
||||||
struct SkImageInfo;
|
struct SkImageInfo;
|
||||||
@ -27,7 +28,7 @@ class SK_API GrContextThreadSafeProxy : public SkRefCnt {
|
|||||||
public:
|
public:
|
||||||
~GrContextThreadSafeProxy() override;
|
~GrContextThreadSafeProxy() override;
|
||||||
|
|
||||||
bool matches(GrContext* context) const;
|
bool matches(GrContext_Base* context) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a surface characterization for a DDL that will be replayed into the GrContext
|
* Create a surface characterization for a DDL that will be replayed into the GrContext
|
||||||
@ -68,7 +69,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) == (fContextUniqueID == that.fContextUniqueID));
|
SkASSERT((this == &that) == (fContextID == that.fContextID));
|
||||||
return this == &that;
|
return this == &that;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +88,8 @@ private:
|
|||||||
sk_sp<GrSkSLFPFactoryCache> cache);
|
sk_sp<GrSkSLFPFactoryCache> cache);
|
||||||
|
|
||||||
sk_sp<const GrCaps> fCaps;
|
sk_sp<const GrCaps> fCaps;
|
||||||
const uint32_t fContextUniqueID;
|
const uint32_t fContextID;
|
||||||
const GrBackendApi fBackend;
|
const GrBackendApi fBackend;
|
||||||
const GrContextOptions fOptions;
|
const GrContextOptions fOptions;
|
||||||
sk_sp<GrSkSLFPFactoryCache> fFPFactoryCache;
|
sk_sp<GrSkSLFPFactoryCache> fFPFactoryCache;
|
||||||
|
|
||||||
|
@ -25,15 +25,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
GrBackendApi backend() const { return fBackend; }
|
GrBackendApi backend() const { return fBackend; }
|
||||||
|
|
||||||
/**
|
|
||||||
* An identifier for this context. The id is used by all compatible contexts. For example,
|
|
||||||
* if SkImages are created on one thread using an image creation context, then fed into a
|
|
||||||
* DDL Recorder on second thread (which has a recording context) and finally replayed on
|
|
||||||
* a third thread with a direct context, then all three contexts will report the same id.
|
|
||||||
* It is an error for an image to be used with contexts that report different ids.
|
|
||||||
*/
|
|
||||||
uint32_t uniqueID() const { return fUniqueID; }
|
|
||||||
|
|
||||||
// Provides access to functions that aren't part of the public API.
|
// Provides access to functions that aren't part of the public API.
|
||||||
GrBaseContextPriv priv();
|
GrBaseContextPriv priv();
|
||||||
const GrBaseContextPriv priv() const;
|
const GrBaseContextPriv priv() const;
|
||||||
@ -43,6 +34,15 @@ protected:
|
|||||||
|
|
||||||
GrContext_Base(GrBackendApi backend, uint32_t uniqueID);
|
GrContext_Base(GrBackendApi backend, uint32_t uniqueID);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An identifier for this context. The id is used by all compatible contexts. For example,
|
||||||
|
* if SkImages are created on one thread using an image creation context, then fed into a
|
||||||
|
* DDL Recorder on second thread (which has a recording context) and finally replayed on
|
||||||
|
* a third thread with a direct context, then all three contexts will report the same id.
|
||||||
|
* It is an error for an image to be used with contexts that report different ids.
|
||||||
|
*/
|
||||||
|
uint32_t contextID() const { return fContextID; }
|
||||||
|
|
||||||
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; }
|
||||||
@ -50,7 +50,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const GrBackendApi fBackend;
|
const GrBackendApi fBackend;
|
||||||
const uint32_t fUniqueID;
|
const uint32_t fContextID;
|
||||||
|
|
||||||
typedef SkRefCnt INHERITED;
|
typedef SkRefCnt INHERITED;
|
||||||
};
|
};
|
||||||
|
@ -192,7 +192,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(GrContext* context,
|
|||||||
|
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef()) {
|
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef()) {
|
||||||
if (as_IB(image)->contextID() != context->uniqueID()) {
|
if (as_IB(image)->contextID() != context->contextPriv().contextID()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,8 @@ GrBackendTextureImageGenerator::Make(sk_sp<GrTexture> texture, GrSurfaceOrigin o
|
|||||||
SkImageInfo info = SkImageInfo::Make(texture->width(), texture->height(), colorType, alphaType,
|
SkImageInfo info = SkImageInfo::Make(texture->width(), texture->height(), colorType, alphaType,
|
||||||
std::move(colorSpace));
|
std::move(colorSpace));
|
||||||
return std::unique_ptr<SkImageGenerator>(new GrBackendTextureImageGenerator(
|
return std::unique_ptr<SkImageGenerator>(new GrBackendTextureImageGenerator(
|
||||||
info, texture.get(), origin, context->uniqueID(), std::move(semaphore), backendTexture));
|
info, texture.get(), origin, context->contextPriv().contextID(),
|
||||||
|
std::move(semaphore), backendTexture));
|
||||||
}
|
}
|
||||||
|
|
||||||
GrBackendTextureImageGenerator::GrBackendTextureImageGenerator(const SkImageInfo& info,
|
GrBackendTextureImageGenerator::GrBackendTextureImageGenerator(const SkImageInfo& info,
|
||||||
@ -104,7 +105,7 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
|||||||
fBorrowingMutex.acquire();
|
fBorrowingMutex.acquire();
|
||||||
sk_sp<GrReleaseProcHelper> releaseProcHelper;
|
sk_sp<GrReleaseProcHelper> releaseProcHelper;
|
||||||
if (SK_InvalidGenID != fRefHelper->fBorrowingContextID) {
|
if (SK_InvalidGenID != fRefHelper->fBorrowingContextID) {
|
||||||
if (fRefHelper->fBorrowingContextID != context->uniqueID()) {
|
if (fRefHelper->fBorrowingContextID != context->contextPriv().contextID()) {
|
||||||
fBorrowingMutex.release();
|
fBorrowingMutex.release();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
@ -121,10 +122,10 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
|||||||
fRefHelper));
|
fRefHelper));
|
||||||
fRefHelper->fBorrowingContextReleaseProc = releaseProcHelper.get();
|
fRefHelper->fBorrowingContextReleaseProc = releaseProcHelper.get();
|
||||||
}
|
}
|
||||||
fRefHelper->fBorrowingContextID = context->uniqueID();
|
fRefHelper->fBorrowingContextID = context->contextPriv().contextID();
|
||||||
fBorrowingMutex.release();
|
fBorrowingMutex.release();
|
||||||
|
|
||||||
SkASSERT(fRefHelper->fBorrowingContextID == context->uniqueID());
|
SkASSERT(fRefHelper->fBorrowingContextID == context->contextPriv().contextID());
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
desc.fWidth = fBackendTexture.width();
|
desc.fWidth = fBackendTexture.width();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
class GrBaseContextPriv {
|
class GrBaseContextPriv {
|
||||||
public:
|
public:
|
||||||
// from GrContext_Base
|
// from GrContext_Base
|
||||||
|
uint32_t contextID() const { return fContext->contextID(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}
|
explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}
|
||||||
|
@ -74,13 +74,13 @@ bool GrContext::initCommon(const GrContextOptions& options) {
|
|||||||
|
|
||||||
if (fGpu) {
|
if (fGpu) {
|
||||||
fCaps = fGpu->refCaps();
|
fCaps = fGpu->refCaps();
|
||||||
fResourceCache = new GrResourceCache(fCaps.get(), &fSingleOwner, this->uniqueID());
|
fResourceCache = new GrResourceCache(fCaps.get(), &fSingleOwner, this->contextID());
|
||||||
fResourceProvider = new GrResourceProvider(fGpu.get(), fResourceCache, &fSingleOwner,
|
fResourceProvider = new GrResourceProvider(fGpu.get(), fResourceCache, &fSingleOwner,
|
||||||
options.fExplicitlyAllocateGPUResources);
|
options.fExplicitlyAllocateGPUResources);
|
||||||
fProxyProvider =
|
fProxyProvider =
|
||||||
new GrProxyProvider(fResourceProvider, fResourceCache, fCaps, &fSingleOwner);
|
new GrProxyProvider(fResourceProvider, fResourceCache, fCaps, &fSingleOwner);
|
||||||
} else {
|
} else {
|
||||||
fProxyProvider = new GrProxyProvider(this->uniqueID(), fCaps, &fSingleOwner);
|
fProxyProvider = new GrProxyProvider(this->contextID(), fCaps, &fSingleOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fResourceCache) {
|
if (fResourceCache) {
|
||||||
@ -131,8 +131,7 @@ bool GrContext::initCommon(const GrContextOptions& options) {
|
|||||||
|
|
||||||
fGlyphCache = new GrStrikeCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes);
|
fGlyphCache = new GrStrikeCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes);
|
||||||
|
|
||||||
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB,
|
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this, this->contextID()));
|
||||||
this, this->uniqueID()));
|
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -30,6 +30,7 @@ class GrContextPriv {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
// from GrContext_Base
|
// from GrContext_Base
|
||||||
|
uint32_t contextID() const { return fContext->contextID(); }
|
||||||
|
|
||||||
// from GrImageContext
|
// from GrImageContext
|
||||||
|
|
||||||
|
@ -8,26 +8,27 @@
|
|||||||
#include "GrContextThreadSafeProxy.h"
|
#include "GrContextThreadSafeProxy.h"
|
||||||
#include "GrContextThreadSafeProxyPriv.h"
|
#include "GrContextThreadSafeProxyPriv.h"
|
||||||
|
|
||||||
|
#include "GrBaseContextPriv.h"
|
||||||
#include "GrCaps.h"
|
#include "GrCaps.h"
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrSkSLFPFactoryCache.h"
|
#include "GrSkSLFPFactoryCache.h"
|
||||||
#include "SkSurface_Gpu.h"
|
#include "SkSurface_Gpu.h"
|
||||||
#include "SkSurfaceCharacterization.h"
|
#include "SkSurfaceCharacterization.h"
|
||||||
|
|
||||||
GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID,
|
GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t contextID,
|
||||||
GrBackendApi backend,
|
GrBackendApi backend,
|
||||||
const GrContextOptions& options,
|
const GrContextOptions& options,
|
||||||
sk_sp<GrSkSLFPFactoryCache> cache)
|
sk_sp<GrSkSLFPFactoryCache> cache)
|
||||||
: fCaps(std::move(caps))
|
: fCaps(std::move(caps))
|
||||||
, fContextUniqueID(uniqueID)
|
, fContextID(contextID)
|
||||||
, fBackend(backend)
|
, fBackend(backend)
|
||||||
, fOptions(options)
|
, fOptions(options)
|
||||||
, fFPFactoryCache(std::move(cache)) {}
|
, fFPFactoryCache(std::move(cache)) {}
|
||||||
|
|
||||||
GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default;
|
GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default;
|
||||||
|
|
||||||
bool GrContextThreadSafeProxy::matches(GrContext* context) const {
|
bool GrContextThreadSafeProxy::matches(GrContext_Base* context) const {
|
||||||
return context->uniqueID() == fContextUniqueID;
|
return context->priv().contextID() == fContextID;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
|
SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
|
|
||||||
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 contextUniqueID() const { return fProxy->fContextUniqueID; }
|
uint32_t contextID() const { return fProxy->fContextID; }
|
||||||
GrBackendApi backend() const { return fProxy->fBackend; }
|
GrBackendApi backend() const { return fProxy->fBackend; }
|
||||||
sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const;
|
sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const;
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ static int32_t next_id() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrContext_Base::GrContext_Base(GrBackendApi backend,
|
GrContext_Base::GrContext_Base(GrBackendApi backend,
|
||||||
uint32_t uniqueID)
|
uint32_t contextID)
|
||||||
: fBackend(backend)
|
: fBackend(backend)
|
||||||
, fUniqueID(SK_InvalidGenID == uniqueID ? next_id() : uniqueID) {
|
, fContextID(SK_InvalidGenID == contextID ? next_id() : contextID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GrContext_Base::~GrContext_Base() {
|
GrContext_Base::~GrContext_Base() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
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().contextUniqueID()) {
|
: INHERITED(proxy->priv().backend(), proxy->priv().contextID()) {
|
||||||
fCaps = proxy->priv().refCaps();
|
fCaps = proxy->priv().refCaps();
|
||||||
fFPFactoryCache = proxy->priv().fpFactoryCache();
|
fFPFactoryCache = proxy->priv().fpFactoryCache();
|
||||||
SkASSERT(fFPFactoryCache);
|
SkASSERT(fFPFactoryCache);
|
||||||
|
@ -63,7 +63,7 @@ protected:
|
|||||||
SkASSERT(!fThreadSafeProxy);
|
SkASSERT(!fThreadSafeProxy);
|
||||||
SkASSERT(!fFPFactoryCache);
|
SkASSERT(!fFPFactoryCache);
|
||||||
fFPFactoryCache.reset(new GrSkSLFPFactoryCache());
|
fFPFactoryCache.reset(new GrSkSLFPFactoryCache());
|
||||||
fThreadSafeProxy.reset(new GrContextThreadSafeProxy(fCaps, this->uniqueID(),
|
fThreadSafeProxy.reset(new GrContextThreadSafeProxy(fCaps, this->contextID(),
|
||||||
this->backend(),
|
this->backend(),
|
||||||
options, fFPFactoryCache));
|
options, fFPFactoryCache));
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
class GrImageContextPriv {
|
class GrImageContextPriv {
|
||||||
public:
|
public:
|
||||||
// from GrContext_Base
|
// from GrContext_Base
|
||||||
|
uint32_t contextID() const { return fContext->contextID(); }
|
||||||
|
|
||||||
// from GrImageContext
|
// from GrImageContext
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ sk_sp<const GrBuffer> GrOnFlushResourceProvider::findOrMakeStaticBuffer(GrBuffer
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GrOnFlushResourceProvider::contextUniqueID() const {
|
uint32_t GrOnFlushResourceProvider::contextID() const {
|
||||||
return fDrawingMgr->getContext()->uniqueID();
|
return fDrawingMgr->getContext()->contextPriv().contextID();
|
||||||
}
|
}
|
||||||
|
|
||||||
const GrCaps* GrOnFlushResourceProvider::caps() const {
|
const GrCaps* GrOnFlushResourceProvider::caps() const {
|
||||||
|
@ -92,7 +92,7 @@ public:
|
|||||||
sk_sp<const GrBuffer> findOrMakeStaticBuffer(GrBufferType, size_t, const void* data,
|
sk_sp<const GrBuffer> findOrMakeStaticBuffer(GrBufferType, size_t, const void* data,
|
||||||
const GrUniqueKey&);
|
const GrUniqueKey&);
|
||||||
|
|
||||||
uint32_t contextUniqueID() const;
|
uint32_t contextID() const;
|
||||||
const GrCaps* caps() const;
|
const GrCaps* caps() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -41,7 +41,7 @@ GrPathRendererChain::GrPathRendererChain(GrContext* context, const Options& opti
|
|||||||
using AllowCaching = GrCoverageCountingPathRenderer::AllowCaching;
|
using AllowCaching = GrCoverageCountingPathRenderer::AllowCaching;
|
||||||
if (auto ccpr = GrCoverageCountingPathRenderer::CreateIfSupported(
|
if (auto ccpr = GrCoverageCountingPathRenderer::CreateIfSupported(
|
||||||
caps, AllowCaching(options.fAllowPathMaskCaching),
|
caps, AllowCaching(options.fAllowPathMaskCaching),
|
||||||
context->uniqueID())) {
|
context->contextPriv().contextID())) {
|
||||||
fCoverageCountingPathRenderer = ccpr.get();
|
fCoverageCountingPathRenderer = ccpr.get();
|
||||||
context->contextPriv().addOnFlushCallbackObject(fCoverageCountingPathRenderer);
|
context->contextPriv().addOnFlushCallbackObject(fCoverageCountingPathRenderer);
|
||||||
fChain.push_back(std::move(ccpr));
|
fChain.push_back(std::move(ccpr));
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
class GrRecordingContextPriv {
|
class GrRecordingContextPriv {
|
||||||
public:
|
public:
|
||||||
// from GrContext_Base
|
// from GrContext_Base
|
||||||
|
uint32_t contextID() const { return fContext->contextID(); }
|
||||||
|
|
||||||
// from GrImageContext
|
// from GrImageContext
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
|||||||
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
|
SkASSERT(proxy->origin() == kTopLeft_GrSurfaceOrigin);
|
||||||
fProxyProvider->assignUniqueKeyToProxy(maskKey, proxy.get());
|
fProxyProvider->assignUniqueKeyToProxy(maskKey, proxy.get());
|
||||||
args.fShape->addGenIDChangeListener(
|
args.fShape->addGenIDChangeListener(
|
||||||
sk_make_sp<PathInvalidator>(maskKey, args.fContext->uniqueID()));
|
sk_make_sp<PathInvalidator>(maskKey, args.fContext->contextPriv().contextID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inverseFilled) {
|
if (inverseFilled) {
|
||||||
|
@ -960,8 +960,8 @@ GR_DRAW_OP_TEST_DEFINE(SmallPathOp) {
|
|||||||
using PathTestStruct = GrSmallPathRenderer::PathTestStruct;
|
using PathTestStruct = GrSmallPathRenderer::PathTestStruct;
|
||||||
static PathTestStruct gTestStruct;
|
static PathTestStruct gTestStruct;
|
||||||
|
|
||||||
if (context->uniqueID() != gTestStruct.fContextID) {
|
if (context->contextPriv().contextID() != gTestStruct.fContextID) {
|
||||||
gTestStruct.fContextID = context->uniqueID();
|
gTestStruct.fContextID = context->contextPriv().contextID();
|
||||||
gTestStruct.reset();
|
gTestStruct.reset();
|
||||||
const GrBackendFormat format =
|
const GrBackendFormat format =
|
||||||
context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
|
context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "GrCaps.h"
|
#include "GrCaps.h"
|
||||||
#include "GrContext.h"
|
#include "GrContext.h"
|
||||||
#include "GrContextPriv.h"
|
#include "GrRecordingContextPriv.h"
|
||||||
#include "GrSDFMaskFilter.h"
|
#include "GrSDFMaskFilter.h"
|
||||||
#include "GrTextBlobCache.h"
|
#include "GrTextBlobCache.h"
|
||||||
#include "SkDistanceFieldGen.h"
|
#include "SkDistanceFieldGen.h"
|
||||||
@ -210,8 +210,8 @@ GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) {
|
|||||||
static std::unique_ptr<GrTextContext> gTextContext;
|
static std::unique_ptr<GrTextContext> gTextContext;
|
||||||
static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
|
static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType);
|
||||||
|
|
||||||
if (context->uniqueID() != gContextID) {
|
if (context->priv().contextID() != gContextID) {
|
||||||
gContextID = context->uniqueID();
|
gContextID = context->priv().contextID();
|
||||||
gTextContext = GrTextContext::Make(GrTextContext::Options());
|
gTextContext = GrTextContext::Make(GrTextContext::Options());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ public:
|
|||||||
int srcX, int srcY, CachingHint) const = 0;
|
int srcX, int srcY, CachingHint) const = 0;
|
||||||
|
|
||||||
virtual GrContext* context() const { return nullptr; }
|
virtual GrContext* context() const { return nullptr; }
|
||||||
|
// TODO: remove this contextID and use GrContext_Base::matches
|
||||||
virtual uint32_t contextID() const { return 0; }
|
virtual uint32_t contextID() const { return 0; }
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
virtual GrTextureProxy* peekProxy() const { return nullptr; }
|
virtual GrTextureProxy* peekProxy() const { return nullptr; }
|
||||||
|
@ -351,7 +351,7 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext* context, SkColorSpace* dstCo
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (uint32_t incumbentID = as_IB(this)->contextID()) {
|
if (uint32_t incumbentID = as_IB(this)->contextID()) {
|
||||||
if (incumbentID != context->uniqueID()) {
|
if (incumbentID != context->contextPriv().contextID()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
sk_sp<GrTextureProxy> proxy = as_IB(this)->asTextureProxyRef();
|
sk_sp<GrTextureProxy> proxy = as_IB(this)->asTextureProxyRef();
|
||||||
|
@ -31,6 +31,13 @@ SkImage_GpuBase::~SkImage_GpuBase() {}
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if GR_TEST_UTILS
|
||||||
|
void SkImage_GpuBase::resetContext(sk_sp<GrContext> newContext) {
|
||||||
|
SkASSERT(fContext->contextPriv().contextID() == newContext->contextPriv().contextID());
|
||||||
|
fContext = newContext;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendTexture& tex,
|
bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendTexture& tex,
|
||||||
GrPixelConfig* config, SkColorType ct, SkAlphaType at,
|
GrPixelConfig* config, SkColorType ct, SkAlphaType at,
|
||||||
sk_sp<SkColorSpace> cs) {
|
sk_sp<SkColorSpace> cs) {
|
||||||
@ -53,6 +60,10 @@ bool SkImage_GpuBase::ValidateBackendTexture(GrContext* ctx, const GrBackendText
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
uint32_t SkImage_GpuBase::contextID() const {
|
||||||
|
return fContext->contextPriv().contextID();
|
||||||
|
}
|
||||||
|
|
||||||
bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {
|
bool SkImage_GpuBase::getROPixels(SkBitmap* dst, CachingHint chint) const {
|
||||||
if (!fContext->contextPriv().resourceProvider()) {
|
if (!fContext->contextPriv().resourceProvider()) {
|
||||||
// DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
|
// DDL TODO: buffer up the readback so it occurs when the DDL is drawn?
|
||||||
@ -200,7 +211,7 @@ bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels,
|
|||||||
sk_sp<GrTextureProxy> SkImage_GpuBase::asTextureProxyRef(GrContext* context,
|
sk_sp<GrTextureProxy> SkImage_GpuBase::asTextureProxyRef(GrContext* context,
|
||||||
const GrSamplerState& params,
|
const GrSamplerState& params,
|
||||||
SkScalar scaleAdjust[2]) const {
|
SkScalar scaleAdjust[2]) const {
|
||||||
if (context->uniqueID() != fContext->uniqueID()) {
|
if (context->contextPriv().contextID() != fContext->contextPriv().contextID()) {
|
||||||
SkASSERT(0);
|
SkASSERT(0);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -498,8 +509,8 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
|||||||
}
|
}
|
||||||
tex->resourcePriv().setUniqueKey(fLastFulfilledKey);
|
tex->resourcePriv().setUniqueKey(fLastFulfilledKey);
|
||||||
SkASSERT(fContextID == SK_InvalidUniqueID ||
|
SkASSERT(fContextID == SK_InvalidUniqueID ||
|
||||||
fContextID == tex->getContext()->uniqueID());
|
fContextID == tex->getContext()->contextPriv().contextID());
|
||||||
fContextID = tex->getContext()->uniqueID();
|
fContextID = tex->getContext()->contextPriv().contextID();
|
||||||
promiseTexture->addKeyToInvalidate(fContextID, fLastFulfilledKey);
|
promiseTexture->addKeyToInvalidate(fContextID, fLastFulfilledKey);
|
||||||
return std::move(tex);
|
return std::move(tex);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
~SkImage_GpuBase() override;
|
~SkImage_GpuBase() override;
|
||||||
|
|
||||||
GrContext* context() const final { return fContext.get(); }
|
GrContext* context() const final { return fContext.get(); }
|
||||||
uint32_t contextID() const final { return fContext->uniqueID(); }
|
uint32_t contextID() const final;
|
||||||
|
|
||||||
bool getROPixels(SkBitmap*, CachingHint) const final;
|
bool getROPixels(SkBitmap*, CachingHint) const final;
|
||||||
sk_sp<SkImage> onMakeSubset(const SkIRect& subset) const final;
|
sk_sp<SkImage> onMakeSubset(const SkIRect& subset) const final;
|
||||||
@ -53,10 +53,7 @@ public:
|
|||||||
bool onIsValid(GrContext*) const final;
|
bool onIsValid(GrContext*) const final;
|
||||||
|
|
||||||
#if GR_TEST_UTILS
|
#if GR_TEST_UTILS
|
||||||
void resetContext(sk_sp<GrContext> newContext) {
|
void resetContext(sk_sp<GrContext> newContext);
|
||||||
SkASSERT(fContext->uniqueID() == newContext->uniqueID());
|
|
||||||
fContext = newContext;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool ValidateBackendTexture(GrContext* ctx, const GrBackendTexture& tex,
|
static bool ValidateBackendTexture(GrContext* ctx, const GrBackendTexture& tex,
|
||||||
|
@ -417,7 +417,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(
|
|||||||
set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
|
set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
|
||||||
if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
|
if (!willBeMipped || GrMipMapped::kYes == proxy->mipMapped()) {
|
||||||
*fUniqueKeyInvalidatedMessages.append() =
|
*fUniqueKeyInvalidatedMessages.append() =
|
||||||
new GrUniqueKeyInvalidatedMessage(key, ctx->uniqueID());
|
new GrUniqueKeyInvalidatedMessage(key, ctx->contextPriv().contextID());
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(
|
|||||||
kLockTexturePathCount);
|
kLockTexturePathCount);
|
||||||
set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
|
set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
|
||||||
*fUniqueKeyInvalidatedMessages.append() =
|
*fUniqueKeyInvalidatedMessages.append() =
|
||||||
new GrUniqueKeyInvalidatedMessage(key, ctx->uniqueID());
|
new GrUniqueKeyInvalidatedMessage(key, ctx->contextPriv().contextID());
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -469,7 +469,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(
|
|||||||
kLockTexturePathCount);
|
kLockTexturePathCount);
|
||||||
set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
|
set_key_on_proxy(proxyProvider, proxy.get(), nullptr, key);
|
||||||
*fUniqueKeyInvalidatedMessages.append() =
|
*fUniqueKeyInvalidatedMessages.append() =
|
||||||
new GrUniqueKeyInvalidatedMessage(key, ctx->uniqueID());
|
new GrUniqueKeyInvalidatedMessage(key, ctx->contextPriv().contextID());
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(
|
|||||||
SkASSERT(willBeMipped);
|
SkASSERT(willBeMipped);
|
||||||
SkASSERT(GrMipMapped::kNo == proxy->mipMapped());
|
SkASSERT(GrMipMapped::kNo == proxy->mipMapped());
|
||||||
*fUniqueKeyInvalidatedMessages.append() =
|
*fUniqueKeyInvalidatedMessages.append() =
|
||||||
new GrUniqueKeyInvalidatedMessage(key, ctx->uniqueID());
|
new GrUniqueKeyInvalidatedMessage(key, ctx->contextPriv().contextID());
|
||||||
if (auto mippedProxy = GrCopyBaseMipMapToTextureProxy(ctx, proxy.get())) {
|
if (auto mippedProxy = GrCopyBaseMipMapToTextureProxy(ctx, proxy.get())) {
|
||||||
set_key_on_proxy(proxyProvider, mippedProxy.get(), proxy.get(), key);
|
set_key_on_proxy(proxyProvider, mippedProxy.get(), proxy.get(), key);
|
||||||
return mippedProxy;
|
return mippedProxy;
|
||||||
|
@ -1045,8 +1045,8 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
|
|||||||
typedef SkMessageBus<GrUniqueKeyInvalidatedMessage> Bus;
|
typedef SkMessageBus<GrUniqueKeyInvalidatedMessage> Bus;
|
||||||
|
|
||||||
// Invalidate two of the three, they should be purged and no longer accessible via their keys.
|
// Invalidate two of the three, they should be purged and no longer accessible via their keys.
|
||||||
Bus::Post(Msg(key1, context->uniqueID()));
|
Bus::Post(Msg(key1, context->contextPriv().contextID()));
|
||||||
Bus::Post(Msg(key2, context->uniqueID()));
|
Bus::Post(Msg(key2, context->contextPriv().contextID()));
|
||||||
cache->purgeAsNeeded();
|
cache->purgeAsNeeded();
|
||||||
// a should be deleted now, but we still have a ref on b.
|
// a should be deleted now, but we still have a ref on b.
|
||||||
REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1));
|
REPORTER_ASSERT(reporter, !cache->hasUniqueKey(key1));
|
||||||
@ -1055,7 +1055,7 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
|
|||||||
REPORTER_ASSERT(reporter, cache->hasUniqueKey(key3));
|
REPORTER_ASSERT(reporter, cache->hasUniqueKey(key3));
|
||||||
|
|
||||||
// Invalidate the third.
|
// Invalidate the third.
|
||||||
Bus::Post(Msg(key3, context->uniqueID()));
|
Bus::Post(Msg(key3, context->contextPriv().contextID()));
|
||||||
cache->purgeAsNeeded();
|
cache->purgeAsNeeded();
|
||||||
// we still have a ref on b, c should be recycled as scratch.
|
// we still have a ref on b, c should be recycled as scratch.
|
||||||
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
|
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
|
||||||
@ -1571,13 +1571,13 @@ static void test_free_resource_messages(skiatest::Reporter* reporter) {
|
|||||||
cache->purgeAsNeeded();
|
cache->purgeAsNeeded();
|
||||||
|
|
||||||
// Send message to free the first resource
|
// Send message to free the first resource
|
||||||
GrGpuResourceFreedMessage msg1{wrapped1, context->uniqueID()};
|
GrGpuResourceFreedMessage msg1{wrapped1, context->contextPriv().contextID()};
|
||||||
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg1);
|
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg1);
|
||||||
cache->purgeAsNeeded();
|
cache->purgeAsNeeded();
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
|
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
|
||||||
|
|
||||||
GrGpuResourceFreedMessage msg2{wrapped3, context->uniqueID()};
|
GrGpuResourceFreedMessage msg2{wrapped3, context->contextPriv().contextID()};
|
||||||
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg2);
|
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg2);
|
||||||
cache->purgeAsNeeded();
|
cache->purgeAsNeeded();
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ static void basic_test(GrContext* context,
|
|||||||
|
|
||||||
if (expectResourceToOutliveProxy) {
|
if (expectResourceToOutliveProxy) {
|
||||||
proxy.reset();
|
proxy.reset();
|
||||||
GrUniqueKeyInvalidatedMessage msg(texKey, context->uniqueID());
|
GrUniqueKeyInvalidatedMessage msg(texKey, context->contextPriv().contextID());
|
||||||
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
|
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(msg);
|
||||||
cache->purgeAsNeeded();
|
cache->purgeAsNeeded();
|
||||||
expectedCacheCount--;
|
expectedCacheCount--;
|
||||||
@ -278,7 +278,7 @@ static void invalidation_and_instantiation_test(GrContext* context, skiatest::Re
|
|||||||
|
|
||||||
// Send an invalidation message, which will be sitting in the cache's inbox
|
// Send an invalidation message, which will be sitting in the cache's inbox
|
||||||
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
|
SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(
|
||||||
GrUniqueKeyInvalidatedMessage(key, context->uniqueID()));
|
GrUniqueKeyInvalidatedMessage(key, context->contextPriv().contextID()));
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
REPORTER_ASSERT(reporter, 1 == proxyProvider->numUniqueKeyProxies_TestOnly());
|
||||||
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
|
||||||
|
Loading…
Reference in New Issue
Block a user