michael@0: michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "GrFrameBufferObj.h" michael@0: #include "GrFBBindableObj.h" michael@0: michael@0: void GrFrameBufferObj::setColor(GrFBBindableObj *buffer) { michael@0: if (fColorBuffer) { michael@0: // automatically break the binding of the old buffer michael@0: GrAlwaysAssert(fColorBuffer->getColorBound(this)); michael@0: fColorBuffer->resetColorBound(this); michael@0: michael@0: GrAlwaysAssert(!fColorBuffer->getDeleted()); michael@0: fColorBuffer->unref(); michael@0: } michael@0: fColorBuffer = buffer; michael@0: if (fColorBuffer) { michael@0: GrAlwaysAssert(!fColorBuffer->getDeleted()); michael@0: fColorBuffer->ref(); michael@0: michael@0: GrAlwaysAssert(!fColorBuffer->getColorBound(this)); michael@0: fColorBuffer->setColorBound(this); michael@0: } michael@0: } michael@0: michael@0: void GrFrameBufferObj::setDepth(GrFBBindableObj *buffer) { michael@0: if (fDepthBuffer) { michael@0: // automatically break the binding of the old buffer michael@0: GrAlwaysAssert(fDepthBuffer->getDepthBound(this)); michael@0: fDepthBuffer->resetDepthBound(this); michael@0: michael@0: GrAlwaysAssert(!fDepthBuffer->getDeleted()); michael@0: fDepthBuffer->unref(); michael@0: } michael@0: fDepthBuffer = buffer; michael@0: if (fDepthBuffer) { michael@0: GrAlwaysAssert(!fDepthBuffer->getDeleted()); michael@0: fDepthBuffer->ref(); michael@0: michael@0: GrAlwaysAssert(!fDepthBuffer->getDepthBound(this)); michael@0: fDepthBuffer->setDepthBound(this); michael@0: } michael@0: } michael@0: michael@0: void GrFrameBufferObj::setStencil(GrFBBindableObj *buffer) { michael@0: if (fStencilBuffer) { michael@0: // automatically break the binding of the old buffer michael@0: GrAlwaysAssert(fStencilBuffer->getStencilBound(this)); michael@0: fStencilBuffer->resetStencilBound(this); michael@0: michael@0: //GrAlwaysAssert(!fStencilBuffer->getDeleted()); michael@0: fStencilBuffer->unref(); michael@0: } michael@0: fStencilBuffer = buffer; michael@0: if (fStencilBuffer) { michael@0: GrAlwaysAssert(!fStencilBuffer->getDeleted()); michael@0: fStencilBuffer->ref(); michael@0: michael@0: GrAlwaysAssert(!fStencilBuffer->getStencilBound(this)); michael@0: fStencilBuffer->setStencilBound(this); michael@0: } michael@0: }