viz/mac: Prepare the ground for CoreAnimation plumbing
The parameters for sending a CALayer tree from the GPU process to the
browser process will have to be shuffled a bit for viz. Before doing
this, clean up the existing path.
Current relevant sequence of events:
* gpu::ImageTransportSurfaceOverlayMac populates
gpu::SwapBuffersCompleteParams in the GPU process.
* Structure includes gfx::SwapResponse,
gpu::TextureInUseResponses, and CALayer parameters.
* gpu::CommandBuffer un-and-re-packs this structure as
GpuCommandBufferMsg_SwapBuffersCompleted_Params to send via IPC.
* gpu::CommandBufferProxyImpl::OnSwapBuffersCompleted then
un-and-re-packs that structure as two separate arguments
* gfx::SwapResponse
* Is consumed on all platforms
* gpu::GpuProcessHostedCALayerTreeParamsMac
* Is consumed by GpuOutputSurfaceMac only, passed by pointer
* Includes gpu::TextureInUseResponses as a member
* These arguments ultimately resurface in a function named
OnGpuSwapBuffersCompleted in viz::DisplayOutputSurface or
content::GpuBrowserCompositorOutputSurface (or subclasses thereof).
The reason for this patch is that, in viz, we will need to split up
gpu::GpuProcessHostedCALayerTreeParamsMac, because different
parts go to different places. In particular:
* The actual CALayer-related parameters need to go up to the browser
* The TextureInUseResponses parameter just goes to the GLRenderer
Since we're doing surgery in the neighborhood, some of the
un-and-re-packing can be done away with.
The changes made are:
* Add a new gfx::CALayerParams structure
* In gfx because it will be passed into ui code on the browser
side.
* Not ifdef-ed out on non-macOS (though is largely depopulated)
to avoid ifdef-spaghetti (an is_empty parameter will be used
for early-out)
* Keep the IOSurface as a mach port much longer, because viz
will need to re-pass it to the browser side (via mojo).
* Populate gpu::SwapBuffersCompleteParams with all three
separately-destined components:
* gfx::SwapResponse (as before)
* gpu::TextureInUseResponses (as before)
* This is not ifdef-ed out even though it is macOS-only
avoid preprocessor-spaghetti and to help testing.
* gpu::CALayerParams (new)
* This was previously just inline
* Move gpu::SwapBuffersCompleteParams from service into common
* This is passed without any inspection or modification from
gpu::ImageTransportSurfaceOverlayMac to *GpuOutputSurfaceMac,
where its sub-parts finally diverge.
* This lets us remove the un-and-re-pack of parameters.
* Delete the redundant structures:
* GpuCommandBufferMsg_SwapBuffersCompleted_Params
* gpu::GpuProcessHostedCALayerTreeParamsMac
Bug: 772576
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I8fd06898a4b1f8432b563c0bc63975787b05cb46
Reviewed-on: https://chromium-review.googlesource.com/798642
Reviewed-by: ccameron <ccameron@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521226}diff --git a/components/viz/service/display_embedder/gl_output_surface.cc b/components/viz/service/display_embedder/gl_output_surface.cc
index 684ea912..68bbf56 100644
--- a/components/viz/service/display_embedder/gl_output_surface.cc
+++ b/components/viz/service/display_embedder/gl_output_surface.cc
@@ -15,6 +15,7 @@
#include "components/viz/service/display/output_surface_frame.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "ui/gl/gl_utils.h"
namespace viz {
@@ -138,10 +139,13 @@
}
void GLOutputSurface::OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
- DidReceiveSwapBuffersAck(response.result, response.swap_id);
- latency_info_cache_.OnSwapBuffersCompleted(response);
+ const gpu::SwapBuffersCompleteParams& params) {
+ // TODO(ccameron): Route |params.ca_layer_params|.
+ if (!params.texture_in_use_responses.empty())
+ client_->DidReceiveTextureInUseResponses(params.texture_in_use_responses);
+ DidReceiveSwapBuffersAck(params.swap_response.result,
+ params.swap_response.swap_id);
+ latency_info_cache_.OnSwapBuffersCompleted(params.swap_response);
}
void GLOutputSurface::LatencyInfoCompleted(
diff --git a/components/viz/service/display_embedder/gl_output_surface.h b/components/viz/service/display_embedder/gl_output_surface.h
index 7f4769c..0a9aef10 100644
--- a/components/viz/service/display_embedder/gl_output_surface.h
+++ b/components/viz/service/display_embedder/gl_output_surface.h
@@ -58,9 +58,7 @@
private:
// Called when a swap completion is signaled from ImageTransportSurface.
- void OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac);
+ void OnGpuSwapBuffersCompleted(const gpu::SwapBuffersCompleteParams& params);
void OnVSyncParametersUpdated(base::TimeTicks timebase,
base::TimeDelta interval);
void OnPresentation(uint64_t swap_id,
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
index a18042e..3f3c30d 100644
--- a/content/browser/compositor/gpu_browser_compositor_output_surface.cc
+++ b/content/browser/compositor/gpu_browser_compositor_output_surface.cc
@@ -15,6 +15,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/ipc/client/command_buffer_proxy_impl.h"
#include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
#include "ui/gl/gl_utils.h"
@@ -58,10 +59,9 @@
}
void GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
- client_->DidReceiveSwapBuffersAck(response.swap_id);
- latency_info_cache_.OnSwapBuffersCompleted(response);
+ const gpu::SwapBuffersCompleteParams& params) {
+ client_->DidReceiveSwapBuffersAck(params.swap_response.swap_id);
+ latency_info_cache_.OnSwapBuffersCompleted(params.swap_response);
}
void GpuBrowserCompositorOutputSurface::LatencyInfoCompleted(
diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.h b/content/browser/compositor/gpu_browser_compositor_output_surface.h
index da2c17e2..a6cff77 100644
--- a/content/browser/compositor/gpu_browser_compositor_output_surface.h
+++ b/content/browser/compositor/gpu_browser_compositor_output_surface.h
@@ -23,7 +23,7 @@
namespace gpu {
class CommandBufferProxyImpl;
-struct GpuProcessHostedCALayerTreeParamsMac;
+struct SwapBuffersCompleteParams;
}
namespace ui {
@@ -50,13 +50,8 @@
~GpuBrowserCompositorOutputSurface() override;
// Called when a swap completion is sent from the GPU process.
- // The argument |params_mac| is used to communicate parameters needed on Mac
- // to display the CALayer for the swap in the browser process.
- // TODO(ccameron): Remove |params_mac| when the CALayer tree is hosted in the
- // browser process.
virtual void OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac);
+ const gpu::SwapBuffersCompleteParams& params);
// BrowserCompositorOutputSurface implementation.
void OnReflectorChanged() override;
diff --git a/content/browser/compositor/gpu_output_surface_mac.h b/content/browser/compositor/gpu_output_surface_mac.h
index 73f30b30..48040e13 100644
--- a/content/browser/compositor/gpu_output_surface_mac.h
+++ b/content/browser/compositor/gpu_output_surface_mac.h
@@ -30,8 +30,7 @@
// BrowserCompositorOutputSurface implementation.
void OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) override;
+ const gpu::SwapBuffersCompleteParams& params) override;
void SetSurfaceSuspendedForRecycle(bool suspended) override;
private:
diff --git a/content/browser/compositor/gpu_output_surface_mac.mm b/content/browser/compositor/gpu_output_surface_mac.mm
index e3615e4..3f56a464 100644
--- a/content/browser/compositor/gpu_output_surface_mac.mm
+++ b/content/browser/compositor/gpu_output_surface_mac.mm
@@ -8,7 +8,7 @@
#include "components/viz/service/display/output_surface_frame.h"
#include "components/viz/service/display_embedder/compositor_overlay_candidate_validator.h"
#include "gpu/GLES2/gl2extchromium.h"
-#include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
#include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
#include "ui/base/cocoa/remote_layer_api.h"
@@ -67,9 +67,9 @@
}
void GpuOutputSurfaceMac::OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
- remote_layers_->UpdateLayers(params_mac->ca_context_id);
+ const gpu::SwapBuffersCompleteParams& params) {
+ const gfx::CALayerParams& ca_layer_params = params.ca_layer_params;
+ remote_layers_->UpdateLayers(ca_layer_params.ca_context_id);
if (should_show_frames_state_ == SHOULD_SHOW_FRAMES) {
ui::AcceleratedWidgetMac* widget = ui::AcceleratedWidgetMac::Get(widget_);
if (widget) {
@@ -77,17 +77,21 @@
widget->GotCALayerFrame(
base::scoped_nsobject<CALayer>(remote_layers_->content_layer.get(),
base::scoped_policy::RETAIN),
- params_mac->pixel_size, params_mac->scale_factor);
+ ca_layer_params.pixel_size, ca_layer_params.scale_factor);
} else {
- widget->GotIOSurfaceFrame(params_mac->io_surface,
- params_mac->pixel_size,
- params_mac->scale_factor);
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface(
+ IOSurfaceLookupFromMachPort(ca_layer_params.io_surface_mach_port));
+ if (!io_surface) {
+ LOG(ERROR) << "Unable to open IOSurface for frame.";
+ }
+ widget->GotIOSurfaceFrame(io_surface, ca_layer_params.pixel_size,
+ ca_layer_params.scale_factor);
}
}
}
- client_->DidReceiveTextureInUseResponses(params_mac->responses);
+ client_->DidReceiveTextureInUseResponses(params.texture_in_use_responses);
GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
- response, params_mac);
+ params);
}
void GpuOutputSurfaceMac::SetSurfaceSuspendedForRecycle(bool suspended) {
diff --git a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc
index 67230cc..c1cb69e 100644
--- a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc
+++ b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.cc
@@ -14,6 +14,7 @@
#include "content/browser/compositor/reflector_impl.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
namespace content {
@@ -111,20 +112,19 @@
}
void GpuSurfacelessBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
- gfx::SwapResponse modified_response(response);
+ const gpu::SwapBuffersCompleteParams& params) {
+ gpu::SwapBuffersCompleteParams modified_params(params);
bool force_swap = false;
- if (response.result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) {
+ if (params.swap_response.result ==
+ gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) {
// Even through the swap failed, this is a fixable error so we can pretend
// it succeeded to the rest of the system.
- modified_response.result = gfx::SwapResult::SWAP_ACK;
+ modified_params.swap_response.result = gfx::SwapResult::SWAP_ACK;
buffer_queue_->RecreateBuffers();
force_swap = true;
}
buffer_queue_->PageFlipComplete();
- GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
- modified_response, params_mac);
+ GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(modified_params);
if (force_swap)
client_->SetNeedsRedrawRect(gfx::Rect(swap_size_));
}
diff --git a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h
index 2e5b2ce..48a7356f 100644
--- a/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h
+++ b/content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h
@@ -51,8 +51,7 @@
// BrowserCompositorOutputSurface implementation.
void OnGpuSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) override;
+ const gpu::SwapBuffersCompleteParams& params) override;
private:
gfx::Size reshape_size_;
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index 23b66fe..ce43af6 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -61,6 +61,7 @@
#include "content/public/browser/browser_thread.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/ipc/client/command_buffer_proxy_impl.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "gpu/ipc/common/gpu_surface_tracker.h"
@@ -73,13 +74,10 @@
#include "ui/android/window_android.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
+#include "ui/gfx/ca_layer_params.h"
#include "ui/gfx/swap_result.h"
#include "ui/gl/gl_utils.h"
-namespace gpu {
-struct GpuProcessHostedCALayerTreeParamsMac;
-}
-
namespace content {
namespace {
@@ -349,12 +347,10 @@
return command_buffer_proxy;
}
- void OnSwapBuffersCompleted(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
- client_->DidReceiveSwapBuffersAck(response.swap_id);
+ void OnSwapBuffersCompleted(const gpu::SwapBuffersCompleteParams& params) {
+ client_->DidReceiveSwapBuffersAck(params.swap_response.swap_id);
swap_buffers_callback_.Run();
- latency_info_cache_.OnSwapBuffersCompleted(response);
+ latency_info_cache_.OnSwapBuffersCompleted(params.swap_response);
}
private:
diff --git a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_schedule_ca_layer.txt b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_schedule_ca_layer.txt
index 5b87c93..06d26ee 100644
--- a/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_schedule_ca_layer.txt
+++ b/gpu/GLES2/extensions/CHROMIUM/CHROMIUM_schedule_ca_layer.txt
@@ -93,9 +93,9 @@
texture is backed by an IOSurface, then the query checks to see whether the
IOSurface is in use by the Window Server. Otherwise, the query returns
false. All the results will be returned with the swap ACK in
- GpuCommandBufferMsg_SwapBuffersCompleted_Params. Clients should not destroy
- any textures while they are being queried, as the swap ACK will use the
- original texture id to identify the queried textures.
+ SwapBuffersCompleteParams. Clients should not destroy any textures while
+ they are being queried, as the swap ACK will use the original texture id to
+ identify the queried textures.
Errors
diff --git a/gpu/command_buffer/common/BUILD.gn b/gpu/command_buffer/common/BUILD.gn
index 1f177b2b..81e58e1 100644
--- a/gpu/command_buffer/common/BUILD.gn
+++ b/gpu/command_buffer/common/BUILD.gn
@@ -57,6 +57,8 @@
"mailbox_holder.h",
"scheduling_priority.cc",
"scheduling_priority.h",
+ "swap_buffers_complete_params.cc",
+ "swap_buffers_complete_params.h",
"sync_token.cc",
"sync_token.h",
"texture_in_use_response.h",
diff --git a/gpu/ipc/service/image_transport_surface_delegate.cc b/gpu/command_buffer/common/swap_buffers_complete_params.cc
similarity index 64%
rename from gpu/ipc/service/image_transport_surface_delegate.cc
rename to gpu/command_buffer/common/swap_buffers_complete_params.cc
index f0be1c5..8a2551a46 100644
--- a/gpu/ipc/service/image_transport_surface_delegate.cc
+++ b/gpu/command_buffer/common/swap_buffers_complete_params.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "gpu/ipc/service/image_transport_surface_delegate.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
namespace gpu {
@@ -11,9 +11,15 @@
SwapBuffersCompleteParams::SwapBuffersCompleteParams(
SwapBuffersCompleteParams&& other) = default;
-SwapBuffersCompleteParams::~SwapBuffersCompleteParams() = default;
+SwapBuffersCompleteParams::SwapBuffersCompleteParams(
+ const SwapBuffersCompleteParams& other) = default;
SwapBuffersCompleteParams& SwapBuffersCompleteParams::operator=(
SwapBuffersCompleteParams&& other) = default;
+SwapBuffersCompleteParams& SwapBuffersCompleteParams::operator=(
+ const SwapBuffersCompleteParams& other) = default;
+
+SwapBuffersCompleteParams::~SwapBuffersCompleteParams() = default;
+
} // namespace gpu
diff --git a/gpu/command_buffer/common/swap_buffers_complete_params.h b/gpu/command_buffer/common/swap_buffers_complete_params.h
new file mode 100644
index 0000000..c2971e2
--- /dev/null
+++ b/gpu/command_buffer/common/swap_buffers_complete_params.h
@@ -0,0 +1,33 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_COMMON_SWAP_BUFFERS_COMPLETE_PARAMS_H_
+#define GPU_COMMAND_BUFFER_COMMON_SWAP_BUFFERS_COMPLETE_PARAMS_H_
+
+#include "gpu/command_buffer/common/texture_in_use_response.h"
+#include "ui/gfx/ca_layer_params.h"
+#include "ui/gfx/swap_result.h"
+
+namespace gpu {
+
+struct GPU_EXPORT SwapBuffersCompleteParams {
+ SwapBuffersCompleteParams();
+ SwapBuffersCompleteParams(SwapBuffersCompleteParams&& other);
+ SwapBuffersCompleteParams(const SwapBuffersCompleteParams& other);
+ SwapBuffersCompleteParams& operator=(SwapBuffersCompleteParams&& other);
+ SwapBuffersCompleteParams& operator=(const SwapBuffersCompleteParams& other);
+ ~SwapBuffersCompleteParams();
+
+ gfx::SwapResponse swap_response;
+ // Used only on macOS, for coordinating IOSurface reuse with the system
+ // WindowServer.
+ gpu::TextureInUseResponses texture_in_use_responses;
+ // Used only on macOS, to allow the browser hosted NSWindow to display
+ // content populated in the GPU process.
+ gfx::CALayerParams ca_layer_params;
+};
+
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_COMMON_SWAP_BUFFERS_COMPLETE_PARAMS_H_
diff --git a/gpu/ipc/client/BUILD.gn b/gpu/ipc/client/BUILD.gn
index 91932137..af8652b 100644
--- a/gpu/ipc/client/BUILD.gn
+++ b/gpu/ipc/client/BUILD.gn
@@ -31,8 +31,6 @@
sources += [
"gpu_memory_buffer_impl_io_surface.cc",
"gpu_memory_buffer_impl_io_surface.h",
- "gpu_process_hosted_ca_layer_tree_params.cc",
- "gpu_process_hosted_ca_layer_tree_params.h",
]
}
if (is_win) {
diff --git a/gpu/ipc/client/command_buffer_proxy_impl.cc b/gpu/ipc/client/command_buffer_proxy_impl.cc
index 4a735f9d..66da21c 100644
--- a/gpu/ipc/client/command_buffer_proxy_impl.cc
+++ b/gpu/ipc/client/command_buffer_proxy_impl.cc
@@ -34,10 +34,6 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_switches.h"
-#if defined(OS_MACOSX)
-#include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h"
-#endif
-
namespace gpu {
namespace {
@@ -791,21 +787,9 @@
}
void CommandBufferProxyImpl::OnSwapBuffersCompleted(
- const GpuCommandBufferMsg_SwapBuffersCompleted_Params& params) {
-#if defined(OS_MACOSX)
- gpu::GpuProcessHostedCALayerTreeParamsMac params_mac;
- params_mac.ca_context_id = params.ca_context_id;
- params_mac.io_surface.reset(IOSurfaceLookupFromMachPort(params.io_surface));
- params_mac.pixel_size = params.pixel_size;
- params_mac.scale_factor = params.scale_factor;
- params_mac.responses = std::move(params.in_use_responses);
- gpu::GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = ¶ms_mac;
-#else
- gpu::GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = nullptr;
-#endif
-
+ const SwapBuffersCompleteParams& params) {
if (!swap_buffers_completion_callback_.is_null())
- swap_buffers_completion_callback_.Run(params.response, mac_frame_ptr);
+ swap_buffers_completion_callback_.Run(params);
}
void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase,
diff --git a/gpu/ipc/client/command_buffer_proxy_impl.h b/gpu/ipc/client/command_buffer_proxy_impl.h
index 64799dc4..56c65b3 100644
--- a/gpu/ipc/client/command_buffer_proxy_impl.h
+++ b/gpu/ipc/client/command_buffer_proxy_impl.h
@@ -36,7 +36,6 @@
#include "ui/gl/gpu_preference.h"
struct GPUCommandBufferConsoleMessage;
-struct GpuCommandBufferMsg_SwapBuffersCompleted_Params;
class GURL;
namespace base {
@@ -48,8 +47,8 @@
}
namespace gpu {
-struct GpuProcessHostedCALayerTreeParamsMac;
struct Mailbox;
+struct SwapBuffersCompleteParams;
struct SyncToken;
namespace gles2 {
@@ -143,9 +142,8 @@
bool EnsureBackbuffer();
- using SwapBuffersCompletionCallback = base::Callback<void(
- const gfx::SwapResponse& response,
- const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac)>;
+ using SwapBuffersCompletionCallback =
+ base::RepeatingCallback<void(const SwapBuffersCompleteParams& params)>;
void SetSwapBuffersCompletionCallback(
const SwapBuffersCompletionCallback& callback);
@@ -196,8 +194,7 @@
gpu::error::Error error);
void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message);
void OnSignalAck(uint32_t id, const CommandBuffer::State& state);
- void OnSwapBuffersCompleted(
- const GpuCommandBufferMsg_SwapBuffersCompleted_Params& params);
+ void OnSwapBuffersCompleted(const SwapBuffersCompleteParams& params);
void OnUpdateVSyncParameters(base::TimeTicks timebase,
base::TimeDelta interval);
void OnBufferPresented(uint64_t swap_id,
diff --git a/gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.cc b/gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.cc
deleted file mode 100644
index 1d1997c..0000000
--- a/gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h"
-
-namespace gpu {
-
-GpuProcessHostedCALayerTreeParamsMac::GpuProcessHostedCALayerTreeParamsMac() {}
-
-GpuProcessHostedCALayerTreeParamsMac::~GpuProcessHostedCALayerTreeParamsMac() {}
-
-} // namespace gpu
diff --git a/gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h b/gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h
deleted file mode 100644
index 938c81a..0000000
--- a/gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <IOSurface/IOSurface.h>
-
-#include "base/mac/scoped_cftyperef.h"
-#include "gpu/command_buffer/common/texture_in_use_response.h"
-#include "gpu/gpu_export.h"
-#include "ui/base/cocoa/remote_layer_api.h"
-#include "ui/gfx/geometry/size.h"
-
-namespace gpu {
-
-struct GPU_EXPORT GpuProcessHostedCALayerTreeParamsMac {
- GpuProcessHostedCALayerTreeParamsMac();
- ~GpuProcessHostedCALayerTreeParamsMac();
-
- CAContextID ca_context_id = 0;
- base::ScopedCFTypeRef<IOSurfaceRef> io_surface;
- gfx::Size pixel_size;
- float scale_factor = 1;
- TextureInUseResponses responses;
-};
-
-} // namespace gpu
diff --git a/gpu/ipc/common/gpu_messages.h b/gpu/ipc/common/gpu_messages.h
index d5a8493..1f9806f 100644
--- a/gpu/ipc/common/gpu_messages.h
+++ b/gpu/ipc/common/gpu_messages.h
@@ -22,7 +22,6 @@
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/sync_token.h"
-#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "gpu/config/gpu_info.h"
#include "gpu/gpu_export.h"
#include "gpu/ipc/common/gpu_command_buffer_traits.h"
@@ -72,22 +71,6 @@
IPC_STRUCT_MEMBER(uint64_t, image_release_count)
IPC_STRUCT_END()
-IPC_STRUCT_BEGIN(GpuCommandBufferMsg_SwapBuffersCompleted_Params)
-#if defined(OS_MACOSX)
- // Mac-specific parameters used to present CALayers hosted in the GPU process.
- // TODO(ccameron): Remove these parameters once the CALayer tree is hosted in
- // the browser process.
- // https://crbug.com/604052
- // Only one of ca_context_id or io_surface may be non-0.
- IPC_STRUCT_MEMBER(CAContextID, ca_context_id)
- IPC_STRUCT_MEMBER(gfx::ScopedRefCountedIOSurfaceMachPort, io_surface)
- IPC_STRUCT_MEMBER(gfx::Size, pixel_size)
- IPC_STRUCT_MEMBER(float, scale_factor)
- IPC_STRUCT_MEMBER(gpu::TextureInUseResponses, in_use_responses)
-#endif
- IPC_STRUCT_MEMBER(gfx::SwapResponse, response)
-IPC_STRUCT_END()
-
//------------------------------------------------------------------------------
// GPU Channel Messages
// These are messages from a renderer process to the GPU process.
@@ -200,9 +183,8 @@
gpu::error::Error /* error */)
// Tells the browser that SwapBuffers returned.
-IPC_MESSAGE_ROUTED1(
- GpuCommandBufferMsg_SwapBuffersCompleted,
- GpuCommandBufferMsg_SwapBuffersCompleted_Params /* params */)
+IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SwapBuffersCompleted,
+ gpu::SwapBuffersCompleteParams /* params */)
// Tells the browser about updated parameters for vsync alignment.
IPC_MESSAGE_ROUTED2(GpuCommandBufferMsg_UpdateVSyncParameters,
diff --git a/gpu/ipc/common/gpu_param_traits_macros.h b/gpu/ipc/common/gpu_param_traits_macros.h
index 5b9088e..46d06a1 100644
--- a/gpu/ipc/common/gpu_param_traits_macros.h
+++ b/gpu/ipc/common/gpu_param_traits_macros.h
@@ -8,10 +8,12 @@
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/common/context_result.h"
#include "gpu/command_buffer/common/scheduling_priority.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/gpu_export.h"
#include "gpu/ipc/common/flush_params.h"
#include "gpu/ipc/common/gpu_command_buffer_traits.h"
#include "ipc/ipc_message_macros.h"
+#include "ui/gfx/ipc/gfx_param_traits.h"
#include "url/ipc/url_param_traits.h"
#undef IPC_MESSAGE_EXPORT
@@ -30,4 +32,10 @@
IPC_ENUM_TRAITS_MAX_VALUE(gpu::ContextResult,
gpu::ContextResult::kLastContextResult);
+IPC_STRUCT_TRAITS_BEGIN(gpu::SwapBuffersCompleteParams)
+ IPC_STRUCT_TRAITS_MEMBER(ca_layer_params)
+ IPC_STRUCT_TRAITS_MEMBER(texture_in_use_responses)
+ IPC_STRUCT_TRAITS_MEMBER(swap_response)
+IPC_STRUCT_TRAITS_END()
+
#endif // GPU_IPC_COMMON_GPU_PARAM_TRAITS_MACROS_H_
diff --git a/gpu/ipc/in_process_command_buffer.cc b/gpu/ipc/in_process_command_buffer.cc
index e70aab81..2f87686 100644
--- a/gpu/ipc/in_process_command_buffer.cc
+++ b/gpu/ipc/in_process_command_buffer.cc
@@ -29,6 +29,7 @@
#include "gpu/command_buffer/client/gpu_control_client.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/context_group.h"
@@ -59,10 +60,6 @@
#include "base/process/process_handle.h"
#endif
-#if defined(OS_MACOSX)
-#include "gpu/ipc/client/gpu_process_hosted_ca_layer_tree_params.h"
-#endif
-
namespace gpu {
namespace {
@@ -1104,19 +1101,8 @@
void InProcessCommandBuffer::DidSwapBuffersCompleteOnOriginThread(
SwapBuffersCompleteParams params) {
-#if defined(OS_MACOSX)
- GpuProcessHostedCALayerTreeParamsMac params_mac;
- params_mac.ca_context_id = params.ca_context_id;
- params_mac.io_surface.reset(IOSurfaceLookupFromMachPort(params.io_surface));
- params_mac.pixel_size = params.pixel_size;
- params_mac.scale_factor = params.scale_factor;
- params_mac.responses = std::move(params.in_use_responses);
- GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = ¶ms_mac;
-#else
- GpuProcessHostedCALayerTreeParamsMac* mac_frame_ptr = nullptr;
-#endif
if (!swap_buffers_completion_callback_.is_null())
- swap_buffers_completion_callback_.Run(params.response, mac_frame_ptr);
+ swap_buffers_completion_callback_.Run(std::move(params));
}
void InProcessCommandBuffer::UpdateVSyncParametersOnOriginThread(
diff --git a/gpu/ipc/in_process_command_buffer.h b/gpu/ipc/in_process_command_buffer.h
index 878313a4..1d2cd3fab 100644
--- a/gpu/ipc/in_process_command_buffer.h
+++ b/gpu/ipc/in_process_command_buffer.h
@@ -61,7 +61,7 @@
class SyncPointClientState;
class SyncPointOrderData;
class SyncPointManager;
-struct GpuProcessHostedCALayerTreeParamsMac;
+struct SwapBuffersCompleteParams;
namespace gles2 {
struct ContextCreationAttribHelper;
@@ -176,9 +176,8 @@
// Upstream this function to GpuControl if needs arise.
const GpuFeatureInfo& GetGpuFeatureInfo() const;
- using SwapBuffersCompletionCallback = base::Callback<void(
- const gfx::SwapResponse& response,
- const GpuProcessHostedCALayerTreeParamsMac* params_mac)>;
+ using SwapBuffersCompletionCallback =
+ base::RepeatingCallback<void(const SwapBuffersCompleteParams& params)>;
void SetSwapBuffersCompletionCallback(
const SwapBuffersCompletionCallback& callback);
diff --git a/gpu/ipc/service/BUILD.gn b/gpu/ipc/service/BUILD.gn
index 80a0f13..3397fbf 100644
--- a/gpu/ipc/service/BUILD.gn
+++ b/gpu/ipc/service/BUILD.gn
@@ -49,7 +49,6 @@
"gpu_watchdog_thread.cc",
"gpu_watchdog_thread.h",
"image_transport_surface.h",
- "image_transport_surface_delegate.cc",
"image_transport_surface_delegate.h",
"pass_through_image_transport_surface.cc",
"pass_through_image_transport_surface.h",
diff --git a/gpu/ipc/service/direct_composition_surface_win_unittest.cc b/gpu/ipc/service/direct_composition_surface_win_unittest.cc
index 21a87fb..09c9517 100644
--- a/gpu/ipc/service/direct_composition_surface_win_unittest.cc
+++ b/gpu/ipc/service/direct_composition_surface_win_unittest.cc
@@ -12,6 +12,7 @@
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_hdc.h"
#include "base/win/scoped_select_object.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gpu_preferences.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/gpu/ipc/service/gpu_command_buffer_stub.cc b/gpu/ipc/service/gpu_command_buffer_stub.cc
index 2363f298..fe38265 100644
--- a/gpu/ipc/service/gpu_command_buffer_stub.cc
+++ b/gpu/ipc/service/gpu_command_buffer_stub.cc
@@ -330,16 +330,7 @@
void GpuCommandBufferStub::DidSwapBuffersComplete(
SwapBuffersCompleteParams params) {
- GpuCommandBufferMsg_SwapBuffersCompleted_Params send_params;
-#if defined(OS_MACOSX)
- send_params.ca_context_id = params.ca_context_id;
- send_params.io_surface = params.io_surface;
- send_params.pixel_size = params.pixel_size;
- send_params.scale_factor = params.scale_factor;
- send_params.in_use_responses = params.in_use_responses;
-#endif
- send_params.response = std::move(params.response);
- Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, send_params));
+ Send(new GpuCommandBufferMsg_SwapBuffersCompleted(route_id_, params));
}
const gles2::FeatureInfo* GpuCommandBufferStub::GetFeatureInfo() const {
diff --git a/gpu/ipc/service/image_transport_surface_delegate.h b/gpu/ipc/service/image_transport_surface_delegate.h
index f6d5192..2af56568 100644
--- a/gpu/ipc/service/image_transport_surface_delegate.h
+++ b/gpu/ipc/service/image_transport_surface_delegate.h
@@ -9,12 +9,6 @@
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "gpu/gpu_export.h"
#include "gpu/ipc/common/surface_handle.h"
-#include "ui/gfx/swap_result.h"
-
-#if defined(OS_MACOSX)
-#include "ui/base/cocoa/remote_layer_api.h"
-#include "ui/gfx/mac/io_surface.h"
-#endif
namespace IPC {
class MessageFilter;
@@ -26,33 +20,12 @@
namespace gpu {
struct GpuPreferences;
+struct SwapBuffersCompleteParams;
namespace gles2 {
class FeatureInfo;
}
-struct GPU_EXPORT SwapBuffersCompleteParams {
- SwapBuffersCompleteParams();
- SwapBuffersCompleteParams(SwapBuffersCompleteParams&& other);
- ~SwapBuffersCompleteParams();
-
- SwapBuffersCompleteParams& operator=(SwapBuffersCompleteParams&& other);
-
-#if defined(OS_MACOSX)
- // Mac-specific parameters used to present CALayers hosted in the GPU process.
- // TODO(ccameron): Remove these parameters once the CALayer tree is hosted in
- // the browser process.
- // https://crbug.com/604052
- // Only one of ca_context_id or io_surface may be non-0.
- CAContextID ca_context_id = 0;
- gfx::ScopedRefCountedIOSurfaceMachPort io_surface;
- gfx::Size pixel_size;
- float scale_factor = 1.f;
- gpu::TextureInUseResponses in_use_responses;
-#endif
- gfx::SwapResponse response;
-};
-
class GPU_EXPORT ImageTransportSurfaceDelegate {
public:
#if defined(OS_WIN)
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
index 0a8c9e5..08ab338 100644
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
@@ -26,6 +26,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/ipc/service/gpu_channel_manager.h"
#include "gpu/ipc/service/gpu_channel_manager_delegate.h"
#include "ui/accelerated_widget_mac/ca_layer_tree_coordinator.h"
@@ -219,21 +220,22 @@
"GLImpl", static_cast<int>(gl::GetGLImplementation()),
"width", pixel_size_.width());
if (use_remote_layer_api_) {
- params.ca_context_id = [ca_context_ contextId];
+ params.ca_layer_params.ca_context_id = [ca_context_ contextId];
} else {
IOSurfaceRef io_surface =
ca_layer_tree_coordinator_->GetIOSurfaceForDisplay();
if (io_surface) {
- params.io_surface.reset(IOSurfaceCreateMachPort(io_surface));
+ params.ca_layer_params.io_surface_mach_port.reset(
+ IOSurfaceCreateMachPort(io_surface));
}
}
- params.pixel_size = pixel_size_;
- params.scale_factor = scale_factor_;
- params.response.swap_id = swap_id_++;
- params.response.result = gfx::SwapResult::SWAP_ACK;
+ params.ca_layer_params.pixel_size = pixel_size_;
+ params.ca_layer_params.scale_factor = scale_factor_;
+ params.swap_response.swap_id = swap_id_++;
+ params.swap_response.result = gfx::SwapResult::SWAP_ACK;
// TODO(brianderson): Tie swap_start to before_flush_time.
- params.response.swap_start = after_flush_before_commit_time;
- params.response.swap_end = after_flush_before_commit_time;
+ params.swap_response.swap_start = after_flush_before_commit_time;
+ params.swap_response.swap_end = after_flush_before_commit_time;
for (auto& query : ca_layer_in_use_queries_) {
gpu::TextureInUseResponse response;
response.texture = query.texture;
@@ -245,7 +247,7 @@
IOSurfaceIsInUse(io_surface_image->io_surface());
}
response.in_use = in_use;
- params.in_use_responses.push_back(std::move(response));
+ params.texture_in_use_responses.push_back(std::move(response));
}
ca_layer_in_use_queries_.clear();
}
diff --git a/gpu/ipc/service/pass_through_image_transport_surface.cc b/gpu/ipc/service/pass_through_image_transport_surface.cc
index e380041..0f6bac5 100644
--- a/gpu/ipc/service/pass_through_image_transport_surface.cc
+++ b/gpu/ipc/service/pass_through_image_transport_surface.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "build/build_config.h"
+#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "ui/gfx/vsync_provider.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_switches.h"
@@ -251,7 +252,7 @@
if (delegate_) {
SwapBuffersCompleteParams params;
- params.response = std::move(response);
+ params.swap_response = std::move(response);
delegate_->DidSwapBuffersComplete(std::move(params));
}
}
diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn
index ed2b6cf..8b14e361 100644
--- a/ui/gfx/BUILD.gn
+++ b/ui/gfx/BUILD.gn
@@ -515,6 +515,8 @@
sources = [
"buffer_format_util.cc",
"buffer_format_util.h",
+ "ca_layer_params.cc",
+ "ca_layer_params.h",
"client_native_pixmap.h",
"client_native_pixmap_factory.cc",
"client_native_pixmap_factory.h",
diff --git a/ui/gfx/ca_layer_params.cc b/ui/gfx/ca_layer_params.cc
new file mode 100644
index 0000000..1824bc5
--- /dev/null
+++ b/ui/gfx/ca_layer_params.cc
@@ -0,0 +1,16 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/ca_layer_params.h"
+
+namespace gfx {
+
+CALayerParams::CALayerParams() {}
+CALayerParams::~CALayerParams() = default;
+CALayerParams::CALayerParams(CALayerParams&& params) = default;
+CALayerParams::CALayerParams(const CALayerParams& params) = default;
+CALayerParams& CALayerParams::operator=(CALayerParams&& params) = default;
+CALayerParams& CALayerParams::operator=(const CALayerParams& params) = default;
+
+} // namespace gfx
diff --git a/ui/gfx/ca_layer_params.h b/ui/gfx/ca_layer_params.h
new file mode 100644
index 0000000..d5ba764
--- /dev/null
+++ b/ui/gfx/ca_layer_params.h
@@ -0,0 +1,49 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_CA_LAYER_PARAMS_H_
+#define UI_GFX_CA_LAYER_PARAMS_H_
+
+#include "build/build_config.h"
+#include "ui/gfx/gfx_export.h"
+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+#include "ui/gfx/mac/io_surface.h"
+#endif
+
+namespace gfx {
+
+// The parameters required to add a composited frame to a CALayer. This
+// is used only on macOS.
+struct GFX_EXPORT CALayerParams {
+ CALayerParams();
+ CALayerParams(CALayerParams&& params);
+ CALayerParams(const CALayerParams& params);
+ CALayerParams& operator=(CALayerParams&& params);
+ CALayerParams& operator=(const CALayerParams& params);
+ ~CALayerParams();
+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ // The |is_empty| flag is used to short-circuit code to handle CALayerParams
+ // on non-macOS platforms.
+ bool is_empty = false;
+ // Can be used to instantiate a CALayerTreeHost in the browser process, which
+ // will display a CALayerTree rooted in the GPU process. This is non-zero when
+ // using remote CoreAnimation.
+ uint32_t ca_context_id = 0;
+ // Used to set the contents of a CALayer in the browser to an IOSurface that
+ // is specified by the GPU process. This is non-null iff |ca_context_id| is
+ // zero.
+ gfx::ScopedRefCountedIOSurfaceMachPort io_surface_mach_port;
+ // The geometry of the
+ gfx::Size pixel_size;
+ float scale_factor = 1.f;
+#else
+ bool is_empty = true;
+#endif
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_CA_LAYER_PARAMS_H_
diff --git a/ui/gfx/ipc/gfx_param_traits_macros.h b/ui/gfx/ipc/gfx_param_traits_macros.h
index 5ecab064..c7b74e9 100644
--- a/ui/gfx/ipc/gfx_param_traits_macros.h
+++ b/ui/gfx/ipc/gfx_param_traits_macros.h
@@ -8,8 +8,10 @@
#ifndef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
#define UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
+#include "build/build_config.h"
#include "ipc/ipc_message_macros.h"
#include "ui/gfx/buffer_types.h"
+#include "ui/gfx/ca_layer_params.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/ipc/gfx_ipc_export.h"
#include "ui/gfx/presentation_feedback.h"
@@ -34,6 +36,16 @@
IPC_ENUM_TRAITS_MAX_VALUE(gfx::SelectionBound::Type, gfx::SelectionBound::LAST);
+IPC_STRUCT_TRAITS_BEGIN(gfx::CALayerParams)
+ IPC_STRUCT_TRAITS_MEMBER(is_empty)
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ IPC_STRUCT_TRAITS_MEMBER(ca_context_id)
+ IPC_STRUCT_TRAITS_MEMBER(io_surface_mach_port)
+ IPC_STRUCT_TRAITS_MEMBER(pixel_size)
+ IPC_STRUCT_TRAITS_MEMBER(scale_factor)
+#endif
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(gfx::GpuMemoryBufferHandle)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_MEMBER(type)