blob: 6a90d0334c79b78b75b484f879549baa9a16caf9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGLBuffer_DEFINED
#define GrGLBuffer_DEFINED
#include "GrBuffer.h"
#include "gl/GrGLTypes.h"
class GrGLGpu;
class GrGLCaps;
class GrGLBuffer : public GrBuffer {
public:
static GrGLBuffer* Create(GrGLGpu*, size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data = nullptr);
~GrGLBuffer() {
// either release or abandon should have been called by the owner of this object.
SkASSERT(0 == fBufferID);
}
GrGLuint bufferID() const { return fBufferID; }
/**
* Returns the actual size of the underlying GL buffer object. In certain cases we may make this
* smaller than the size reported by GrBuffer.
*/
size_t glSizeInBytes() const { return fGLSizeInBytes; }
void setHasAttachedToTexture() { fHasAttachedToTexture = true; }
bool hasAttachedToTexture() const { return fHasAttachedToTexture; }
protected:
GrGLBuffer(GrGLGpu*, size_t size, GrBufferType intendedType, GrAccessPattern, const void* data);
void onAbandon() override;
void onRelease() override;
void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
const SkString& dumpName) const override;
private:
GrGLGpu* glGpu() const;
const GrGLCaps& glCaps() const;
void onMap() override;
void onUnmap() override;
bool onUpdateData(const void* src, size_t srcSizeInBytes) override;
#ifdef SK_DEBUG
void validate() const;
#endif
GrBufferType fIntendedType;
GrGLuint fBufferID;
GrGLenum fUsage;
size_t fGLSizeInBytes;
bool fHasAttachedToTexture;
typedef GrBuffer INHERITED;
};
#endif
|