// // Copyright 2002 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //
// HandleAllocator.cpp: Implements the gl::HandleAllocator class, which is used // to allocate GL handles.
// Allocate from released list, logarithmic time for pop_heap. if (!mReleasedList.empty())
{
std::pop_heap(mReleasedList.begin(), mReleasedList.end(), std::greater<GLuint>());
GLuint reusedHandle = mReleasedList.back();
mReleasedList.pop_back();
// Add to released list, logarithmic time for push_heap.
mReleasedList.push_back(handle);
std::push_heap(mReleasedList.begin(), mReleasedList.end(), std::greater<GLuint>());
}
// Clear from released list -- might be a slow operation. if (!mReleasedList.empty())
{ auto releasedIt = std::find(mReleasedList.begin(), mReleasedList.end(), handle); if (releasedIt != mReleasedList.end())
{
mReleasedList.erase(releasedIt);
std::make_heap(mReleasedList.begin(), mReleasedList.end(), std::greater<GLuint>()); return;
}
}
// Not in released list, reserve in the unallocated list. auto boundIt = std::lower_bound(mUnallocatedList.begin(), mUnallocatedList.end(), handle,
HandleRangeComparator());
ASSERT(boundIt != mUnallocatedList.end());
GLuint begin = boundIt->begin;
GLuint end = boundIt->end;
// need to split the range auto placementIt = mUnallocatedList.erase(boundIt);
placementIt = mUnallocatedList.insert(placementIt, HandleRange(handle + 1, end));
mUnallocatedList.insert(placementIt, HandleRange(begin, handle - 1));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.