gfx/angle/src/common/RefCountObject.cpp

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

     1 #include "precompiled.h"
     2 //
     3 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
     4 // Use of this source code is governed by a BSD-style license that can be
     5 // found in the LICENSE file.
     6 //
     8 // RefCountObject.cpp: Defines the gl::RefCountObject base class that provides
     9 // lifecycle support for GL objects using the traditional BindObject scheme, but
    10 // that need to be reference counted for correct cross-context deletion.
    11 // (Concretely, textures, buffers and renderbuffers.)
    13 #include "RefCountObject.h"
    15 RefCountObject::RefCountObject(GLuint id)
    16 {
    17     mId = id;
    18     mRefCount = 0;
    19 }
    21 RefCountObject::~RefCountObject()
    22 {
    23     ASSERT(mRefCount == 0);
    24 }
    26 void RefCountObject::addRef() const
    27 {
    28     mRefCount++;
    29 }
    31 void RefCountObject::release() const
    32 {
    33     ASSERT(mRefCount > 0);
    35     if (--mRefCount == 0)
    36     {
    37         delete this;
    38     }
    39 }
    41 void RefCountObjectBindingPointer::set(RefCountObject *newObject)
    42 {
    43     // addRef first in case newObject == mObject and this is the last reference to it.
    44     if (newObject != NULL) newObject->addRef();
    45     if (mObject != NULL) mObject->release();
    47     mObject = newObject;
    48 }

mercurial