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 |
| 5 #ifndef CCTextureUpdateController_h |
| 6 #define CCTextureUpdateController_h |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/time.h" |
| 10 #include "CCTextureUpdateQueue.h" |
| 11 #include "CCTimer.h" |
| 12 #include <wtf/OwnPtr.h> |
| 13 |
| 14 namespace cc { |
| 15 |
| 16 class TextureUploader; |
| 17 |
| 18 class CCTextureUpdateControllerClient { |
| 19 public: |
| 20 virtual void readyToFinalizeTextureUpdates() = 0; |
| 21 |
| 22 protected: |
| 23 virtual ~CCTextureUpdateControllerClient() { } |
| 24 }; |
| 25 |
| 26 class CCTextureUpdateController : public CCTimerClient { |
| 27 public: |
| 28 static PassOwnPtr<CCTextureUpdateController> create(CCTextureUpdateControlle
rClient* client, CCThread* thread, PassOwnPtr<CCTextureUpdateQueue> queue, CCRes
ourceProvider* resourceProvider, TextureUploader* uploader) |
| 29 { |
| 30 return adoptPtr(new CCTextureUpdateController(client, thread, queue, res
ourceProvider, uploader)); |
| 31 } |
| 32 static size_t maxPartialTextureUpdates(); |
| 33 |
| 34 virtual ~CCTextureUpdateController(); |
| 35 |
| 36 // Discard uploads to textures that were evicted on the impl thread. |
| 37 void discardUploadsToEvictedResources(); |
| 38 |
| 39 void performMoreUpdates(base::TimeTicks timeLimit); |
| 40 void finalize(); |
| 41 |
| 42 // CCTimerClient implementation. |
| 43 virtual void onTimerFired() OVERRIDE; |
| 44 |
| 45 // Virtual for testing. |
| 46 virtual base::TimeTicks now() const; |
| 47 virtual base::TimeDelta updateMoreTexturesTime() const; |
| 48 virtual size_t updateMoreTexturesSize() const; |
| 49 |
| 50 protected: |
| 51 CCTextureUpdateController(CCTextureUpdateControllerClient*, CCThread*, PassO
wnPtr<CCTextureUpdateQueue>, CCResourceProvider*, TextureUploader*); |
| 52 |
| 53 static size_t maxFullUpdatesPerTick(TextureUploader*); |
| 54 |
| 55 size_t maxBlockingUpdates() const; |
| 56 |
| 57 // This returns true when there were textures left to update. |
| 58 bool updateMoreTexturesIfEnoughTimeRemaining(); |
| 59 void updateMoreTexturesNow(); |
| 60 |
| 61 CCTextureUpdateControllerClient* m_client; |
| 62 OwnPtr<CCTimer> m_timer; |
| 63 OwnPtr<CCTextureUpdateQueue> m_queue; |
| 64 bool m_contentsTexturesPurged; |
| 65 CCResourceProvider* m_resourceProvider; |
| 66 TextureUploader* m_uploader; |
| 67 base::TimeTicks m_timeLimit; |
| 68 size_t m_textureUpdatesPerTick; |
| 69 bool m_firstUpdateAttempt; |
| 70 |
| 71 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(CCTextureUpdateController); |
| 73 }; |
| 74 |
| 75 } |
| 76 |
| 77 #endif // CCTextureUpdateController_h |
OLD | NEW |