• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 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 GrDawnRingBuffer_DEFINED
9 #define GrDawnRingBuffer_DEFINED
10 
11 #include "src/gpu/ganesh/dawn/GrDawnBuffer.h"
12 
13 class GrDawnGpu;
14 
15 class GrDawnRingBuffer : public SkRefCnt {
16 public:
17     GrDawnRingBuffer(GrDawnGpu* gpu, wgpu::BufferUsage usage);
18     ~GrDawnRingBuffer() override;
19 
20     struct Slice {
SliceSlice21         Slice(wgpu::Buffer buffer, int offset)
22           : fBuffer(buffer), fOffset(offset) {}
SliceSlice23         Slice()
24           : fBuffer(nullptr), fOffset(0) {}
SliceSlice25         Slice(const Slice& other)
26           : fBuffer(other.fBuffer), fOffset(other.fOffset) {}
27         Slice& operator=(const Slice& other) {
28             fBuffer = other.fBuffer;
29             fOffset = other.fOffset;
30             return *this;
31         }
32         wgpu::Buffer fBuffer;
33         int          fOffset;
34     };
35     Slice allocate(int size);
36 
37 private:
38     GrDawnGpu*            fGpu;
39     wgpu::BufferUsage     fUsage;
40     wgpu::Buffer          fBuffer;
41     int                   fOffset = 0;
42 };
43 
44 #endif
45