• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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 skgpu_Buffer_DEFINED
9 #define skgpu_Buffer_DEFINED
10 
11 #include "experimental/graphite/src/ResourceTypes.h"
12 #include "include/core/SkRefCnt.h"
13 
14 namespace skgpu {
15 
16 class Buffer : public SkRefCnt {
17 public:
size()18     size_t size() const { return fSize; }
19 
20     void* map();
21     void unmap();
22 
isMapped()23     bool isMapped() const { return fMapPtr; }
24 
25 protected:
Buffer(size_t size,BufferType type,PrioritizeGpuReads prioritizeGpuReads)26     Buffer(size_t size, BufferType type, PrioritizeGpuReads prioritizeGpuReads)
27         : fSize(size), fType(type), fPrioritizeGpuReads(prioritizeGpuReads) {}
28 
29     void* fMapPtr = nullptr;
30 
31 private:
32     virtual void onMap() = 0;
33     virtual void onUnmap() = 0;
34 
35     // TODO: Remove these getters once we start using fType and fPrioritizeGpuReads in key
36     // generation. For now this silences compiler unused member warnings.
bufferType()37     BufferType bufferType() const { return fType; }
prioritizeGpuReads()38     PrioritizeGpuReads prioritizeGpuReads() const { return fPrioritizeGpuReads; }
39 
40     size_t             fSize;
41     BufferType         fType;
42     PrioritizeGpuReads fPrioritizeGpuReads;
43 };
44 
45 } // namespace skgpu
46 
47 #endif // skgpu_Buffer_DEFINED
48 
49