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

Unified Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 2527283003: cc: Introduce BeginFrame sequence numbers and acknowledgements.
Patch Set: Address Brian's comments. Created 4 years 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: content/browser/renderer_host/compositor_impl_android.cc
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index 91f20de9a037eced030689532e55fcc8556fd08e..4a8dc4bc29969f87887f43af295d0fba15a4db1b 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -138,78 +138,6 @@ gpu::gles2::ContextCreationAttribHelper GetCompositorContextAttributes(
return attributes;
}
-class ExternalBeginFrameSource : public cc::BeginFrameSource,
- public CompositorImpl::VSyncObserver {
- public:
- explicit ExternalBeginFrameSource(CompositorImpl* compositor)
- : compositor_(compositor) {
- compositor_->AddObserver(this);
- }
- ~ExternalBeginFrameSource() override { compositor_->RemoveObserver(this); }
-
- // cc::BeginFrameSource implementation.
- void AddObserver(cc::BeginFrameObserver* obs) override;
- void RemoveObserver(cc::BeginFrameObserver* obs) override;
- void DidFinishFrame(cc::BeginFrameObserver* obs,
- size_t remaining_frames) override {}
- bool IsThrottled() const override { return true; }
-
- // CompositorImpl::VSyncObserver implementation.
- void OnVSync(base::TimeTicks frame_time,
- base::TimeDelta vsync_period) override;
-
- private:
- CompositorImpl* const compositor_;
- std::unordered_set<cc::BeginFrameObserver*> observers_;
- cc::BeginFrameArgs last_begin_frame_args_;
-};
-
-void ExternalBeginFrameSource::AddObserver(cc::BeginFrameObserver* obs) {
- DCHECK(obs);
- DCHECK(observers_.find(obs) == observers_.end());
-
- observers_.insert(obs);
- obs->OnBeginFrameSourcePausedChanged(false);
- compositor_->OnNeedsBeginFramesChange(true);
-
- if (last_begin_frame_args_.IsValid()) {
- // Send a MISSED begin frame if necessary.
- cc::BeginFrameArgs last_args = obs->LastUsedBeginFrameArgs();
- if (!last_args.IsValid() ||
- (last_begin_frame_args_.frame_time > last_args.frame_time)) {
- last_begin_frame_args_.type = cc::BeginFrameArgs::MISSED;
- // TODO(crbug.com/602485): A deadline doesn't make too much sense
- // for a missed BeginFrame (the intention rather is 'immediately'),
- // but currently the retro frame logic is very strict in discarding
- // BeginFrames.
- last_begin_frame_args_.deadline =
- base::TimeTicks::Now() + last_begin_frame_args_.interval;
- obs->OnBeginFrame(last_begin_frame_args_);
- }
- }
-}
-
-void ExternalBeginFrameSource::RemoveObserver(cc::BeginFrameObserver* obs) {
- DCHECK(obs);
- DCHECK(observers_.find(obs) != observers_.end());
-
- observers_.erase(obs);
- if (observers_.empty())
- compositor_->OnNeedsBeginFramesChange(false);
-}
-
-void ExternalBeginFrameSource::OnVSync(base::TimeTicks frame_time,
- base::TimeDelta vsync_period) {
- // frame time is in the past, so give the next vsync period as the deadline.
- base::TimeTicks deadline = frame_time + vsync_period;
- last_begin_frame_args_ =
- cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline,
- vsync_period, cc::BeginFrameArgs::NORMAL);
- std::unordered_set<cc::BeginFrameObserver*> observers(observers_);
- for (auto* obs : observers)
- obs->OnBeginFrame(last_begin_frame_args_);
-}
-
class AndroidOutputSurface : public cc::OutputSurface {
public:
explicit AndroidOutputSurface(
@@ -406,7 +334,6 @@ CompositorImpl::CompositorImpl(CompositorClient* client,
pending_swapbuffers_(0U),
num_successive_context_creation_failures_(0),
compositor_frame_sink_request_pending_(false),
- needs_begin_frames_(false),
weak_factory_(this) {
ui::ContextProviderFactory::GetInstance()
->GetSurfaceManager()
@@ -728,11 +655,10 @@ void CompositorImpl::InitializeDisplay(
cc::SurfaceManager* manager =
ui::ContextProviderFactory::GetInstance()->GetSurfaceManager();
auto* task_runner = base::ThreadTaskRunnerHandle::Get().get();
- std::unique_ptr<ExternalBeginFrameSource> begin_frame_source(
- new ExternalBeginFrameSource(this));
+ std::unique_ptr<cc::DelegatingBeginFrameSource> begin_frame_source(
+ new cc::DelegatingBeginFrameSource(root_window_->GetBeginFrameSource()));
std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler(
- begin_frame_source.get(), task_runner,
- display_output_surface->capabilities().max_frames_pending));
+ task_runner, display_output_surface->capabilities().max_frames_pending));
display_.reset(new cc::Display(
HostSharedBitmapManager::current(),
@@ -757,14 +683,6 @@ void CompositorImpl::InitializeDisplay(
host_->SetCompositorFrameSink(std::move(compositor_frame_sink));
}
-void CompositorImpl::AddObserver(VSyncObserver* observer) {
- observer_list_.AddObserver(observer);
-}
-
-void CompositorImpl::RemoveObserver(VSyncObserver* observer) {
- observer_list_.RemoveObserver(observer);
-}
-
cc::UIResourceId CompositorImpl::CreateUIResource(
cc::UIResourceClient* client) {
TRACE_EVENT0("compositor", "CompositorImpl::CreateUIResource");
@@ -810,23 +728,6 @@ void CompositorImpl::RequestCopyOfOutputOnRootLayer(
root_window_->GetLayer()->RequestCopyOfOutput(std::move(request));
}
-void CompositorImpl::OnVSync(base::TimeTicks frame_time,
- base::TimeDelta vsync_period) {
- for (auto& observer : observer_list_)
- observer.OnVSync(frame_time, vsync_period);
- if (needs_begin_frames_)
- root_window_->RequestVSyncUpdate();
-}
-
-void CompositorImpl::OnNeedsBeginFramesChange(bool needs_begin_frames) {
- if (needs_begin_frames_ == needs_begin_frames)
- return;
-
- needs_begin_frames_ = needs_begin_frames;
- if (needs_begin_frames_)
- root_window_->RequestVSyncUpdate();
-}
-
void CompositorImpl::SetNeedsAnimate() {
needs_animate_ = true;
if (!host_->IsVisible())
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/browser/renderer_host/delegated_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698