blob: 7dc12acafbc08674a7eb62b90573da42532c56d5 [file] [log] [blame]
robertphillips@google.comdd743fe2012-04-05 14:40:53 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#include "GrFrameBufferObj.h"
10#include "GrFBBindableObj.h"
11
12void GrFrameBufferObj::setColor(GrFBBindableObj *buffer) {
13 if (fColorBuffer) {
14 // automatically break the binding of the old buffer
15 GrAlwaysAssert(fColorBuffer->getColorBound(this));
16 fColorBuffer->resetColorBound(this);
17
18 GrAlwaysAssert(!fColorBuffer->getDeleted());
19 fColorBuffer->unref();
20 }
21 fColorBuffer = buffer;
22 if (fColorBuffer) {
23 GrAlwaysAssert(!fColorBuffer->getDeleted());
24 fColorBuffer->ref();
25
26 GrAlwaysAssert(!fColorBuffer->getColorBound(this));
27 fColorBuffer->setColorBound(this);
28 }
29}
30
31void GrFrameBufferObj::setDepth(GrFBBindableObj *buffer) {
32 if (fDepthBuffer) {
33 // automatically break the binding of the old buffer
34 GrAlwaysAssert(fDepthBuffer->getDepthBound(this));
35 fDepthBuffer->resetDepthBound(this);
36
37 GrAlwaysAssert(!fDepthBuffer->getDeleted());
38 fDepthBuffer->unref();
39 }
40 fDepthBuffer = buffer;
41 if (fDepthBuffer) {
42 GrAlwaysAssert(!fDepthBuffer->getDeleted());
43 fDepthBuffer->ref();
44
45 GrAlwaysAssert(!fDepthBuffer->getDepthBound(this));
46 fDepthBuffer->setDepthBound(this);
47 }
48}
49
50void GrFrameBufferObj::setStencil(GrFBBindableObj *buffer) {
51 if (fStencilBuffer) {
52 // automatically break the binding of the old buffer
53 GrAlwaysAssert(fStencilBuffer->getStencilBound(this));
54 fStencilBuffer->resetStencilBound(this);
55
bsalomon@google.comeb6879f2013-06-13 19:34:18 +000056 //GrAlwaysAssert(!fStencilBuffer->getDeleted());
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000057 fStencilBuffer->unref();
58 }
59 fStencilBuffer = buffer;
60 if (fStencilBuffer) {
61 GrAlwaysAssert(!fStencilBuffer->getDeleted());
62 fStencilBuffer->ref();
63
64 GrAlwaysAssert(!fStencilBuffer->getStencilBound(this));
65 fStencilBuffer->setStencilBound(this);
66 }
caryclark@google.comcf6285b2012-06-06 12:09:01 +000067}