Commit f3612407 authored by fsamuel's avatar fsamuel Committed by Commit bot

Delete dead (and obsolete) display compositor API

BUG=none

Review-Url: https://chromiumcodereview.appspot.com/2441093002
Cr-Commit-Position: refs/heads/master@{#426930}
parent 1ec85106
# Copyright 2016 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.
import("//build/config/ui.gni")
source_set("display_compositor") {
sources = [
"compositor_frame_sink_delegate.h",
"compositor_frame_sink_factory_impl.cc",
"compositor_frame_sink_factory_impl.h",
"compositor_frame_sink_impl.cc",
"compositor_frame_sink_impl.h",
"display_compositor_impl.cc",
"display_compositor_impl.h",
"display_impl.cc",
"display_impl.h",
]
deps = [
"//base",
"//cc",
"//cc/ipc:interfaces",
"//cc/surfaces",
"//cc/surfaces:surface_id",
"//services/ui/public/interfaces/gpu:interfaces",
# TODO(fsamuel): Remove this dependency.
"//services/ui/surfaces",
]
}
// Copyright 2016 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.
#ifndef SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_DELEGATE_H_
#define SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_DELEGATE_H_
#include "cc/surfaces/surface_id.h"
namespace ui {
namespace gpu {
class CompositorFrameSinkImpl;
// A CompositorFrameSinkDelegate decouples CompositorFrameSinks from their
// factories enabling them to be unit tested.
class CompositorFrameSinkDelegate {
public:
virtual void CompositorFrameSinkConnectionLost(int sink_id) = 0;
virtual cc::SurfaceId GenerateSurfaceId() = 0;
};
} // namespace gpu
} // namespace ui
#endif // SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_DELEGATE_H_
// Copyright 2016 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 "services/ui/gpu/display_compositor/compositor_frame_sink_factory_impl.h"
#include "base/memory/ptr_util.h"
#include "cc/surfaces/surface_id.h"
#include "services/ui/gpu/display_compositor/compositor_frame_sink_impl.h"
namespace ui {
namespace gpu {
CompositorFrameSinkFactoryImpl::CompositorFrameSinkFactoryImpl(
uint32_t client_id,
const scoped_refptr<DisplayCompositor>& display_compositor)
: client_id_(client_id),
display_compositor_(display_compositor),
allocator_(client_id) {}
CompositorFrameSinkFactoryImpl::~CompositorFrameSinkFactoryImpl() {}
void CompositorFrameSinkFactoryImpl::CompositorFrameSinkConnectionLost(
int local_id) {
sinks_.erase(local_id);
}
cc::SurfaceId CompositorFrameSinkFactoryImpl::GenerateSurfaceId() {
return allocator_.GenerateId();
}
void CompositorFrameSinkFactoryImpl::CreateCompositorFrameSink(
uint32_t local_id,
uint64_t nonce,
mojo::InterfaceRequest<mojom::CompositorFrameSink> sink,
mojom::CompositorFrameSinkClientPtr client) {
// TODO(fsamuel): Use nonce once patch lands:
// https://codereview.chromium.org/1996783002/
sinks_[local_id] = base::MakeUnique<CompositorFrameSinkImpl>(
this, local_id, display_compositor_, std::move(sink), std::move(client));
}
} // namespace gpu
} // namespace ui
// Copyright 2016 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.
#ifndef SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_FACTORY_IMPL_H_
#define SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_FACTORY_IMPL_H_
#include "cc/surfaces/surface_id_allocator.h"
#include "services/ui/gpu/display_compositor/compositor_frame_sink_delegate.h"
#include "services/ui/public/interfaces/gpu/display_compositor.mojom.h"
#include "services/ui/surfaces/display_compositor.h"
namespace ui {
namespace gpu {
class CompositorFrameSinkImpl;
class CompositorFrameSinkFactoryImpl : public mojom::CompositorFrameSinkFactory,
public CompositorFrameSinkDelegate {
public:
CompositorFrameSinkFactoryImpl(
uint32_t client_id,
const scoped_refptr<DisplayCompositor>& display_compositor);
~CompositorFrameSinkFactoryImpl() override;
uint32_t client_id() const { return client_id_; }
void CompositorFrameSinkConnectionLost(int local_id) override;
cc::SurfaceId GenerateSurfaceId() override;
// mojom::CompositorFrameSinkFactory implementation.
void CreateCompositorFrameSink(
uint32_t local_id,
uint64_t nonce,
mojo::InterfaceRequest<mojom::CompositorFrameSink> sink,
mojom::CompositorFrameSinkClientPtr client) override;
private:
const uint32_t client_id_;
scoped_refptr<DisplayCompositor> display_compositor_;
cc::SurfaceIdAllocator allocator_;
using CompositorFrameSinkMap =
std::map<uint32_t, std::unique_ptr<CompositorFrameSinkImpl>>;
CompositorFrameSinkMap sinks_;
DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkFactoryImpl);
};
} // namespace gpu
} // namespace ui
#endif // SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_FACTORY_IMPL_H_
// Copyright 2016 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 "services/ui/gpu/display_compositor/compositor_frame_sink_impl.h"
#include "cc/ipc/compositor_frame.mojom.h"
#include "cc/surfaces/surface_factory.h"
#include "services/ui/gpu/display_compositor/compositor_frame_sink_delegate.h"
namespace ui {
namespace gpu {
CompositorFrameSinkImpl::CompositorFrameSinkImpl(
CompositorFrameSinkDelegate* delegate,
int sink_id,
const scoped_refptr<DisplayCompositor>& surfaces_state,
mojo::InterfaceRequest<mojom::CompositorFrameSink> request,
mojom::CompositorFrameSinkClientPtr client)
: delegate_(delegate),
surfaces_state_(surfaces_state),
sink_id_(sink_id),
begin_frame_source_(nullptr),
needs_begin_frame_(false),
factory_(surfaces_state->manager(), this),
client_(std::move(client)),
binding_(this, std::move(request)) {
DCHECK(delegate_);
binding_.set_connection_error_handler(base::Bind(
&CompositorFrameSinkImpl::OnConnectionLost, base::Unretained(this)));
}
CompositorFrameSinkImpl::~CompositorFrameSinkImpl() {}
void CompositorFrameSinkImpl::SetNeedsBeginFrame(bool needs_begin_frame) {
if (needs_begin_frame_ == needs_begin_frame)
return;
needs_begin_frame_ = needs_begin_frame;
if (begin_frame_source_) {
if (needs_begin_frame_)
begin_frame_source_->AddObserver(this);
else
begin_frame_source_->RemoveObserver(this);
}
}
void CompositorFrameSinkImpl::SubmitCompositorFrame(
cc::CompositorFrame compositor_frame,
const SubmitCompositorFrameCallback& callback) {
gfx::Size frame_size =
compositor_frame.delegated_frame_data->render_pass_list.back()
->output_rect.size();
if (frame_size.IsEmpty() || frame_size != last_submitted_frame_size_) {
if (!surface_id_.is_null())
factory_.Destroy(surface_id_);
// TODO(fsamuel): The allocator should live on CompositorFrameSinkFactory.
surface_id_ = delegate_->GenerateSurfaceId();
factory_.Create(surface_id_);
last_submitted_frame_size_ = frame_size;
}
factory_.SubmitCompositorFrame(surface_id_, std::move(compositor_frame),
callback);
}
void CompositorFrameSinkImpl::ReturnResources(
const cc::ReturnedResourceArray& resources) {
if (!client_)
return;
client_->ReturnResources(mojo::Array<cc::ReturnedResource>::From(resources));
}
void CompositorFrameSinkImpl::WillDrawSurface(const cc::SurfaceId& surface_id,
const gfx::Rect& damage_rect) {
NOTIMPLEMENTED();
}
void CompositorFrameSinkImpl::SetBeginFrameSource(
cc::BeginFrameSource* begin_frame_source) {
begin_frame_source_ = begin_frame_source;
}
void CompositorFrameSinkImpl::OnBeginFrame(const cc::BeginFrameArgs& args) {
// TODO(fsamuel): Implement this.
}
const cc::BeginFrameArgs& CompositorFrameSinkImpl::LastUsedBeginFrameArgs()
const {
// TODO(fsamuel): Implement this.
return last_used_begin_frame_args_;
}
void CompositorFrameSinkImpl::OnBeginFrameSourcePausedChanged(bool paused) {
// TODO(fsamuel): Implement this.
}
void CompositorFrameSinkImpl::OnConnectionLost() {
delegate_->CompositorFrameSinkConnectionLost(sink_id_);
}
} // namespace gpu
} // namespace ui
// Copyright 2016 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.
#ifndef SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_
#define SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_
#include "base/memory/ref_counted.h"
#include "cc/ipc/mojo_compositor_frame_sink.mojom.h"
#include "cc/scheduler/begin_frame_source.h"
#include "cc/surfaces/surface_factory.h"
#include "cc/surfaces/surface_factory_client.h"
#include "cc/surfaces/surface_id.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/ui/surfaces/display_compositor.h"
namespace ui {
namespace gpu {
class CompositorFrameSinkDelegate;
// A client presents visuals to screen by submitting CompositorFrames to a
// CompositorFrameSink.
class CompositorFrameSinkImpl : public cc::SurfaceFactoryClient,
public cc::mojom::MojoCompositorFrameSink,
public cc::BeginFrameObserver {
public:
CompositorFrameSinkImpl(
CompositorFrameSinkDelegate* delegate,
int sink_id,
const scoped_refptr<DisplayCompositor>& display_compositor,
mojo::InterfaceRequest<mojom::CompositorFrameSink> request,
mojom::CompositorFrameSinkClientPtr client);
~CompositorFrameSinkImpl() override;
// cc::mojom::MojoCompositorFrameSink implementation.
void SetNeedsBeginFrame(bool needs_begin_frame) override;
void SubmitCompositorFrame(
cc::CompositorFrame compositor_frame,
const SubmitCompositorFrameCallback& callback) override;
private:
// SurfaceFactoryClient implementation.
void ReturnResources(const cc::ReturnedResourceArray& resources) override;
void WillDrawSurface(const cc::SurfaceId& surface_id,
const gfx::Rect& damage_rect) override;
void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override;
// BeginFrameObserver implementation.
void OnBeginFrame(const cc::BeginFrameArgs& args) override;
const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
void OnBeginFrameSourcePausedChanged(bool paused) override;
void OnConnectionLost();
CompositorFrameSinkDelegate* const delegate_;
scoped_refptr<DisplayCompositor> display_compositor_;
const int sink_id_;
cc::BeginFrameSource* begin_frame_source_;
bool needs_begin_frame_;
cc::BeginFrameArgs last_used_begin_frame_args_;
cc::SurfaceFactory factory_;
cc::SurfaceId surface_id_;
gfx::Size last_submitted_frame_size_;
mojom::CompositorFrameSinkClientPtr client_;
mojo::Binding<mojom::CompositorFrameSink> binding_;
DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkImpl);
};
} // namespace gpu
} // namespace ui
#endif // SERVICES_UI_GPU_DISPLAY_COMPOSITOR_COMPOSITOR_FRAME_SINK_IMPL_H_
// Copyright 2016 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 "services/ui/gpu/display_compositor/display_compositor_impl.h"
#include "services/ui/gpu/display_compositor/display_impl.h"
namespace ui {
namespace gpu {
DisplayCompositorImpl::DisplayCompositorImpl() {}
DisplayCompositorImpl::~DisplayCompositorImpl() {}
void DisplayCompositorImpl::CreateDisplay(
int accelerated_widget,
mojo::InterfaceRequest<mojom::Display> display,
mojom::DisplayHostPtr host,
mojo::InterfaceRequest<mojom::CompositorFrameSink> sink,
mojom::CompositorFrameSinkClientPtr client) {
NOTIMPLEMENTED();
}
} // namespace gpu
} // namespace ui
// Copyright 2016 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.
#ifndef SERVICES_UI_GPU_DISPLAY_COMPOSITOR_DISPLAY_COMPOSITOR_IMPL_H_
#define SERVICES_UI_GPU_DISPLAY_COMPOSITOR_DISPLAY_COMPOSITOR_IMPL_H_
#include "services/ui/public/interfaces/gpu/display_compositor.mojom.h"
#include "services/ui/public/interfaces/gpu/display_compositor_host.mojom.h"
namespace ui {
namespace gpu {
class DisplayCompositorImpl : public mojom::DisplayCompositor {
public:
DisplayCompositorImpl();
~DisplayCompositorImpl() override;
// mojom::DisplayCompositor implementation.
void CreateDisplay(int accelerated_widget,
mojo::InterfaceRequest<mojom::Display> display,
mojom::DisplayHostPtr host,
mojo::InterfaceRequest<mojom::CompositorFrameSink> sink,
mojom::CompositorFrameSinkClientPtr client) override;
private:
DISALLOW_COPY_AND_ASSIGN(DisplayCompositorImpl);
};
} // namespace gpu
} // namespace ui
#endif // SERVICES_UI_GPU_DISPLAY_COMPOSITOR_DISPLAY_COMPOSITOR_IMPL_H_
// Copyright 2016 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 "services/ui/gpu/display_compositor/display_impl.h"
#include "services/ui/gpu/display_compositor/compositor_frame_sink_impl.h"
namespace ui {
namespace gpu {
DisplayImpl::DisplayImpl(
int accelerated_widget,
mojo::InterfaceRequest<mojom::Display> display,
mojom::DisplayHostPtr host,
mojo::InterfaceRequest<mojom::CompositorFrameSink> sink,
mojom::CompositorFrameSinkClientPtr client,
const scoped_refptr<DisplayCompositor>& display_compositor)
: binding_(this, std::move(display)) {
const uint32_t client_id = 1;
sink_.reset(new CompositorFrameSinkImpl(this, client_id, display_compositor,
std::move(sink), std::move(client)));
}
DisplayImpl::~DisplayImpl() {}
void DisplayImpl::CreateClient(
uint32_t client_id,
mojo::InterfaceRequest<mojom::DisplayClient> client) {
NOTIMPLEMENTED();
}
void DisplayImpl::CompositorFrameSinkConnectionLost(int sink_id) {
NOTIMPLEMENTED();
}
cc::SurfaceId DisplayImpl::GenerateSurfaceId() {
NOTIMPLEMENTED();
return cc::SurfaceId();
}
} // namespace gpu
} // namespace ui
// Copyright 2016 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.
#ifndef SERVICES_UI_GPU_DISPLAY_COMPOSITOR_DISPLAY_IMPL_H_
#define SERVICES_UI_GPU_DISPLAY_COMPOSITOR_DISPLAY_IMPL_H_
#include "mojo/public/cpp/bindings/binding.h"
#include "services/ui/gpu/display_compositor/compositor_frame_sink_delegate.h"
#include "services/ui/public/interfaces/gpu/display_compositor_host.mojom.h"
#include "services/ui/surfaces/display_compositor.h"
namespace ui {
namespace gpu {
class DisplayImpl : public mojom::Display, public CompositorFrameSinkDelegate {
public:
DisplayImpl(int accelerated_widget,
mojo::InterfaceRequest<mojom::Display> display,
mojom::DisplayHostPtr host,
mojo::InterfaceRequest<mojom::CompositorFrameSink> sink,
mojom::CompositorFrameSinkClientPtr client,
const scoped_refptr<DisplayCompositor>& display_compositor);
~DisplayImpl() override;
// mojom::Display implementation.
void CreateClient(
uint32_t client_id,
mojo::InterfaceRequest<mojom::DisplayClient> client) override;
private:
// CompositorFrameSinkDelegate implementation:
void CompositorFrameSinkConnectionLost(int sink_id) override;
cc::SurfaceId GenerateSurfaceId() override;
std::unique_ptr<CompositorFrameSinkImpl> sink_;
mojo::Binding<mojom::Display> binding_;
DISALLOW_COPY_AND_ASSIGN(DisplayImpl);
};
} // namespace gpu
} // namespace ui
#endif // SERVICES_UI_GPU_DISPLAY_COMPOSITOR_DISPLAY_IMPL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment