Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / gl / GrGLBuffer.h
1 /*
2  * Copyright 2016 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 #ifndef GrGLBuffer_DEFINED
9 #define GrGLBuffer_DEFINED
10
11 #include "include/gpu/gl/GrGLTypes.h"
12 #include "src/gpu/ganesh/GrGpuBuffer.h"
13
14 class GrGLGpu;
15 class GrGLCaps;
16
17 class GrGLBuffer : public GrGpuBuffer {
18 public:
19     static sk_sp<GrGLBuffer> Make(GrGLGpu*, size_t size, GrGpuBufferType intendedType,
20                                   GrAccessPattern, const void* data = nullptr);
21
22     ~GrGLBuffer() override {
23         // either release or abandon should have been called by the owner of this object.
24         SkASSERT(0 == fBufferID);
25     }
26
27     GrGLuint bufferID() const { return fBufferID; }
28
29     /**
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.
32      */
33     size_t glSizeInBytes() const { return fGLSizeInBytes; }
34
35     void setHasAttachedToTexture() { fHasAttachedToTexture = true; }
36     bool hasAttachedToTexture() const { return fHasAttachedToTexture; }
37
38 protected:
39     GrGLBuffer(GrGLGpu*,
40                size_t size,
41                GrGpuBufferType intendedType,
42                GrAccessPattern,
43                const void* data,
44                std::string_view label);
45
46     void onAbandon() override;
47     void onRelease() override;
48     void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
49                           const SkString& dumpName) const override;
50
51 private:
52     GrGLGpu* glGpu() const;
53     const GrGLCaps& glCaps() const;
54
55     void onMap() override;
56     void onUnmap() override;
57     bool onUpdateData(const void* src, size_t srcSizeInBytes) override;
58
59 #ifdef SK_DEBUG
60     void validate() const;
61 #endif
62
63     GrGpuBufferType fIntendedType;
64     GrGLuint        fBufferID;
65     GrGLenum        fUsage;
66     size_t          fGLSizeInBytes;
67     bool            fHasAttachedToTexture;
68
69     using INHERITED = GrGpuBuffer;
70 };
71
72 #endif