From 42873cd85b4eb504013abb6258a66e90c8baf83d Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 29 Jan 2019 16:09:17 -0500 Subject: [PATCH] Windows: Fix OSR rendering with shared texture enabled (issue #2559) --- .../osr/render_widget_host_view_osr.cc | 30 ++++++++----------- .../browser/osr/render_widget_host_view_osr.h | 5 ++-- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/libcef/browser/osr/render_widget_host_view_osr.cc b/libcef/browser/osr/render_widget_host_view_osr.cc index a32bc4a84..89a4ceab2 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.cc +++ b/libcef/browser/osr/render_widget_host_view_osr.cc @@ -81,17 +81,15 @@ class CefCompositorFrameSinkClient void DidReceiveCompositorFrameAck( const std::vector& resources) override { + if (render_widget_host_view_) { + render_widget_host_view_->OnPresentCompositorFrame(); + } forward_->DidReceiveCompositorFrameAck(resources); } void OnBeginFrame(const viz::BeginFrameArgs& args, const base::flat_map& feedbacks) override { - if (render_widget_host_view_) { - for (const auto& pair : feedbacks) { - render_widget_host_view_->OnPresentCompositorFrame(pair.first); - } - } forward_->OnBeginFrame(args, feedbacks); } @@ -602,8 +600,7 @@ void CefRenderWidgetHostViewOSR::DidCreateNewRendererCompositorFrameSink( } } -void CefRenderWidgetHostViewOSR::OnPresentCompositorFrame( - uint32_t presentation_token) { +void CefRenderWidgetHostViewOSR::OnPresentCompositorFrame() { // Is Chromium rendering to a shared texture? void* shared_texture = nullptr; ui::Compositor* compositor = GetCompositor(); @@ -623,10 +620,13 @@ void CefRenderWidgetHostViewOSR::OnPresentCompositorFrame( // view size for a full redraw. base::AutoLock lock_scope(damage_rect_lock_); + // TODO: in the future we need to correlate the presentation + // notification with the sequence number from BeginFrame gfx::Rect damage; - auto const i = damage_rects_.find(presentation_token); + auto const i = damage_rects_.begin(); if (i != damage_rects_.end()) { damage = i->second; + damage_rects_.erase(i); } else { damage = GetViewBounds(); } @@ -640,7 +640,7 @@ void CefRenderWidgetHostViewOSR::OnPresentCompositorFrame( } } -void CefRenderWidgetHostViewOSR::AddDamageRect(uint32_t presentation_token, +void CefRenderWidgetHostViewOSR::AddDamageRect(uint32_t sequence, const gfx::Rect& rect) { // Associate the given damage rect with the presentation token. // For OnAcceleratedPaint we'll lookup the corresponding damage area based on @@ -653,7 +653,7 @@ void CefRenderWidgetHostViewOSR::AddDamageRect(uint32_t presentation_token, while (damage_rects_.size() >= kMaxDamageRects) { damage_rects_.erase(damage_rects_.begin()); } - damage_rects_[presentation_token] = rect; + damage_rects_[sequence] = rect; } void CefRenderWidgetHostViewOSR::SubmitCompositorFrame( @@ -717,14 +717,8 @@ void CefRenderWidgetHostViewOSR::SubmitCompositorFrame( damage_rect.Intersect(gfx::Rect(frame_size)); if (shared_texture) { - // Indicate that we want feedback every frame. - if (!++presentation_token_) - ++presentation_token_; - - AddDamageRect(presentation_token_, damage_rect); - - frame.metadata.frame_token = presentation_token_; - frame.metadata.request_presentation_feedback = true; + AddDamageRect(frame.metadata.begin_frame_ack.sequence_number, + damage_rect); } // We would normally call BrowserCompositorMac::SubmitCompositorFrame on diff --git a/libcef/browser/osr/render_widget_host_view_osr.h b/libcef/browser/osr/render_widget_host_view_osr.h index 2d21ff0f1..6a1ddeadc 100644 --- a/libcef/browser/osr/render_widget_host_view_osr.h +++ b/libcef/browser/osr/render_widget_host_view_osr.h @@ -267,7 +267,7 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase, } #endif - void OnPresentCompositorFrame(uint32_t presentation_token); + void OnPresentCompositorFrame(); private: content::DelegatedFrameHost* GetDelegatedFrameHost() const; @@ -301,7 +301,7 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase, viz::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack); - void AddDamageRect(uint32_t presentation_token, const gfx::Rect& rect); + void AddDamageRect(uint32_t sequence, const gfx::Rect& rect); // Applies background color without notifying the RenderWidget about // opaqueness changes. @@ -394,7 +394,6 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase, bool is_showing_; bool is_destroyed_; gfx::Rect popup_position_; - uint32_t presentation_token_ = 0; base::Lock damage_rect_lock_; std::map damage_rects_;