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

Side by Side Diff: cc/CCTextureUpdateController.cpp

Issue 10950008: cc: Remove CCTextureUpdateController::updateTextures(). (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 25 matching lines...) Expand all
36 return maxPartialTextureUpdatesMax; 36 return maxPartialTextureUpdatesMax;
37 } 37 }
38 38
39 size_t CCTextureUpdateController::maxFullUpdatesPerTick(TextureUploader* uploade r) 39 size_t CCTextureUpdateController::maxFullUpdatesPerTick(TextureUploader* uploade r)
40 { 40 {
41 double texturesPerSecond = uploader->estimatedTexturesPerSecond(); 41 double texturesPerSecond = uploader->estimatedTexturesPerSecond();
42 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); 42 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond);
43 return texturesPerTick ? texturesPerTick : 1; 43 return texturesPerTick ? texturesPerTick : 1;
44 } 44 }
45 45
46 void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvi der, TextureUploader* uploader, CCTextureUpdateQueue* queue)
47 {
48 size_t uploadCount = 0;
49 while (queue->fullUploadSize()) {
50 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
51 resourceProvider->shallowFlushIfSupported();
52
53 uploader->uploadTexture(
54 resourceProvider, queue->takeFirstFullUpload());
55 uploadCount++;
56 }
57
58 while (queue->partialUploadSize()) {
59 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
60 resourceProvider->shallowFlushIfSupported();
61
62 uploader->uploadTexture(
63 resourceProvider, queue->takeFirstPartialUpload());
64 uploadCount++;
65 }
66
67 if (uploadCount)
68 resourceProvider->shallowFlushIfSupported();
69
70 if (queue->copySize()) {
71 TextureCopier* copier = resourceProvider->textureCopier();
72 while (queue->copySize())
73 copier->copyTexture(queue->takeFirstCopy());
74
75 // If we've performed any texture copies, we need to insert a flush
76 // here into the compositor context before letting the main thread
77 // proceed as it may make draw calls to the source texture of one of
78 // our copy operations.
79 copier->flush();
80 }
81 }
82
83 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureUploader* uploader) 46 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureUploader* uploader)
84 : m_client(client) 47 : m_client(client)
85 , m_timer(adoptPtr(new CCTimer(thread, this))) 48 , m_timer(adoptPtr(new CCTimer(thread, this)))
86 , m_queue(queue) 49 , m_queue(queue)
87 , m_resourceProvider(resourceProvider) 50 , m_resourceProvider(resourceProvider)
88 , m_uploader(uploader) 51 , m_uploader(uploader)
89 , m_monotonicTimeLimit(0) 52 , m_monotonicTimeLimit(0)
90 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(uploader)) 53 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(uploader))
91 , m_firstUpdateAttempt(true) 54 , m_firstUpdateAttempt(true)
92 { 55 {
(...skipping 27 matching lines...) Expand all
120 updateMoreTexturesNow(); 83 updateMoreTexturesNow();
121 } 84 }
122 85
123 void CCTextureUpdateController::discardUploadsToEvictedResources() 86 void CCTextureUpdateController::discardUploadsToEvictedResources()
124 { 87 {
125 m_queue->clearUploadsToEvictedResources(); 88 m_queue->clearUploadsToEvictedResources();
126 } 89 }
127 90
128 void CCTextureUpdateController::finalize() 91 void CCTextureUpdateController::finalize()
129 { 92 {
130 updateTextures(m_resourceProvider, m_uploader, m_queue.get()); 93 size_t uploadCount = 0;
94 while (m_queue->fullUploadSize()) {
95 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
96 m_resourceProvider->shallowFlushIfSupported();
97
98 m_uploader->uploadTexture(
99 m_resourceProvider, m_queue->takeFirstFullUpload());
100 uploadCount++;
101 }
102
103 while (m_queue->partialUploadSize()) {
104 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
105 m_resourceProvider->shallowFlushIfSupported();
106
107 m_uploader->uploadTexture(
108 m_resourceProvider, m_queue->takeFirstPartialUpload());
109 uploadCount++;
110 }
111
112 if (uploadCount)
113 m_resourceProvider->shallowFlushIfSupported();
114
115 if (m_queue->copySize()) {
116 TextureCopier* copier = m_resourceProvider->textureCopier();
117 while (m_queue->copySize())
118 copier->copyTexture(m_queue->takeFirstCopy());
119
120 // If we've performed any texture copies, we need to insert a flush
121 // here into the compositor context before letting the main thread
122 // proceed as it may make draw calls to the source texture of one of
123 // our copy operations.
124 copier->flush();
125 }
131 } 126 }
132 127
133 void CCTextureUpdateController::onTimerFired() 128 void CCTextureUpdateController::onTimerFired()
134 { 129 {
135 if (!updateMoreTexturesIfEnoughTimeRemaining()) 130 if (!updateMoreTexturesIfEnoughTimeRemaining())
136 m_client->readyToFinalizeTextureUpdates(); 131 m_client->readyToFinalizeTextureUpdates();
137 } 132 }
138 133
139 double CCTextureUpdateController::monotonicTimeNow() const 134 double CCTextureUpdateController::monotonicTimeNow() const
140 { 135 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) 182 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
188 m_resourceProvider->shallowFlushIfSupported(); 183 m_resourceProvider->shallowFlushIfSupported();
189 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo ad()); 184 m_uploader->uploadTexture(m_resourceProvider, m_queue->takeFirstFullUplo ad());
190 uploadCount++; 185 uploadCount++;
191 } 186 }
192 m_uploader->endUploads(); 187 m_uploader->endUploads();
193 m_resourceProvider->shallowFlushIfSupported(); 188 m_resourceProvider->shallowFlushIfSupported();
194 } 189 }
195 190
196 } 191 }
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