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

Unified Diff: content/browser/compositor/browser_compositor_output_surface.cc

Issue 1821863002: Hook up ui::Compositor to Display's BeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; refactor mus output surface Created 4 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: content/browser/compositor/browser_compositor_output_surface.cc
diff --git a/content/browser/compositor/browser_compositor_output_surface.cc b/content/browser/compositor/browser_compositor_output_surface.cc
index f865702effe067a645bc434c72882385ed5195a5..0b0e21ff4d93b4291fd82094d18828126be36a01 100644
--- a/content/browser/compositor/browser_compositor_output_surface.cc
+++ b/content/browser/compositor/browser_compositor_output_surface.cc
@@ -11,6 +11,7 @@
#include "base/location.h"
#include "base/strings/string_number_conversions.h"
#include "cc/base/switches.h"
+#include "cc/output/output_surface_client.h"
#include "content/browser/compositor/browser_compositor_overlay_candidate_validator.h"
#include "content/browser/compositor/reflector_impl.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
@@ -21,27 +22,35 @@ BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
const scoped_refptr<cc::ContextProvider>& context_provider,
const scoped_refptr<cc::ContextProvider>& worker_context_provider,
const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
+ base::SingleThreadTaskRunner* task_runner,
scoped_ptr<BrowserCompositorOverlayCandidateValidator>
overlay_candidate_validator)
: OutputSurface(context_provider, worker_context_provider),
vsync_manager_(vsync_manager),
+ synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource(
+ task_runner,
+ cc::BeginFrameArgs::DefaultInterval())),
reflector_(nullptr),
use_begin_frame_scheduling_(
- base::CommandLine::ForCurrentProcess()
- ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) {
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ cc::switches::kEnableBeginFrameScheduling)) {
overlay_candidate_validator_ = std::move(overlay_candidate_validator);
Initialize();
}
BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
scoped_ptr<cc::SoftwareOutputDevice> software_device,
- const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager)
+ const scoped_refptr<ui::CompositorVSyncManager>& vsync_manager,
+ base::SingleThreadTaskRunner* task_runner)
: OutputSurface(std::move(software_device)),
vsync_manager_(vsync_manager),
+ synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource(
+ task_runner,
+ cc::BeginFrameArgs::DefaultInterval())),
reflector_(nullptr),
use_begin_frame_scheduling_(
- base::CommandLine::ForCurrentProcess()
- ->HasSwitch(cc::switches::kEnableBeginFrameScheduling)) {
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ cc::switches::kEnableBeginFrameScheduling)) {
sunnyps 2016/04/01 22:35:25 nit: Is this flag ever false? If not can you remov
enne (OOO) 2016/04/02 00:18:38 Yes. This flag is sometimes false. That boolean
Initialize();
}
@@ -67,18 +76,34 @@ bool BrowserCompositorOutputSurface::BindToClient(
if (!OutputSurface::BindToClient(client))
return false;
+ // Pass begin frame source up to Display to use for DisplayScheduler.
+ client->SetBeginFrameSource(synthetic_begin_frame_source_.get());
+
// Don't want vsync notifications until there is a client.
if (!use_begin_frame_scheduling_)
vsync_manager_->AddObserver(this);
return true;
}
+void BrowserCompositorOutputSurface::UpdateVSyncParametersInternal(
+ base::TimeTicks timebase,
+ base::TimeDelta interval) {
+ if (interval == base::TimeDelta()) {
+ // TODO(brianderson): We should not be receiving 0 intervals.
+ interval = cc::BeginFrameArgs::DefaultInterval();
+ }
+ synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval);
+
+ // TODO(enne): remove this once vsyncs are no longer used in the renderer.
+ CommitVSyncParameters(timebase, interval);
+}
+
void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
base::TimeTicks timebase,
base::TimeDelta interval) {
DCHECK(HasClient());
DCHECK(!use_begin_frame_scheduling_);
- CommitVSyncParameters(timebase, interval);
+ UpdateVSyncParametersInternal(timebase, interval);
}
void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
@@ -86,7 +111,7 @@ void BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu(
base::TimeDelta interval) {
DCHECK(HasClient());
if (use_begin_frame_scheduling_) {
- CommitVSyncParameters(timebase, interval);
+ UpdateVSyncParametersInternal(timebase, interval);
return;
}

Powered by Google App Engine
This is Rietveld 408576698