1 /* 2 * Copyright 2019 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "GrContext_Base.h" 9 10 static int32_t next_id() { 11 static std::atomic<int32_t> nextID{1}; 12 int32_t id; 13 do { 14 id = nextID++; 15 } while (id == SK_InvalidGenID); 16 return id; 17 } 18 19 GrContext_Base::GrContext_Base(GrBackendApi backend, 20 uint32_t contextID) 21 : fBackend(backend) 22 , fContextID(SK_InvalidGenID == contextID ? next_id() : contextID) { 23 } 24 25 GrContext_Base::~GrContext_Base() { 26 } 27 28 29