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

Side by Side Diff: cc/CCTextureUpdateController.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/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(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) 95 CCTextureUpdateController::CCTextureUpdateController(CCThread* thread, PassOwnPt r<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureCopi er* copier, TextureUploader* uploader)
96 : m_client(client) 96 : m_timer(adoptPtr(new CCTimer(thread, this)))
97 , m_timer(adoptPtr(new CCTimer(thread, this)))
98 , m_queue(queue) 97 , m_queue(queue)
99 , m_resourceProvider(resourceProvider) 98 , m_resourceProvider(resourceProvider)
100 , m_copier(copier) 99 , m_copier(copier)
101 , m_uploader(uploader) 100 , m_uploader(uploader)
102 , m_monotonicTimeLimit(0) 101 , m_monotonicTimeLimit(0)
103 , m_firstUpdateAttempt(true) 102 , m_firstUpdateAttempt(true)
104 { 103 {
105 } 104 }
106 105
107 CCTextureUpdateController::~CCTextureUpdateController() 106 CCTextureUpdateController::~CCTextureUpdateController()
108 { 107 {
109 } 108 }
110 109
110 bool CCTextureUpdateController::hasMoreUpdates() const
111 {
112 return m_queue->hasMoreUpdates();
113 }
114
111 void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit) 115 void CCTextureUpdateController::updateMoreTextures(double monotonicTimeLimit)
112 { 116 {
113 ASSERT(monotonicTimeLimit >= m_monotonicTimeLimit);
114 m_monotonicTimeLimit = monotonicTimeLimit; 117 m_monotonicTimeLimit = monotonicTimeLimit;
115 118
116 // Update already in progress. 119 if (!m_queue->hasMoreUpdates())
117 if (m_timer->isActive())
118 return; 120 return;
119 121
120 // Call updateMoreTexturesNow() directly unless it's the first update 122 // Call updateMoreTexturesNow() directly unless it's the first update
121 // attempt. This ensures that we empty the update queue in a finite 123 // attempt. This ensures that we empty the update queue in a finite
122 // amount of time. 124 // amount of time.
123 if (m_firstUpdateAttempt) { 125 if (m_firstUpdateAttempt) {
124 // Post a 0-delay task when no updates were left. When it runs, 126 updateMoreTexturesIfEnoughTimeRemaining();
125 // updateTexturesCompleted() will be called.
126 if (!updateMoreTexturesIfEnoughTimeRemaining())
127 m_timer->startOneShot(0);
128
129 m_firstUpdateAttempt = false; 127 m_firstUpdateAttempt = false;
130 } else 128 } else
131 updateMoreTexturesNow(); 129 updateMoreTexturesNow();
132 } 130 }
133 131
134 void CCTextureUpdateController::discardUploads()
135 {
136 // CCTextureUpdateControllerClient::updateTexturesCompleted will be
137 // called when all remaining texture copies are done.
138 m_queue->clearUploads();
139 }
140
141 void CCTextureUpdateController::onTimerFired() 132 void CCTextureUpdateController::onTimerFired()
142 { 133 {
143 if (!updateMoreTexturesIfEnoughTimeRemaining()) 134 if (!m_queue->hasMoreUpdates())
144 m_client->updateTexturesCompleted(); 135 return;
136
137 updateMoreTexturesIfEnoughTimeRemaining();
145 } 138 }
146 139
147 double CCTextureUpdateController::monotonicTimeNow() const 140 double CCTextureUpdateController::monotonicTimeNow() const
148 { 141 {
149 return monotonicallyIncreasingTime(); 142 return monotonicallyIncreasingTime();
150 } 143 }
151 144
152 double CCTextureUpdateController::updateMoreTexturesTime() const 145 double CCTextureUpdateController::updateMoreTexturesTime() const
153 { 146 {
154 return textureUpdateTickRate; 147 return textureUpdateTickRate;
155 } 148 }
156 149
157 size_t CCTextureUpdateController::updateMoreTexturesSize() const 150 size_t CCTextureUpdateController::updateMoreTexturesSize() const
158 { 151 {
159 return textureUpdatesPerTick; 152 return textureUpdatesPerTick;
160 } 153 }
161 154
162 bool CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining() 155 void CCTextureUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
163 { 156 {
164 if (!m_queue->hasMoreUpdates())
165 return false;
166
167 bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMo reTexturesTime(); 157 bool hasTimeRemaining = monotonicTimeNow() < m_monotonicTimeLimit - updateMo reTexturesTime();
168 if (hasTimeRemaining) 158 if (hasTimeRemaining)
169 updateMoreTexturesNow(); 159 updateMoreTexturesNow();
170
171 return true;
172 } 160 }
173 161
174 void CCTextureUpdateController::updateMoreTexturesNow() 162 void CCTextureUpdateController::updateMoreTexturesNow()
175 { 163 {
176 m_timer->startOneShot(updateMoreTexturesTime()); 164 m_timer->startOneShot(updateMoreTexturesTime());
177 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), upda teMoreTexturesSize()); 165 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), upda teMoreTexturesSize());
178 } 166 }
179 167
180 } 168 }
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