Commit 7ece806c authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

viz/mac: Add plumbing for GL rendering on mac

Plumb the flag --disable-mac-overlays.

Update CALayer parameters to make the IOSurfaces CAContextID mutually
exclusive (otherwise we get warned that the IOSurface mach port is
invalid, when it is expected to be invalid).

R=dcheng, fsamuel
TBR=avi (content/)

Bug: 772576
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Iaa2f2fdfb6dbb4135bd989f4c2af1ab6be892a1a
Reviewed-on: https://chromium-review.googlesource.com/882316
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532269}
parent 8bda3f89
...@@ -30,6 +30,7 @@ class VIZ_COMMON_EXPORT RendererSettings { ...@@ -30,6 +30,7 @@ class VIZ_COMMON_EXPORT RendererSettings {
bool show_overdraw_feedback = false; bool show_overdraw_feedback = false;
bool enable_draw_occlusion = false; bool enable_draw_occlusion = false;
bool use_skia_renderer = false; bool use_skia_renderer = false;
bool allow_overlays = true;
bool dont_round_texture_sizes_for_pixel_tests = false; bool dont_round_texture_sizes_for_pixel_tests = false;
int highp_threshold_min = 0; int highp_threshold_min = 0;
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
#include "components/viz/common/display/renderer_settings.h" #include "components/viz/common/display/renderer_settings.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#if defined(OS_MACOSX)
#include "ui/base/cocoa/remote_layer_api.h"
#endif
namespace viz { namespace viz {
namespace { namespace {
...@@ -59,6 +63,12 @@ RendererSettings CreateRendererSettings() { ...@@ -59,6 +63,12 @@ RendererSettings CreateRendererSettings() {
!command_line->HasSwitch(switches::kDisableCompositedAntialiasing); !command_line->HasSwitch(switches::kDisableCompositedAntialiasing);
renderer_settings.use_skia_renderer = renderer_settings.use_skia_renderer =
command_line->HasSwitch(switches::kUseSkiaRenderer); command_line->HasSwitch(switches::kUseSkiaRenderer);
#if defined(OS_MACOSX)
renderer_settings.allow_overlays =
ui::RemoteLayerAPISupported() &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableMacOverlays);
#endif
if (command_line->HasSwitch(switches::kSlowDownCompositingScaleFactor)) { if (command_line->HasSwitch(switches::kSlowDownCompositingScaleFactor)) {
const int kMinSlowDownScaleFactor = 1; const int kMinSlowDownScaleFactor = 1;
const int kMaxSlowDownScaleFactor = 1000; const int kMaxSlowDownScaleFactor = 1000;
......
...@@ -8,16 +8,12 @@ ...@@ -8,16 +8,12 @@
namespace viz { namespace viz {
namespace {
// TODO(ccameron): Plumb this appropriately.
const bool kDisableRemoteCoreAnimation = false;
} // namespace
GLOutputSurfaceMac::GLOutputSurfaceMac( GLOutputSurfaceMac::GLOutputSurfaceMac(
scoped_refptr<InProcessContextProvider> context_provider, scoped_refptr<InProcessContextProvider> context_provider,
gpu::SurfaceHandle surface_handle, gpu::SurfaceHandle surface_handle,
SyntheticBeginFrameSource* synthetic_begin_frame_source, SyntheticBeginFrameSource* synthetic_begin_frame_source,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
bool allow_overlays)
: GLOutputSurfaceBufferQueue(context_provider, : GLOutputSurfaceBufferQueue(context_provider,
surface_handle, surface_handle,
synthetic_begin_frame_source, synthetic_begin_frame_source,
...@@ -25,8 +21,8 @@ GLOutputSurfaceMac::GLOutputSurfaceMac( ...@@ -25,8 +21,8 @@ GLOutputSurfaceMac::GLOutputSurfaceMac(
GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_RECTANGLE_ARB,
GL_RGBA, GL_RGBA,
gfx::BufferFormat::RGBA_8888), gfx::BufferFormat::RGBA_8888),
overlay_validator_(new CompositorOverlayCandidateValidatorMac( overlay_validator_(
kDisableRemoteCoreAnimation)) {} new CompositorOverlayCandidateValidatorMac(!allow_overlays)) {}
GLOutputSurfaceMac::~GLOutputSurfaceMac() {} GLOutputSurfaceMac::~GLOutputSurfaceMac() {}
......
...@@ -15,7 +15,8 @@ class GLOutputSurfaceMac : public GLOutputSurfaceBufferQueue { ...@@ -15,7 +15,8 @@ class GLOutputSurfaceMac : public GLOutputSurfaceBufferQueue {
GLOutputSurfaceMac(scoped_refptr<InProcessContextProvider> context_provider, GLOutputSurfaceMac(scoped_refptr<InProcessContextProvider> context_provider,
gpu::SurfaceHandle surface_handle, gpu::SurfaceHandle surface_handle,
SyntheticBeginFrameSource* synthetic_begin_frame_source, SyntheticBeginFrameSource* synthetic_begin_frame_source,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager); gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
bool allow_overlays);
~GLOutputSurfaceMac() override; ~GLOutputSurfaceMac() override;
private: private:
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "components/viz/service/display_embedder/gl_output_surface_mac.h" #include "components/viz/service/display_embedder/gl_output_surface_mac.h"
#include "components/viz/service/display_embedder/software_output_device_mac.h" #include "components/viz/service/display_embedder/software_output_device_mac.h"
#include "ui/base/cocoa/remote_layer_api.h"
#endif #endif
#if defined(USE_X11) #if defined(USE_X11)
...@@ -141,7 +142,8 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay( ...@@ -141,7 +142,8 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay(
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
output_surface = std::make_unique<GLOutputSurfaceMac>( output_surface = std::make_unique<GLOutputSurfaceMac>(
std::move(context_provider), surface_handle, std::move(context_provider), surface_handle,
synthetic_begin_frame_source.get(), gpu_memory_buffer_manager_.get()); synthetic_begin_frame_source.get(), gpu_memory_buffer_manager_.get(),
renderer_settings.allow_overlays);
#else #else
NOTREACHED(); NOTREACHED();
#endif #endif
......
...@@ -146,6 +146,7 @@ static const char* const kSwitchNames[] = { ...@@ -146,6 +146,7 @@ static const char* const kSwitchNames[] = {
switches::kVModule, switches::kVModule,
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
switches::kDisableAVFoundationOverlays, switches::kDisableAVFoundationOverlays,
switches::kDisableMacOverlays,
switches::kDisableRemoteCoreAnimation, switches::kDisableRemoteCoreAnimation,
switches::kEnableSandboxLogging, switches::kEnableSandboxLogging,
switches::kShowMacOverlayBorders, switches::kShowMacOverlayBorders,
......
...@@ -21,4 +21,5 @@ struct RendererSettings { ...@@ -21,4 +21,5 @@ struct RendererSettings {
bool enable_draw_occlusion; bool enable_draw_occlusion;
int32 slow_down_compositing_scale_factor; int32 slow_down_compositing_scale_factor;
bool use_skia_renderer; bool use_skia_renderer;
bool allow_overlays;
}; };
...@@ -26,6 +26,7 @@ bool StructTraits<viz::mojom::RendererSettingsDataView, viz::RendererSettings>:: ...@@ -26,6 +26,7 @@ bool StructTraits<viz::mojom::RendererSettingsDataView, viz::RendererSettings>::
out->slow_down_compositing_scale_factor = out->slow_down_compositing_scale_factor =
data.slow_down_compositing_scale_factor(); data.slow_down_compositing_scale_factor();
out->use_skia_renderer = data.use_skia_renderer(); out->use_skia_renderer = data.use_skia_renderer();
out->allow_overlays = data.allow_overlays();
return data.ReadResourceSettings(&out->resource_settings); return data.ReadResourceSettings(&out->resource_settings);
} }
......
...@@ -72,6 +72,10 @@ struct StructTraits<viz::mojom::RendererSettingsDataView, ...@@ -72,6 +72,10 @@ struct StructTraits<viz::mojom::RendererSettingsDataView,
return input.use_skia_renderer; return input.use_skia_renderer;
} }
static bool allow_overlays(const viz::RendererSettings& input) {
return input.allow_overlays;
}
static bool Read(viz::mojom::RendererSettingsDataView data, static bool Read(viz::mojom::RendererSettingsDataView data,
viz::RendererSettings* out); viz::RendererSettings* out);
}; };
......
...@@ -6,13 +6,17 @@ module gfx.mojom; ...@@ -6,13 +6,17 @@ module gfx.mojom;
import "ui/gfx/geometry/mojo/geometry.mojom"; import "ui/gfx/geometry/mojo/geometry.mojom";
union CALayerContent {
uint32 ca_context_id;
handle io_surface_mach_port;
};
// gfx::CALayerParams // gfx::CALayerParams
struct CALayerParams { struct CALayerParams {
// TODO(676224): Use preprocessor to restrict platform-specific members to // TODO(676224): Use preprocessor to restrict platform-specific members to
// desired platform. // desired platform.
bool is_empty; bool is_empty;
uint32 ca_context_id; CALayerContent content;
handle? io_surface_mach_port;
gfx.mojom.Size pixel_size; gfx.mojom.Size pixel_size;
float scale_factor; float scale_factor;
}; };
...@@ -10,33 +10,48 @@ ...@@ -10,33 +10,48 @@
namespace mojo { namespace mojo {
mojo::ScopedHandle gfx::mojom::CALayerContentPtr
StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>:: StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>::content(
io_surface_mach_port(const gfx::CALayerParams& ca_layer_params) { const gfx::CALayerParams& ca_layer_params) {
#if defined(OS_MACOSX) && !defined(OS_IOS) #if defined(OS_MACOSX) && !defined(OS_IOS)
return mojo::WrapMachPort(ca_layer_params.io_surface_mach_port.get()); if (ca_layer_params.io_surface_mach_port) {
#else DCHECK(!ca_layer_params.ca_context_id);
return mojo::ScopedHandle(); return gfx::mojom::CALayerContent::NewIoSurfaceMachPort(
mojo::WrapMachPort(ca_layer_params.io_surface_mach_port.get()));
}
#endif #endif
return gfx::mojom::CALayerContent::NewCaContextId(
ca_layer_params.ca_context_id);
} }
bool StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>::Read( bool StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>::Read(
gfx::mojom::CALayerParamsDataView data, gfx::mojom::CALayerParamsDataView data,
gfx::CALayerParams* out) { gfx::CALayerParams* out) {
out->is_empty = data.is_empty(); out->is_empty = data.is_empty();
out->ca_context_id = data.ca_context_id();
gfx::mojom::CALayerContentDataView content_data;
data.GetContentDataView(&content_data);
switch (content_data.tag()) {
case gfx::mojom::CALayerContentDataView::Tag::CA_CONTEXT_ID:
out->ca_context_id = content_data.ca_context_id();
break;
case gfx::mojom::CALayerContentDataView::Tag::IO_SURFACE_MACH_PORT:
#if defined(OS_MACOSX) && !defined(OS_IOS) #if defined(OS_MACOSX) && !defined(OS_IOS)
mach_port_t io_surface_mach_port; mach_port_t io_surface_mach_port;
MojoResult unwrap_result = MojoResult unwrap_result = mojo::UnwrapMachPort(
mojo::UnwrapMachPort(data.TakeIoSurfaceMachPort(), &io_surface_mach_port); content_data.TakeIoSurfaceMachPort(), &io_surface_mach_port);
if (unwrap_result != MOJO_RESULT_OK) if (unwrap_result != MOJO_RESULT_OK)
return false; return false;
out->io_surface_mach_port.reset(io_surface_mach_port); out->io_surface_mach_port.reset(io_surface_mach_port);
#else
return false;
#endif #endif
break;
}
if (!data.ReadPixelSize(&out->pixel_size)) if (!data.ReadPixelSize(&out->pixel_size))
return false; return false;
out->scale_factor = data.scale_factor(); out->scale_factor = data.scale_factor();
return true; return true;
} }
......
...@@ -16,13 +16,6 @@ struct StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams> { ...@@ -16,13 +16,6 @@ struct StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams> {
return ca_layer_params.is_empty; return ca_layer_params.is_empty;
} }
static uint32_t ca_context_id(const gfx::CALayerParams& ca_layer_params) {
return ca_layer_params.ca_context_id;
}
static mojo::ScopedHandle io_surface_mach_port(
const gfx::CALayerParams& ca_layer_params);
static gfx::Size pixel_size(const gfx::CALayerParams& ca_layer_params) { static gfx::Size pixel_size(const gfx::CALayerParams& ca_layer_params) {
return ca_layer_params.pixel_size; return ca_layer_params.pixel_size;
} }
...@@ -31,6 +24,9 @@ struct StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams> { ...@@ -31,6 +24,9 @@ struct StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams> {
return ca_layer_params.scale_factor; return ca_layer_params.scale_factor;
} }
static gfx::mojom::CALayerContentPtr content(
const gfx::CALayerParams& ca_layer_params);
static bool Read(gfx::mojom::CALayerParamsDataView data, static bool Read(gfx::mojom::CALayerParamsDataView data,
gfx::CALayerParams* out); gfx::CALayerParams* out);
}; };
......
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