gralloc: support codec2 via GraphicBufferAllocator/Mapper
Codec2 is moving to GraphicBufferAllocator/Mapper. This patch
cleans up GBA/M so codec2 can use it.
- Since the graphic buffer id isn't used by GBA/M, deprecate
the old allocate function.
- Include Rect so clients aren't required to include Rect.
Bug: 145139476
Test: Cherry pick ag/9741096 and run
android.media.cts.MediaMetadataRetrieverTest#testThumbnailVP9Hdr
Change-Id: I3c0a03b771423f23741731e725a2846709ffc5da
diff --git a/libs/ui/GraphicBufferAllocator.cpp b/libs/ui/GraphicBufferAllocator.cpp
index fcc2547..efe0931 100644
--- a/libs/ui/GraphicBufferAllocator.cpp
+++ b/libs/ui/GraphicBufferAllocator.cpp
@@ -111,11 +111,10 @@
ALOGD("%s", s.c_str());
}
-status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height,
- PixelFormat format, uint32_t layerCount, uint64_t usage,
- buffer_handle_t* handle, uint32_t* stride,
- uint64_t /*graphicBufferId*/, std::string requestorName)
-{
+status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format,
+ uint32_t layerCount, uint64_t usage,
+ buffer_handle_t* handle, uint32_t* stride,
+ std::string requestorName) {
ATRACE_CALL();
// make sure to not allocate a N x 0 or 0 x N buffer, since this is
@@ -175,6 +174,13 @@
}
}
+status_t GraphicBufferAllocator::allocate(uint32_t width, uint32_t height, PixelFormat format,
+ uint32_t layerCount, uint64_t usage,
+ buffer_handle_t* handle, uint32_t* stride,
+ uint64_t /*graphicBufferId*/, std::string requestorName) {
+ return allocate(width, height, format, layerCount, usage, handle, stride, requestorName);
+}
+
status_t GraphicBufferAllocator::free(buffer_handle_t handle)
{
ATRACE_CALL();
diff --git a/libs/ui/include/ui/GraphicBufferAllocator.h b/libs/ui/include/ui/GraphicBufferAllocator.h
index 324d9e1..9f6159a 100644
--- a/libs/ui/include/ui/GraphicBufferAllocator.h
+++ b/libs/ui/include/ui/GraphicBufferAllocator.h
@@ -42,11 +42,16 @@
public:
static inline GraphicBufferAllocator& get() { return getInstance(); }
+ // DEPRECATED: GraphicBufferAllocator does not use the graphicBufferId
status_t allocate(uint32_t w, uint32_t h, PixelFormat format,
uint32_t layerCount, uint64_t usage,
buffer_handle_t* handle, uint32_t* stride, uint64_t graphicBufferId,
std::string requestorName);
+ status_t allocate(uint32_t w, uint32_t h, PixelFormat format, uint32_t layerCount,
+ uint64_t usage, buffer_handle_t* handle, uint32_t* stride,
+ std::string requestorName);
+
status_t free(buffer_handle_t handle);
size_t getTotalSize() const;
diff --git a/libs/ui/include/ui/GraphicBufferMapper.h b/libs/ui/include/ui/GraphicBufferMapper.h
index c401a48..83fb144 100644
--- a/libs/ui/include/ui/GraphicBufferMapper.h
+++ b/libs/ui/include/ui/GraphicBufferMapper.h
@@ -23,6 +23,7 @@
#include <memory>
#include <ui/PixelFormat.h>
+#include <ui/Rect.h>
#include <utils/Singleton.h>
@@ -36,7 +37,6 @@
// ---------------------------------------------------------------------------
class GrallocMapper;
-class Rect;
class GraphicBufferMapper : public Singleton<GraphicBufferMapper>
{