180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2012 Google Inc. 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrFrameBufferObj.h" 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrFBBindableObj.h" 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid GrFrameBufferObj::setColor(GrFBBindableObj *buffer) { 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fColorBuffer) { 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // automatically break the binding of the old buffer 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(fColorBuffer->getColorBound(this)); 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fColorBuffer->resetColorBound(this); 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fColorBuffer->getDeleted()); 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fColorBuffer->unref(); 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fColorBuffer = buffer; 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fColorBuffer) { 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fColorBuffer->getDeleted()); 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fColorBuffer->ref(); 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fColorBuffer->getColorBound(this)); 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fColorBuffer->setColorBound(this); 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid GrFrameBufferObj::setDepth(GrFBBindableObj *buffer) { 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fDepthBuffer) { 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // automatically break the binding of the old buffer 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(fDepthBuffer->getDepthBound(this)); 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fDepthBuffer->resetDepthBound(this); 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fDepthBuffer->getDeleted()); 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fDepthBuffer->unref(); 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fDepthBuffer = buffer; 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fDepthBuffer) { 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fDepthBuffer->getDeleted()); 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fDepthBuffer->ref(); 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fDepthBuffer->getDepthBound(this)); 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fDepthBuffer->setDepthBound(this); 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid GrFrameBufferObj::setStencil(GrFBBindableObj *buffer) { 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fStencilBuffer) { 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru // automatically break the binding of the old buffer 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(fStencilBuffer->getStencilBound(this)); 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fStencilBuffer->resetStencilBound(this); 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger //GrAlwaysAssert(!fStencilBuffer->getDeleted()); 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fStencilBuffer->unref(); 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fStencilBuffer = buffer; 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fStencilBuffer) { 6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fStencilBuffer->getDeleted()); 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fStencilBuffer->ref(); 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru GrAlwaysAssert(!fStencilBuffer->getStencilBound(this)); 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fStencilBuffer->setStencilBound(this); 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 68