blob: 8c032a0ef744a5aa7083569fc4e96c8d5f03d4d8 [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
Greg Danielc0d69152020-10-08 14:59:00 -04008#include "src/gpu/gl/GrGLAttachment.h"
bsalomon@google.com0b77d682011-08-19 13:28:54 +00009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkTraceMemoryDump.h"
11#include "src/gpu/gl/GrGLGpu.h"
bsalomon@google.com0b77d682011-08-19 13:28:54 +000012
Greg Danielc0d69152020-10-08 14:59:00 -040013void GrGLAttachment::onRelease() {
kkinnunen2e6055b2016-04-22 01:48:29 -070014 if (0 != fRenderbufferID) {
Greg Danielc0d69152020-10-08 14:59:00 -040015 GrGLGpu* gpuGL = (GrGLGpu*)this->getGpu();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000016 const GrGLInterface* gl = gpuGL->glInterface();
17 GR_GL_CALL(gl, DeleteRenderbuffers(1, &fRenderbufferID));
18 fRenderbufferID = 0;
19 }
robertphillips@google.comd3645542012-09-05 18:37:39 +000020
21 INHERITED::onRelease();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000022}
23
Greg Danielc0d69152020-10-08 14:59:00 -040024void GrGLAttachment::onAbandon() {
bsalomon@google.com0b77d682011-08-19 13:28:54 +000025 fRenderbufferID = 0;
robertphillips@google.comd3645542012-09-05 18:37:39 +000026
27 INHERITED::onAbandon();
bsalomon@google.com0b77d682011-08-19 13:28:54 +000028}
ericrk0a5fa482015-09-15 14:16:10 -070029
Greg Danielc0d69152020-10-08 14:59:00 -040030GrBackendFormat GrGLAttachment::backendFormat() const {
Greg Daniel8ade5e82020-10-07 13:09:48 -040031 return GrBackendFormat::MakeGL(GrGLFormatToEnum(fFormat), GR_GL_TEXTURE_NONE);
Greg Daniele77162e2020-09-21 15:32:11 -040032}
33
Greg Danielc0d69152020-10-08 14:59:00 -040034void GrGLAttachment::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
35 const SkString& dumpName) const {
ericrk0a5fa482015-09-15 14:16:10 -070036 SkString renderbuffer_id;
37 renderbuffer_id.appendU32(this->renderbufferID());
Greg Danielc0d69152020-10-08 14:59:00 -040038 traceMemoryDump->setMemoryBacking(dumpName.c_str(), "gl_renderbuffer", renderbuffer_id.c_str());
ericrk0a5fa482015-09-15 14:16:10 -070039}