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