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