cc: Do not request redraw on commit when impl-side painting

When impl-side painting, we draw when the pending tree
becomes active and should no longer draw on commit.

BUG=168724

Review URL: https://chromiumcodereview.appspot.com/11830040

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177274 0039d316-1c4b-4281-b951-d872f2087c98
parent ec7540f6
......@@ -206,6 +206,8 @@
'ring_buffer.h',
'scheduler.cc',
'scheduler.h',
'scheduler_settings.cc',
'scheduler_settings.h',
'scheduler_state_machine.cc',
'scheduler_state_machine.h',
'scoped_ptr_algorithm.h',
......
......@@ -537,6 +537,13 @@ class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest {
return can_activate_;
}
virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
// We force a second draw here of the first commit before activating
// the second commit.
if (impl->activeTree()->source_frame_number() == 0)
impl->setNeedsRedraw();
}
virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
ImplSidePaintingScrollTest::drawLayersOnThread(impl);
......@@ -558,6 +565,9 @@ class ImplSidePaintingScrollTestSimple : public ImplSidePaintingScrollTest {
EXPECT_VECTOR_EQ(root->scrollDelta(), impl_thread_scroll1_);
EXPECT_VECTOR_EQ(root->sentScrollDelta(), gfx::Vector2d());
postSetNeedsCommitToMainThread();
// commitCompleteOnThread will trigger this function again
// and cause us to take the else clause.
} else {
can_activate_ = true;
ASSERT_TRUE(pending_root);
......
......@@ -10,9 +10,13 @@
namespace cc {
Scheduler::Scheduler(SchedulerClient* client, scoped_ptr<FrameRateController> frameRateController)
: m_client(client)
Scheduler::Scheduler(SchedulerClient* client,
scoped_ptr<FrameRateController> frameRateController,
const SchedulerSettings& schedulerSettings)
: m_settings(schedulerSettings)
, m_client(client)
, m_frameRateController(frameRateController.Pass())
, m_stateMachine(schedulerSettings)
, m_insideProcessScheduledActions(false)
{
DCHECK(m_client);
......
......@@ -11,6 +11,7 @@
#include "cc/cc_export.h"
#include "cc/frame_rate_controller.h"
#include "cc/layer_tree_host.h"
#include "cc/scheduler_settings.h"
#include "cc/scheduler_state_machine.h"
namespace cc {
......@@ -49,9 +50,11 @@ protected:
class CC_EXPORT Scheduler : FrameRateControllerClient {
public:
static scoped_ptr<Scheduler> create(SchedulerClient* client, scoped_ptr<FrameRateController> frameRateController)
static scoped_ptr<Scheduler> create(SchedulerClient* client,
scoped_ptr<FrameRateController> frameRateController,
const SchedulerSettings& schedulerSettings)
{
return make_scoped_ptr(new Scheduler(client, frameRateController.Pass()));
return make_scoped_ptr(new Scheduler(client, frameRateController.Pass(), schedulerSettings));
}
virtual ~Scheduler();
......@@ -97,10 +100,12 @@ public:
virtual void vsyncTick(bool throttled) OVERRIDE;
private:
Scheduler(SchedulerClient*, scoped_ptr<FrameRateController>);
Scheduler(SchedulerClient*, scoped_ptr<FrameRateController>,
const SchedulerSettings& schedulerSettings);
void processScheduledActions();
const SchedulerSettings m_settings;
SchedulerClient* m_client;
scoped_ptr<FrameRateController> m_frameRateController;
SchedulerStateMachine m_stateMachine;
......
// Copyright 2013 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 "cc/scheduler_settings.h"
namespace cc {
SchedulerSettings::SchedulerSettings()
: implSidePainting(false)
{
}
SchedulerSettings::~SchedulerSettings()
{
}
} // namespace cc
// Copyright 2013 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 CC_SCHEDULER_SETTINGS_H_
#define CC_SCHEDULER_SETTINGS_H_
#include "cc/cc_export.h"
namespace cc {
class CC_EXPORT SchedulerSettings
{
public:
SchedulerSettings();
~SchedulerSettings();
bool implSidePainting;
};
} // namespace cc
#endif // CC_SCHEDULER_SETTINGS_H_
......@@ -9,8 +9,9 @@
namespace cc {
SchedulerStateMachine::SchedulerStateMachine()
: m_commitState(COMMIT_STATE_IDLE)
SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
: m_settings(settings)
, m_commitState(COMMIT_STATE_IDLE)
, m_currentFrameNumber(0)
, m_lastFrameNumberWhereDrawWasCalled(-1)
, m_lastFrameNumberWhereTreeActivationAttempted(-1)
......@@ -209,7 +210,9 @@ void SchedulerStateMachine::updateState(Action action)
m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_FORCED_DRAW;
else
m_commitState = COMMIT_STATE_WAITING_FOR_FIRST_DRAW;
m_needsRedraw = true;
// When impl-side painting, we draw on activation instead of on commit.
if (!m_settings.implSidePainting)
m_needsRedraw = true;
if (m_drawIfPossibleFailed)
m_lastFrameNumberWhereDrawWasCalled = -1;
......
......@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "cc/cc_export.h"
#include "cc/scheduler_settings.h"
namespace cc {
......@@ -24,7 +25,8 @@ namespace cc {
// make testing cleaner.
class CC_EXPORT SchedulerStateMachine {
public:
SchedulerStateMachine();
// settings must be valid for the lifetime of this class.
SchedulerStateMachine(const SchedulerSettings& settings);
enum CommitState {
COMMIT_STATE_IDLE,
......@@ -149,6 +151,8 @@ protected:
bool hasDrawnThisFrame() const;
bool hasAttemptedTreeActivationThisFrame() const;
const SchedulerSettings m_settings;
CommitState m_commitState;
int m_currentFrameNumber;
......
This diff is collapsed.
......@@ -69,7 +69,8 @@ TEST(SchedulerTest, RequestCommit)
{
FakeSchedulerClient client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
scheduler->setCanDraw(true);
......@@ -103,7 +104,8 @@ TEST(SchedulerTest, RequestCommitAfterBeginFrame)
{
FakeSchedulerClient client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
scheduler->setCanDraw(true);
......@@ -137,7 +139,8 @@ TEST(SchedulerTest, TextureAcquisitionCollision)
{
FakeSchedulerClient client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
scheduler->setCanDraw(true);
......@@ -176,7 +179,8 @@ TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition)
{
FakeSchedulerClient client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
scheduler->setCanDraw(true);
......@@ -239,7 +243,8 @@ TEST(SchedulerTest, RequestRedrawInsideDraw)
{
SchedulerClientThatSetNeedsDrawInsideDraw client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
client.setScheduler(scheduler.get());
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
......@@ -266,7 +271,8 @@ TEST(SchedulerTest, RequestRedrawInsideFailedDraw)
{
SchedulerClientThatSetNeedsDrawInsideDraw client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
client.setScheduler(scheduler.get());
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
......@@ -339,7 +345,8 @@ TEST(SchedulerTest, RequestCommitInsideDraw)
{
SchedulerClientThatSetNeedsCommitInsideDraw client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
client.setScheduler(scheduler.get());
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
......@@ -367,7 +374,8 @@ TEST(SchedulerTest, RequestCommitInsideFailedDraw)
{
SchedulerClientThatSetNeedsDrawInsideDraw client;
scoped_refptr<FakeTimeSource> timeSource(new FakeTimeSource());
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)));
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, make_scoped_ptr(new FrameRateController(timeSource)), defaultSchedulerSettings);
client.setScheduler(scheduler.get());
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
......@@ -410,7 +418,8 @@ TEST(SchedulerTest, NoBeginFrameWhenDrawFails)
SchedulerClientThatSetNeedsCommitInsideDraw client;
scoped_ptr<FakeFrameRateController> controller(new FakeFrameRateController(timeSource));
FakeFrameRateController* controllerPtr = controller.get();
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, controller.PassAs<FrameRateController>());
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, controller.PassAs<FrameRateController>(), defaultSchedulerSettings);
client.setScheduler(scheduler.get());
scheduler->setCanBeginFrame(true);
scheduler->setVisible(true);
......@@ -447,7 +456,8 @@ TEST(SchedulerTest, NoBeginFrameWhenSwapFailsDuringForcedCommit)
FakeSchedulerClient client;
scoped_ptr<FakeFrameRateController> controller(new FakeFrameRateController(timeSource));
FakeFrameRateController* controllerPtr = controller.get();
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, controller.PassAs<FrameRateController>());
SchedulerSettings defaultSchedulerSettings;
scoped_ptr<Scheduler> scheduler = Scheduler::create(&client, controller.PassAs<FrameRateController>(), defaultSchedulerSettings);
EXPECT_EQ(0, controllerPtr->numFramesPending());
......
......@@ -936,7 +936,10 @@ void ThreadProxy::initializeImplOnImplThread(CompletionEvent* completion, InputH
frameRateController.reset(new FrameRateController(DelayBasedTimeSource::create(displayRefreshInterval, Proxy::implThread())));
else
frameRateController.reset(new FrameRateController(Proxy::implThread()));
m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass());
SchedulerSettings schedulerSettings;
schedulerSettings.implSidePainting = m_layerTreeHost->settings().implSidePainting;
m_schedulerOnImplThread = Scheduler::create(this, frameRateController.Pass(),
schedulerSettings);
m_schedulerOnImplThread->setVisible(m_layerTreeHostImpl->visible());
m_inputHandlerOnImplThread = scoped_ptr<InputHandler>(handler);
......
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