summaryrefslogtreecommitdiff
path: root/cros_gralloc/cros_gralloc_buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'cros_gralloc/cros_gralloc_buffer.h')
-rw-r--r--cros_gralloc/cros_gralloc_buffer.h35
1 files changed, 23 insertions, 12 deletions
diff --git a/cros_gralloc/cros_gralloc_buffer.h b/cros_gralloc/cros_gralloc_buffer.h
index 9bc0ef0..21f8306 100644
--- a/cros_gralloc/cros_gralloc_buffer.h
+++ b/cros_gralloc/cros_gralloc_buffer.h
@@ -7,18 +7,30 @@
#ifndef CROS_GRALLOC_BUFFER_H
#define CROS_GRALLOC_BUFFER_H
-#include "../drv.h"
+#include <memory>
+
#include "cros_gralloc_helpers.h"
class cros_gralloc_buffer
{
public:
- cros_gralloc_buffer(uint32_t id, struct bo *acquire_bo,
- struct cros_gralloc_handle *acquire_handle, int32_t reserved_region_fd,
- uint64_t reserved_region_size);
+ static std::unique_ptr<cros_gralloc_buffer>
+ create(struct bo *acquire_bo, const struct cros_gralloc_handle *borrowed_handle);
+
~cros_gralloc_buffer();
uint32_t get_id() const;
+ uint32_t get_width() const;
+ uint32_t get_height() const;
+ uint32_t get_format() const;
+ uint64_t get_format_modifier() const;
+ uint64_t get_total_size() const;
+ uint32_t get_num_planes() const;
+ uint32_t get_plane_offset(uint32_t plane) const;
+ uint32_t get_plane_stride(uint32_t plane) const;
+ uint32_t get_plane_size(uint32_t plane) const;
+ int32_t get_android_format() const;
+ uint64_t get_android_usage() const;
/* The new reference count is returned by both these functions. */
int32_t increase_refcount();
@@ -33,28 +45,27 @@ class cros_gralloc_buffer
int32_t invalidate();
int32_t flush();
- int32_t get_reserved_region(void **reserved_region_addr, uint64_t *reserved_region_size);
+ int32_t get_reserved_region(void **reserved_region_addr,
+ uint64_t *reserved_region_size) const;
private:
+ cros_gralloc_buffer(struct bo *acquire_bo, struct cros_gralloc_handle *acquire_handle);
+
cros_gralloc_buffer(cros_gralloc_buffer const &);
cros_gralloc_buffer operator=(cros_gralloc_buffer const &);
- uint32_t id_;
struct bo *bo_;
/* Note: this will be nullptr for imported/retained buffers. */
struct cros_gralloc_handle *hnd_;
- int32_t refcount_;
- int32_t lockcount_;
- uint32_t num_planes_;
+ int32_t refcount_ = 1;
+ int32_t lockcount_ = 0;
struct mapping *lock_data_[DRV_MAX_PLANES];
/* Optional additional shared memory region attached to some gralloc buffers. */
- int32_t reserved_region_fd_;
- uint64_t reserved_region_size_;
- void *reserved_region_addr_;
+ mutable void *reserved_region_addr_ = nullptr;
};
#endif