OLD | NEW |
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 #ifndef CCTextureUpdateController_h | 5 #ifndef CCTextureUpdateController_h |
6 #define CCTextureUpdateController_h | 6 #define CCTextureUpdateController_h |
7 | 7 |
8 #include "CCTextureUpdateQueue.h" | 8 #include "CCTextureUpdateQueue.h" |
9 #include "CCTimer.h" | 9 #include "CCTimer.h" |
10 #include <wtf/Noncopyable.h> | 10 #include <wtf/Noncopyable.h> |
11 #include <wtf/OwnPtr.h> | 11 #include <wtf/OwnPtr.h> |
12 | 12 |
13 namespace WebCore { | 13 namespace WebCore { |
14 | 14 |
15 class TextureCopier; | 15 class TextureCopier; |
16 class TextureUploader; | 16 class TextureUploader; |
17 | 17 |
18 class CCTextureUpdateControllerClient { | |
19 public: | |
20 virtual void updateTexturesCompleted() = 0; | |
21 | |
22 protected: | |
23 virtual ~CCTextureUpdateControllerClient() { } | |
24 }; | |
25 | |
26 class CCTextureUpdateController : public CCTimerClient { | 18 class CCTextureUpdateController : public CCTimerClient { |
27 WTF_MAKE_NONCOPYABLE(CCTextureUpdateController); | 19 WTF_MAKE_NONCOPYABLE(CCTextureUpdateController); |
28 public: | 20 public: |
29 static PassOwnPtr<CCTextureUpdateController> create(CCTextureUpdateControlle
rClient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCRes
ourceProvider* resourceProvider, TextureCopier* copier, TextureUploader* uploade
r) | 21 static PassOwnPtr<CCTextureUpdateController> create(CCThread* thread, PassOw
nPtr<CCTextureUpdateQueue> queue, CCResourceProvider* resourceProvider, TextureC
opier* copier, TextureUploader* uploader) |
30 { | 22 { |
31 return adoptPtr(new CCTextureUpdateController(client, thread, queue, res
ourceProvider, copier, uploader)); | 23 return adoptPtr(new CCTextureUpdateController(thread, queue, resourcePro
vider, copier, uploader)); |
32 } | 24 } |
33 static size_t maxPartialTextureUpdates(); | 25 static size_t maxPartialTextureUpdates(); |
34 static void updateTextures(CCResourceProvider*, TextureCopier*, TextureUploa
der*, CCTextureUpdateQueue*, size_t count); | 26 static void updateTextures(CCResourceProvider*, TextureCopier*, TextureUploa
der*, CCTextureUpdateQueue*, size_t count); |
35 | 27 |
36 virtual ~CCTextureUpdateController(); | 28 virtual ~CCTextureUpdateController(); |
37 | 29 |
| 30 bool hasMoreUpdates() const; |
38 void updateMoreTextures(double monotonicTimeLimit); | 31 void updateMoreTextures(double monotonicTimeLimit); |
39 | 32 |
40 // Discard all remaining uploads. | |
41 void discardUploads(); | |
42 | |
43 // CCTimerClient implementation. | 33 // CCTimerClient implementation. |
44 virtual void onTimerFired() OVERRIDE; | 34 virtual void onTimerFired() OVERRIDE; |
45 | 35 |
46 // Virtual for testing. | 36 // Virtual for testing. |
47 virtual double monotonicTimeNow() const; | 37 virtual double monotonicTimeNow() const; |
48 virtual double updateMoreTexturesTime() const; | 38 virtual double updateMoreTexturesTime() const; |
49 virtual size_t updateMoreTexturesSize() const; | 39 virtual size_t updateMoreTexturesSize() const; |
50 | 40 |
51 protected: | 41 protected: |
52 CCTextureUpdateController(CCTextureUpdateControllerClient*, CCThread*, PassO
wnPtr<CCTextureUpdateQueue>, CCResourceProvider*, TextureCopier*, TextureUploade
r*); | 42 CCTextureUpdateController(CCThread*, PassOwnPtr<CCTextureUpdateQueue>, CCRes
ourceProvider*, TextureCopier*, TextureUploader*); |
53 | 43 |
54 // This returns true when there were textures left to update. | 44 void updateMoreTexturesIfEnoughTimeRemaining(); |
55 bool updateMoreTexturesIfEnoughTimeRemaining(); | |
56 void updateMoreTexturesNow(); | 45 void updateMoreTexturesNow(); |
57 | 46 |
58 CCTextureUpdateControllerClient* m_client; | |
59 OwnPtr<CCTimer> m_timer; | 47 OwnPtr<CCTimer> m_timer; |
60 OwnPtr<CCTextureUpdateQueue> m_queue; | 48 OwnPtr<CCTextureUpdateQueue> m_queue; |
61 bool m_contentsTexturesPurged; | 49 bool m_contentsTexturesPurged; |
62 CCResourceProvider* m_resourceProvider; | 50 CCResourceProvider* m_resourceProvider; |
63 TextureCopier* m_copier; | 51 TextureCopier* m_copier; |
64 TextureUploader* m_uploader; | 52 TextureUploader* m_uploader; |
65 double m_monotonicTimeLimit; | 53 double m_monotonicTimeLimit; |
66 bool m_firstUpdateAttempt; | 54 bool m_firstUpdateAttempt; |
67 }; | 55 }; |
68 | 56 |
69 } | 57 } |
70 | 58 |
71 #endif // CCTextureUpdateController_h | 59 #endif // CCTextureUpdateController_h |
OLD | NEW |