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

Side by Side Diff: cc/CCTextureUpdateController.cpp

Issue 10917251: Move TextureCopier and TextureUploader from CCRenderer to CCResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix rebase merge issues 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 16 matching lines...) Expand all
27 27
28 } // anonymous namespace 28 } // anonymous namespace
29 29
30 namespace cc { 30 namespace cc {
31 31
32 size_t CCTextureUpdateController::maxPartialTextureUpdates() 32 size_t CCTextureUpdateController::maxPartialTextureUpdates()
33 { 33 {
34 return textureUpdatesPerTick; 34 return textureUpdatesPerTick;
35 } 35 }
36 36
37 void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvi der, TextureCopier* copier, TextureUploader* uploader, CCTextureUpdateQueue* que ue, size_t count) 37 void CCTextureUpdateController::updateTextures(CCResourceProvider* resourceProvi der, TextureUploader* uploader, CCTextureUpdateQueue* queue, size_t count)
38 { 38 {
39 if (queue->fullUploadSize() || queue->partialUploadSize()) { 39 if (queue->fullUploadSize() || queue->partialUploadSize()) {
40 if (uploader->isBusy()) 40 if (uploader->isBusy())
41 return; 41 return;
42 42
43 uploader->beginUploads(); 43 uploader->beginUploads();
44 44
45 size_t fullUploadCount = 0; 45 size_t fullUploadCount = 0;
46 while (queue->fullUploadSize() && fullUploadCount < count) { 46 while (queue->fullUploadSize() && fullUploadCount < count) {
47 uploader->uploadTexture(resourceProvider, queue->takeFirstFullUpload ()); 47 uploader->uploadTexture(resourceProvider, queue->takeFirstFullUpload ());
(...skipping 27 matching lines...) Expand all
75 resourceProvider->shallowFlushIfSupported(); 75 resourceProvider->shallowFlushIfSupported();
76 } 76 }
77 77
78 // Make sure there are no dangling partial uploads without a flush. 78 // Make sure there are no dangling partial uploads without a flush.
79 if (partialUploadCount % textureUploadFlushPeriod) 79 if (partialUploadCount % textureUploadFlushPeriod)
80 resourceProvider->shallowFlushIfSupported(); 80 resourceProvider->shallowFlushIfSupported();
81 81
82 uploader->endUploads(); 82 uploader->endUploads();
83 } 83 }
84 84
85 TextureCopier* copier = resourceProvider->textureCopier();
85 size_t copyCount = 0; 86 size_t copyCount = 0;
86 while (queue->copySize()) { 87 while (queue->copySize()) {
87 copier->copyTexture(queue->takeFirstCopy()); 88 copier->copyTexture(queue->takeFirstCopy());
88 copyCount++; 89 copyCount++;
89 } 90 }
90 91
91 // If we've performed any texture copies, we need to insert a flush here int o the compositor context 92 // If we've performed any texture copies, we need to insert a flush here int o the compositor context
92 // before letting the main thread proceed as it may make draw calls to the s ource texture of one of 93 // before letting the main thread proceed as it may make draw calls to the s ource texture of one of
93 // our copy operations. 94 // our copy operations.
94 if (copyCount) 95 if (copyCount)
95 copier->flush(); 96 copier->flush();
96 } 97 }
97 98
98 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploader) 99 CCTextureUpdateController::CCTextureUpdateController(CCTextureUpdateControllerCl ient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCResour ceProvider* resourceProvider, TextureUploader* uploader)
99 : m_client(client) 100 : m_client(client)
100 , m_timer(adoptPtr(new CCTimer(thread, this))) 101 , m_timer(adoptPtr(new CCTimer(thread, this)))
101 , m_queue(queue) 102 , m_queue(queue)
102 , m_resourceProvider(resourceProvider) 103 , m_resourceProvider(resourceProvider)
103 , m_copier(copier)
104 , m_uploader(uploader) 104 , m_uploader(uploader)
105 , m_monotonicTimeLimit(0) 105 , m_monotonicTimeLimit(0)
106 , m_firstUpdateAttempt(true) 106 , m_firstUpdateAttempt(true)
107 { 107 {
108 } 108 }
109 109
110 CCTextureUpdateController::~CCTextureUpdateController() 110 CCTextureUpdateController::~CCTextureUpdateController()
111 { 111 {
112 } 112 }
113 113
(...skipping 17 matching lines...) Expand all
131 m_timer->startOneShot(0); 131 m_timer->startOneShot(0);
132 132
133 m_firstUpdateAttempt = false; 133 m_firstUpdateAttempt = false;
134 } else 134 } else
135 updateMoreTexturesNow(); 135 updateMoreTexturesNow();
136 } 136 }
137 137
138 void CCTextureUpdateController::finalize() 138 void CCTextureUpdateController::finalize()
139 { 139 {
140 while (m_queue->hasMoreUpdates()) 140 while (m_queue->hasMoreUpdates())
141 updateTextures(m_resourceProvider, m_copier, m_uploader, m_queue.get(), 141 updateTextures(m_resourceProvider, m_uploader, m_queue.get(),
142 updateMoreTexturesSize()); 142 updateMoreTexturesSize());
143 } 143 }
144 144
145 void CCTextureUpdateController::onTimerFired() 145 void CCTextureUpdateController::onTimerFired()
146 { 146 {
147 if (!updateMoreTexturesIfEnoughTimeRemaining()) 147 if (!updateMoreTexturesIfEnoughTimeRemaining())
148 m_client->readyToFinalizeTextureUpdates(); 148 m_client->readyToFinalizeTextureUpdates();
149 } 149 }
150 150
151 double CCTextureUpdateController::monotonicTimeNow() const 151 double CCTextureUpdateController::monotonicTimeNow() const
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 206
207 // Make sure there are no dangling partial uploads without a flush. 207 // Make sure there are no dangling partial uploads without a flush.
208 if (uploadCount % textureUploadFlushPeriod) 208 if (uploadCount % textureUploadFlushPeriod)
209 m_resourceProvider->shallowFlushIfSupported(); 209 m_resourceProvider->shallowFlushIfSupported();
210 210
211 m_uploader->endUploads(); 211 m_uploader->endUploads();
212 } 212 }
213 213
214 } 214 }
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