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

Side by Side Diff: cc/tile_manager.h

Issue 11348384: cc: Use asynchronous set pixels API for impl-side painting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and removed unused CheckForPendingSetPixelsCompletion(). Created 8 years 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 | Annotate | Revision Log
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 CC_TILE_MANAGER_H_ 5 #ifndef CC_TILE_MANAGER_H_
6 #define CC_TILE_MANAGER_H_ 6 #define CC_TILE_MANAGER_H_
7 7
8 #include <queue>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "cc/resource_pool.h" 13 #include "cc/resource_pool.h"
13 #include "cc/tile_priority.h" 14 #include "cc/tile_priority.h"
14 15
15 namespace cc { 16 namespace cc {
16 17
17 class RasterThread; 18 class RasterThread;
18 class ResourceProvider; 19 class ResourceProvider;
19 class Tile; 20 class Tile;
20 class TileVersion; 21 class TileVersion;
21 struct RenderingStats; 22 struct RenderingStats;
22 23
23 class CC_EXPORT TileManagerClient { 24 class CC_EXPORT TileManagerClient {
24 public: 25 public:
25 virtual void ScheduleManageTiles() = 0; 26 virtual void ScheduleManageTiles() = 0;
26 virtual void ScheduleRedraw() = 0; 27 virtual void ScheduleCheckForCompletedSetPixels() = 0;
27 28
28 protected: 29 protected:
29 virtual ~TileManagerClient() {} 30 virtual ~TileManagerClient() {}
30 }; 31 };
31 32
32 // Tile manager classifying tiles into a few basic 33 // Tile manager classifying tiles into a few basic
33 // bins: 34 // bins:
34 enum TileManagerBin { 35 enum TileManagerBin {
35 NOW_BIN = 0, // Needed ASAP. 36 NOW_BIN = 0, // Needed ASAP.
36 SOON_BIN = 1, // Impl-side version of prepainting. 37 SOON_BIN = 1, // Impl-side version of prepainting.
37 EVENTUALLY_BIN = 2, // Nice to have, if we've got memory and time. 38 EVENTUALLY_BIN = 2, // Nice to have, if we've got memory and time.
38 NEVER_BIN = 3, // Dont bother. 39 NEVER_BIN = 3, // Dont bother.
39 NUM_BINS = 4 40 NUM_BINS = 4
40 }; 41 };
41 42
42 // This is state that is specific to a tile that is 43 // This is state that is specific to a tile that is
43 // managed by the TileManager. 44 // managed by the TileManager.
44 class CC_EXPORT ManagedTileState { 45 class CC_EXPORT ManagedTileState {
45 public: 46 public:
46 ManagedTileState(); 47 ManagedTileState();
47 ~ManagedTileState(); 48 ~ManagedTileState();
48 49
49 // Persisted state: valid all the time. 50 // Persisted state: valid all the time.
50 bool can_use_gpu_memory; 51 bool can_use_gpu_memory;
51 bool can_be_freed; 52 bool can_be_freed;
52 scoped_ptr<ResourcePool::Resource> resource; 53 scoped_ptr<ResourcePool::Resource> resource;
54 // |resource_id| will be 0 while resource is being initialized.
55 ResourceProvider::ResourceId resource_id;
53 bool resource_is_being_initialized; 56 bool resource_is_being_initialized;
54 bool contents_swizzled; 57 bool contents_swizzled;
55 58
56 // Ephemeral state, valid only during Manage. 59 // Ephemeral state, valid only during Manage.
57 TileManagerBin bin; 60 TileManagerBin bin;
58 TileResolution resolution; 61 TileResolution resolution;
59 float time_to_needed_in_seconds; 62 float time_to_needed_in_seconds;
60 }; 63 };
61 64
62 // This class manages tiles, deciding which should get rasterized and which 65 // This class manages tiles, deciding which should get rasterized and which
63 // should no longer have any memory assigned to them. Tile objects are "owned" 66 // should no longer have any memory assigned to them. Tile objects are "owned"
64 // by layers; they automatically register with the manager when they are 67 // by layers; they automatically register with the manager when they are
65 // created, and unregister from the manager when they are deleted. 68 // created, and unregister from the manager when they are deleted.
66 class CC_EXPORT TileManager { 69 class CC_EXPORT TileManager {
67 public: 70 public:
68 TileManager(TileManagerClient* client, 71 TileManager(TileManagerClient* client,
69 ResourceProvider *resource_provider, 72 ResourceProvider *resource_provider,
70 size_t num_raster_threads); 73 size_t num_raster_threads);
71 virtual ~TileManager(); 74 virtual ~TileManager();
72 75
73 const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_ state_; } 76 const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_ state_; }
74 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); 77 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state);
75 78
76 void ManageTiles(); 79 void ManageTiles();
80 void CheckForCompletedSetPixels();
77 81
78 void renderingStats(RenderingStats* stats); 82 void renderingStats(RenderingStats* stats);
79 83
80 protected: 84 protected:
81 // Methods called by Tile 85 // Methods called by Tile
82 friend class Tile; 86 friend class Tile;
83 void RegisterTile(Tile*); 87 void RegisterTile(Tile*);
84 void UnregisterTile(Tile*); 88 void UnregisterTile(Tile*);
85 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority ); 89 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority );
86 90
87 private: 91 private:
88 void AssignGpuMemoryToTiles(); 92 void AssignGpuMemoryToTiles();
89 void FreeResourcesForTile(Tile*); 93 void FreeResourcesForTile(Tile*);
90 void ScheduleManageTiles(); 94 void ScheduleManageTiles();
95 void ScheduleCheckForCompletedSetPixels();
91 void DispatchMoreRasterTasks(); 96 void DispatchMoreRasterTasks();
92 void DispatchOneRasterTask(RasterThread*, scoped_refptr<Tile>); 97 void DispatchOneRasterTask(RasterThread*, scoped_refptr<Tile>);
93 void OnRasterTaskCompleted( 98 void OnRasterTaskCompleted(
94 scoped_refptr<Tile>, 99 scoped_refptr<Tile>,
95 scoped_ptr<ResourcePool::Resource>, 100 scoped_ptr<ResourcePool::Resource>,
96 scoped_refptr<PicturePileImpl>, 101 scoped_refptr<PicturePileImpl>,
97 RenderingStats*); 102 RenderingStats*);
98 void DidFinishTileInitialization(Tile*, scoped_ptr<ResourcePool::Resource>); 103 void DidFinishTileInitialization(Tile*);
99 104
100 TileManagerClient* client_; 105 TileManagerClient* client_;
101 scoped_ptr<ResourcePool> resource_pool_; 106 scoped_ptr<ResourcePool> resource_pool_;
102 bool manage_tiles_pending_; 107 bool manage_tiles_pending_;
108 bool check_for_completed_set_pixels_pending_;
103 109
104 GlobalStateThatImpactsTilePriority global_state_; 110 GlobalStateThatImpactsTilePriority global_state_;
105 111
106 typedef std::vector<Tile*> TileVector; 112 typedef std::vector<Tile*> TileVector;
107 TileVector tiles_; 113 TileVector tiles_;
108 TileVector tiles_that_need_to_be_rasterized_; 114 TileVector tiles_that_need_to_be_rasterized_;
109 115
116 typedef std::queue<scoped_refptr<Tile> > TileQueue;
117 TileQueue tiles_with_pending_set_pixels_;
118
110 typedef ScopedPtrVector<RasterThread> RasterThreadVector; 119 typedef ScopedPtrVector<RasterThread> RasterThreadVector;
111 RasterThreadVector raster_threads_; 120 RasterThreadVector raster_threads_;
112 121
113 RenderingStats rendering_stats_; 122 RenderingStats rendering_stats_;
123
124 DISALLOW_COPY_AND_ASSIGN(TileManager);
114 }; 125 };
115 126
116 } // namespace cc 127 } // namespace cc
117 128
118 #endif // CC_TILE_MANAGER_H_ 129 #endif // CC_TILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698