Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1256)

Unified Diff: blimp/client/core/compositor/blimp_compositor.cc

Issue 2241623002: blimp: Move compositing, input and render widget feature to client/core. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn files Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/client/core/compositor/blimp_compositor.cc
diff --git a/blimp/client/core/compositor/blimp_compositor.cc b/blimp/client/core/compositor/blimp_compositor.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5318164106a4f9211e2dd43c6ed87ff1d56ee103
--- /dev/null
+++ b/blimp/client/core/compositor/blimp_compositor.cc
@@ -0,0 +1,204 @@
+// Copyright 2015 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 "blimp/client/core/compositor/blimp_compositor.h"
+
+#include "base/bind_helpers.h"
+#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
+#include "base/numerics/safe_conversions.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread.h"
+#include "base/threading/thread_local.h"
+#include "base/threading/thread_restrictions.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "blimp/client/core/input/blimp_input_manager.h"
+#include "cc/animation/animation_host.h"
+#include "cc/layers/layer.h"
+#include "cc/output/output_surface.h"
+#include "cc/proto/compositor_message.pb.h"
+#include "cc/trees/layer_tree_host.h"
+#include "cc/trees/layer_tree_settings.h"
+
+namespace blimp {
+namespace client {
+
+BlimpCompositor::BlimpCompositor(
+ cc::TaskGraphRunner* task_graph_runner,
+ gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
+ cc::ImageSerializationProcessor* image_serialization_processor,
+ cc::LayerTreeSettings* settings,
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
+ BlimpCompositorClient* client)
+ : task_graph_runner_(task_graph_runner),
+ gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
+ image_serialization_processor_(image_serialization_processor),
+ settings_(settings),
+ compositor_task_runner_(compositor_task_runner),
+ client_(client),
+ host_should_be_visible_(false),
+ remote_proto_channel_receiver_(nullptr) {
+ DCHECK(client_);
+ // TODO(khushalsagar): The BlimpCompositor is the remote counterpart to the
+ // RenderWidgetCompositor, and should have a 1:1 mapping with the
+ // LayerTreeHost, and we should be creating it when we create the host.
+ // Clean up this mess... D:
+}
+
+BlimpCompositor::~BlimpCompositor() {
+ if (host_)
nyquist 2016/08/16 23:14:57 Nit: the curlies?
Khushal 2016/08/18 03:16:32 Done.
+ DestroyLayerTreeHost();
+}
+
+void BlimpCompositor::SetVisible(bool visible) {
+ host_should_be_visible_ = visible;
+ if (host_)
+ host_->SetVisible(visible);
+}
+
+bool BlimpCompositor::IsVisible() const {
+ return host_should_be_visible_;
+}
+
+void BlimpCompositor::SetOutputSurface(
+ std::unique_ptr<cc::OutputSurface> output_surface) {
+ if (host_)
+ host_->SetOutputSurface(std::move(output_surface));
+}
+
+void BlimpCompositor::ReleaseOutputSurface() {
+ if (!host_ || host_->output_surface_lost())
+ return;
+
+ host_->ReleaseOutputSurface();
+}
+
+void BlimpCompositor::WillBeginMainFrame() {}
+
+void BlimpCompositor::DidBeginMainFrame() {}
+
+void BlimpCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) {}
+
+void BlimpCompositor::BeginMainFrameNotExpectedSoon() {}
+
+void BlimpCompositor::UpdateLayerTreeHost() {}
+
+void BlimpCompositor::ApplyViewportDeltas(
+ const gfx::Vector2dF& inner_delta,
+ const gfx::Vector2dF& outer_delta,
+ const gfx::Vector2dF& elastic_overscroll_delta,
+ float page_scale,
+ float top_controls_delta) {}
+
+void BlimpCompositor::RequestNewOutputSurface() {
+ client_->RequestOutputSurface();
+}
+
+void BlimpCompositor::DidInitializeOutputSurface() {}
+
+void BlimpCompositor::DidFailToInitializeOutputSurface() {}
+
+void BlimpCompositor::WillCommit() {}
+
+void BlimpCompositor::DidCommit() {}
+
+void BlimpCompositor::DidCommitAndDrawFrame() {
+ client_->DidCommitAndDrawFrame();
+}
+
+void BlimpCompositor::DidCompleteSwapBuffers() {
+ client_->DidCompleteSwapBuffers();
+}
+
+void BlimpCompositor::DidCompletePageScaleAnimation() {}
+
+void BlimpCompositor::SetProtoReceiver(ProtoReceiver* receiver) {
+ remote_proto_channel_receiver_ = receiver;
+}
+
+void BlimpCompositor::SendCompositorProto(
+ const cc::proto::CompositorMessage& proto) {
+ client_->SendCompositorMessage(proto);
+}
+
+void BlimpCompositor::OnCompositorMessageReceived(
+ std::unique_ptr<cc::proto::CompositorMessage> message) {
+ DCHECK(message->has_to_impl());
+ const cc::proto::CompositorMessageToImpl& to_impl_proto = message->to_impl();
+
+ DCHECK(to_impl_proto.has_message_type());
+ switch (to_impl_proto.message_type()) {
+ case cc::proto::CompositorMessageToImpl::UNKNOWN:
+ NOTIMPLEMENTED() << "Ignoring message of UNKNOWN type";
+ break;
+ case cc::proto::CompositorMessageToImpl::INITIALIZE_IMPL:
+ DCHECK(!host_);
+ DCHECK(to_impl_proto.has_initialize_impl_message());
+
+ // Create the remote client LayerTreeHost for the compositor.
+ CreateLayerTreeHost();
+ break;
+ case cc::proto::CompositorMessageToImpl::CLOSE_IMPL:
+ DCHECK(host_);
+
+ // Destroy the remote client LayerTreeHost for the compositor.
+ DestroyLayerTreeHost();
+ break;
+ default:
+ // We should have a receiver if we're getting compositor messages that
+ // are not INITIALIZE_IMPL or CLOSE_IMPL.
+ DCHECK(remote_proto_channel_receiver_);
+ remote_proto_channel_receiver_->OnProtoReceived(std::move(message));
+ }
+}
+
+void BlimpCompositor::SendWebGestureEvent(
+ const blink::WebGestureEvent& gesture_event) {
+ client_->SendWebGestureEvent(gesture_event);
+}
+
+void BlimpCompositor::CreateLayerTreeHost() {
+ DCHECK(!host_);
+ VLOG(1) << "Creating LayerTreeHost";
+
+ cc::LayerTreeHost::InitParams host_params;
+ host_params.client = this;
+ host_params.task_graph_runner = task_graph_runner_;
+ host_params.gpu_memory_buffer_manager = gpu_memory_buffer_manager_;
+ host_params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
+ host_params.image_serialization_processor = image_serialization_processor_;
+ host_params.settings = settings_;
+ host_params.animation_host = cc::AnimationHost::CreateMainInstance();
+
+ // Create the LayerTreeHost
+ host_ = cc::LayerTreeHost::CreateRemoteClient(
+ this /* remote_proto_channel */, compositor_task_runner_, &host_params);
+
+ host_->SetVisible(host_should_be_visible_);
+
+ DCHECK(!input_manager_);
+ input_manager_ = BlimpInputManager::Create(
+ this, base::ThreadTaskRunnerHandle::Get(), compositor_task_runner_,
+ host_->GetInputHandler());
+}
+
+void BlimpCompositor::DestroyLayerTreeHost() {
+ DCHECK(host_);
+ VLOG(1) << "Destroying LayerTreeHost";
+
+ // Destroy the old LayerTreeHost state.
+ host_.reset();
+
+ // Destroy the old input manager state.
+ // It is important to destroy the LayerTreeHost before destroying the input
+ // manager as it has a reference to the cc::InputHandlerClient owned by the
+ // BlimpInputManager.
+ input_manager_.reset();
+
+ // Make sure we don't have a receiver at this point.
+ DCHECK(!remote_proto_channel_receiver_);
+}
+
+} // namespace client
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698