Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit fd0d970

Browse files
rphilliSkia Commit-Bot
authored andcommitted
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>
1 parent e6e72bc commit fd0d970

27 files changed

+77
-62
lines changed

include/gpu/GrContextThreadSafeProxy.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class GrBackendFormat;
1515
class GrCaps;
1616
class GrContext;
17+
class GrContext_Base;
1718
class GrContextThreadSafeProxyPriv;
1819
class GrSkSLFPFactoryCache;
1920
struct SkImageInfo;
@@ -27,7 +28,7 @@ class SK_API GrContextThreadSafeProxy : public SkRefCnt {
2728
public:
2829
~GrContextThreadSafeProxy() override;
2930

30-
bool matches(GrContext* context) const;
31+
bool matches(GrContext_Base* context) const;
3132

3233
/**
3334
* Create a surface characterization for a DDL that will be replayed into the GrContext
@@ -68,7 +69,7 @@ class SK_API GrContextThreadSafeProxy : public SkRefCnt {
6869

6970
bool operator==(const GrContextThreadSafeProxy& that) const {
7071
// Each GrContext should only ever have a single thread-safe proxy.
71-
SkASSERT((this == &that) == (fContextUniqueID == that.fContextUniqueID));
72+
SkASSERT((this == &that) == (fContextID == that.fContextID));
7273
return this == &that;
7374
}
7475

@@ -87,8 +88,8 @@ class SK_API GrContextThreadSafeProxy : public SkRefCnt {
8788
sk_sp<GrSkSLFPFactoryCache> cache);
8889

8990
sk_sp<const GrCaps> fCaps;
90-
const uint32_t fContextUniqueID;
91-
const GrBackendApi fBackend;
91+
const uint32_t fContextID;
92+
const GrBackendApi fBackend;
9293
const GrContextOptions fOptions;
9394
sk_sp<GrSkSLFPFactoryCache> fFPFactoryCache;
9495

include/private/GrContext_Base.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ class SK_API GrContext_Base : public SkRefCnt {
2525
*/
2626
GrBackendApi backend() const { return fBackend; }
2727

28-
/**
29-
* An identifier for this context. The id is used by all compatible contexts. For example,
30-
* if SkImages are created on one thread using an image creation context, then fed into a
31-
* DDL Recorder on second thread (which has a recording context) and finally replayed on
32-
* a third thread with a direct context, then all three contexts will report the same id.
33-
* It is an error for an image to be used with contexts that report different ids.
34-
*/
35-
uint32_t uniqueID() const { return fUniqueID; }
36-
3728
// Provides access to functions that aren't part of the public API.
3829
GrBaseContextPriv priv();
3930
const GrBaseContextPriv priv() const;
@@ -43,14 +34,23 @@ class SK_API GrContext_Base : public SkRefCnt {
4334

4435
GrContext_Base(GrBackendApi backend, uint32_t uniqueID);
4536

37+
/**
38+
* An identifier for this context. The id is used by all compatible contexts. For example,
39+
* if SkImages are created on one thread using an image creation context, then fed into a
40+
* DDL Recorder on second thread (which has a recording context) and finally replayed on
41+
* a third thread with a direct context, then all three contexts will report the same id.
42+
* It is an error for an image to be used with contexts that report different ids.
43+
*/
44+
uint32_t contextID() const { return fContextID; }
45+
4646
GrContext_Base* asBaseContext() { return this; }
4747
virtual GrImageContext* asImageContext() { return nullptr; }
4848
virtual GrRecordingContext* asRecordingContext() { return nullptr; }
4949
virtual GrContext* asDirectContext() { return nullptr; }
5050

5151
private:
5252
const GrBackendApi fBackend;
53-
const uint32_t fUniqueID;
53+
const uint32_t fContextID;
5454

5555
typedef SkRefCnt INHERITED;
5656
};

src/core/SkSpecialImage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(GrContext* context,
192192

193193
#if SK_SUPPORT_GPU
194194
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef()) {
195-
if (as_IB(image)->contextID() != context->uniqueID()) {
195+
if (as_IB(image)->contextID() != context->contextPriv().contextID()) {
196196
return nullptr;
197197
}
198198

src/gpu/GrBackendTextureImageGenerator.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ GrBackendTextureImageGenerator::Make(sk_sp<GrTexture> texture, GrSurfaceOrigin o
5656
SkImageInfo info = SkImageInfo::Make(texture->width(), texture->height(), colorType, alphaType,
5757
std::move(colorSpace));
5858
return std::unique_ptr<SkImageGenerator>(new GrBackendTextureImageGenerator(
59-
info, texture.get(), origin, context->uniqueID(), std::move(semaphore), backendTexture));
59+
info, texture.get(), origin, context->contextPriv().contextID(),
60+
std::move(semaphore), backendTexture));
6061
}
6162

6263
GrBackendTextureImageGenerator::GrBackendTextureImageGenerator(const SkImageInfo& info,
@@ -104,7 +105,7 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
104105
fBorrowingMutex.acquire();
105106
sk_sp<GrReleaseProcHelper> releaseProcHelper;
106107
if (SK_InvalidGenID != fRefHelper->fBorrowingContextID) {
107-
if (fRefHelper->fBorrowingContextID != context->uniqueID()) {
108+
if (fRefHelper->fBorrowingContextID != context->contextPriv().contextID()) {
108109
fBorrowingMutex.release();
109110
return nullptr;
110111
} else {
@@ -121,10 +122,10 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
121122
fRefHelper));
122123
fRefHelper->fBorrowingContextReleaseProc = releaseProcHelper.get();
123124
}
124-
fRefHelper->fBorrowingContextID = context->uniqueID();
125+
fRefHelper->fBorrowingContextID = context->contextPriv().contextID();
125126
fBorrowingMutex.release();
126127

127-
SkASSERT(fRefHelper->fBorrowingContextID == context->uniqueID());
128+
SkASSERT(fRefHelper->fBorrowingContextID == context->contextPriv().contextID());
128129

129130
GrSurfaceDesc desc;
130131
desc.fWidth = fBackendTexture.width();

src/gpu/GrBaseContextPriv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
class GrBaseContextPriv {
1717
public:
1818
// from GrContext_Base
19+
uint32_t contextID() const { return fContext->contextID(); }
1920

2021
private:
2122
explicit GrBaseContextPriv(GrContext_Base* context) : fContext(context) {}

src/gpu/GrContext.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ bool GrContext::initCommon(const GrContextOptions& options) {
7474

7575
if (fGpu) {
7676
fCaps = fGpu->refCaps();
77-
fResourceCache = new GrResourceCache(fCaps.get(), &fSingleOwner, this->uniqueID());
77+
fResourceCache = new GrResourceCache(fCaps.get(), &fSingleOwner, this->contextID());
7878
fResourceProvider = new GrResourceProvider(fGpu.get(), fResourceCache, &fSingleOwner,
7979
options.fExplicitlyAllocateGPUResources);
8080
fProxyProvider =
8181
new GrProxyProvider(fResourceProvider, fResourceCache, fCaps, &fSingleOwner);
8282
} else {
83-
fProxyProvider = new GrProxyProvider(this->uniqueID(), fCaps, &fSingleOwner);
83+
fProxyProvider = new GrProxyProvider(this->contextID(), fCaps, &fSingleOwner);
8484
}
8585

8686
if (fResourceCache) {
@@ -131,8 +131,7 @@ bool GrContext::initCommon(const GrContextOptions& options) {
131131

132132
fGlyphCache = new GrStrikeCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes);
133133

134-
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB,
135-
this, this->uniqueID()));
134+
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this, this->contextID()));
136135

137136
// DDL TODO: we need to think through how the task group & persistent cache
138137
// get passed on to/shared between all the DDLRecorders created with this context.

src/gpu/GrContextPriv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class GrContextPriv {
3030
public:
3131

3232
// from GrContext_Base
33+
uint32_t contextID() const { return fContext->contextID(); }
3334

3435
// from GrImageContext
3536

src/gpu/GrContextThreadSafeProxy.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@
88
#include "GrContextThreadSafeProxy.h"
99
#include "GrContextThreadSafeProxyPriv.h"
1010

11+
#include "GrBaseContextPriv.h"
1112
#include "GrCaps.h"
1213
#include "GrContext.h"
1314
#include "GrSkSLFPFactoryCache.h"
1415
#include "SkSurface_Gpu.h"
1516
#include "SkSurfaceCharacterization.h"
1617

17-
GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID,
18+
GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t contextID,
1819
GrBackendApi backend,
1920
const GrContextOptions& options,
2021
sk_sp<GrSkSLFPFactoryCache> cache)
2122
: fCaps(std::move(caps))
22-
, fContextUniqueID(uniqueID)
23+
, fContextID(contextID)
2324
, fBackend(backend)
2425
, fOptions(options)
2526
, fFPFactoryCache(std::move(cache)) {}
2627

2728
GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default;
2829

29-
bool GrContextThreadSafeProxy::matches(GrContext* context) const {
30-
return context->uniqueID() == fContextUniqueID;
30+
bool GrContextThreadSafeProxy::matches(GrContext_Base* context) const {
31+
return context->priv().contextID() == fContextID;
3132
}
3233

3334
SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(

src/gpu/GrContextThreadSafeProxyPriv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class GrContextThreadSafeProxyPriv {
2121

2222
const GrCaps* caps() const { return fProxy->fCaps.get(); }
2323
sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
24-
uint32_t contextUniqueID() const { return fProxy->fContextUniqueID; }
24+
uint32_t contextID() const { return fProxy->fContextID; }
2525
GrBackendApi backend() const { return fProxy->fBackend; }
2626
sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const;
2727

src/gpu/GrContext_Base.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ static int32_t next_id() {
1717
}
1818

1919
GrContext_Base::GrContext_Base(GrBackendApi backend,
20-
uint32_t uniqueID)
20+
uint32_t contextID)
2121
: fBackend(backend)
22-
, fUniqueID(SK_InvalidGenID == uniqueID ? next_id() : uniqueID) {
22+
, fContextID(SK_InvalidGenID == contextID ? next_id() : contextID) {
2323
}
2424

2525
GrContext_Base::~GrContext_Base() {

0 commit comments

Comments
 (0)