blob: abcb3c4ba01c75c784b03bb9933cbe6d80978993 [file] [log] [blame]
bsalomon@google.com0b77d682011-08-19 13:28:54 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9#include "GrGLStencilBuffer.h"
10#include "GrGpuGL.h"
11
12GrGLStencilBuffer::~GrGLStencilBuffer() {
13 this->release();
14}
15
commit-bot@chromium.org089a7802014-05-02 21:38:22 +000016size_t GrGLStencilBuffer::gpuMemorySize() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000017 uint64_t size = this->width();
18 size *= this->height();
19 size *= fFormat.fTotalBits;
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +000020 size *= SkTMax(1,this->numSamples());
bsalomon@google.com0b77d682011-08-19 13:28:54 +000021 return static_cast<size_t>(size / 8);
22}
23
24void GrGLStencilBuffer::onRelease() {
bsalomon@google.com72830222013-01-23 20:25:22 +000025 if (0 != fRenderbufferID && !this->isWrapped()) {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000026 GrGpuGL* gpuGL = (GrGpuGL*) this->getGpu();
27 const GrGLInterface* gl = gpuGL->glInterface();
28 GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
29 fRenderbufferID = 0;
30 }
robertphillips@google.comd3645542012-09-05 18:37:39 +000031
32 INHERITED::onRelease();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000033}
34
35void GrGLStencilBuffer::onAbandon() {
36 fRenderbufferID = 0;
robertphillips@google.comd3645542012-09-05 18:37:39 +000037
38 INHERITED::onAbandon();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000039}