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
3 // found in the LICENSE file.
5 #ifndef CCTextureUpdateController_h
6 #define CCTextureUpdateController_h
8 #include "CCTextureUpdateQueue.h"
10 #include <wtf/Noncopyable.h>
11 #include <wtf/OwnPtr.h>
16 class TextureUploader
;
18 class CCTextureUpdateController
: public CCTimerClient
{
19 WTF_MAKE_NONCOPYABLE(CCTextureUpdateController
);
21 static PassOwnPtr
<CCTextureUpdateController
> create(CCThread
* thread
, PassOwnPtr
<CCTextureUpdateQueue
> queue
, CCResourceProvider
* resourceProvider
, TextureCopier
* copier
, TextureUploader
* uploader
)
23 return adoptPtr(new CCTextureUpdateController(thread
, queue
, resourceProvider
, copier
, uploader
));
25 static size_t maxPartialTextureUpdates();
26 static void updateTextures(CCResourceProvider
*, TextureCopier
*, TextureUploader
*, CCTextureUpdateQueue
*, size_t count
);
28 virtual ~CCTextureUpdateController();
30 bool hasMoreUpdates() const;
31 void updateMoreTextures(double monotonicTimeLimit
);
33 // CCTimerClient implementation.
34 virtual void onTimerFired() OVERRIDE
;
36 // Virtual for testing.
37 virtual double monotonicTimeNow() const;
38 virtual double updateMoreTexturesTime() const;
39 virtual size_t updateMoreTexturesSize() const;
42 CCTextureUpdateController(CCThread
*, PassOwnPtr
<CCTextureUpdateQueue
>, CCResourceProvider
*, TextureCopier
*, TextureUploader
*);
44 void updateMoreTexturesIfEnoughTimeRemaining();
45 void updateMoreTexturesNow();
47 OwnPtr
<CCTimer
> m_timer
;
48 OwnPtr
<CCTextureUpdateQueue
> m_queue
;
49 bool m_contentsTexturesPurged
;
50 CCResourceProvider
* m_resourceProvider
;
51 TextureCopier
* m_copier
;
52 TextureUploader
* m_uploader
;
53 double m_monotonicTimeLimit
;
54 bool m_firstUpdateAttempt
;
59 #endif // CCTextureUpdateController_h