blob: aa813ed50edee1fb940302ca79c29356f7f95ea5 [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
egdaniel8dc7c3a2015-04-16 11:22:42 -07009#include "GrGLStencilAttachment.h"
jvanverth39edf762014-12-22 11:44:19 -080010#include "GrGLGpu.h"
ericrk0a5fa482015-09-15 14:16:10 -070011#include "SkTraceMemoryDump.h"
bsalomon@google.com0b77d682011-08-19 13:28:54 +000012
egdaniel8dc7c3a2015-04-16 11:22:42 -070013size_t GrGLStencilAttachment::onGpuMemorySize() const {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000014 uint64_t size = this->width();
15 size *= this->height();
16 size *= fFormat.fTotalBits;
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +000017 size *= SkTMax(1,this->numSamples());
bsalomon@google.com0b77d682011-08-19 13:28:54 +000018 return static_cast<size_t>(size / 8);
19}
20
egdaniel8dc7c3a2015-04-16 11:22:42 -070021void GrGLStencilAttachment::onRelease() {
kkinnunen2e6055b2016-04-22 01:48:29 -070022 if (0 != fRenderbufferID) {
bsalomon861e1032014-12-16 07:33:49 -080023 GrGLGpu* gpuGL = (GrGLGpu*) this->getGpu();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000024 const GrGLInterface* gl = gpuGL->glInterface();
25 GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
26 fRenderbufferID = 0;
27 }
robertphillips@google.comd3645542012-09-05 18:37:39 +000028
29 INHERITED::onRelease();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000030}
31
egdaniel8dc7c3a2015-04-16 11:22:42 -070032void GrGLStencilAttachment::onAbandon() {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000033 fRenderbufferID = 0;
robertphillips@google.comd3645542012-09-05 18:37:39 +000034
35 INHERITED::onAbandon();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000036}
ericrk0a5fa482015-09-15 14:16:10 -070037
38void 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}