chromium/third_party/angle/src/libANGLE/RefCountObject.h

//
// 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.
//

// RefCountObject.h: Defines the gl::RefCountObject base class that provides
// lifecycle support for GL objects using the traditional BindObject scheme, but
// that need to be reference counted for correct cross-context deletion.
// (Concretely, textures, buffers and renderbuffers.)

#ifndef LIBANGLE_REFCOUNTOBJECT_H_
#define LIBANGLE_REFCOUNTOBJECT_H_

#include "angle_gl.h"
#include "common/PackedEnums.h"
#include "common/debug.h"
#include "libANGLE/Error.h"
#include "libANGLE/Observer.h"
#include "libANGLE/renderer/serial_utils.h"

#include <cstddef>

namespace angle
{

template <typename ContextT, typename ErrorT>
class RefCountObject : angle::NonCopyable
{};

// Alternative base class to RefCountObject using atomics to track the reference count.
// Interchangable with RefCountObject for usage with BindingPointer and other wrappers.
template <typename ContextT, typename ErrorT>
class ThreadSafeRefCountObject : angle::NonCopyable
{};

template <class ObjectType, typename ContextT, typename ErrorT = angle::Result>
class RefCountObjectReleaser : angle::NonCopyable
{};

template <class ObjectType, typename ContextT, typename ErrorT = angle::Result>
class BindingPointer
{};
}  // namespace angle

namespace gl
{
class Context;

template <class ObjectType>
class BindingPointer;

RefCountObjectNoID;
ThreadSafeRefCountObjectNoID;

template <typename IDType, typename RC = RefCountObjectNoID>
class RefCountObject : public RC
{};
ThreadSafeRefCountObject;

template <class ObjectType>
class BindingPointer : public angle::BindingPointer<ObjectType, Context>
{};

template <class ObjectType>
class OffsetBindingPointer : public BindingPointer<ObjectType>
{};

template <typename SubjectT>
class SubjectBindingPointer : protected BindingPointer<SubjectT>, public angle::ObserverBindingBase
{};
}  // namespace gl

namespace egl
{
class Display;

RefCountObject;
ThreadSafeRefCountObject;

RefCountObjectReleaser;

BindingPointer;

}  // namespace egl

#endif  // LIBANGLE_REFCOUNTOBJECT_H_