1
2/*
3 * Copyright 2011 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
10#include "GrGLStencilBuffer.h"
11#include "GrGpuGL.h"
12
13GrGLStencilBuffer::~GrGLStencilBuffer() {
14    this->release();
15}
16
17size_t GrGLStencilBuffer::sizeInBytes() const {
18    uint64_t size = this->width();
19    size *= this->height();
20    size *= fFormat.fTotalBits;
21    size *= GrMax(1,this->numSamples());
22    return static_cast<size_t>(size / 8);
23}
24
25void GrGLStencilBuffer::onRelease() {
26    if (0 != fRenderbufferID) {
27        GrGpuGL* gpuGL = (GrGpuGL*) this->getGpu();
28        const GrGLInterface* gl = gpuGL->glInterface();
29        GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
30        fRenderbufferID = 0;
31    }
32    INHERITED::onRelease();
33}
34
35void GrGLStencilBuffer::onAbandon() {
36    fRenderbufferID = 0;
37    INHERITED::onAbandon();
38}
39
40
41