| bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 1 | /* | 
|  | 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 |  | 
|  | 12 | GrGLStencilBuffer::~GrGLStencilBuffer() { | 
|  | 13 | this->release(); | 
|  | 14 | } | 
|  | 15 |  | 
|  | 16 | size_t GrGLStencilBuffer::sizeInBytes() const { | 
|  | 17 | uint64_t size = this->width(); | 
|  | 18 | size *= this->height(); | 
|  | 19 | size *= fFormat.fTotalBits; | 
|  | 20 | size *= GrMax(1,this->numSamples()); | 
|  | 21 | return static_cast<size_t>(size / 8); | 
|  | 22 | } | 
|  | 23 |  | 
|  | 24 | void GrGLStencilBuffer::onRelease() { | 
| bsalomon@google.com | 7283022 | 2013-01-23 20:25:22 +0000 | [diff] [blame] | 25 | if (0 != fRenderbufferID && !this->isWrapped()) { | 
| bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 26 | 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.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 31 |  | 
|  | 32 | INHERITED::onRelease(); | 
| bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 33 | } | 
|  | 34 |  | 
|  | 35 | void GrGLStencilBuffer::onAbandon() { | 
|  | 36 | fRenderbufferID = 0; | 
| robertphillips@google.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 37 |  | 
|  | 38 | INHERITED::onAbandon(); | 
| bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 39 | } |