blob: cc710c73bd29d8e83082d798b731a6595ac30660 [file] [log] [blame]
cdalton397536c2016-03-25 12:15:03 -07001/*
Brian Salomondbf70722019-02-07 11:31:24 -05002 * Copyright 2019 Google Inc.
cdalton397536c2016-03-25 12:15:03 -07003 *
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
Brian Salomondbf70722019-02-07 11:31:24 -050011#include "GrTypes.h"
cdalton397536c2016-03-25 12:15:03 -070012
Brian Salomondbf70722019-02-07 11:31:24 -050013/** Base class for a GPU buffer object or a client side arrays. */
14class GrBuffer {
cdalton397536c2016-03-25 12:15:03 -070015public:
Brian Salomondbf70722019-02-07 11:31:24 -050016 GrBuffer(const GrBuffer&) = delete;
17 GrBuffer& operator=(const GrBuffer&) = delete;
csmartdalton485a1202016-07-13 10:16:32 -070018
Brian Salomondbf70722019-02-07 11:31:24 -050019 virtual ~GrBuffer() = default;
cdalton397536c2016-03-25 12:15:03 -070020
Brian Salomondbf70722019-02-07 11:31:24 -050021 // 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;
cdalton397536c2016-03-25 12:15:03 -070025
Brian Salomondbf70722019-02-07 11:31:24 -050026 /** Size of the buffer in bytes. */
27 virtual size_t size() const = 0;
cdalton397536c2016-03-25 12:15:03 -070028
Brian Salomondbf70722019-02-07 11:31:24 -050029 /** Is this an instance of GrCpuBuffer? Otherwise, an instance of GrGpuBuffer. */
30 virtual bool isCpuBuffer() const = 0;
kkinnunen2e6055b2016-04-22 01:48:29 -070031
csmartdalton485a1202016-07-13 10:16:32 -070032protected:
Brian Salomondbf70722019-02-07 11:31:24 -050033 GrBuffer() = default;
cdalton397536c2016-03-25 12:15:03 -070034};
35
36#endif