adding uniqueID to GrContext
BUG=skia: Review URL: https://codereview.chromium.org/1128873009
This commit is contained in:
parent
622d3aded2
commit
0acd0d33fd
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user