summaryrefslogtreecommitdiff
path: root/gpu/gl/debug/GrFrameBufferObj.cpp
blob: 7dc12acafbc08674a7eb62b90573da42532c56d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "GrFrameBufferObj.h"
#include "GrFBBindableObj.h"

void GrFrameBufferObj::setColor(GrFBBindableObj *buffer) {
    if (fColorBuffer) {
        // automatically break the binding of the old buffer
        GrAlwaysAssert(fColorBuffer->getColorBound(this));
        fColorBuffer->resetColorBound(this);

        GrAlwaysAssert(!fColorBuffer->getDeleted());
        fColorBuffer->unref();
    }
    fColorBuffer = buffer;
    if (fColorBuffer) {
        GrAlwaysAssert(!fColorBuffer->getDeleted());
        fColorBuffer->ref();

        GrAlwaysAssert(!fColorBuffer->getColorBound(this));
        fColorBuffer->setColorBound(this);
    }
}

void GrFrameBufferObj::setDepth(GrFBBindableObj *buffer) {
    if (fDepthBuffer) {
        // automatically break the binding of the old buffer
        GrAlwaysAssert(fDepthBuffer->getDepthBound(this));
        fDepthBuffer->resetDepthBound(this);

        GrAlwaysAssert(!fDepthBuffer->getDeleted());
        fDepthBuffer->unref();
    }
    fDepthBuffer = buffer;
    if (fDepthBuffer) {
        GrAlwaysAssert(!fDepthBuffer->getDeleted());
        fDepthBuffer->ref();

        GrAlwaysAssert(!fDepthBuffer->getDepthBound(this));
        fDepthBuffer->setDepthBound(this);
    }
}

void GrFrameBufferObj::setStencil(GrFBBindableObj *buffer) {
    if (fStencilBuffer) {
        // automatically break the binding of the old buffer
        GrAlwaysAssert(fStencilBuffer->getStencilBound(this));
        fStencilBuffer->resetStencilBound(this);

        //GrAlwaysAssert(!fStencilBuffer->getDeleted());
        fStencilBuffer->unref();
    }
    fStencilBuffer = buffer;
    if (fStencilBuffer) {
        GrAlwaysAssert(!fStencilBuffer->getDeleted());
        fStencilBuffer->ref();

        GrAlwaysAssert(!fStencilBuffer->getStencilBound(this));
        fStencilBuffer->setStencilBound(this);
    }
}