mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-04 14:02:45 +01:00
Merge pull request #9345 from lioncash/fence
consumer_base: Pass std::shared_ptr by const reference
This commit is contained in:
commit
a7f1fa7bfc
6 changed files with 15 additions and 16 deletions
|
@ -39,7 +39,7 @@ Status BufferItemConsumer::AcquireBuffer(BufferItem* item, std::chrono::nanoseco
|
||||||
return Status::NoError;
|
return Status::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, Fence& release_fence) {
|
Status BufferItemConsumer::ReleaseBuffer(const BufferItem& item, const Fence& release_fence) {
|
||||||
std::scoped_lock lock{mutex};
|
std::scoped_lock lock{mutex};
|
||||||
|
|
||||||
if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence);
|
if (const auto status = AddReleaseFenceLocked(item.buf, item.graphic_buffer, release_fence);
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
explicit BufferItemConsumer(std::unique_ptr<BufferQueueConsumer> consumer);
|
explicit BufferItemConsumer(std::unique_ptr<BufferQueueConsumer> consumer);
|
||||||
Status AcquireBuffer(BufferItem* item, std::chrono::nanoseconds present_when,
|
Status AcquireBuffer(BufferItem* item, std::chrono::nanoseconds present_when,
|
||||||
bool wait_for_fence = true);
|
bool wait_for_fence = true);
|
||||||
Status ReleaseBuffer(const BufferItem& item, Fence& release_fence);
|
Status ReleaseBuffer(const BufferItem& item, const Fence& release_fence);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::android
|
} // namespace Service::android
|
||||||
|
|
|
@ -169,7 +169,7 @@ Status BufferQueueConsumer::Connect(std::shared_ptr<IConsumerListener> consumer_
|
||||||
return Status::NoInit;
|
return Status::NoInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
core->consumer_listener = consumer_listener;
|
core->consumer_listener = std::move(consumer_listener);
|
||||||
core->consumer_controlled_by_app = controlled_by_app;
|
core->consumer_controlled_by_app = controlled_by_app;
|
||||||
|
|
||||||
return Status::NoError;
|
return Status::NoError;
|
||||||
|
|
|
@ -83,7 +83,7 @@ Status ConsumerBase::AcquireBufferLocked(BufferItem* item, std::chrono::nanoseco
|
||||||
}
|
}
|
||||||
|
|
||||||
Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
|
Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
|
||||||
const std::shared_ptr<GraphicBuffer> graphic_buffer,
|
const std::shared_ptr<GraphicBuffer>& graphic_buffer,
|
||||||
const Fence& fence) {
|
const Fence& fence) {
|
||||||
LOG_DEBUG(Service_NVFlinger, "slot={}", slot);
|
LOG_DEBUG(Service_NVFlinger, "slot={}", slot);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ Status ConsumerBase::AddReleaseFenceLocked(s32 slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
Status ConsumerBase::ReleaseBufferLocked(s32 slot,
|
Status ConsumerBase::ReleaseBufferLocked(s32 slot,
|
||||||
const std::shared_ptr<GraphicBuffer> graphic_buffer) {
|
const std::shared_ptr<GraphicBuffer>& graphic_buffer) {
|
||||||
// If consumer no longer tracks this graphic_buffer (we received a new
|
// If consumer no longer tracks this graphic_buffer (we received a new
|
||||||
// buffer on the same slot), the buffer producer is definitely no longer
|
// buffer on the same slot), the buffer producer is definitely no longer
|
||||||
// tracking it.
|
// tracking it.
|
||||||
|
@ -121,7 +121,7 @@ Status ConsumerBase::ReleaseBufferLocked(s32 slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConsumerBase::StillTracking(s32 slot,
|
bool ConsumerBase::StillTracking(s32 slot,
|
||||||
const std::shared_ptr<GraphicBuffer> graphic_buffer) const {
|
const std::shared_ptr<GraphicBuffer>& graphic_buffer) const {
|
||||||
if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
|
if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,18 +27,18 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit ConsumerBase(std::unique_ptr<BufferQueueConsumer> consumer_);
|
explicit ConsumerBase(std::unique_ptr<BufferQueueConsumer> consumer_);
|
||||||
virtual ~ConsumerBase();
|
~ConsumerBase() override;
|
||||||
|
|
||||||
virtual void OnFrameAvailable(const BufferItem& item) override;
|
void OnFrameAvailable(const BufferItem& item) override;
|
||||||
virtual void OnFrameReplaced(const BufferItem& item) override;
|
void OnFrameReplaced(const BufferItem& item) override;
|
||||||
virtual void OnBuffersReleased() override;
|
void OnBuffersReleased() override;
|
||||||
virtual void OnSidebandStreamChanged() override;
|
void OnSidebandStreamChanged() override;
|
||||||
|
|
||||||
void FreeBufferLocked(s32 slot_index);
|
void FreeBufferLocked(s32 slot_index);
|
||||||
Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when);
|
Status AcquireBufferLocked(BufferItem* item, std::chrono::nanoseconds present_when);
|
||||||
Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer);
|
Status ReleaseBufferLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer);
|
||||||
bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer) const;
|
bool StillTracking(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer) const;
|
||||||
Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer> graphic_buffer,
|
Status AddReleaseFenceLocked(s32 slot, const std::shared_ptr<GraphicBuffer>& graphic_buffer,
|
||||||
const Fence& fence);
|
const Fence& fence);
|
||||||
|
|
||||||
struct Slot final {
|
struct Slot final {
|
||||||
|
|
|
@ -307,8 +307,7 @@ void NVFlinger::Compose() {
|
||||||
|
|
||||||
swap_interval = buffer.swap_interval;
|
swap_interval = buffer.swap_interval;
|
||||||
|
|
||||||
auto fence = android::Fence::NoFence();
|
layer.GetConsumer().ReleaseBuffer(buffer, android::Fence::NoFence());
|
||||||
layer.GetConsumer().ReleaseBuffer(buffer, fence);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue