GrBuffer.h 934 B

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