Commit 3394c050 authored by Vikas Soni's avatar Vikas Soni Committed by Commit Bot

Generate AHB in backing instead of representation.

Generate AHardwareBuffer in backing when ProduceSKia is called rather
than generating it in the skia vulkan representation.

Bug: 1091945
Change-Id: I9c9411fecec41932d1f16aba28d9e5d5db32f99a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264613
Auto-Submit: vikas soni <vikassoni@chromium.org>
Commit-Queue: vikas soni <vikassoni@chromium.org>
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782169}
parent 7cbf49f6
......@@ -207,11 +207,15 @@ class SharedImageRepresentationVideoSkiaVk
SharedImageManager* manager,
SharedImageBacking* backing,
scoped_refptr<SharedContextState> context_state,
MemoryTypeTracker* tracker)
MemoryTypeTracker* tracker,
std::unique_ptr<base::android::ScopedHardwareBufferFenceSync>
scoped_hardware_buffer)
: SharedImageRepresentationSkia(manager, backing, tracker),
context_state_(std::move(context_state)) {
context_state_(std::move(context_state)),
scoped_hardware_buffer_(std::move(scoped_hardware_buffer)) {
DCHECK(context_state_);
DCHECK(context_state_->vk_context_provider());
DCHECK(scoped_hardware_buffer_);
}
~SharedImageRepresentationVideoSkiaVk() override {
......@@ -242,18 +246,6 @@ class SharedImageRepresentationVideoSkiaVk
sk_sp<SkPromiseImageTexture> BeginReadAccess(
std::vector<GrBackendSemaphore>* begin_semaphores,
std::vector<GrBackendSemaphore>* end_semaphores) override {
DCHECK(!scoped_hardware_buffer_);
auto* video_backing = static_cast<SharedImageVideo*>(backing());
DCHECK(video_backing);
auto* stream_texture_sii = video_backing->stream_texture_sii_.get();
// GetAHardwareBuffer() renders the latest image and gets AHardwareBuffer
// from it.
scoped_hardware_buffer_ = stream_texture_sii->GetAHardwareBuffer();
if (!scoped_hardware_buffer_) {
LOG(ERROR) << "Failed to get the hardware buffer.";
return nullptr;
}
DCHECK(scoped_hardware_buffer_->buffer());
// Wait on the sync fd attached to the buffer to make sure buffer is
......@@ -313,7 +305,6 @@ class SharedImageRepresentationVideoSkiaVk
fence_helper()->EnqueueSemaphoreCleanupForSubmittedWork(
end_access_semaphore_);
end_access_semaphore_ = VK_NULL_HANDLE;
scoped_hardware_buffer_ = nullptr;
}
private:
......@@ -440,8 +431,16 @@ std::unique_ptr<SharedImageRepresentationSkia> SharedImageVideo::ProduceSkia(
return nullptr;
if (context_state->GrContextIsVulkan()) {
// GetAHardwareBuffer() renders the latest image and gets AHardwareBuffer
// from it.
auto scoped_hardware_buffer = stream_texture_sii_->GetAHardwareBuffer();
if (!scoped_hardware_buffer) {
LOG(ERROR) << "Failed to get the hardware buffer.";
return nullptr;
}
return std::make_unique<SharedImageRepresentationVideoSkiaVk>(
manager, this, std::move(context_state), tracker);
manager, this, std::move(context_state), tracker,
std::move(scoped_hardware_buffer));
}
DCHECK(context_state->GrContextIsGL());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment