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" |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 10 | #include "GrGLGpu.h" |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 11 | |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 12 | size_t GrGLStencilBuffer::onGpuMemorySize() const { |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 13 | uint64_t size = this->width(); |
| 14 | size *= this->height(); |
| 15 | size *= fFormat.fTotalBits; |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 16 | size *= SkTMax(1,this->numSamples()); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 17 | return static_cast<size_t>(size / 8); |
| 18 | } |
| 19 | |
| 20 | void GrGLStencilBuffer::onRelease() { |
bsalomon@google.com | 7283022 | 2013-01-23 20:25:22 +0000 | [diff] [blame] | 21 | if (0 != fRenderbufferID && !this->isWrapped()) { |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 22 | GrGLGpu* gpuGL = (GrGLGpu*) this->getGpu(); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 23 | const GrGLInterface* gl = gpuGL->glInterface(); |
| 24 | GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID)); |
| 25 | fRenderbufferID = 0; |
| 26 | } |
robertphillips@google.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 27 | |
| 28 | INHERITED::onRelease(); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | void GrGLStencilBuffer::onAbandon() { |
| 32 | fRenderbufferID = 0; |
robertphillips@google.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 33 | |
| 34 | INHERITED::onAbandon(); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 35 | } |