Commit de6bfca7 authored by enne's avatar enne Committed by Commit bot

Fold BeginFrameSource::SetClientReady into AddObserver

As a part of https://codereview.chromium.org/1774323003, it became clear
that it needed to be possible to call SetClientReady repeatedly, which
some sources didn't support.

Instead of just making that part of the contract, instead fold the two
places where SetClientReady mattered into AddObserver (the first time
where a begin frame could actually be delivered) and remove
SetClientReady from the API.

R=skyostil@chromium.org,sunnyps@chomium.org
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1778853003

Cr-Commit-Position: refs/heads/master@{#381612}
parent d35f14e7
......@@ -126,9 +126,6 @@ class CC_EXPORT BeginFrameSource {
virtual void AddObserver(BeginFrameObserver* obs) = 0;
virtual void RemoveObserver(BeginFrameObserver* obs) = 0;
// Tells the Source that client is ready to handle BeginFrames messages.
virtual void SetClientReady() = 0;
// Tracing support - Recommend (but not required) to call this implementation
// in any override.
virtual void AsValueInto(base::trace_event::TracedValue* dict) const = 0;
......@@ -149,7 +146,6 @@ class CC_EXPORT BeginFrameSourceBase : public BeginFrameSource {
void DidFinishFrame(size_t remaining_frames) override {}
void AddObserver(BeginFrameObserver* obs) override;
void RemoveObserver(BeginFrameObserver* obs) override;
void SetClientReady() override {}
// Tracing support - Recommend (but not required) to call this implementation
// in any override.
......
......@@ -68,7 +68,6 @@ Scheduler::Scheduler(
begin_impl_frame_deadline_closure_ = base::Bind(
&Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr());
begin_frame_source_->SetClientReady();
ProcessScheduledActions();
}
......
......@@ -61,7 +61,6 @@ class EmptyBeginFrameSource : public BeginFrameSource {
void DidFinishFrame(size_t remaining_frames) override{};
void AddObserver(BeginFrameObserver* obs) override{};
void RemoveObserver(BeginFrameObserver* obs) override{};
void SetClientReady() override {}
void AsValueInto(base::trace_event::TracedValue* dict) const override{};
};
......
......@@ -14,7 +14,6 @@ namespace cc {
FakeExternalBeginFrameSource::FakeExternalBeginFrameSource(double refresh_rate)
: milliseconds_per_frame_(1000.0 / refresh_rate),
is_ready_(false),
weak_ptr_factory_(this) {
DetachFromThread();
}
......@@ -23,11 +22,6 @@ FakeExternalBeginFrameSource::~FakeExternalBeginFrameSource() {
DCHECK(CalledOnValidThread());
}
void FakeExternalBeginFrameSource::SetClientReady() {
DCHECK(CalledOnValidThread());
is_ready_ = true;
}
void FakeExternalBeginFrameSource::OnNeedsBeginFramesChanged(
bool needs_begin_frames) {
DCHECK(CalledOnValidThread());
......
......@@ -17,11 +17,6 @@ class FakeExternalBeginFrameSource
explicit FakeExternalBeginFrameSource(double refresh_rate);
~FakeExternalBeginFrameSource() override;
bool is_ready() const { return is_ready_; }
// BeginFrameSource implementation.
void SetClientReady() override;
// BeginFrameSourceBase overrides.
void OnNeedsBeginFramesChanged(bool needs_begin_frames) override;
......@@ -30,7 +25,6 @@ class FakeExternalBeginFrameSource
private:
double milliseconds_per_frame_;
bool is_ready_;
base::CancelableClosure begin_frame_task_;
base::WeakPtrFactory<FakeExternalBeginFrameSource> weak_ptr_factory_;
};
......
......@@ -914,7 +914,6 @@ scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface() {
if (settings_.use_external_begin_frame_source &&
settings_.wait_for_beginframe_interval) {
DCHECK(external_begin_frame_source_);
DCHECK(external_begin_frame_source_->is_ready());
}
return std::move(output_surface);
}
......
......@@ -61,8 +61,12 @@ void SynchronousCompositorExternalBeginFrameSource::OnNeedsBeginFramesChanged(
client_->OnNeedsBeginFramesChange(needs_begin_frames);
}
void SynchronousCompositorExternalBeginFrameSource::SetClientReady() {
void SynchronousCompositorExternalBeginFrameSource::AddObserver(
cc::BeginFrameObserver* obs) {
DCHECK(CalledOnValidThread());
BeginFrameSourceBase::AddObserver(obs);
if (registered_)
return;
registry_->RegisterBeginFrameSource(routing_id_, this);
registered_ = true;
}
......
......@@ -38,7 +38,7 @@ class SynchronousCompositorExternalBeginFrameSource
// cc::BeginFrameSourceBase implementation.
void OnNeedsBeginFramesChanged(bool needs_begin_frames) override;
void SetClientReady() override;
void AddObserver(cc::BeginFrameObserver* obs) override;
private:
bool CalledOnValidThread() const;
......
......@@ -43,6 +43,7 @@ void CompositorExternalBeginFrameSource::OnNeedsBeginFramesChanged(
void CompositorExternalBeginFrameSource::AddObserver(
cc::BeginFrameObserver* obs) {
DCHECK(CalledOnValidThread());
SetClientReady();
BeginFrameSourceBase::AddObserver(obs);
// Send a MISSED begin frame if necessary.
if (missed_begin_frame_args_.IsValid()) {
......@@ -56,7 +57,8 @@ void CompositorExternalBeginFrameSource::AddObserver(
void CompositorExternalBeginFrameSource::SetClientReady() {
DCHECK(CalledOnValidThread());
DCHECK(!begin_frame_source_proxy_.get());
if (begin_frame_source_proxy_)
return;
begin_frame_source_proxy_ =
new CompositorExternalBeginFrameSourceProxy(this);
begin_frame_source_filter_handler_ = base::Bind(
......
......@@ -33,7 +33,6 @@ class CompositorExternalBeginFrameSource
// cc::BeginFrameSourceBase implementation.
void AddObserver(cc::BeginFrameObserver* obs) override;
void OnNeedsBeginFramesChanged(bool needs_begin_frames) override;
void SetClientReady() override;
private:
class CompositorExternalBeginFrameSourceProxy
......@@ -59,6 +58,7 @@ class CompositorExternalBeginFrameSource
DISALLOW_COPY_AND_ASSIGN(CompositorExternalBeginFrameSourceProxy);
};
void SetClientReady();
void OnMessageReceived(const IPC::Message& message);
void OnBeginFrame(const cc::BeginFrameArgs& args);
......
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