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 "GrProgramObj.h"
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrShaderObj.h"
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid GrProgramObj::AttachShader(GrShaderObj *shader) {
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    shader->ref();
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fShaders.push_back(shader);
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid GrProgramObj::deleteAction() {
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // shaders are automatically detached from a deleted program. They will only be
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // deleted if they were marked for deletion by a prior call to glDeleteShader
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (int i = 0; i < fShaders.count(); ++i) {
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fShaders[i]->unref();
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    fShaders.reset();
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    this->INHERITED::deleteAction();
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
28