Loading libs/vr/libdvr/display_manager_client.cpp +6 −4 Original line number Diff line number Diff line #include "include/dvr/display_manager_client.h" #include <dvr/dvr_buffer.h> #include <private/android/AHardwareBufferHelpers.h> #include <private/dvr/buffer_hub_client.h> #include <private/dvr/display_manager_client_impl.h> Loading Loading @@ -44,10 +45,11 @@ void dvrDisplayManagerClientDestroy(DvrDisplayManagerClient* client) { DvrBuffer* dvrDisplayManagerSetupNamedBuffer(DvrDisplayManagerClient* client, const char* name, size_t size, uint64_t producer_usage, uint64_t consumer_usage) { // TODO(hendrikw): When we move to gralloc1, pass both producer_usage and // consumer_usage down. uint64_t usage0, uint64_t usage1) { uint64_t producer_usage = 0; uint64_t consumer_usage = 0; android::AHardwareBuffer_convertToGrallocUsageBits( &producer_usage, &consumer_usage, usage0, usage1); auto ion_buffer = client->client->SetupNamedBuffer(name, size, producer_usage, consumer_usage); if (ion_buffer) { Loading libs/vr/libdvr/include/dvr/display_manager_client.h +1 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,7 @@ void dvrDisplayManagerClientDestroy(DvrDisplayManagerClient* client); DvrBuffer* dvrDisplayManagerSetupNamedBuffer(DvrDisplayManagerClient* client, const char* name, size_t size, uint64_t producer_usage, uint64_t consumer_usage); uint64_t usage0, uint64_t usage1); // Return an event fd for checking if there was an event on the server // Note that the only event which will be flagged is POLLIN. You must use Loading libs/vr/libdvr/include/dvr/dvr_api.h +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ typedef void (*DvrDisplayManagerClientSurfaceListDestroyPtr)( DvrDisplayManagerClientSurfaceList* surface_list); typedef DvrBuffer* (*DvrDisplayManagerSetupNamedBufferPtr)( DvrDisplayManagerClient* client, const char* name, size_t size, uint64_t producer_usage, uint64_t consumer_usage); uint64_t usage0, uint64_t usage1); typedef size_t (*DvrDisplayManagerClientSurfaceListGetSizePtr)( DvrDisplayManagerClientSurfaceList* surface_list); typedef int (*DvrDisplayManagerClientSurfaceListGetSurfaceIdPtr)( Loading libs/vr/libdvr/tests/dvr_named_buffer-test.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,34 @@ TEST_F(DvrNamedBufferTest, TestMultipleNamedBuffers) { dvrBufferDestroy(buffer2); } TEST_F(DvrNamedBufferTest, TestNamedBufferUsage) { const char* buffer_name = "buffer_usage"; // Set usage0 to AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE. We use this because // internally AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE is converted to // GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, and these two values are different. // If all is good, when we get the AHardwareBuffer, it should be converted // back to AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE. const int64_t usage0 = AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE; DvrBuffer* setup_buffer = dvrDisplayManagerSetupNamedBuffer(client_, buffer_name, 10, usage0, 0); ASSERT_NE(nullptr, setup_buffer); AHardwareBuffer* hardware_buffer = nullptr; int e2 = dvrBufferGetAHardwareBuffer(setup_buffer, &hardware_buffer); ASSERT_EQ(0, e2); ASSERT_NE(nullptr, hardware_buffer); AHardwareBuffer_Desc desc = {}; AHardwareBuffer_describe(hardware_buffer, &desc); ASSERT_EQ(desc.usage0, AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE); dvrBufferDestroy(setup_buffer); } } // namespace } // namespace dvr Loading libs/vr/libvrflinger/display_service.cpp +8 −10 Original line number Diff line number Diff line Loading @@ -208,17 +208,17 @@ void DisplayService::OnSetViewerParams(pdx::Message& message, // We should always have a red distortion. LOG_FATAL_IF(view_params.distortion_coefficients_r.empty()); red_distortion = std::make_shared<PolynomialRadialDistortion>(0.0f, view_params.distortion_coefficients_r); red_distortion = std::make_shared<PolynomialRadialDistortion>( 0.0f, view_params.distortion_coefficients_r); if (!view_params.distortion_coefficients_g.empty()) { green_distortion = std::make_shared<PolynomialRadialDistortion>(0.0f, view_params.distortion_coefficients_g); green_distortion = std::make_shared<PolynomialRadialDistortion>( 0.0f, view_params.distortion_coefficients_g); } if (!view_params.distortion_coefficients_b.empty()) { blue_distortion = std::make_shared<PolynomialRadialDistortion>(0.0f, view_params.distortion_coefficients_b); blue_distortion = std::make_shared<PolynomialRadialDistortion>( 0.0f, view_params.distortion_coefficients_b); } HeadMountMetrics::EyeOrientation left_orientation = Loading Loading @@ -331,11 +331,9 @@ pdx::Status<BorrowedNativeBufferHandle> DisplayService::SetupNamedBuffer( int consumer_usage) { auto named_buffer = named_buffers_.find(name); if (named_buffer == named_buffers_.end()) { // TODO(hendrikw): Update BufferProducer to take producer_usage and // consumer_usage flags. auto ion_buffer = std::make_unique<IonBuffer>( static_cast<int>(size), 1, HAL_PIXEL_FORMAT_BLOB, producer_usage | consumer_usage); static_cast<int>(size), 1, HAL_PIXEL_FORMAT_BLOB, producer_usage, consumer_usage); named_buffer = named_buffers_.insert(std::make_pair(name, std::move(ion_buffer))) .first; Loading Loading
libs/vr/libdvr/display_manager_client.cpp +6 −4 Original line number Diff line number Diff line #include "include/dvr/display_manager_client.h" #include <dvr/dvr_buffer.h> #include <private/android/AHardwareBufferHelpers.h> #include <private/dvr/buffer_hub_client.h> #include <private/dvr/display_manager_client_impl.h> Loading Loading @@ -44,10 +45,11 @@ void dvrDisplayManagerClientDestroy(DvrDisplayManagerClient* client) { DvrBuffer* dvrDisplayManagerSetupNamedBuffer(DvrDisplayManagerClient* client, const char* name, size_t size, uint64_t producer_usage, uint64_t consumer_usage) { // TODO(hendrikw): When we move to gralloc1, pass both producer_usage and // consumer_usage down. uint64_t usage0, uint64_t usage1) { uint64_t producer_usage = 0; uint64_t consumer_usage = 0; android::AHardwareBuffer_convertToGrallocUsageBits( &producer_usage, &consumer_usage, usage0, usage1); auto ion_buffer = client->client->SetupNamedBuffer(name, size, producer_usage, consumer_usage); if (ion_buffer) { Loading
libs/vr/libdvr/include/dvr/display_manager_client.h +1 −2 Original line number Diff line number Diff line Loading @@ -22,8 +22,7 @@ void dvrDisplayManagerClientDestroy(DvrDisplayManagerClient* client); DvrBuffer* dvrDisplayManagerSetupNamedBuffer(DvrDisplayManagerClient* client, const char* name, size_t size, uint64_t producer_usage, uint64_t consumer_usage); uint64_t usage0, uint64_t usage1); // Return an event fd for checking if there was an event on the server // Note that the only event which will be flagged is POLLIN. You must use Loading
libs/vr/libdvr/include/dvr/dvr_api.h +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ typedef void (*DvrDisplayManagerClientSurfaceListDestroyPtr)( DvrDisplayManagerClientSurfaceList* surface_list); typedef DvrBuffer* (*DvrDisplayManagerSetupNamedBufferPtr)( DvrDisplayManagerClient* client, const char* name, size_t size, uint64_t producer_usage, uint64_t consumer_usage); uint64_t usage0, uint64_t usage1); typedef size_t (*DvrDisplayManagerClientSurfaceListGetSizePtr)( DvrDisplayManagerClientSurfaceList* surface_list); typedef int (*DvrDisplayManagerClientSurfaceListGetSurfaceIdPtr)( Loading
libs/vr/libdvr/tests/dvr_named_buffer-test.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,34 @@ TEST_F(DvrNamedBufferTest, TestMultipleNamedBuffers) { dvrBufferDestroy(buffer2); } TEST_F(DvrNamedBufferTest, TestNamedBufferUsage) { const char* buffer_name = "buffer_usage"; // Set usage0 to AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE. We use this because // internally AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE is converted to // GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER, and these two values are different. // If all is good, when we get the AHardwareBuffer, it should be converted // back to AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE. const int64_t usage0 = AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE; DvrBuffer* setup_buffer = dvrDisplayManagerSetupNamedBuffer(client_, buffer_name, 10, usage0, 0); ASSERT_NE(nullptr, setup_buffer); AHardwareBuffer* hardware_buffer = nullptr; int e2 = dvrBufferGetAHardwareBuffer(setup_buffer, &hardware_buffer); ASSERT_EQ(0, e2); ASSERT_NE(nullptr, hardware_buffer); AHardwareBuffer_Desc desc = {}; AHardwareBuffer_describe(hardware_buffer, &desc); ASSERT_EQ(desc.usage0, AHARDWAREBUFFER_USAGE0_VIDEO_ENCODE); dvrBufferDestroy(setup_buffer); } } // namespace } // namespace dvr Loading
libs/vr/libvrflinger/display_service.cpp +8 −10 Original line number Diff line number Diff line Loading @@ -208,17 +208,17 @@ void DisplayService::OnSetViewerParams(pdx::Message& message, // We should always have a red distortion. LOG_FATAL_IF(view_params.distortion_coefficients_r.empty()); red_distortion = std::make_shared<PolynomialRadialDistortion>(0.0f, view_params.distortion_coefficients_r); red_distortion = std::make_shared<PolynomialRadialDistortion>( 0.0f, view_params.distortion_coefficients_r); if (!view_params.distortion_coefficients_g.empty()) { green_distortion = std::make_shared<PolynomialRadialDistortion>(0.0f, view_params.distortion_coefficients_g); green_distortion = std::make_shared<PolynomialRadialDistortion>( 0.0f, view_params.distortion_coefficients_g); } if (!view_params.distortion_coefficients_b.empty()) { blue_distortion = std::make_shared<PolynomialRadialDistortion>(0.0f, view_params.distortion_coefficients_b); blue_distortion = std::make_shared<PolynomialRadialDistortion>( 0.0f, view_params.distortion_coefficients_b); } HeadMountMetrics::EyeOrientation left_orientation = Loading Loading @@ -331,11 +331,9 @@ pdx::Status<BorrowedNativeBufferHandle> DisplayService::SetupNamedBuffer( int consumer_usage) { auto named_buffer = named_buffers_.find(name); if (named_buffer == named_buffers_.end()) { // TODO(hendrikw): Update BufferProducer to take producer_usage and // consumer_usage flags. auto ion_buffer = std::make_unique<IonBuffer>( static_cast<int>(size), 1, HAL_PIXEL_FORMAT_BLOB, producer_usage | consumer_usage); static_cast<int>(size), 1, HAL_PIXEL_FORMAT_BLOB, producer_usage, consumer_usage); named_buffer = named_buffers_.insert(std::make_pair(name, std::move(ion_buffer))) .first; Loading