blob: b6dfbb551d57ab1c5f50ed94c0af184432ebf973 [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"
jvanverth39edf762014-12-22 11:44:19 -080010#include "GrGLGpu.h"
bsalomon@google.com0b77d682011-08-19 13:28:54 +000011
bsalomon69ed47f2014-11-12 11:13:39 -080012size_t GrGLStencilBuffer::onGpuMemorySize() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000013 uint64_t size = this->width();
14 size *= this->height();
15 size *= fFormat.fTotalBits;
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +000016 size *= SkTMax(1,this->numSamples());
bsalomon@google.com0b77d682011-08-19 13:28:54 +000017 return static_cast<size_t>(size / 8);
18}
19
20void GrGLStencilBuffer::onRelease() {
bsalomon@google.com72830222013-01-23 20:25:22 +000021 if (0 != fRenderbufferID && !this->isWrapped()) {
bsalomon861e1032014-12-16 07:33:49 -080022 GrGLGpu* gpuGL = (GrGLGpu*) this->getGpu();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000023 const GrGLInterface* gl = gpuGL->glInterface();
24 GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
25 fRenderbufferID = 0;
26 }
robertphillips@google.comd3645542012-09-05 18:37:39 +000027
28 INHERITED::onRelease();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000029}
30
31void GrGLStencilBuffer::onAbandon() {
32 fRenderbufferID = 0;
robertphillips@google.comd3645542012-09-05 18:37:39 +000033
34 INHERITED::onAbandon();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000035}