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 "include/core/SkTraceMemoryDump.h"
10#include "src/gpu/gl/GrGLGpu.h"
11#include "src/gpu/gl/GrGLStencilAttachment.h"
12
13size_t GrGLStencilAttachment::onGpuMemorySize() const {
14 uint64_t size = this->width();
15 size *= this->height();
16 size *= fFormat.fTotalBits;
17 size *= this->numSamples();
18 return static_cast<size_t>(size / 8);
19}
20
21void GrGLStencilAttachment::onRelease() {
22 if (0 != fRenderbufferID) {
23 GrGLGpu* gpuGL = (GrGLGpu*) this->getGpu();
24 const GrGLInterface* gl = gpuGL->glInterface();
25 GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
26 fRenderbufferID = 0;
27 }
28
29 INHERITED::onRelease();
30}
31
32void GrGLStencilAttachment::onAbandon() {
33 fRenderbufferID = 0;
34
35 INHERITED::onAbandon();
36}
37
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}
45