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