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

Unified Diff: blimp/client/core/contents/blimp_contents_impl.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: addressed comments from #7 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/contents/blimp_contents_impl.cc
diff --git a/blimp/client/core/contents/blimp_contents_impl.cc b/blimp/client/core/contents/blimp_contents_impl.cc
index bfbbca356113bdd5f4e70743840be803cef4daf0..3ef3617f3819c6cf588e4b509db129e9908ee6b5 100644
--- a/blimp/client/core/contents/blimp_contents_impl.cc
+++ b/blimp/client/core/contents/blimp_contents_impl.cc
@@ -6,7 +6,10 @@
#include "base/memory/ptr_util.h"
#include "base/supports_user_data.h"
+#include "blimp/client/core/compositor/compositor_deps_provider.h"
+#include "blimp/client/core/render_widget/blimp_render_widget.h"
#include "blimp/client/public/contents/blimp_contents_observer.h"
+#include "cc/proto/compositor_message.pb.h"
#if defined(OS_ANDROID)
#include "blimp/client/core/contents/android/blimp_contents_impl_android.h"
@@ -17,15 +20,30 @@ namespace client {
namespace {
+const int kDummyTabId = 0;
+
#if defined(OS_ANDROID)
const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android";
#endif // OS_ANDROID
}
-BlimpContentsImpl::BlimpContentsImpl(int id)
- : navigation_controller_(this, nullptr), id_(id) {}
+BlimpContentsImpl::BlimpContentsImpl(int id,
+ RenderWidgetFeature* render_widget_feature)
+ : id_(id),
+ render_widget_feature_(render_widget_feature),
+ visible_(false),
+ window_(gfx::kNullAcceleratedWidget),
+ active_widget_(nullptr),
+ navigation_controller_(this, nullptr) {
+ render_widget_feature_->SetDelegate(kDummyTabId, this);
+}
BlimpContentsImpl::~BlimpContentsImpl() {
+ // Drop any references to the |window_|
+ if (CompositorDepsProvider::current()->use_internal_display()) {
+ SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
+ }
+
FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, BlimpContentsDying());
}
@@ -70,5 +88,115 @@ void BlimpContentsImpl::OnNavigationStateChanged() {
OnNavigationStateChanged());
}
+void BlimpContentsImpl::SetVisible(bool visible) {
+ visible_ = visible;
+ if (active_widget_) {
+ active_widget_->SetVisible(visible);
+ }
+}
+
+void BlimpContentsImpl::SetAcceleratedWidget(gfx::AcceleratedWidget widget) {
+ DCHECK(CompositorDepsProvider::current()->use_internal_display());
+
+ // Drop any references to the current |window_| first.
+ if (active_widget_) {
+ active_widget_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
+ }
+
+ window_ = widget;
+
+ if (active_widget_) {
+ active_widget_->SetAcceleratedWidget(window_);
+ }
+}
+
+BlimpRenderWidget* BlimpContentsImpl::GetActiveWidget() const {
+ return active_widget_;
+}
+
+void BlimpContentsImpl::SendWebGestureEvent(
+ BlimpRenderWidget* render_widget,
+ const blink::WebGestureEvent& gesture_event) {
+ render_widget_feature_->SendWebGestureEvent(
+ kDummyTabId, render_widget->GetId(), gesture_event);
+}
+
+void BlimpContentsImpl::SendCompositorMessage(
+ BlimpRenderWidget* render_widget,
+ const cc::proto::CompositorMessage& message) {
+ render_widget_feature_->SendCompositorMessage(
+ kDummyTabId, render_widget->GetId(), message);
+}
+
+void BlimpContentsImpl::CompositorDidCompleteSwapBuffers() {
+ if (!did_complete_swap_buffers_.is_null())
+ did_complete_swap_buffers_.Run();
+}
+
+BlimpRenderWidget* BlimpContentsImpl::GetWidgetForId(int render_widget_id) {
+ RenderWidgetMap::const_iterator it = render_widgets_.find(render_widget_id);
+ if (it == render_widgets_.end()) {
+ return nullptr;
+ }
+
+ return it->second.get();
+}
+
+std::unique_ptr<BlimpRenderWidget> BlimpContentsImpl::CreateBlimpRenderWidget(
+ int32_t render_widget_id,
+ BlimpRenderWidgetDelegate* delegate) {
+ return base::MakeUnique<BlimpRenderWidget>(render_widget_id, delegate);
+}
+
+void BlimpContentsImpl::OnRenderWidgetCreated(int render_widget_id) {
+ CHECK(!GetWidgetForId(render_widget_id));
+
+ render_widgets_[render_widget_id] =
+ CreateBlimpRenderWidget(render_widget_id, this);
+}
+
+void BlimpContentsImpl::OnRenderWidgetInitialized(int render_widget_id) {
+ if (active_widget_ && active_widget_->GetId() == render_widget_id)
+ return;
+
+ if (active_widget_) {
+ VLOG(1) << "Hiding currently active compositor for render widget: "
+ << active_widget_->GetId();
+ active_widget_->SetVisible(false);
+ if (CompositorDepsProvider::current()->use_internal_display()) {
+ active_widget_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
+ }
+ }
+
+ active_widget_ = GetWidgetForId(render_widget_id);
+ CHECK(active_widget_);
+
+ active_widget_->SetVisible(visible_);
+ if (CompositorDepsProvider::current()->use_internal_display()) {
+ active_widget_->SetAcceleratedWidget(window_);
+ }
+}
+
+void BlimpContentsImpl::OnRenderWidgetDeleted(int render_widget_id) {
+ RenderWidgetMap::const_iterator it = render_widgets_.find(render_widget_id);
+ CHECK(it != render_widgets_.end());
+
+ // Reset the |active_widget_| if that is what we're destroying right now.
+ if (active_widget_ == it->second.get()) {
+ active_widget_ = nullptr;
+ }
+
+ render_widgets_.erase(it);
+}
+
+void BlimpContentsImpl::OnCompositorMessageReceived(
+ int render_widget_id,
+ std::unique_ptr<cc::proto::CompositorMessage> message) {
+ BlimpRenderWidget* render_widget = GetWidgetForId(render_widget_id);
+ CHECK(render_widget);
+
+ render_widget->OnCompositorMessageReceived(std::move(message));
+}
+
} // namespace client
} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698