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

Side by Side Diff: cc/CCScheduler.cpp

Issue 10909020: Enable webkit_compositor_unittests (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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 unified diff | Download patch
« no previous file with comments | « cc/CCScheduler.h ('k') | cc/CCSchedulerTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCScheduler.h" 7 #include "CCScheduler.h"
8 8
9 #include "TraceEvent.h" 9 #include "TraceEvent.h"
10 10
11 namespace WebCore { 11 namespace WebCore {
12 12
13 CCScheduler::CCScheduler(CCSchedulerClient* client, PassOwnPtr<CCFrameRateContro ller> frameRateController) 13 CCScheduler::CCScheduler(CCSchedulerClient* client, PassOwnPtr<CCFrameRateContro ller> frameRateController)
14 : m_client(client) 14 : m_client(client)
15 , m_frameRateController(frameRateController) 15 , m_frameRateController(frameRateController)
16 , m_hasMoreResourceUpdates(false)
17 , m_updateMoreResourcesPending(false) 16 , m_updateMoreResourcesPending(false)
18 { 17 {
19 ASSERT(m_client); 18 ASSERT(m_client);
20 m_frameRateController->setClient(this); 19 m_frameRateController->setClient(this);
21 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded()); 20 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
22 } 21 }
23 22
24 CCScheduler::~CCScheduler() 23 CCScheduler::~CCScheduler()
25 { 24 {
26 m_frameRateController->setActive(false); 25 m_frameRateController->setActive(false);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 m_stateMachine.setNeedsForcedRedraw(); 60 m_stateMachine.setNeedsForcedRedraw();
62 processScheduledActions(); 61 processScheduledActions();
63 } 62 }
64 63
65 void CCScheduler::setMainThreadNeedsLayerTextures() 64 void CCScheduler::setMainThreadNeedsLayerTextures()
66 { 65 {
67 m_stateMachine.setMainThreadNeedsLayerTextures(); 66 m_stateMachine.setMainThreadNeedsLayerTextures();
68 processScheduledActions(); 67 processScheduledActions();
69 } 68 }
70 69
71 void CCScheduler::beginFrameComplete(bool hasResourceUpdates) 70 void CCScheduler::beginFrameComplete()
72 { 71 {
73 TRACE_EVENT0("cc", "CCScheduler::beginFrameComplete"); 72 TRACE_EVENT0("cc", "CCScheduler::beginFrameComplete");
74 m_hasMoreResourceUpdates = hasResourceUpdates;
75 m_stateMachine.beginFrameComplete(); 73 m_stateMachine.beginFrameComplete();
76 processScheduledActions(); 74 processScheduledActions();
77 } 75 }
78 76
79 void CCScheduler::beginFrameAborted() 77 void CCScheduler::beginFrameAborted()
80 { 78 {
81 TRACE_EVENT0("cc", "CCScheduler::beginFrameAborted"); 79 TRACE_EVENT0("cc", "CCScheduler::beginFrameAborted");
82 m_stateMachine.beginFrameAborted(); 80 m_stateMachine.beginFrameAborted();
83 processScheduledActions(); 81 processScheduledActions();
84 } 82 }
(...skipping 26 matching lines...) Expand all
111 109
112 void CCScheduler::setTimebaseAndInterval(double timebase, double intervalSeconds ) 110 void CCScheduler::setTimebaseAndInterval(double timebase, double intervalSeconds )
113 { 111 {
114 m_frameRateController->setTimebaseAndInterval(timebase, intervalSeconds); 112 m_frameRateController->setTimebaseAndInterval(timebase, intervalSeconds);
115 } 113 }
116 114
117 void CCScheduler::vsyncTick() 115 void CCScheduler::vsyncTick()
118 { 116 {
119 if (m_updateMoreResourcesPending) { 117 if (m_updateMoreResourcesPending) {
120 m_updateMoreResourcesPending = false; 118 m_updateMoreResourcesPending = false;
121 ASSERT(m_hasMoreResourceUpdates); 119 m_stateMachine.beginUpdateMoreResourcesComplete(m_client->hasMoreResourc eUpdates());
122 m_stateMachine.beginUpdateMoreResourcesComplete(true);
123 } 120 }
124 TRACE_EVENT0("cc", "CCScheduler::vsyncTick"); 121 TRACE_EVENT0("cc", "CCScheduler::vsyncTick");
125 122
126 m_stateMachine.didEnterVSync(); 123 m_stateMachine.didEnterVSync();
127 processScheduledActions(); 124 processScheduledActions();
128 m_stateMachine.didLeaveVSync(); 125 m_stateMachine.didLeaveVSync();
129 } 126 }
130 127
131 void CCScheduler::updateResourcesComplete()
132 {
133 TRACE_EVENT0("cc", "CCScheduler::updateResourcesComplete");
134 if (m_updateMoreResourcesPending) {
135 m_updateMoreResourcesPending = false;
136 m_stateMachine.beginUpdateMoreResourcesComplete(false);
137 }
138 m_hasMoreResourceUpdates = false;
139 processScheduledActions();
140 }
141
142 CCSchedulerStateMachine::Action CCScheduler::nextAction() 128 CCSchedulerStateMachine::Action CCScheduler::nextAction()
143 { 129 {
144 m_stateMachine.setCanDraw(m_client->canDraw()); 130 m_stateMachine.setCanDraw(m_client->canDraw());
145 return m_stateMachine.nextAction(); 131 return m_stateMachine.nextAction();
146 } 132 }
147 133
148 void CCScheduler::processScheduledActions() 134 void CCScheduler::processScheduledActions()
149 { 135 {
150 // Early out so we don't spam TRACE_EVENTS with useless processScheduledActi ons. 136 // Early out so we don't spam TRACE_EVENTS with useless processScheduledActi ons.
151 if (nextAction() == CCSchedulerStateMachine::ACTION_NONE) { 137 if (nextAction() == CCSchedulerStateMachine::ACTION_NONE) {
152 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded()); 138 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
153 return; 139 return;
154 } 140 }
155 141
156 // This function can re-enter itself. For example, draw may call 142 // This function can re-enter itself. For example, draw may call
157 // setNeedsCommit. Proceeed with caution. 143 // setNeedsCommit. Proceeed with caution.
158 CCSchedulerStateMachine::Action action; 144 CCSchedulerStateMachine::Action action;
159 do { 145 do {
160 action = nextAction(); 146 action = nextAction();
161 m_stateMachine.updateState(action); 147 m_stateMachine.updateState(action);
162 TRACE_EVENT1("cc", "CCScheduler::processScheduledActions()", "action", a ction); 148 TRACE_EVENT1("cc", "CCScheduler::processScheduledActions()", "action", a ction);
163 149
164 switch (action) { 150 switch (action) {
165 case CCSchedulerStateMachine::ACTION_NONE: 151 case CCSchedulerStateMachine::ACTION_NONE:
166 break; 152 break;
167 case CCSchedulerStateMachine::ACTION_BEGIN_FRAME: 153 case CCSchedulerStateMachine::ACTION_BEGIN_FRAME:
168 m_client->scheduledActionBeginFrame(); 154 m_client->scheduledActionBeginFrame();
169 break; 155 break;
170 case CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES: 156 case CCSchedulerStateMachine::ACTION_BEGIN_UPDATE_MORE_RESOURCES:
171 if (m_hasMoreResourceUpdates) { 157 if (m_client->hasMoreResourceUpdates()) {
172 m_client->scheduledActionUpdateMoreResources(m_frameRateControll er->nextTickTimeIfActivated()); 158 m_client->scheduledActionUpdateMoreResources(m_frameRateControll er->nextTickTimeIfActivated());
173 m_updateMoreResourcesPending = true; 159 m_updateMoreResourcesPending = true;
174 } else 160 } else
175 m_stateMachine.beginUpdateMoreResourcesComplete(false); 161 m_stateMachine.beginUpdateMoreResourcesComplete(false);
176 break; 162 break;
177 case CCSchedulerStateMachine::ACTION_COMMIT: 163 case CCSchedulerStateMachine::ACTION_COMMIT:
178 m_client->scheduledActionCommit(); 164 m_client->scheduledActionCommit();
179 break; 165 break;
180 case CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: { 166 case CCSchedulerStateMachine::ACTION_DRAW_IF_POSSIBLE: {
181 CCScheduledActionDrawAndSwapResult result = m_client->scheduledActio nDrawAndSwapIfPossible(); 167 CCScheduledActionDrawAndSwapResult result = m_client->scheduledActio nDrawAndSwapIfPossible();
(...skipping 14 matching lines...) Expand all
196 m_client->scheduledActionAcquireLayerTexturesForMainThread(); 182 m_client->scheduledActionAcquireLayerTexturesForMainThread();
197 break; 183 break;
198 } 184 }
199 } while (action != CCSchedulerStateMachine::ACTION_NONE); 185 } while (action != CCSchedulerStateMachine::ACTION_NONE);
200 186
201 // Activate or deactivate the frame rate controller. 187 // Activate or deactivate the frame rate controller.
202 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded()); 188 m_frameRateController->setActive(m_stateMachine.vsyncCallbackNeeded());
203 } 189 }
204 190
205 } 191 }
OLDNEW
« no previous file with comments | « cc/CCScheduler.h ('k') | cc/CCSchedulerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698