Loading libs/vr/libvrflinger/display_surface.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,8 @@ DisplaySurface::DisplaySurface(DisplayService* service, int surface_id, manager_visible_(false), manager_z_order_(0), manager_blur_(0.0f), layer_order_(0) {} layer_order_(0), allocated_buffer_index_(0) {} DisplaySurface::~DisplaySurface() { ALOGD_IF(LOCAL_TRACE, Loading Loading @@ -104,6 +105,14 @@ void DisplaySurface::DequeueBuffersLocked() { return; } // Save buffer index, associated with the buffer id so that it can be looked // up later. int buffer_id = buffer_consumer->id(); if (buffer_id_to_index_.find(buffer_id) == buffer_id_to_index_.end()) { buffer_id_to_index_[buffer_id] = allocated_buffer_index_; ++allocated_buffer_index_; } if (!IsVisible()) { ATRACE_NAME("DropFrameOnInvisibleSurface"); ALOGD_IF(TRACE, Loading Loading @@ -171,6 +180,17 @@ AcquiredBuffer DisplaySurface::AcquireNewestAvailableBuffer( return buffer; } uint32_t DisplaySurface::GetRenderBufferIndex(int buffer_id) { std::lock_guard<std::mutex> autolock(lock_); if (buffer_id_to_index_.find(buffer_id) == buffer_id_to_index_.end()) { ALOGW("DisplaySurface::GetRenderBufferIndex: unknown buffer_id %d.", buffer_id); return 0; } return buffer_id_to_index_[buffer_id]; } bool DisplaySurface::IsBufferAvailable() { std::lock_guard<std::mutex> autolock(lock_); DequeueBuffersLocked(); Loading libs/vr/libvrflinger/display_surface.h +3 −4 Original line number Diff line number Diff line Loading @@ -60,10 +60,7 @@ class DisplaySurface : public SurfaceChannel { } } uint32_t GetRenderBufferIndex(int buffer_id) { return buffer_id_to_index_[buffer_id]; } uint32_t GetRenderBufferIndex(int buffer_id); bool IsBufferAvailable(); bool IsBufferPosted(); AcquiredBuffer AcquireCurrentBuffer(); Loading Loading @@ -172,6 +169,8 @@ class DisplaySurface : public SurfaceChannel { float manager_blur_; int layer_order_; // The monotonically increasing index for allocated buffers in this surface. uint32_t allocated_buffer_index_; // Maps from the buffer id to the corresponding allocated buffer index. std::unordered_map<int, uint32_t> buffer_id_to_index_; }; Loading Loading
libs/vr/libvrflinger/display_surface.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,8 @@ DisplaySurface::DisplaySurface(DisplayService* service, int surface_id, manager_visible_(false), manager_z_order_(0), manager_blur_(0.0f), layer_order_(0) {} layer_order_(0), allocated_buffer_index_(0) {} DisplaySurface::~DisplaySurface() { ALOGD_IF(LOCAL_TRACE, Loading Loading @@ -104,6 +105,14 @@ void DisplaySurface::DequeueBuffersLocked() { return; } // Save buffer index, associated with the buffer id so that it can be looked // up later. int buffer_id = buffer_consumer->id(); if (buffer_id_to_index_.find(buffer_id) == buffer_id_to_index_.end()) { buffer_id_to_index_[buffer_id] = allocated_buffer_index_; ++allocated_buffer_index_; } if (!IsVisible()) { ATRACE_NAME("DropFrameOnInvisibleSurface"); ALOGD_IF(TRACE, Loading Loading @@ -171,6 +180,17 @@ AcquiredBuffer DisplaySurface::AcquireNewestAvailableBuffer( return buffer; } uint32_t DisplaySurface::GetRenderBufferIndex(int buffer_id) { std::lock_guard<std::mutex> autolock(lock_); if (buffer_id_to_index_.find(buffer_id) == buffer_id_to_index_.end()) { ALOGW("DisplaySurface::GetRenderBufferIndex: unknown buffer_id %d.", buffer_id); return 0; } return buffer_id_to_index_[buffer_id]; } bool DisplaySurface::IsBufferAvailable() { std::lock_guard<std::mutex> autolock(lock_); DequeueBuffersLocked(); Loading
libs/vr/libvrflinger/display_surface.h +3 −4 Original line number Diff line number Diff line Loading @@ -60,10 +60,7 @@ class DisplaySurface : public SurfaceChannel { } } uint32_t GetRenderBufferIndex(int buffer_id) { return buffer_id_to_index_[buffer_id]; } uint32_t GetRenderBufferIndex(int buffer_id); bool IsBufferAvailable(); bool IsBufferPosted(); AcquiredBuffer AcquireCurrentBuffer(); Loading Loading @@ -172,6 +169,8 @@ class DisplaySurface : public SurfaceChannel { float manager_blur_; int layer_order_; // The monotonically increasing index for allocated buffers in this surface. uint32_t allocated_buffer_index_; // Maps from the buffer id to the corresponding allocated buffer index. std::unordered_map<int, uint32_t> buffer_id_to_index_; }; Loading