macOS: Fix OSR configuration of device scale factor
This commit is contained in:
parent
7f3c21b64a
commit
0fb03e7aa1
|
@ -156,6 +156,10 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||||
void GetScreenInfo(content::ScreenInfo* results) const override;
|
void GetScreenInfo(content::ScreenInfo* results) const override;
|
||||||
void TransformPointToRootSurface(gfx::PointF* point) override;
|
void TransformPointToRootSurface(gfx::PointF* point) override;
|
||||||
gfx::Rect GetBoundsInRootWindow() override;
|
gfx::Rect GetBoundsInRootWindow() override;
|
||||||
|
#if defined(OS_MACOSX)
|
||||||
|
viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties(
|
||||||
|
const cc::RenderFrameMetadata& metadata) override;
|
||||||
|
#endif
|
||||||
viz::SurfaceId GetCurrentSurfaceId() const override;
|
viz::SurfaceId GetCurrentSurfaceId() const override;
|
||||||
content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
|
content::BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
|
||||||
content::BrowserAccessibilityDelegate* delegate,
|
content::BrowserAccessibilityDelegate* delegate,
|
||||||
|
@ -297,6 +301,10 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
|
||||||
void UpdateBackgroundColorFromRenderer(SkColor color);
|
void UpdateBackgroundColorFromRenderer(SkColor color);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
|
display::Display GetDisplay();
|
||||||
|
void OnDidUpdateVisualPropertiesComplete(
|
||||||
|
const cc::RenderFrameMetadata& metadata);
|
||||||
|
|
||||||
friend class MacHelper;
|
friend class MacHelper;
|
||||||
bool UpdateNSViewAndDisplay();
|
bool UpdateNSViewAndDisplay();
|
||||||
#endif // defined(OS_MACOSX)
|
#endif // defined(OS_MACOSX)
|
||||||
|
|
|
@ -19,15 +19,6 @@
|
||||||
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
|
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
|
||||||
#include "ui/display/screen.h"
|
#include "ui/display/screen.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
display::Display GetDisplay() {
|
|
||||||
// TODO(cef): Get display info from callbacks.
|
|
||||||
return display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
class MacHelper : public content::BrowserCompositorMacClient,
|
class MacHelper : public content::BrowserCompositorMacClient,
|
||||||
public ui::AcceleratedWidgetMacNSView {
|
public ui::AcceleratedWidgetMacNSView {
|
||||||
public:
|
public:
|
||||||
|
@ -100,6 +91,46 @@ bool CefRenderWidgetHostViewOSR::ShouldContinueToPauseForFrame() {
|
||||||
return browser_compositor_->ShouldContinueToPauseForFrame();
|
return browser_compositor_->ShouldContinueToPauseForFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viz::ScopedSurfaceIdAllocator
|
||||||
|
CefRenderWidgetHostViewOSR::DidUpdateVisualProperties(
|
||||||
|
const cc::RenderFrameMetadata& metadata) {
|
||||||
|
base::OnceCallback<void()> allocation_task = base::BindOnce(
|
||||||
|
base::IgnoreResult(
|
||||||
|
&CefRenderWidgetHostViewOSR::OnDidUpdateVisualPropertiesComplete),
|
||||||
|
weak_ptr_factory_.GetWeakPtr(), metadata);
|
||||||
|
return browser_compositor_->GetScopedRendererSurfaceIdAllocator(
|
||||||
|
std::move(allocation_task));
|
||||||
|
}
|
||||||
|
|
||||||
|
display::Display CefRenderWidgetHostViewOSR::GetDisplay() {
|
||||||
|
content::ScreenInfo screen_info;
|
||||||
|
GetScreenInfo(&screen_info);
|
||||||
|
|
||||||
|
// Start with a reasonable display representation.
|
||||||
|
display::Display display =
|
||||||
|
display::Screen::GetScreen()->GetDisplayNearestView(nullptr);
|
||||||
|
|
||||||
|
// Populate attributes based on |screen_info|.
|
||||||
|
display.set_bounds(screen_info.rect);
|
||||||
|
display.set_work_area(screen_info.available_rect);
|
||||||
|
display.set_device_scale_factor(screen_info.device_scale_factor);
|
||||||
|
display.set_color_space(screen_info.color_space);
|
||||||
|
display.set_color_depth(screen_info.depth);
|
||||||
|
display.set_depth_per_component(screen_info.depth_per_component);
|
||||||
|
display.set_is_monochrome(screen_info.is_monochrome);
|
||||||
|
display.SetRotationAsDegree(screen_info.orientation_angle);
|
||||||
|
|
||||||
|
return display;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefRenderWidgetHostViewOSR::OnDidUpdateVisualPropertiesComplete(
|
||||||
|
const cc::RenderFrameMetadata& metadata) {
|
||||||
|
DCHECK_EQ(current_device_scale_factor_, metadata.device_scale_factor);
|
||||||
|
browser_compositor_->SynchronizeVisualProperties(
|
||||||
|
metadata.device_scale_factor, metadata.viewport_size_in_pixels,
|
||||||
|
metadata.local_surface_id.value_or(viz::LocalSurfaceId()));
|
||||||
|
}
|
||||||
|
|
||||||
const viz::LocalSurfaceId& CefRenderWidgetHostViewOSR::GetLocalSurfaceId()
|
const viz::LocalSurfaceId& CefRenderWidgetHostViewOSR::GetLocalSurfaceId()
|
||||||
const {
|
const {
|
||||||
return browser_compositor_->GetRendererLocalSurfaceId();
|
return browser_compositor_->GetRendererLocalSurfaceId();
|
||||||
|
|
|
@ -452,11 +452,7 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||||
EXPECT_EQ(dirtyRects.size(), 1U);
|
EXPECT_EQ(dirtyRects.size(), 1U);
|
||||||
EXPECT_TRUE(IsFullRepaint(dirtyRects[0], GetScaledInt(kOsrWidth),
|
EXPECT_TRUE(IsFullRepaint(dirtyRects[0], GetScaledInt(kOsrWidth),
|
||||||
GetScaledInt(kOsrHeight)));
|
GetScaledInt(kOsrHeight)));
|
||||||
#if defined(OS_MACOSX)
|
|
||||||
EXPECT_EQ(0xfffd8081U, *(reinterpret_cast<const uint32*>(buffer)));
|
|
||||||
#else
|
|
||||||
EXPECT_EQ(0xffff7f7fU, *(reinterpret_cast<const uint32*>(buffer)));
|
EXPECT_EQ(0xffff7f7fU, *(reinterpret_cast<const uint32*>(buffer)));
|
||||||
#endif
|
|
||||||
DestroySucceededTestSoon();
|
DestroySucceededTestSoon();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -466,11 +462,7 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||||
EXPECT_EQ(dirtyRects.size(), 1U);
|
EXPECT_EQ(dirtyRects.size(), 1U);
|
||||||
EXPECT_TRUE(IsFullRepaint(dirtyRects[0], GetScaledInt(kOsrWidth),
|
EXPECT_TRUE(IsFullRepaint(dirtyRects[0], GetScaledInt(kOsrWidth),
|
||||||
GetScaledInt(kOsrHeight)));
|
GetScaledInt(kOsrHeight)));
|
||||||
#if defined(OS_MACOSX)
|
|
||||||
EXPECT_EQ(0x807F070EU, *(reinterpret_cast<const uint32*>(buffer)));
|
|
||||||
#else
|
|
||||||
EXPECT_EQ(0x80800000U, *(reinterpret_cast<const uint32*>(buffer)));
|
EXPECT_EQ(0x80800000U, *(reinterpret_cast<const uint32*>(buffer)));
|
||||||
#endif
|
|
||||||
DestroySucceededTestSoon();
|
DestroySucceededTestSoon();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -715,7 +707,7 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||||
// first pixel of border
|
// first pixel of border
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
EXPECT_EQ(0xff609ad4U, *(reinterpret_cast<const uint32*>(buffer)));
|
EXPECT_EQ(0xff5d99d6U, *(reinterpret_cast<const uint32*>(buffer)));
|
||||||
#else
|
#else
|
||||||
EXPECT_EQ(0xff6497eaU, *(reinterpret_cast<const uint32*>(buffer)));
|
EXPECT_EQ(0xff6497eaU, *(reinterpret_cast<const uint32*>(buffer)));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue