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

Unified Diff: services/ui/ws/frame_generator.cc

Issue 2738923002: Add DisplayClientCompositorFrameSink (Closed)
Patch Set: Crashing mojo Created 3 years, 9 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: services/ui/ws/frame_generator.cc
diff --git a/services/ui/ws/frame_generator.cc b/services/ui/ws/frame_generator.cc
index b1574c4309aed1a6f18ff7b26dc21a7339066e7f..57e62098265f6f3fc7eee9744d876ff53b6007d3 100644
--- a/services/ui/ws/frame_generator.cc
+++ b/services/ui/ws/frame_generator.cc
@@ -9,6 +9,7 @@
#include "base/containers/adapters.h"
#include "cc/output/compositor_frame.h"
+#include "cc/output/compositor_frame_sink.h"
#include "cc/quads/render_pass.h"
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/shared_quad_state.h"
@@ -22,19 +23,16 @@ namespace ui {
namespace ws {
-FrameGenerator::FrameGenerator(FrameGeneratorDelegate* delegate,
- ServerWindow* root_window,
- gfx::AcceleratedWidget widget)
- : delegate_(delegate), root_window_(root_window), binding_(this) {
+FrameGenerator::FrameGenerator(
+ FrameGeneratorDelegate* delegate,
+ ServerWindow* root_window,
+ gfx::AcceleratedWidget widget,
+ std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink)
+ : delegate_(delegate),
+ root_window_(root_window),
+ compositor_frame_sink_(std::move(compositor_frame_sink)) {
DCHECK(delegate_);
DCHECK_NE(gfx::kNullAcceleratedWidget, widget);
- cc::mojom::MojoCompositorFrameSinkAssociatedRequest sink_request =
- mojo::MakeRequest(&compositor_frame_sink_);
- cc::mojom::DisplayPrivateAssociatedRequest display_request =
- mojo::MakeRequest(&display_private_);
- root_window_->CreateRootCompositorFrameSink(
- widget, std::move(sink_request), binding_.CreateInterfacePtrAndBind(),
- std::move(display_request));
}
FrameGenerator::~FrameGenerator() = default;
@@ -44,7 +42,7 @@ void FrameGenerator::SetDeviceScaleFactor(float device_scale_factor) {
return;
device_scale_factor_ = device_scale_factor;
if (window_manager_surface_info_.is_valid())
- compositor_frame_sink_->SetNeedsBeginFrame(true);
+ compositor_frame_sink_->BindToClient(this);
Fady Samuel 2017/03/09 21:25:19 Do this in the constructor.
Alex Z. 2017/03/10 16:04:01 Done.
}
void FrameGenerator::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) {
@@ -54,18 +52,47 @@ void FrameGenerator::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) {
// changing is handled immediately after the CompositorFrame is submitted.
if (surface_info != window_manager_surface_info_) {
window_manager_surface_info_ = surface_info;
- compositor_frame_sink_->SetNeedsBeginFrame(true);
+ compositor_frame_sink_->BindToClient(this);
Fady Samuel 2017/03/09 21:25:19 Add an observer on the begin_frame_source instead.
Alex Z. 2017/03/10 16:04:01 Done.
}
}
void FrameGenerator::OnWindowDamaged() {
if (window_manager_surface_info_.is_valid())
- compositor_frame_sink_->SetNeedsBeginFrame(true);
Fady Samuel 2017/03/09 21:25:18 What you want instead is to add an observer on the
Alex Z. 2017/03/10 16:04:01 Done.
+ compositor_frame_sink_->BindToClient(this);
Fady Samuel 2017/03/09 21:25:19 Do this in the constructor.
Alex Z. 2017/03/10 16:04:01 Done.
}
+void FrameGenerator::SetBeginFrameSource(cc::BeginFrameSource* source) {
+ if (begin_frame_source_)
+ begin_frame_source_->RemoveObserver(this);
+
+ begin_frame_source_ = source;
+ begin_frame_source_->AddObserver(this);
+}
+
+void FrameGenerator::ReclaimResources(
+ const cc::ReturnedResourceArray& resources) {
+ // Nothing to do here because FrameGenerator CompositorFrames don't reference
+ // any resources.
+ DCHECK(resources.empty());
+}
+
+void FrameGenerator::SetTreeActivationCallback(const base::Closure& callback) {}
+
void FrameGenerator::DidReceiveCompositorFrameAck() {}
-void FrameGenerator::OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) {
+void FrameGenerator::DidLoseCompositorFrameSink() {}
+
+void FrameGenerator::OnDraw(const gfx::Transform& transform,
+ const gfx::Rect& viewport,
+ bool resourceless_software_draw) {}
+
+void FrameGenerator::SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) {}
+
+void FrameGenerator::SetExternalTilePriorityConstraints(
+ const gfx::Rect& viewport_rect,
+ const gfx::Transform& transform) {}
+
+void FrameGenerator::OnBeginFrame(const cc::BeginFrameArgs& begin_frame_args) {
if (!root_window_->visible())
return;
@@ -76,30 +103,17 @@ void FrameGenerator::OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) {
if (!frame.render_pass_list.empty())
frame_size = frame.render_pass_list.back()->output_rect.size();
- if (!local_surface_id_.is_valid() ||
- frame_size != last_submitted_frame_size_) {
- local_surface_id_ = id_allocator_.GenerateId();
- display_private_->ResizeDisplay(frame_size);
- }
-
- display_private_->SetLocalSurfaceId(local_surface_id_, device_scale_factor_);
- compositor_frame_sink_->SubmitCompositorFrame(local_surface_id_,
- std::move(frame));
- compositor_frame_sink_->SetNeedsBeginFrame(false);
+ compositor_frame_sink_->SubmitCompositorFrame(std::move(frame));
+ compositor_frame_sink_->DetachFromClient();
Fady Samuel 2017/03/09 21:25:18 Don't DetachFromClient here.
Alex Z. 2017/03/10 16:04:01 Done.
last_submitted_frame_size_ = frame_size;
+ last_begin_frame_args_ = begin_frame_args;
}
-void FrameGenerator::ReclaimResources(
- const cc::ReturnedResourceArray& resources) {
- // Nothing to do here because FrameGenerator CompositorFrames don't reference
- // any resources.
- DCHECK(resources.empty());
+const cc::BeginFrameArgs& FrameGenerator::LastUsedBeginFrameArgs() const {
+ return last_begin_frame_args_;
}
-void FrameGenerator::WillDrawSurface(const cc::LocalSurfaceId& local_surface_id,
- const gfx::Rect& damage_rect) {
- // TODO(fsamuel, staraz): Implement this.
-}
+void FrameGenerator::OnBeginFrameSourcePausedChanged(bool paused) {}
cc::CompositorFrame FrameGenerator::GenerateCompositorFrame(
const gfx::Rect& output_rect) {

Powered by Google App Engine
This is Rietveld 408576698