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

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

Issue 1653553002: blimp: Use remote client LayerTreeHost in the BlimpCompositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Run tests for linux only for now. Created 4 years, 10 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/feature/compositor/blimp_compositor.cc
diff --git a/blimp/client/feature/compositor/blimp_compositor.cc b/blimp/client/feature/compositor/blimp_compositor.cc
index 4536beef78b69ac3daf2a43bc2f78997dd07f5b7..7598a46b347d64178a31a29feab139632b70c9a7 100644
--- a/blimp/client/feature/compositor/blimp_compositor.cc
+++ b/blimp/client/feature/compositor/blimp_compositor.cc
@@ -16,7 +16,6 @@
#include "blimp/client/feature/compositor/blimp_context_provider.h"
#include "blimp/client/feature/compositor/blimp_layer_tree_settings.h"
#include "blimp/client/feature/compositor/blimp_output_surface.h"
-#include "blimp/client/feature/compositor/test/dummy_layer_driver.h"
#include "blimp/client/feature/render_widget_feature.h"
#include "blimp/common/compositor/blimp_task_graph_runner.h"
#include "cc/layers/layer.h"
@@ -36,11 +35,6 @@ base::LazyInstance<blimp::BlimpTaskGraphRunner> g_task_graph_runner =
const int kDummyTabId = 0;
-// TODO(dtrainor): Replace this when Layer content comes from the server (see
-// crbug.com/527200 for details).
-base::LazyInstance<DummyLayerDriver> g_dummy_layer_driver =
- LAZY_INSTANCE_INITIALIZER;
-
} // namespace
BlimpCompositor::BlimpCompositor(float dp_to_px,
@@ -51,6 +45,7 @@ BlimpCompositor::BlimpCompositor(float dp_to_px,
output_surface_request_pending_(false),
remote_proto_channel_receiver_(nullptr),
render_widget_feature_(render_widget_feature) {
+ DCHECK(render_widget_feature_);
render_widget_feature_->SetDelegate(kDummyTabId, this);
}
@@ -71,34 +66,8 @@ BlimpCompositor::~BlimpCompositor() {
}
void BlimpCompositor::SetVisible(bool visible) {
- // For testing. Remove once we bind to the network layer.
- if (!host_)
- CreateLayerTreeHost(nullptr);
-
host_should_be_visible_ = visible;
- if (!host_ || host_->visible() == visible)
- return;
-
- if (visible) {
- // If visible, show the compositor. If the compositor had an outstanding
- // output surface request, trigger the request again so we build the output
- // surface.
- host_->SetVisible(true);
- if (output_surface_request_pending_)
- HandlePendingOutputSurfaceRequest();
- } else {
- // If not visible, hide the compositor and have it drop it's output surface.
- DCHECK(host_->visible());
- host_->SetVisible(false);
- if (!host_->output_surface_lost())
- host_->ReleaseOutputSurface();
- }
-}
-
-void BlimpCompositor::SetSize(const gfx::Size& size) {
- viewport_size_ = size;
- if (host_)
- host_->SetViewportSize(viewport_size_);
+ SetVisibleInternal(host_should_be_visible_);
}
void BlimpCompositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) {
@@ -113,7 +82,7 @@ void BlimpCompositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) {
// This will properly set visibility and will build the output surface if
// necessary.
- SetVisible(host_should_be_visible_);
+ SetVisibleInternal(host_should_be_visible_);
}
void BlimpCompositor::ReleaseAcceleratedWidget() {
@@ -121,7 +90,7 @@ void BlimpCompositor::ReleaseAcceleratedWidget() {
return;
// Hide the compositor and drop the output surface if necessary.
- SetVisible(false);
+ SetVisibleInternal(false);
window_ = gfx::kNullAcceleratedWidget;
}
@@ -183,41 +152,43 @@ void BlimpCompositor::SendCompositorProto(
}
void BlimpCompositor::OnRenderWidgetInitialized() {
- DVLOG(1) << "OnRenderWidgetInitialized";
-
- // Tear down the output surface connection with the old LayerTreeHost
- // instance.
- SetVisible(false);
-
- // 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();
-
- // Reset other state.
- output_surface_request_pending_ = false;
-
- // Make sure we don't have a receiver at this point.
- DCHECK(!remote_proto_channel_receiver_);
-
- // TODO(khushalsagar): re-initialize compositor and input state for the new
- // render widget.
- SetVisible(true);
+ // Destroy the state for the current LayerTreeHost. Since a new render widget
+ // has been initialized, we will start receiving compositor messages from
+ // this widget now.
+ if (host_)
+ DestroyLayerTreeHost();
}
void BlimpCompositor::OnCompositorMessageReceived(
scoped_ptr<cc::proto::CompositorMessage> message) {
- // TODO(dtrainor, khushalsagar): Look into the CompositorMessage. If it is
- // initialize or shutdown, create or destroy |host_|.
-
- // We should have a receiver if we're getting compositor messages that aren't
- // initialize.
- DCHECK(remote_proto_channel_receiver_);
- remote_proto_channel_receiver_->OnProtoReceived(std::move(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(to_impl_proto.initialize_impl_message());
+ 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::GenerateLayerTreeSettings(
@@ -230,10 +201,39 @@ void BlimpCompositor::SendWebInputEvent(
render_widget_feature_->SendInputEvent(kDummyTabId, input_event);
}
+void BlimpCompositor::SetVisibleInternal(bool visible) {
+ if (!host_)
+ return;
+
+ if (visible && window_ != gfx::kNullAcceleratedWidget) {
+ // If we're supposed to be visible and we have a valid
+ // gfx::AcceleratedWidget make our compositor visible. If the compositor
+ // had an outstanding output surface request, trigger the request again so
+ // we build the output surface.
+ host_->SetVisible(true);
+ if (output_surface_request_pending_)
+ HandlePendingOutputSurfaceRequest();
+ } else if (!visible) {
+ // If not visible, hide the compositor and have it drop it's output
+ // surface.
+ host_->SetVisible(false);
+ if (!host_->output_surface_lost()) {
+ host_->ReleaseOutputSurface();
+ }
+ }
+}
+
void BlimpCompositor::CreateLayerTreeHost(
- scoped_ptr<cc::proto::CompositorMessage> message) {
+ const cc::proto::InitializeImpl& initialize_message) {
+ DCHECK(!host_);
+
if (!settings_) {
settings_.reset(new cc::LayerTreeSettings);
+
+ // TODO(khushalsagar): The server should selectively send only those
+ // LayerTreeSettings which should remain consistent across the server and
+ // client. Since it currently overrides all settings, ignore them.
+ // See crbug/577985.
GenerateLayerTreeSettings(settings_.get());
}
@@ -245,27 +245,15 @@ void BlimpCompositor::CreateLayerTreeHost(
params.main_task_runner = base::ThreadTaskRunnerHandle::Get();
params.settings = settings_.get();
- // TODO(dtrainor): Swap this out with the remote client proxy when
- // implemented.
- host_ =
- cc::LayerTreeHost::CreateThreaded(GetCompositorTaskRunner(), &params);
-
- // If we're supposed to be visible and we have a valid gfx::AcceleratedWidget
- // make our compositor visible.
- if (host_should_be_visible_ && window_ != gfx::kNullAcceleratedWidget)
- host_->SetVisible(true);
+ // TODO(khushalsagar): Add the GpuMemoryBufferManager to params
- host_->SetViewportSize(viewport_size_);
- host_->SetDeviceScaleFactor(device_scale_factor_);
+ host_ =
+ cc::LayerTreeHost::CreateRemoteClient(this /* remote_proto_channel */,
+ GetCompositorTaskRunner(), &params);
- // For testing, set the dummy Layer.
- scoped_refptr<cc::Layer> root(
- cc::Layer::Create(BlimpCompositor::LayerSettings()));
- host_->SetRootLayer(root);
- g_dummy_layer_driver.Pointer()->SetParentLayer(root);
+ // Now that we have a host, set the visiblity on it correctly.
+ SetVisibleInternal(host_should_be_visible_);
- // TODO(khushalsagar): Create this after successful initialization of the
- // remote client compositor when implemented.
DCHECK(!input_manager_);
input_manager_ =
BlimpInputManager::Create(this,
@@ -274,6 +262,28 @@ void BlimpCompositor::CreateLayerTreeHost(
host_->GetInputHandler());
}
+void BlimpCompositor::DestroyLayerTreeHost() {
+ DCHECK(host_);
+ // Tear down the output surface connection with the old LayerTreeHost
+ // instance.
+ SetVisibleInternal(false);
+
+ // 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();
+
+ // Reset other state.
+ output_surface_request_pending_ = false;
+
+ // Make sure we don't have a receiver at this point.
+ DCHECK(!remote_proto_channel_receiver_);
+}
+
scoped_refptr<base::SingleThreadTaskRunner>
BlimpCompositor::GetCompositorTaskRunner() {
if (compositor_thread_)
@@ -314,11 +324,5 @@ void BlimpCompositor::HandlePendingOutputSurfaceRequest() {
output_surface_request_pending_ = false;
}
-cc::LayerSettings BlimpCompositor::LayerSettings() {
- cc::LayerSettings settings;
- settings.use_compositor_animation_timelines = true;
- return settings;
-}
-
} // namespace client
} // namespace blimp
« no previous file with comments | « blimp/client/feature/compositor/blimp_compositor.h ('k') | blimp/client/feature/compositor/blimp_compositor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698