~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/ThirdParty/ANGLE/src/common/RefCountObject.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

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