Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: cc/resource_update_controller.h

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 165064 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CCResourceUpdateController_h 5 #ifndef CCResourceUpdateController_h
6 #define CCResourceUpdateController_h 6 #define CCResourceUpdateController_h
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "cc/resource_update_queue.h" 12 #include "cc/resource_update_queue.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 class ResourceProvider; 16 class ResourceProvider;
17 class Thread; 17 class Thread;
18 18
19 class ResourceUpdateControllerClient { 19 class ResourceUpdateControllerClient {
20 public: 20 public:
21 virtual void readyToFinalizeTextureUpdates() = 0; 21 virtual void readyToFinalizeTextureUpdates() = 0;
22 22
23 protected: 23 protected:
24 virtual ~ResourceUpdateControllerClient() { } 24 virtual ~ResourceUpdateControllerClient() { }
25 }; 25 };
26 26
27 class ResourceUpdateController { 27 class ResourceUpdateController {
28 public: 28 public:
29 static scoped_ptr<ResourceUpdateController> create(ResourceUpdateControllerC lient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourcePr ovider* resourceProvider) 29 static scoped_ptr<ResourceUpdateController> create(ResourceUpdateControllerC lient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourcePr ovider* resourceProvider, bool hasImplThread)
30 { 30 {
31 return make_scoped_ptr(new ResourceUpdateController(client, thread, queu e.Pass(), resourceProvider)); 31 return make_scoped_ptr(new ResourceUpdateController(client, thread, queu e.Pass(), resourceProvider, hasImplThread));
32 } 32 }
33 static size_t maxPartialTextureUpdates(); 33 static size_t maxPartialTextureUpdates();
34 34
35 virtual ~ResourceUpdateController(); 35 virtual ~ResourceUpdateController();
36 36
37 // Discard uploads to textures that were evicted on the impl thread. 37 // Discard uploads to textures that were evicted on the impl thread.
38 void discardUploadsToEvictedResources(); 38 void discardUploadsToEvictedResources();
39 39
40 void performMoreUpdates(base::TimeTicks timeLimit); 40 void performMoreUpdates(base::TimeTicks timeLimit);
41 void finalize(); 41 void finalize();
42 42
43 43
44 // Virtual for testing. 44 // Virtual for testing.
45 virtual base::TimeTicks now() const; 45 virtual base::TimeTicks now() const;
46 virtual base::TimeDelta updateMoreTexturesTime() const; 46 virtual base::TimeDelta updateMoreTexturesTime() const;
47 virtual size_t updateMoreTexturesSize() const; 47 virtual size_t updateMoreTexturesSize() const;
48 48
49 protected: 49 protected:
50 ResourceUpdateController(ResourceUpdateControllerClient*, Thread*, scoped_pt r<ResourceUpdateQueue>, ResourceProvider*); 50 ResourceUpdateController(ResourceUpdateControllerClient*, Thread*, scoped_pt r<ResourceUpdateQueue>, ResourceProvider*, bool hasImplThread);
51 51
52 private: 52 private:
53 static size_t maxFullUpdatesPerTick(ResourceProvider*); 53 static size_t maxFullUpdatesPerTick(ResourceProvider*);
54 54
55 size_t maxBlockingUpdates() const; 55 size_t maxBlockingUpdates() const;
56 56
57 void updateTexture(ResourceUpdate); 57 void updateTexture(ResourceUpdate);
58 58
59 // This returns true when there were textures left to update. 59 // This returns true when there were textures left to update.
60 bool updateMoreTexturesIfEnoughTimeRemaining(); 60 bool updateMoreTexturesIfEnoughTimeRemaining();
61 void updateMoreTexturesNow(); 61 void updateMoreTexturesNow();
62 void onTimerFired(); 62 void onTimerFired();
63 63
64 ResourceUpdateControllerClient* m_client; 64 ResourceUpdateControllerClient* m_client;
65 bool m_hasImplThread;
65 scoped_ptr<ResourceUpdateQueue> m_queue; 66 scoped_ptr<ResourceUpdateQueue> m_queue;
66 bool m_contentsTexturesPurged; 67 bool m_contentsTexturesPurged;
67 ResourceProvider* m_resourceProvider; 68 ResourceProvider* m_resourceProvider;
68 base::TimeTicks m_timeLimit; 69 base::TimeTicks m_timeLimit;
69 size_t m_textureUpdatesPerTick; 70 size_t m_textureUpdatesPerTick;
70 bool m_firstUpdateAttempt; 71 bool m_firstUpdateAttempt;
71 Thread* m_thread; 72 Thread* m_thread;
72 base::WeakPtrFactory<ResourceUpdateController> m_weakFactory; 73 base::WeakPtrFactory<ResourceUpdateController> m_weakFactory;
73 bool m_taskPosted; 74 bool m_taskPosted;
74 75
75 DISALLOW_COPY_AND_ASSIGN(ResourceUpdateController); 76 DISALLOW_COPY_AND_ASSIGN(ResourceUpdateController);
76 }; 77 };
77 78
78 } // namespace cc 79 } // namespace cc
79 80
80 #endif // CCResourceUpdateController_h 81 #endif // CCResourceUpdateController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698