| 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 GrBuffer_DEFINED | 
|---|
| 9 | #define GrBuffer_DEFINED | 
|---|
| 10 |  | 
|---|
| 11 | #include "include/gpu/GrTypes.h" | 
|---|
| 12 |  | 
|---|
| 13 | /** Base class for a GPU buffer object or a client side arrays. */ | 
|---|
| 14 | class GrBuffer { | 
|---|
| 15 | public: | 
|---|
| 16 | GrBuffer(const GrBuffer&) = delete; | 
|---|
| 17 | GrBuffer& operator=(const GrBuffer&) = delete; | 
|---|
| 18 |  | 
|---|
| 19 | virtual ~GrBuffer() = default; | 
|---|
| 20 |  | 
|---|
| 21 | // Our subclasses derive from different ref counting base classes. In order to use base | 
|---|
| 22 | // class pointers with sk_sp we virtualize ref() and unref(). | 
|---|
| 23 | virtual void ref() const = 0; | 
|---|
| 24 | virtual void unref() const = 0; | 
|---|
| 25 |  | 
|---|
| 26 | /** Size of the buffer in bytes. */ | 
|---|
| 27 | virtual size_t size() const = 0; | 
|---|
| 28 |  | 
|---|
| 29 | /** Is this an instance of GrCpuBuffer? Otherwise, an instance of GrGpuBuffer. */ | 
|---|
| 30 | virtual bool isCpuBuffer() const = 0; | 
|---|
| 31 |  | 
|---|
| 32 | protected: | 
|---|
| 33 | GrBuffer() = default; | 
|---|
| 34 | }; | 
|---|
| 35 |  | 
|---|
| 36 | #endif | 
|---|
| 37 |  | 
|---|