2 * Copyright 2016 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrGLBuffer_DEFINED
9 #define GrGLBuffer_DEFINED
11 #include "include/gpu/gl/GrGLTypes.h"
12 #include "src/gpu/ganesh/GrGpuBuffer.h"
17 class GrGLBuffer : public GrGpuBuffer {
19 static sk_sp<GrGLBuffer> Make(GrGLGpu*, size_t size, GrGpuBufferType intendedType,
20 GrAccessPattern, const void* data = nullptr);
22 ~GrGLBuffer() override {
23 // either release or abandon should have been called by the owner of this object.
24 SkASSERT(0 == fBufferID);
27 GrGLuint bufferID() const { return fBufferID; }
30 * Returns the actual size of the underlying GL buffer object. In certain cases we may make this
31 * smaller than the size reported by GrGpuBuffer.
33 size_t glSizeInBytes() const { return fGLSizeInBytes; }
35 void setHasAttachedToTexture() { fHasAttachedToTexture = true; }
36 bool hasAttachedToTexture() const { return fHasAttachedToTexture; }
41 GrGpuBufferType intendedType,
44 std::string_view label);
46 void onAbandon() override;
47 void onRelease() override;
48 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
49 const SkString& dumpName) const override;
52 GrGLGpu* glGpu() const;
53 const GrGLCaps& glCaps() const;
55 void onMap() override;
56 void onUnmap() override;
57 bool onUpdateData(const void* src, size_t srcSizeInBytes) override;
60 void validate() const;
63 GrGpuBufferType fIntendedType;
66 size_t fGLSizeInBytes;
67 bool fHasAttachedToTexture;
69 using INHERITED = GrGpuBuffer;