Commit 0352b590 authored by James Wallace-Lee's avatar James Wallace-Lee Committed by Commit Bot

Merge SynchronousCompositorProxyMojo into SynchronousCompositorProxy

SynchronousCompositorProxy only uses mojo and no longer uses the old
IPC. Mojo is now the default implementation rather than a subclass of
SynchronousCompositorProxyMojo.

Bug: 687695
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ieddf50f1441648ba1a88197b690b321ff6f83ba1
Reviewed-on: https://chromium-review.googlesource.com/1062956Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: James Wallace-Lee <jamwalla@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565364}
parent 3cfa1707
...@@ -45,8 +45,6 @@ target(link_target_type, "renderer") { ...@@ -45,8 +45,6 @@ target(link_target_type, "renderer") {
"android/renderer_date_time_picker.h", "android/renderer_date_time_picker.h",
"android/synchronous_compositor_proxy.cc", "android/synchronous_compositor_proxy.cc",
"android/synchronous_compositor_proxy.h", "android/synchronous_compositor_proxy.h",
"android/synchronous_compositor_proxy_mojo.cc",
"android/synchronous_compositor_proxy_mojo.h",
"android/synchronous_compositor_registry.h", "android/synchronous_compositor_registry.h",
"android/synchronous_layer_tree_frame_sink.cc", "android/synchronous_layer_tree_frame_sink.cc",
"android/synchronous_layer_tree_frame_sink.h", "android/synchronous_layer_tree_frame_sink.h",
......
...@@ -23,6 +23,7 @@ namespace content { ...@@ -23,6 +23,7 @@ namespace content {
SynchronousCompositorProxy::SynchronousCompositorProxy( SynchronousCompositorProxy::SynchronousCompositorProxy(
ui::SynchronousInputHandlerProxy* input_handler_proxy) ui::SynchronousInputHandlerProxy* input_handler_proxy)
: input_handler_proxy_(input_handler_proxy), : input_handler_proxy_(input_handler_proxy),
binding_(this),
use_in_process_zero_copy_software_draw_( use_in_process_zero_copy_software_draw_(
base::CommandLine::ForCurrentProcess()->HasSwitch( base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess)), switches::kSingleProcess)),
...@@ -336,4 +337,55 @@ uint32_t SynchronousCompositorProxy::NextMetadataVersion() { ...@@ -336,4 +337,55 @@ uint32_t SynchronousCompositorProxy::NextMetadataVersion() {
return ++metadata_version_; return ++metadata_version_;
} }
void SynchronousCompositorProxy::SendDemandDrawHwAsyncReply(
const content::SyncCompositorCommonRendererParams&,
uint32_t layer_tree_frame_sink_id,
uint32_t metadata_version,
base::Optional<viz::CompositorFrame> frame) {
control_host_->ReturnFrame(layer_tree_frame_sink_id, metadata_version,
std::move(frame));
}
void SynchronousCompositorProxy::SendBeginFrameResponse(
const content::SyncCompositorCommonRendererParams& param) {
control_host_->BeginFrameResponse(param);
}
void SynchronousCompositorProxy::SendAsyncRendererStateIfNeeded() {
if (hardware_draw_reply_ || software_draw_reply_ || zoom_by_reply_ || !host_)
return;
SyncCompositorCommonRendererParams params;
PopulateCommonParams(&params);
host_->UpdateState(params);
}
void SynchronousCompositorProxy::SendSetNeedsBeginFrames(
bool needs_begin_frames) {
needs_begin_frame_ = needs_begin_frames;
if (host_)
host_->SetNeedsBeginFrames(needs_begin_frames);
}
void SynchronousCompositorProxy::LayerTreeFrameSinkCreated() {
DCHECK(layer_tree_frame_sink_);
if (host_)
host_->LayerTreeFrameSinkCreated();
}
void SynchronousCompositorProxy::BindChannel(
mojom::SynchronousCompositorControlHostPtr control_host,
mojom::SynchronousCompositorHostAssociatedPtrInfo host,
mojom::SynchronousCompositorAssociatedRequest compositor_request) {
control_host_ = std::move(control_host);
host_.Bind(std::move(host));
binding_.Bind(std::move(compositor_request));
if (layer_tree_frame_sink_)
LayerTreeFrameSinkCreated();
if (needs_begin_frame_)
host_->SetNeedsBeginFrames(true);
}
} // namespace content } // namespace content
...@@ -40,6 +40,10 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler, ...@@ -40,6 +40,10 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler,
~SynchronousCompositorProxy() override; ~SynchronousCompositorProxy() override;
void Init(); void Init();
void BindChannel(
mojom::SynchronousCompositorControlHostPtr control_host,
mojom::SynchronousCompositorHostAssociatedPtrInfo host,
mojom::SynchronousCompositorAssociatedRequest compositor_request);
// ui::SynchronousInputHandler overrides. // ui::SynchronousInputHandler overrides.
void SetNeedsSynchronousAnimateInput() final; void SetNeedsSynchronousAnimateInput() final;
...@@ -85,16 +89,16 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler, ...@@ -85,16 +89,16 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler,
void SetBeginFrameSourcePaused(bool paused) final; void SetBeginFrameSourcePaused(bool paused) final;
protected: protected:
virtual void SendSetNeedsBeginFrames(bool needs_begin_frames) = 0; void SendSetNeedsBeginFrames(bool needs_begin_frames);
virtual void SendAsyncRendererStateIfNeeded() = 0; void SendAsyncRendererStateIfNeeded();
virtual void LayerTreeFrameSinkCreated() = 0; void LayerTreeFrameSinkCreated();
virtual void SendBeginFrameResponse( void SendBeginFrameResponse(
const content::SyncCompositorCommonRendererParams&) = 0; const content::SyncCompositorCommonRendererParams&);
virtual void SendDemandDrawHwAsyncReply( void SendDemandDrawHwAsyncReply(
const content::SyncCompositorCommonRendererParams&, const content::SyncCompositorCommonRendererParams&,
uint32_t layer_tree_frame_sink_id, uint32_t layer_tree_frame_sink_id,
uint32_t metadata_version, uint32_t metadata_version,
base::Optional<viz::CompositorFrame>) = 0; base::Optional<viz::CompositorFrame>);
DemandDrawHwCallback hardware_draw_reply_; DemandDrawHwCallback hardware_draw_reply_;
DemandDrawSwCallback software_draw_reply_; DemandDrawSwCallback software_draw_reply_;
...@@ -109,10 +113,14 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler, ...@@ -109,10 +113,14 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler,
struct SharedMemoryWithSize; struct SharedMemoryWithSize;
ui::SynchronousInputHandlerProxy* const input_handler_proxy_; ui::SynchronousInputHandlerProxy* const input_handler_proxy_;
mojom::SynchronousCompositorControlHostPtr control_host_;
mojom::SynchronousCompositorHostAssociatedPtr host_;
mojo::AssociatedBinding<mojom::SynchronousCompositor> binding_;
const bool use_in_process_zero_copy_software_draw_; const bool use_in_process_zero_copy_software_draw_;
bool compute_scroll_called_via_ipc_ = false; bool compute_scroll_called_via_ipc_ = false;
bool browser_needs_begin_frame_state_ = false; bool browser_needs_begin_frame_state_ = false;
bool needs_begin_frame_ = false;
bool needs_begin_frame_for_frame_sink_ = false; bool needs_begin_frame_for_frame_sink_ = false;
bool needs_begin_frame_for_animate_input_ = false; bool needs_begin_frame_for_animate_input_ = false;
......
// Copyright 2018 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 "content/renderer/android/synchronous_compositor_proxy_mojo.h"
namespace content {
SynchronousCompositorProxyMojo::SynchronousCompositorProxyMojo(
ui::SynchronousInputHandlerProxy* input_handler_proxy)
: SynchronousCompositorProxy(input_handler_proxy), binding_(this) {}
SynchronousCompositorProxyMojo::~SynchronousCompositorProxyMojo() {}
void SynchronousCompositorProxyMojo::SendDemandDrawHwAsyncReply(
const content::SyncCompositorCommonRendererParams&,
uint32_t layer_tree_frame_sink_id,
uint32_t metadata_version,
base::Optional<viz::CompositorFrame> frame) {
control_host_->ReturnFrame(layer_tree_frame_sink_id, metadata_version,
std::move(frame));
}
void SynchronousCompositorProxyMojo::SendBeginFrameResponse(
const content::SyncCompositorCommonRendererParams& param) {
control_host_->BeginFrameResponse(param);
}
void SynchronousCompositorProxyMojo::SendAsyncRendererStateIfNeeded() {
if (hardware_draw_reply_ || software_draw_reply_ || zoom_by_reply_ || !host_)
return;
SyncCompositorCommonRendererParams params;
PopulateCommonParams(&params);
host_->UpdateState(params);
}
void SynchronousCompositorProxyMojo::SendSetNeedsBeginFrames(
bool needs_begin_frames) {
needs_begin_frame_ = needs_begin_frames;
if (host_)
host_->SetNeedsBeginFrames(needs_begin_frames);
}
void SynchronousCompositorProxyMojo::LayerTreeFrameSinkCreated() {
DCHECK(layer_tree_frame_sink_);
if (host_)
host_->LayerTreeFrameSinkCreated();
}
void SynchronousCompositorProxyMojo::BindChannel(
mojom::SynchronousCompositorControlHostPtr control_host,
mojom::SynchronousCompositorHostAssociatedPtrInfo host,
mojom::SynchronousCompositorAssociatedRequest compositor_request) {
control_host_ = std::move(control_host);
host_.Bind(std::move(host));
binding_.Bind(std::move(compositor_request));
if (layer_tree_frame_sink_)
LayerTreeFrameSinkCreated();
if (needs_begin_frame_)
host_->SetNeedsBeginFrames(true);
}
} // namespace content
// Copyright 2018 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 CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_MOJO_H_
#define CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_MOJO_H_
#include "content/renderer/android/synchronous_compositor_proxy.h"
namespace content {
// This class implements the SynchronousCompositorProxy with
// IPC messaging backed by mojo.
class SynchronousCompositorProxyMojo : public SynchronousCompositorProxy {
public:
SynchronousCompositorProxyMojo(
ui::SynchronousInputHandlerProxy* input_handler_proxy);
~SynchronousCompositorProxyMojo() override;
void BindChannel(
mojom::SynchronousCompositorControlHostPtr control_host,
mojom::SynchronousCompositorHostAssociatedPtrInfo host,
mojom::SynchronousCompositorAssociatedRequest compositor_request);
protected:
void SendSetNeedsBeginFrames(bool needs_begin_frames) final;
void SendAsyncRendererStateIfNeeded() final;
void LayerTreeFrameSinkCreated() final;
void SendBeginFrameResponse(
const content::SyncCompositorCommonRendererParams&) final;
void SendDemandDrawHwAsyncReply(
const content::SyncCompositorCommonRendererParams&,
uint32_t layer_tree_frame_sink_id,
uint32_t metadata_version,
base::Optional<viz::CompositorFrame>) final;
private:
mojom::SynchronousCompositorControlHostPtr control_host_;
mojom::SynchronousCompositorHostAssociatedPtr host_;
mojo::AssociatedBinding<mojom::SynchronousCompositor> binding_;
bool needs_begin_frame_ = false;
DISALLOW_COPY_AND_ASSIGN(SynchronousCompositorProxyMojo);
};
} // namespace content
#endif // CONTENT_RENDERER_ANDROID_SYNCHRONOUS_COMPOSITOR_PROXY_MOJO_H_
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/renderer/android/synchronous_compositor_proxy_mojo.h" #include "content/renderer/android/synchronous_compositor_proxy.h"
#include "content/renderer/android/synchronous_compositor_registry.h" #include "content/renderer/android/synchronous_compositor_registry.h"
#endif #endif
...@@ -80,14 +80,14 @@ class SynchronousCompositorProxyRegistry ...@@ -80,14 +80,14 @@ class SynchronousCompositorProxyRegistry
void CreateProxy(ui::SynchronousInputHandlerProxy* handler) { void CreateProxy(ui::SynchronousInputHandlerProxy* handler) {
DCHECK(compositor_task_runner_->BelongsToCurrentThread()); DCHECK(compositor_task_runner_->BelongsToCurrentThread());
proxy_ = std::make_unique<SynchronousCompositorProxyMojo>(handler); proxy_ = std::make_unique<SynchronousCompositorProxy>(handler);
proxy_->Init(); proxy_->Init();
if (sink_) if (sink_)
proxy_->SetLayerTreeFrameSink(sink_); proxy_->SetLayerTreeFrameSink(sink_);
} }
SynchronousCompositorProxyMojo* proxy() { return proxy_.get(); } SynchronousCompositorProxy* proxy() { return proxy_.get(); }
void RegisterLayerTreeFrameSink( void RegisterLayerTreeFrameSink(
int routing_id, int routing_id,
...@@ -114,7 +114,7 @@ class SynchronousCompositorProxyRegistry ...@@ -114,7 +114,7 @@ class SynchronousCompositorProxyRegistry
private: private:
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
std::unique_ptr<SynchronousCompositorProxyMojo> proxy_; std::unique_ptr<SynchronousCompositorProxy> proxy_;
SynchronousLayerTreeFrameSink* sink_ = nullptr; SynchronousLayerTreeFrameSink* sink_ = nullptr;
}; };
......
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