adding uniqueID to GrContext

BUG=skia:

Review URL: https://codereview.chromium.org/1128873009
This commit is contained in:
joshualitt 2015-05-07 08:23:19 -07:00 committed by Commit bot
parent 622d3aded2
commit 0acd0d33fd
2 changed files with 16 additions and 1 deletions

View File

@ -514,6 +514,11 @@ public:
*/
void discardRenderTarget(GrRenderTarget*);
/**
* An ID associated with this context, guaranteed to be unique.
*/
uint32_t uniqueID() { return fUniqueID; }
///////////////////////////////////////////////////////////////////////////
// Legacy functions, to be removed once Chromium stops using them.
@ -614,6 +619,7 @@ private:
int fMaxTextureSizeOverride;
const Options fOptions;
const uint32_t fUniqueID;
GrContext(const Options&); // init must be called after the constructor.
bool init(GrBackend, GrBackendContext);

View File

@ -92,7 +92,16 @@ GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
}
}
GrContext::GrContext(const Options& opts) : fOptions(opts) {
static int32_t gNextID = 1;
static int32_t next_id() {
int32_t id;
do {
id = sk_atomic_inc(&gNextID);
} while (id == SK_InvalidGenID);
return id;
}
GrContext::GrContext(const Options& opts) : fOptions(opts), fUniqueID(next_id()) {
fGpu = NULL;
fResourceCache = NULL;
fResourceProvider = NULL;