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 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 9 | #include "GrGLStencilAttachment.h" |
jvanverth | 39edf76 | 2014-12-22 11:44:19 -0800 | [diff] [blame] | 10 | #include "GrGLGpu.h" |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 11 | #include "SkTraceMemoryDump.h" |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 12 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 13 | size_t GrGLStencilAttachment::onGpuMemorySize() const { |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 14 | uint64_t size = this->width(); |
| 15 | size *= this->height(); |
| 16 | size *= fFormat.fTotalBits; |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 17 | size *= SkTMax(1,this->numSamples()); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 18 | return static_cast<size_t>(size / 8); |
| 19 | } |
| 20 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 21 | void GrGLStencilAttachment::onRelease() { |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 22 | if (0 != fRenderbufferID) { |
bsalomon | 861e103 | 2014-12-16 07:33:49 -0800 | [diff] [blame] | 23 | GrGLGpu* gpuGL = (GrGLGpu*) this->getGpu(); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 24 | const GrGLInterface* gl = gpuGL->glInterface(); |
| 25 | GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID)); |
| 26 | fRenderbufferID = 0; |
| 27 | } |
robertphillips@google.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 28 | |
| 29 | INHERITED::onRelease(); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 30 | } |
| 31 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 32 | void GrGLStencilAttachment::onAbandon() { |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 33 | fRenderbufferID = 0; |
robertphillips@google.com | d364554 | 2012-09-05 18:37:39 +0000 | [diff] [blame] | 34 | |
| 35 | INHERITED::onAbandon(); |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 36 | } |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 37 | |
| 38 | void GrGLStencilAttachment::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 39 | const SkString& dumpName) const { |
| 40 | SkString renderbuffer_id; |
| 41 | renderbuffer_id.appendU32(this->renderbufferID()); |
| 42 | traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_renderbuffer", |
| 43 | renderbuffer_id.c_str()); |
| 44 | } |