Int key for the named buffers.
Also, rename them to global buffers from named buffers.
Bug: 38320428
Test: Run frameworks/native/libs/vr/libdvr/tests on device
Change-Id: I2109aea77e35f2ccd8055208058df4b7287c1d5e
diff --git a/libs/vr/libdisplay/Android.bp b/libs/vr/libdisplay/Android.bp
index d90521a..c0c7e2f 100644
--- a/libs/vr/libdisplay/Android.bp
+++ b/libs/vr/libdisplay/Android.bp
@@ -45,6 +45,7 @@
headerLibraries = [
"vulkan_headers",
+ "libdvr_headers",
]
cc_library {
diff --git a/libs/vr/libdisplay/display_client.cpp b/libs/vr/libdisplay/display_client.cpp
index 935ca2e..6e5d432 100644
--- a/libs/vr/libdisplay/display_client.cpp
+++ b/libs/vr/libdisplay/display_client.cpp
@@ -176,14 +176,14 @@
return ErrorStatus(error);
}
-Status<std::unique_ptr<IonBuffer>> DisplayClient::GetNamedBuffer(
- const std::string& name) {
- auto status = InvokeRemoteMethod<DisplayProtocol::GetNamedBuffer>(name);
+Status<std::unique_ptr<IonBuffer>> DisplayClient::GetGlobalBuffer(
+ DvrGlobalBufferKey key) {
+ auto status = InvokeRemoteMethod<DisplayProtocol::GetGlobalBuffer>(key);
if (!status) {
ALOGE(
- "DisplayClient::GetNamedBuffer: Failed to get named buffer: name=%s; "
+ "DisplayClient::GetGlobalBuffer: Failed to get named buffer: key=%d; "
"error=%s",
- name.c_str(), status.GetErrorMessage().c_str());
+ key, status.GetErrorMessage().c_str());
return status.error_status();
}
@@ -192,9 +192,9 @@
const int ret = native_buffer_handle.Import(ion_buffer.get());
if (ret < 0) {
ALOGE(
- "DisplayClient::GetNamedBuffer: Failed to import named buffer: "
- "name=%s; error=%s",
- name.c_str(), strerror(-ret));
+ "DisplayClient::GetGlobalBuffer: Failed to import global buffer: "
+ "key=%d; error=%s",
+ key, strerror(-ret));
return ErrorStatus(-ret);
}
diff --git a/libs/vr/libdisplay/display_manager_client.cpp b/libs/vr/libdisplay/display_manager_client.cpp
index a99f2a3..47c4599 100644
--- a/libs/vr/libdisplay/display_manager_client.cpp
+++ b/libs/vr/libdisplay/display_manager_client.cpp
@@ -32,13 +32,13 @@
return status;
}
-pdx::Status<std::unique_ptr<IonBuffer>> DisplayManagerClient::SetupNamedBuffer(
- const std::string& name, size_t size, uint64_t usage) {
- auto status = InvokeRemoteMethod<DisplayManagerProtocol::SetupNamedBuffer>(
- name, size, usage);
+pdx::Status<std::unique_ptr<IonBuffer>> DisplayManagerClient::SetupGlobalBuffer(
+ DvrGlobalBufferKey key, size_t size, uint64_t usage) {
+ auto status = InvokeRemoteMethod<DisplayManagerProtocol::SetupGlobalBuffer>(
+ key, size, usage);
if (!status) {
ALOGE(
- "DisplayManagerClient::SetupPoseBuffer: Failed to create the named "
+ "DisplayManagerClient::SetupGlobalBuffer: Failed to create the global "
"buffer %s",
status.GetErrorMessage().c_str());
return status.error_status();
@@ -49,9 +49,9 @@
const int ret = native_buffer_handle.Import(ion_buffer.get());
if (ret < 0) {
ALOGE(
- "DisplayClient::GetNamedBuffer: Failed to import named buffer: "
- "name=%s; error=%s",
- name.c_str(), strerror(-ret));
+ "DisplayClient::GetGlobalBuffer: Failed to import global buffer: "
+ "key=%d; error=%s",
+ key, strerror(-ret));
return ErrorStatus(-ret);
}
diff --git a/libs/vr/libdisplay/include/private/dvr/display_client.h b/libs/vr/libdisplay/include/private/dvr/display_client.h
index 7a7f670..e5b3340 100644
--- a/libs/vr/libdisplay/include/private/dvr/display_client.h
+++ b/libs/vr/libdisplay/include/private/dvr/display_client.h
@@ -1,6 +1,7 @@
#ifndef ANDROID_DVR_DISPLAY_CLIENT_H_
#define ANDROID_DVR_DISPLAY_CLIENT_H_
+#include <dvr/dvr_api.h>
#include <hardware/hwcomposer.h>
#include <pdx/client.h>
#include <pdx/file_handle.h>
@@ -67,8 +68,8 @@
class DisplayClient : public pdx::ClientBase<DisplayClient> {
public:
pdx::Status<Metrics> GetDisplayMetrics();
- pdx::Status<std::unique_ptr<IonBuffer>> GetNamedBuffer(
- const std::string& name);
+ pdx::Status<std::unique_ptr<IonBuffer>> GetGlobalBuffer(
+ DvrGlobalBufferKey key);
pdx::Status<std::unique_ptr<Surface>> CreateSurface(
const SurfaceAttributes& attributes);
diff --git a/libs/vr/libdisplay/include/private/dvr/display_manager_client.h b/libs/vr/libdisplay/include/private/dvr/display_manager_client.h
index a5b4e7e..8bf12b6 100644
--- a/libs/vr/libdisplay/include/private/dvr/display_manager_client.h
+++ b/libs/vr/libdisplay/include/private/dvr/display_manager_client.h
@@ -21,8 +21,8 @@
~DisplayManagerClient() override;
pdx::Status<std::vector<SurfaceState>> GetSurfaceState();
- pdx::Status<std::unique_ptr<IonBuffer>> SetupNamedBuffer(
- const std::string& name, size_t size, uint64_t usage);
+ pdx::Status<std::unique_ptr<IonBuffer>> SetupGlobalBuffer(
+ DvrGlobalBufferKey key, size_t size, uint64_t usage);
pdx::Status<std::unique_ptr<ConsumerQueue>> GetSurfaceQueue(int surface_id,
int queue_id);
diff --git a/libs/vr/libdisplay/include/private/dvr/display_protocol.h b/libs/vr/libdisplay/include/private/dvr/display_protocol.h
index 19bfb30..b22ddfa 100644
--- a/libs/vr/libdisplay/include/private/dvr/display_protocol.h
+++ b/libs/vr/libdisplay/include/private/dvr/display_protocol.h
@@ -8,6 +8,7 @@
#include <dvr/dvr_display_types.h>
+#include <dvr/dvr_api.h>
#include <pdx/rpc/buffer_wrapper.h>
#include <pdx/rpc/remote_method.h>
#include <pdx/rpc/serializable.h>
@@ -192,7 +193,7 @@
// Op codes.
enum {
kOpGetMetrics = 0,
- kOpGetNamedBuffer,
+ kOpGetGlobalBuffer,
kOpIsVrAppRunning,
kOpCreateSurface,
kOpGetSurfaceInfo,
@@ -206,8 +207,8 @@
// Methods.
PDX_REMOTE_METHOD(GetMetrics, kOpGetMetrics, Metrics(Void));
- PDX_REMOTE_METHOD(GetNamedBuffer, kOpGetNamedBuffer,
- LocalNativeBufferHandle(std::string name));
+ PDX_REMOTE_METHOD(GetGlobalBuffer, kOpGetGlobalBuffer,
+ LocalNativeBufferHandle(DvrGlobalBufferKey key));
PDX_REMOTE_METHOD(IsVrAppRunning, kOpIsVrAppRunning, bool(Void));
PDX_REMOTE_METHOD(CreateSurface, kOpCreateSurface,
SurfaceInfo(const SurfaceAttributes& attributes));
@@ -232,7 +233,7 @@
enum {
kOpGetSurfaceState = 0,
kOpGetSurfaceQueue,
- kOpSetupNamedBuffer,
+ kOpSetupGlobalBuffer,
kOpGetConfigurationData,
};
@@ -245,9 +246,9 @@
std::vector<SurfaceState>(Void));
PDX_REMOTE_METHOD(GetSurfaceQueue, kOpGetSurfaceQueue,
LocalChannelHandle(int surface_id, int queue_id));
- PDX_REMOTE_METHOD(SetupNamedBuffer, kOpSetupNamedBuffer,
- LocalNativeBufferHandle(const std::string& name,
- size_t size, uint64_t usage));
+ PDX_REMOTE_METHOD(SetupGlobalBuffer, kOpSetupGlobalBuffer,
+ LocalNativeBufferHandle(DvrGlobalBufferKey key, size_t size,
+ uint64_t usage));
PDX_REMOTE_METHOD(GetConfigurationData, kOpGetConfigurationData,
std::string(ConfigFileType config_type));
};
diff --git a/libs/vr/libdvr/dvr_display_manager.cpp b/libs/vr/libdvr/dvr_display_manager.cpp
index 40d93ba..e67e8c3 100644
--- a/libs/vr/libdvr/dvr_display_manager.cpp
+++ b/libs/vr/libdvr/dvr_display_manager.cpp
@@ -112,19 +112,20 @@
void dvrDisplayManagerDestroy(DvrDisplayManager* client) { delete client; }
-int dvrDisplayManagerSetupNamedBuffer(DvrDisplayManager* client,
- const char* name, size_t size,
- uint64_t usage, DvrBuffer** buffer_out) {
- if (!client || !name || !buffer_out)
+int dvrDisplayManagerSetupGlobalBuffer(DvrDisplayManager* client,
+ DvrGlobalBufferKey key, size_t size,
+ uint64_t usage, DvrBuffer** buffer_out) {
+ if (!client || !buffer_out)
return -EINVAL;
uint64_t gralloc_usage = AHardwareBuffer_convertToGrallocUsageBits(usage);
auto buffer_status =
- client->client->SetupNamedBuffer(name, size, gralloc_usage);
+ client->client->SetupGlobalBuffer(key, size, gralloc_usage);
if (!buffer_status) {
- ALOGE("dvrDisplayManagerSetupPoseBuffer: Failed to setup named buffer: %s",
- buffer_status.GetErrorMessage().c_str());
+ ALOGE(
+ "dvrDisplayManagerSetupGlobalBuffer: Failed to setup global buffer: %s",
+ buffer_status.GetErrorMessage().c_str());
return -buffer_status.error();
}
diff --git a/libs/vr/libdvr/dvr_surface.cpp b/libs/vr/libdvr/dvr_surface.cpp
index 67e2ae8..1fe9874 100644
--- a/libs/vr/libdvr/dvr_surface.cpp
+++ b/libs/vr/libdvr/dvr_surface.cpp
@@ -156,22 +156,22 @@
return 0;
}
-int dvrGetNamedBuffer(const char* name, DvrBuffer** out_buffer) {
+int dvrGetGlobalBuffer(DvrGlobalBufferKey key, DvrBuffer** out_buffer) {
auto client = DisplayClient::Create();
if (!client) {
- ALOGE("dvrGetNamedBuffer: Failed to create display client!");
+ ALOGE("dvrGetGlobalBuffer: Failed to create display client!");
return -ECOMM;
}
- if (out_buffer == nullptr || name == nullptr) {
- ALOGE("dvrGetNamedBuffer: Invalid inputs: name=%p, out_buffer=%p.", name,
+ if (out_buffer == nullptr) {
+ ALOGE("dvrGetGlobalBuffer: Invalid inputs: key=%d, out_buffer=%p.", key,
out_buffer);
return -EINVAL;
}
- auto status = client->GetNamedBuffer(name);
+ auto status = client->GetGlobalBuffer(key);
if (!status) {
- ALOGE("dvrGetNamedBuffer: Failed to find named buffer name=%s: %s", name,
+ ALOGE("dvrGetGlobalBuffer: Failed to find named buffer key=%d: %s", key,
status.GetErrorMessage().c_str());
return -status.error();
}
diff --git a/libs/vr/libdvr/include/dvr/dvr_api.h b/libs/vr/libdvr/include/dvr/dvr_api.h
index 8326a5b..ef2c975 100644
--- a/libs/vr/libdvr/include/dvr/dvr_api.h
+++ b/libs/vr/libdvr/include/dvr/dvr_api.h
@@ -33,6 +33,7 @@
typedef struct DvrSurface DvrSurface;
typedef uint64_t DvrSurfaceAttributeType;
typedef int32_t DvrSurfaceAttributeKey;
+typedef int32_t DvrGlobalBufferKey;
typedef struct DvrSurfaceAttributeValue DvrSurfaceAttributeValue;
typedef struct DvrSurfaceAttribute DvrSurfaceAttribute;
@@ -42,10 +43,11 @@
// dvr_display_manager.h
typedef int (*DvrDisplayManagerCreatePtr)(DvrDisplayManager** client_out);
typedef void (*DvrDisplayManagerDestroyPtr)(DvrDisplayManager* client);
-typedef int (*DvrDisplayManagerSetupNamedBufferPtr)(DvrDisplayManager* client,
- const char* name,
- size_t size, uint64_t usage,
- DvrBuffer** buffer_out);
+typedef int (*DvrDisplayManagerSetupGlobalBufferPtr)(DvrDisplayManager* client,
+ DvrGlobalBufferKey key,
+ size_t size,
+ uint64_t usage,
+ DvrBuffer** buffer_out);
typedef int (*DvrDisplayManagerGetEventFdPtr)(DvrDisplayManager* client);
typedef int (*DvrDisplayManagerTranslateEpollEventMaskPtr)(
DvrDisplayManager* client, int in_events, int* out_events);
@@ -156,7 +158,8 @@
size_t meta_size_bytes);
// dvr_surface.h
-typedef int (*DvrGetNamedBufferPtr)(const char* name, DvrBuffer** out_buffer);
+typedef int (*DvrGetGlobalBufferPtr)(DvrGlobalBufferKey key,
+ DvrBuffer** out_buffer);
typedef int (*DvrSurfaceCreatePtr)(const DvrSurfaceAttribute* attributes,
size_t attribute_count,
DvrSurface** surface_out);
diff --git a/libs/vr/libdvr/include/dvr/dvr_api_entries.h b/libs/vr/libdvr/include/dvr/dvr_api_entries.h
index 42c1178..30d0a65 100644
--- a/libs/vr/libdvr/include/dvr/dvr_api_entries.h
+++ b/libs/vr/libdvr/include/dvr/dvr_api_entries.h
@@ -11,7 +11,7 @@
// Display manager client
DVR_V1_API_ENTRY(DisplayManagerCreate);
DVR_V1_API_ENTRY(DisplayManagerDestroy);
-DVR_V1_API_ENTRY(DisplayManagerSetupNamedBuffer);
+DVR_V1_API_ENTRY(DisplayManagerSetupGlobalBuffer);
DVR_V1_API_ENTRY(DisplayManagerGetEventFd);
DVR_V1_API_ENTRY(DisplayManagerTranslateEpollEventMask);
DVR_V1_API_ENTRY(DisplayManagerGetSurfaceState);
@@ -86,7 +86,7 @@
DVR_V1_API_ENTRY(SurfaceGetId);
DVR_V1_API_ENTRY(SurfaceSetAttributes);
DVR_V1_API_ENTRY(SurfaceCreateWriteBufferQueue);
-DVR_V1_API_ENTRY(GetNamedBuffer);
+DVR_V1_API_ENTRY(GetGlobalBuffer);
// Pose client
DVR_V1_API_ENTRY(PoseCreate);
diff --git a/libs/vr/libdvr/include/dvr/dvr_display_manager.h b/libs/vr/libdvr/include/dvr/dvr_display_manager.h
index b8af108..f8db182 100644
--- a/libs/vr/libdvr/include/dvr/dvr_display_manager.h
+++ b/libs/vr/libdvr/include/dvr/dvr_display_manager.h
@@ -28,9 +28,9 @@
// Sets up a named buffer for shared memory data transfer between display
// clients and the display manager.
// @return 0 on success. Otherwise returns a negative error value.
-int dvrDisplayManagerSetupNamedBuffer(DvrDisplayManager* client,
- const char* name, size_t size,
- uint64_t usage, DvrBuffer** buffer_out);
+int dvrDisplayManagerSetupGlobalBuffer(DvrDisplayManager* client,
+ DvrGlobalBufferKey key, size_t size,
+ uint64_t usage, DvrBuffer** buffer_out);
// Device metrics data type enums.
enum {
diff --git a/libs/vr/libdvr/include/dvr/dvr_surface.h b/libs/vr/libdvr/include/dvr/dvr_surface.h
index 361488e..e3ab41b 100644
--- a/libs/vr/libdvr/include/dvr/dvr_surface.h
+++ b/libs/vr/libdvr/include/dvr/dvr_surface.h
@@ -6,16 +6,13 @@
#include <stdint.h>
#include <sys/cdefs.h>
+#include <dvr/dvr_api.h>
#include <dvr/dvr_buffer.h>
#include <dvr/dvr_buffer_queue.h>
#include <dvr/dvr_display_types.h>
__BEGIN_DECLS
-typedef struct DvrBuffer DvrBuffer;
-typedef struct DvrSurface DvrSurface;
-typedef struct DvrWriteBufferQueue DvrWriteBufferQueue;
-
// Attribute types. The values are one-hot encoded to support singluar types or
// masks of supported types.
enum {
@@ -82,9 +79,9 @@
size_t capacity,
DvrWriteBufferQueue** queue_out);
-// Get a named buffer from the display service.
+// Get a global buffer from the display service.
// @return 0 on success. Otherwise returns a negative error value.
-int dvrGetNamedBuffer(const char* name, DvrBuffer** out_buffer);
+int dvrGetGlobalBuffer(DvrGlobalBufferKey key, DvrBuffer** out_buffer);
__END_DECLS
diff --git a/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp b/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp
index e65f6d5..336f11f 100644
--- a/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp
+++ b/libs/vr/libdvr/tests/dvr_named_buffer-test.cpp
@@ -29,16 +29,16 @@
};
TEST_F(DvrNamedBufferTest, TestNamedBuffersSameName) {
- const char* buffer_name = "same_name";
+ const DvrGlobalBufferKey buffer_key = 101;
DvrBuffer* buffer1 = nullptr;
int ret1 =
- dvrDisplayManagerSetupNamedBuffer(client_, buffer_name, 10, 0, &buffer1);
+ dvrDisplayManagerSetupGlobalBuffer(client_, buffer_key, 10, 0, &buffer1);
ASSERT_EQ(0, ret1);
ASSERT_NE(nullptr, buffer1);
DvrBuffer* buffer2 = nullptr;
int ret2 =
- dvrDisplayManagerSetupNamedBuffer(client_, buffer_name, 10, 0, &buffer2);
+ dvrDisplayManagerSetupGlobalBuffer(client_, buffer_key, 10, 0, &buffer2);
ASSERT_EQ(0, ret1);
ASSERT_NE(nullptr, buffer2);
@@ -71,7 +71,7 @@
dvrBufferDestroy(buffer2);
DvrBuffer* buffer3 = nullptr;
- int e3 = dvrGetNamedBuffer(buffer_name, &buffer3);
+ int e3 = dvrGetGlobalBuffer(buffer_key, &buffer3);
ASSERT_NE(nullptr, buffer3);
ASSERT_EQ(0, e3);
@@ -96,37 +96,37 @@
}
TEST_F(DvrNamedBufferTest, TestMultipleNamedBuffers) {
- const char* buffer_name1 = "test1";
- const char* buffer_name2 = "test2";
+ const DvrGlobalBufferKey buffer_key1 = 102;
+ const DvrGlobalBufferKey buffer_key2 = 103;
DvrBuffer* setup_buffer1 = nullptr;
- int ret1 = dvrDisplayManagerSetupNamedBuffer(client_, buffer_name1, 10, 0,
- &setup_buffer1);
+ int ret1 = dvrDisplayManagerSetupGlobalBuffer(client_, buffer_key1, 10, 0,
+ &setup_buffer1);
ASSERT_EQ(0, ret1);
ASSERT_NE(nullptr, setup_buffer1);
dvrBufferDestroy(setup_buffer1);
DvrBuffer* setup_buffer2 = nullptr;
- int ret2 = dvrDisplayManagerSetupNamedBuffer(client_, buffer_name2, 10, 0,
- &setup_buffer2);
+ int ret2 = dvrDisplayManagerSetupGlobalBuffer(client_, buffer_key2, 10, 0,
+ &setup_buffer2);
ASSERT_EQ(0, ret2);
ASSERT_NE(nullptr, setup_buffer2);
dvrBufferDestroy(setup_buffer2);
DvrBuffer* buffer1 = nullptr;
- int e1 = dvrGetNamedBuffer(buffer_name1, &buffer1);
+ int e1 = dvrGetGlobalBuffer(buffer_key1, &buffer1);
ASSERT_NE(nullptr, buffer1);
ASSERT_EQ(0, e1);
dvrBufferDestroy(buffer1);
DvrBuffer* buffer2 = nullptr;
- int e2 = dvrGetNamedBuffer(buffer_name2, &buffer2);
+ int e2 = dvrGetGlobalBuffer(buffer_key2, &buffer2);
ASSERT_NE(nullptr, buffer2);
ASSERT_EQ(0, e2);
dvrBufferDestroy(buffer2);
}
TEST_F(DvrNamedBufferTest, TestNamedBufferUsage) {
- const char* buffer_name = "buffer_usage";
+ const DvrGlobalBufferKey buffer_key = 100;
// Set usage to AHARDWAREBUFFER_USAGE_VIDEO_ENCODE. We use this because
// internally AHARDWAREBUFFER_USAGE_VIDEO_ENCODE is converted to
@@ -136,8 +136,8 @@
const uint64_t usage = AHARDWAREBUFFER_USAGE_VIDEO_ENCODE;
DvrBuffer* setup_buffer = nullptr;
- int e1 = dvrDisplayManagerSetupNamedBuffer(client_, buffer_name, 10, usage,
- &setup_buffer);
+ int e1 = dvrDisplayManagerSetupGlobalBuffer(client_, buffer_key, 10, usage,
+ &setup_buffer);
ASSERT_NE(nullptr, setup_buffer);
ASSERT_EQ(0, e1);
diff --git a/libs/vr/libvrflinger/Android.bp b/libs/vr/libvrflinger/Android.bp
index de26a74..d37031f 100644
--- a/libs/vr/libvrflinger/Android.bp
+++ b/libs/vr/libvrflinger/Android.bp
@@ -61,6 +61,10 @@
"libfmq",
]
+headerLibraries = [
+ "libdvr_headers"
+]
+
cc_library_static {
srcs: sourceFiles,
export_include_dirs: includeFiles,
@@ -73,6 +77,7 @@
"-DEGL_EGLEXT_PROTOTYPES",
],
shared_libs: sharedLibraries,
+ header_libs: headerLibraries,
whole_static_libs: staticLibraries,
name: "libvrflinger",
}
diff --git a/libs/vr/libvrflinger/display_manager_service.cpp b/libs/vr/libvrflinger/display_manager_service.cpp
index dfb0231..7b5aa79 100644
--- a/libs/vr/libvrflinger/display_manager_service.cpp
+++ b/libs/vr/libvrflinger/display_manager_service.cpp
@@ -88,9 +88,9 @@
*this, &DisplayManagerService::OnGetSurfaceQueue, message);
return {};
- case DisplayManagerProtocol::SetupNamedBuffer::Opcode:
- DispatchRemoteMethod<DisplayManagerProtocol::SetupNamedBuffer>(
- *this, &DisplayManagerService::OnSetupNamedBuffer, message);
+ case DisplayManagerProtocol::SetupGlobalBuffer::Opcode:
+ DispatchRemoteMethod<DisplayManagerProtocol::SetupGlobalBuffer>(
+ *this, &DisplayManagerService::OnSetupGlobalBuffer, message);
return {};
case DisplayManagerProtocol::GetConfigurationData::Opcode:
@@ -145,20 +145,20 @@
}
pdx::Status<BorrowedNativeBufferHandle>
-DisplayManagerService::OnSetupNamedBuffer(pdx::Message& message,
- const std::string& name, size_t size,
- uint64_t usage) {
+DisplayManagerService::OnSetupGlobalBuffer(pdx::Message& message,
+ DvrGlobalBufferKey key, size_t size,
+ uint64_t usage) {
const int user_id = message.GetEffectiveUserId();
const bool trusted = user_id == AID_ROOT || IsTrustedUid(user_id);
if (!trusted) {
ALOGE(
- "DisplayService::SetupNamedBuffer: Named buffers may only be created "
+ "DisplayService::SetupGlobalBuffer: Global buffers may only be created "
"by trusted UIDs: user_id=%d",
user_id);
return ErrorStatus(EPERM);
}
- return display_service_->SetupNamedBuffer(name, size, usage);
+ return display_service_->SetupGlobalBuffer(key, size, usage);
}
pdx::Status<std::string> DisplayManagerService::OnGetConfigurationData(
diff --git a/libs/vr/libvrflinger/display_manager_service.h b/libs/vr/libvrflinger/display_manager_service.h
index e23b991..4a08405 100644
--- a/libs/vr/libvrflinger/display_manager_service.h
+++ b/libs/vr/libvrflinger/display_manager_service.h
@@ -56,8 +56,8 @@
pdx::Status<pdx::LocalChannelHandle> OnGetSurfaceQueue(pdx::Message& message,
int surface_id,
int queue_id);
- pdx::Status<BorrowedNativeBufferHandle> OnSetupNamedBuffer(
- pdx::Message& message, const std::string& name, size_t size,
+ pdx::Status<BorrowedNativeBufferHandle> OnSetupGlobalBuffer(
+ pdx::Message& message, DvrGlobalBufferKey key, size_t size,
uint64_t usage);
pdx::Status<std::string> OnGetConfigurationData(
pdx::Message& message, display::ConfigFileType config_type);
diff --git a/libs/vr/libvrflinger/display_service.cpp b/libs/vr/libvrflinger/display_service.cpp
index 47efa76..4cc5f02 100644
--- a/libs/vr/libvrflinger/display_service.cpp
+++ b/libs/vr/libvrflinger/display_service.cpp
@@ -65,9 +65,9 @@
*this, &DisplayService::OnCreateSurface, message);
return {};
- case DisplayProtocol::GetNamedBuffer::Opcode:
- DispatchRemoteMethod<DisplayProtocol::GetNamedBuffer>(
- *this, &DisplayService::OnGetNamedBuffer, message);
+ case DisplayProtocol::GetGlobalBuffer::Opcode:
+ DispatchRemoteMethod<DisplayProtocol::GetGlobalBuffer>(
+ *this, &DisplayService::OnGetGlobalBuffer, message);
return {};
case DisplayProtocol::IsVrAppRunning::Opcode:
@@ -155,12 +155,12 @@
}
}
-pdx::Status<BorrowedNativeBufferHandle> DisplayService::OnGetNamedBuffer(
- pdx::Message& /* message */, const std::string& name) {
- ALOGD_IF(TRACE, "displayService::OnGetNamedBuffer: name=%s", name.c_str());
- auto named_buffer = named_buffers_.find(name);
- if (named_buffer != named_buffers_.end())
- return {BorrowedNativeBufferHandle(*named_buffer->second, 0)};
+pdx::Status<BorrowedNativeBufferHandle> DisplayService::OnGetGlobalBuffer(
+ pdx::Message& /* message */, DvrGlobalBufferKey key) {
+ ALOGD_IF(TRACE, "DisplayService::OnGetGlobalBuffer: key=%d", key);
+ auto global_buffer = global_buffers_.find(key);
+ if (global_buffer != global_buffers_.end())
+ return {BorrowedNativeBufferHandle(*global_buffer->second, 0)};
else
return pdx::ErrorStatus(EINVAL);
}
@@ -221,18 +221,18 @@
hardware_composer_.SetDisplaySurfaces(std::move(visible_surfaces));
}
-pdx::Status<BorrowedNativeBufferHandle> DisplayService::SetupNamedBuffer(
- const std::string& name, size_t size, uint64_t usage) {
- auto named_buffer = named_buffers_.find(name);
- if (named_buffer == named_buffers_.end()) {
+pdx::Status<BorrowedNativeBufferHandle> DisplayService::SetupGlobalBuffer(
+ DvrGlobalBufferKey key, size_t size, uint64_t usage) {
+ auto global_buffer = global_buffers_.find(key);
+ if (global_buffer == global_buffers_.end()) {
auto ion_buffer = std::make_unique<IonBuffer>(static_cast<int>(size), 1,
HAL_PIXEL_FORMAT_BLOB, usage);
- named_buffer =
- named_buffers_.insert(std::make_pair(name, std::move(ion_buffer)))
+ global_buffer =
+ global_buffers_.insert(std::make_pair(key, std::move(ion_buffer)))
.first;
}
- return {BorrowedNativeBufferHandle(*named_buffer->second, 0)};
+ return {BorrowedNativeBufferHandle(*global_buffer->second, 0)};
}
void DisplayService::OnHardwareComposerRefresh() {
diff --git a/libs/vr/libvrflinger/display_service.h b/libs/vr/libvrflinger/display_service.h
index bb4eeef..77e45a4 100644
--- a/libs/vr/libvrflinger/display_service.h
+++ b/libs/vr/libvrflinger/display_service.h
@@ -1,6 +1,7 @@
#ifndef ANDROID_DVR_SERVICES_DISPLAYD_DISPLAY_SERVICE_H_
#define ANDROID_DVR_SERVICES_DISPLAYD_DISPLAY_SERVICE_H_
+#include <dvr/dvr_api.h>
#include <pdx/service.h>
#include <pdx/status.h>
#include <private/dvr/buffer_hub_client.h>
@@ -40,8 +41,8 @@
// any change to client/manager attributes that affect visibility or z order.
void UpdateActiveDisplaySurfaces();
- pdx::Status<BorrowedNativeBufferHandle> SetupNamedBuffer(
- const std::string& name, size_t size, uint64_t usage);
+ pdx::Status<BorrowedNativeBufferHandle> SetupGlobalBuffer(
+ DvrGlobalBufferKey key, size_t size, uint64_t usage);
template <class A>
void ForEachDisplaySurface(SurfaceType surface_type, A action) const {
@@ -82,8 +83,8 @@
DisplayService(android::Hwc2::Composer* hidl,
RequestDisplayCallback request_display_callback);
- pdx::Status<BorrowedNativeBufferHandle> OnGetNamedBuffer(
- pdx::Message& message, const std::string& name);
+ pdx::Status<BorrowedNativeBufferHandle> OnGetGlobalBuffer(
+ pdx::Message& message, DvrGlobalBufferKey key);
pdx::Status<display::Metrics> OnGetMetrics(pdx::Message& message);
pdx::Status<display::SurfaceInfo> OnCreateSurface(
pdx::Message& message, const display::SurfaceAttributes& attributes);
@@ -113,7 +114,8 @@
EpollEventDispatcher dispatcher_;
DisplayConfigurationUpdateNotifier update_notifier_;
- std::unordered_map<std::string, std::unique_ptr<IonBuffer>> named_buffers_;
+ std::unordered_map<DvrGlobalBufferKey, std::unique_ptr<IonBuffer>>
+ global_buffers_;
DisplayService(const DisplayService&) = delete;
void operator=(const DisplayService&) = delete;