GrGLStencilAttachment.cpp 1.3 KB

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