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

Unified Diff: ui/aura/mus/window_port_mus.cc

Issue 2878113002: mus: Embedder can request and observe BeginFrame for embedded client. (Closed)
Patch Set: . Created 3 years, 7 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: ui/aura/mus/window_port_mus.cc
diff --git a/ui/aura/mus/window_port_mus.cc b/ui/aura/mus/window_port_mus.cc
index 4c98ed4558a036614237a01cf0d8aa1497009064..ee4d46d91d6934da11332f0aa60affbd3773a9b9 100644
--- a/ui/aura/mus/window_port_mus.cc
+++ b/ui/aura/mus/window_port_mus.cc
@@ -5,6 +5,7 @@
#include "ui/aura/mus/window_port_mus.h"
#include "base/memory/ptr_util.h"
+#include "cc/ipc/frame_sink_manager.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/transient_window_client.h"
#include "ui/aura/mus/client_surface_embedder.h"
@@ -34,6 +35,27 @@ WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default;
WindowPortMus::WindowMusChangeDataImpl::~WindowMusChangeDataImpl() = default;
+class WindowPortMus::FrameSinkObserver : public cc::mojom::FrameSinkObserver {
+ public:
+ explicit FrameSinkObserver(base::RepeatingClosure begin_frame_callback)
+ : binding_(this),
+ begin_frame_callback_(std::move(begin_frame_callback)) {}
+ ~FrameSinkObserver() override {}
+
+ cc::mojom::FrameSinkObserverPtr GetPtr() {
+ return binding_.CreateInterfacePtrAndBind();
+ }
+
+ private:
+ // cc::mojom::FrameSinkObserver:
+ void OnBeginFrame() override { begin_frame_callback_.Run(); }
+
+ mojo::Binding<cc::mojom::FrameSinkObserver> binding_;
+ base::RepeatingClosure begin_frame_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameSinkObserver);
+};
+
// static
WindowMus* WindowMus::Get(Window* window) {
return WindowPortMus::Get(window);
@@ -531,6 +553,19 @@ cc::SurfaceId WindowPortMus::GetSurfaceId() const {
return cc::SurfaceId();
}
+void WindowPortMus::SetNeedsBeginFrames(bool needs,
+ base::RepeatingClosure callback) {
+ if (!needs) {
+ frame_sink_observer_ = nullptr;
+ return;
+ }
+ if (frame_sink_observer_)
+ return;
+ frame_sink_observer_ =
+ base::MakeUnique<FrameSinkObserver>(std::move(callback));
+ window_tree_client_->RequestBeginFrames(this, frame_sink_observer_->GetPtr());
+}
+
void WindowPortMus::UpdatePrimarySurfaceInfo() {
bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
window_mus_type() == WindowMusType::EMBED_IN_OWNER;

Powered by Google App Engine
This is Rietveld 408576698