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

Side by Side Diff: cc/CCTextureUpdateController.cpp

Issue 10911262: cc: Scheduler will never process a commit until it receives a vsync tick. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 | Annotate | Revision Log
« no previous file with comments | « cc/CCTextureUpdateController.h ('k') | cc/CCTextureUpdateControllerTest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "CCTextureUpdateController.h" 7 #include "CCTextureUpdateController.h"
8 8
9 #include "GraphicsContext3D.h" 9 #include "GraphicsContext3D.h"
10 #include "TextureCopier.h" 10 #include "TextureCopier.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 copyCount++; 85 copyCount++;
86 } 86 }
87 87
88 // If we've performed any texture copies, we need to insert a flush here int o the compositor context 88 // If we've performed any texture copies, we need to insert a flush here int o the compositor context
89 // before letting the main thread proceed as it may make draw calls to the s ource texture of one of 89 // before letting the main thread proceed as it may make draw calls to the s ource texture of one of
90 // our copy operations. 90 // our copy operations.
91 if (copyCount) 91 if (copyCount)
92 copier->flush(); 92 copier->flush();
93 } 93 }
94 94
95 CCTextureUpdateController::CCTextureUpdateController(CCThread* thread, PassOwnPt r<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopi er* copier, TextureUploader* uploader) 95 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader)
96 : m_timer(adoptPtr(new CCTimer(thread, this))) 96 : m_client(client)
97 , m_timer(adoptPtr(new CCTimer(thread, this)))
97 , m_queue(queue) 98 , m_queue(queue)
98 , m_resourceProvider(resourceProvider) 99 , m_resourceProvider(resourceProvider)
99 , m_copier(copier) 100 , m_copier(copier)
100 , m_uploader(uploader) 101 , m_uploader(uploader)
101 , m_monotonicTimeLimit(0) 102 , m_monotonicTimeLimit(0)
102 , m_firstUpdateAttempt(true) 103 , m_firstUpdateAttempt(true)
103 { 104 {
104 } 105 }
105 106
106 CCTextureUpdateController::~CCTextureUpdateController() 107 CCTextureUpdateController::~CCTextureUpdateController()
107 { 108 {
108 } 109 }
109 110
110 bool CCTextureUpdateController::hasMoreUpdates() const
111 {
112 return m_queue->hasMoreUpdates();
113 }
114
115 void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit) 111 void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit)
116 { 112 {
113 ASSERT(monotonicTimeLimit >= m_monotonicTimeLimit);
117 m_monotonicTimeLimit = monotonicTimeLimit; 114 m_monotonicTimeLimit = monotonicTimeLimit;
118 115
119 if (!m_queue->hasMoreUpdates()) 116 // Update already in progress.
117 if (m_timer->isActive())
120 return; 118 return;
121 119
122 // Call updateMoreTexturesNow() directly unless it's the first update 120 // Call updateMoreTexturesNow() directly unless it's the first update
123 // attempt. This ensures that we empty the update queue in a finite 121 // attempt. This ensures that we empty the update queue in a finite
124 // amount of time. 122 // amount of time.
125 if (m_firstUpdateAttempt) { 123 if (m_firstUpdateAttempt) {
126 updateMoreTexturesIfEnoughTimeRemaining(); 124 // Post a 0-delay task when no updates were left. When it runs,
125 // updateTexturesCompleted() will be called.
126 if (!updateMoreTexturesIfEnoughTimeRemaining())
127 m_timer->startOneShot(0);
128
127 m_firstUpdateAttempt = false; 129 m_firstUpdateAttempt = false;
128 } else 130 } else
129 updateMoreTexturesNow(); 131 updateMoreTexturesNow();
130 } 132 }
131 133
132 void CCTextureUpdateController::onTimerFired() 134 void CCTextureUpdateController::onTimerFired()
133 { 135 {
134 if (!m_queue->hasMoreUpdates()) 136 if (!updateMoreTexturesIfEnoughTimeRemaining())
135 return; 137 m_client->updateTexturesCompleted();
136
137 updateMoreTexturesIfEnoughTimeRemaining();
138 } 138 }
139 139
140 double CCTextureUpdateController::monotonicTimeNow() const 140 double CCTextureUpdateController::monotonicTimeNow() const
141 { 141 {
142 return monotonicallyIncreasingTime(); 142 return monotonicallyIncreasingTime();
143 } 143 }
144 144
145 double CCTextureUpdateController::updateMoreTexturesTime() const 145 double CCTextureUpdateController::updateMoreTexturesTime() const
146 { 146 {
147 return textureUpdateTickRate; 147 return textureUpdateTickRate;
148 } 148 }
149 149
150 size_t CCTextureUpdateController::updateMoreTexturesSize() const 150 size_t CCTextureUpdateController::updateMoreTexturesSize() const
151 { 151 {
152 return textureUpdatesPerTick; 152 return textureUpdatesPerTick;
153 } 153 }
154 154
155 void CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() 155 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
156 { 156 {
157 if (!m_queue->hasMoreUpdates())
158 return false;
159
157 bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMo reTexturesTime(); 160 bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMo reTexturesTime();
158 if (hasTimeRemaining) 161 if (hasTimeRemaining)
159 updateMoreTexturesNow(); 162 updateMoreTexturesNow();
163
164 return true;
160 } 165 }
161 166
162 void CCTextureUpdateController::updateMoreTexturesNow() 167 void CCTextureUpdateController::updateMoreTexturesNow()
163 { 168 {
164 m_timer->startOneShot(updateMoreTexturesTime()); 169 m_timer->startOneShot(updateMoreTexturesTime());
165 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), upda teMoreTexturesSize()); 170 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), upda teMoreTexturesSize());
166 } 171 }
167 172
168 } 173 }
OLDNEW
« no previous file with comments | « cc/CCTextureUpdateController.h ('k') | cc/CCTextureUpdateControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698