Fix PDF rendering with OSR (issue #1689)
This commit is contained in:
parent
c9e81c082f
commit
5ec98243a9
|
@ -23,6 +23,7 @@
|
||||||
#include "components/display_compositor/gl_helper.h"
|
#include "components/display_compositor/gl_helper.h"
|
||||||
#include "content/browser/bad_message.h"
|
#include "content/browser/bad_message.h"
|
||||||
#include "content/browser/compositor/image_transport_factory.h"
|
#include "content/browser/compositor/image_transport_factory.h"
|
||||||
|
#include "content/browser/frame_host/render_widget_host_view_guest.h"
|
||||||
#include "content/browser/renderer_host/dip_util.h"
|
#include "content/browser/renderer_host/dip_util.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||||
|
@ -472,6 +473,7 @@ CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
|
||||||
#endif
|
#endif
|
||||||
weak_ptr_factory_(this) {
|
weak_ptr_factory_(this) {
|
||||||
DCHECK(render_widget_host_);
|
DCHECK(render_widget_host_);
|
||||||
|
DCHECK(!render_widget_host_->GetView());
|
||||||
render_widget_host_->SetView(this);
|
render_widget_host_->SetView(this);
|
||||||
|
|
||||||
// CefBrowserHostImpl might not be created at this time for popups.
|
// CefBrowserHostImpl might not be created at this time for popups.
|
||||||
|
@ -1154,13 +1156,7 @@ void CefRenderWidgetHostViewOSR::Invalidate(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gfx::Rect& bounds_in_pixels = gfx::Rect(GetPhysicalBackingSize());
|
InvalidateInternal(gfx::Rect(GetPhysicalBackingSize()));
|
||||||
|
|
||||||
if (software_output_device_) {
|
|
||||||
software_output_device_->OnPaint(bounds_in_pixels);
|
|
||||||
} else if (copy_frame_generator_.get()) {
|
|
||||||
copy_frame_generator_->GenerateCopyFrame(true, bounds_in_pixels);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefRenderWidgetHostViewOSR::SendKeyEvent(
|
void CefRenderWidgetHostViewOSR::SendKeyEvent(
|
||||||
|
@ -1314,6 +1310,14 @@ void CefRenderWidgetHostViewOSR::RemoveGuestHostView(
|
||||||
guest_host_views_.erase(guest_host);
|
guest_host_views_.erase(guest_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefRenderWidgetHostViewOSR::RegisterGuestViewFrameSwappedCallback(
|
||||||
|
content::RenderWidgetHostViewGuest* guest_host_view) {
|
||||||
|
guest_host_view->RegisterFrameSwappedCallback(base::MakeUnique<base::Closure>(
|
||||||
|
base::Bind(&CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped,
|
||||||
|
weak_ptr_factory_.GetWeakPtr(),
|
||||||
|
base::Unretained(guest_host_view))));
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
|
|
||||||
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
|
ui::Compositor* CefRenderWidgetHostViewOSR::GetCompositor() const {
|
||||||
|
@ -1495,3 +1499,20 @@ void CefRenderWidgetHostViewOSR::OnScrollOffsetChanged() {
|
||||||
}
|
}
|
||||||
is_scroll_offset_changed_pending_ = false;
|
is_scroll_offset_changed_pending_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped(
|
||||||
|
content::RenderWidgetHostViewGuest* guest_host_view) {
|
||||||
|
InvalidateInternal(
|
||||||
|
gfx::ConvertRectToPixel(scale_factor_, guest_host_view->GetViewBounds()));
|
||||||
|
|
||||||
|
RegisterGuestViewFrameSwappedCallback(guest_host_view);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefRenderWidgetHostViewOSR::InvalidateInternal(
|
||||||
|
const gfx::Rect& bounds_in_pixels) {
|
||||||
|
if (software_output_device_) {
|
||||||
|
software_output_device_->OnPaint(bounds_in_pixels);
|
||||||
|
} else if (copy_frame_generator_.get()) {
|
||||||
|
copy_frame_generator_->GenerateCopyFrame(true, bounds_in_pixels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
namespace content {
|
namespace content {
|
||||||
class RenderWidgetHost;
|
class RenderWidgetHost;
|
||||||
class RenderWidgetHostImpl;
|
class RenderWidgetHostImpl;
|
||||||
|
class RenderWidgetHostViewGuest;
|
||||||
class BackingStore;
|
class BackingStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +250,11 @@ class CefRenderWidgetHostViewOSR
|
||||||
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
|
void AddGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
|
||||||
void RemoveGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
|
void RemoveGuestHostView(CefRenderWidgetHostViewOSR* guest_host);
|
||||||
|
|
||||||
|
// Register a callback that will be executed when |guest_host_view| receives
|
||||||
|
// OnSwapCompositorFrame. The callback triggers repaint of the embedder view.
|
||||||
|
void RegisterGuestViewFrameSwappedCallback(
|
||||||
|
content::RenderWidgetHostViewGuest* guest_host_view);
|
||||||
|
|
||||||
CefRefPtr<CefBrowserHostImpl> browser_impl() const { return browser_impl_; }
|
CefRefPtr<CefBrowserHostImpl> browser_impl() const { return browser_impl_; }
|
||||||
void set_browser_impl(CefRefPtr<CefBrowserHostImpl> browser) {
|
void set_browser_impl(CefRefPtr<CefBrowserHostImpl> browser) {
|
||||||
browser_impl_ = browser;
|
browser_impl_ = browser;
|
||||||
|
@ -282,6 +288,11 @@ class CefRenderWidgetHostViewOSR
|
||||||
|
|
||||||
void OnScrollOffsetChanged();
|
void OnScrollOffsetChanged();
|
||||||
|
|
||||||
|
void OnGuestViewFrameSwapped(
|
||||||
|
content::RenderWidgetHostViewGuest* guest_host_view);
|
||||||
|
|
||||||
|
void InvalidateInternal(const gfx::Rect& bounds_in_pixels);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
friend class MacHelper;
|
friend class MacHelper;
|
||||||
|
|
||||||
|
|
|
@ -139,10 +139,13 @@ content::RenderWidgetHostViewBase* CefWebContentsViewOSR::CreateViewForWidget(
|
||||||
embedder_host_view);
|
embedder_host_view);
|
||||||
embedder_host_view->AddGuestHostView(platform_widget);
|
embedder_host_view->AddGuestHostView(platform_widget);
|
||||||
|
|
||||||
return content::RenderWidgetHostViewGuest::Create(
|
content::RenderWidgetHostViewGuest* guest_host_view =
|
||||||
render_widget_host,
|
content::RenderWidgetHostViewGuest::Create(
|
||||||
guest_,
|
render_widget_host,
|
||||||
platform_widget->GetWeakPtr());
|
guest_,
|
||||||
|
platform_widget->GetWeakPtr());
|
||||||
|
embedder_host_view->RegisterGuestViewFrameSwappedCallback(guest_host_view);
|
||||||
|
return guest_host_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
view_ = new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
|
view_ = new CefRenderWidgetHostViewOSR(transparent_, render_widget_host,
|
||||||
|
|
Loading…
Reference in New Issue