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

Unified Diff: cc/tile_manager.h

Issue 12082086: cc: Improve tile deletion and general tile manager performance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Detach managed state from tiles Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/tile.h ('k') | cc/tile_manager.cc » ('j') | cc/tile_manager.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tile_manager.h
diff --git a/cc/tile_manager.h b/cc/tile_manager.h
index 16212ed66e5f7398d0bbbaf572f245ace0824ace..43f54841b972c2bcd17b97e04dd179f523642a77 100644
--- a/cc/tile_manager.h
+++ b/cc/tile_manager.h
@@ -18,9 +18,24 @@
#include "cc/tile_priority.h"
namespace cc {
+class Tile;
+} // namespace cc
+
+#if defined(COMPILER_GCC)
+namespace BASE_HASH_NAMESPACE {
+template<>
+struct hash<cc::Tile*> {
+ size_t operator()(cc::Tile* ptr) const {
+ return hash<size_t>()(reinterpret_cast<size_t>(ptr));
+ }
+};
+} // namespace BASE_HASH_NAMESPACE
+#endif // COMPILER
+
+namespace cc {
class RasterWorkerPool;
class ResourceProvider;
-class Tile;
+class TileManager;
class TileVersion;
class CC_EXPORT TileManagerClient {
@@ -61,12 +76,12 @@ enum TileRasterState {
// This is state that is specific to a tile that is
// managed by the TileManager.
-class CC_EXPORT ManagedTileState {
+class CC_EXPORT ManagedTileState : public base::RefCounted<ManagedTileState> {
public:
- ManagedTileState();
- ~ManagedTileState();
+ explicit ManagedTileState(TileManager* tile_manager);
// Persisted state: valid all the time.
+ TileManager* tile_manager;
bool can_use_gpu_memory;
bool can_be_freed;
scoped_ptr<ResourcePool::Resource> resource;
@@ -75,15 +90,28 @@ class CC_EXPORT ManagedTileState {
bool need_to_gather_pixel_refs;
std::list<skia::LazyPixelRef*> pending_pixel_refs;
TileRasterState raster_state;
+ size_t bytes_consumed_if_allocated;
+ bool visible_high_resolution;
+ scoped_refptr<PicturePileImpl> picture_pile;
+ gfx::Rect content_rect;
+ float contents_scale;
+ gfx::Size tile_size;
+ GLenum format;
// Ephemeral state, valid only during Manage.
TileManagerBin bin[NUM_BIN_PRIORITIES];
TileManagerBin tree_bin[NUM_TREES];
- // The bin that the tile would have if the GPU memory manager had a maximally permissive policy,
- // send to the GPU memory manager to determine policy.
+ // The bin that the tile would have if the GPU memory manager had a
+ // maximally permissive policy, send to the GPU memory manager to
+ // determine policy.
TileManagerBin gpu_memmgr_stats_bin;
TileResolution resolution;
float time_to_needed_in_seconds;
+
+ private:
+ friend class base::RefCounted<ManagedTileState>;
+
+ ~ManagedTileState();
};
// This class manages tiles, deciding which should get rasterized and which
@@ -107,13 +135,15 @@ class CC_EXPORT TileManager {
void CheckForCompletedTileUploads();
scoped_ptr<base::Value> AsValue() const;
- void GetMemoryStats(size_t* memoryRequiredBytes,
- size_t* memoryNiceToHaveBytes,
- size_t* memoryUsedBytes) const;
+ void GetMemoryStats(size_t* memory_required_bytes,
+ size_t* memory_nice_to_have_bytes,
+ size_t* memory_used_bytes) const;
void GetRenderingStats(RenderingStats* stats);
bool HasPendingWorkScheduled(WhichTree tree) const;
- const MemoryHistory::Entry& memory_stats_from_last_assign() const { return memory_stats_from_last_assign_; }
+ const MemoryHistory::Entry& memory_stats_from_last_assign() const {
+ return memory_stats_from_last_assign_;
+ }
protected:
// Methods called by Tile
@@ -128,9 +158,15 @@ class CC_EXPORT TileManager {
}
private:
+ friend class ManagedTileState;
+
+ // Methods called by ManagedTileState
+ void RegisterManagedTile(ManagedTileState* mts);
+ void UnregisterManagedTile(ManagedTileState* mts);
+
void SortTiles();
void AssignGpuMemoryToTiles();
- void FreeResourcesForTile(Tile* tile);
+ void FreeResourcesForTile(ManagedTileState* mts);
void ScheduleManageTiles() {
if (manage_tiles_pending_)
return;
@@ -138,21 +174,21 @@ class CC_EXPORT TileManager {
manage_tiles_pending_ = true;
}
void DispatchMoreTasks();
- void GatherPixelRefsForTile(Tile* tile);
- void DispatchImageDecodeTasksForTile(Tile* tile);
+ void GatherPixelRefsForTile(ManagedTileState* mts);
+ void DispatchImageDecodeTasksForTile(ManagedTileState* mts);
void DispatchOneImageDecodeTask(
- scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref);
+ scoped_refptr<ManagedTileState> mts, skia::LazyPixelRef* pixel_ref);
void OnImageDecodeTaskCompleted(
- scoped_refptr<Tile> tile, uint32_t pixel_ref_id);
- bool CanDispatchRasterTask(Tile* tile);
- void DispatchOneRasterTask(scoped_refptr<Tile> tile);
+ scoped_refptr<ManagedTileState> mts, uint32_t pixel_ref_id);
+ bool CanDispatchRasterTask(ManagedTileState* mts);
+ void DispatchOneRasterTask(scoped_refptr<ManagedTileState> mts);
void OnRasterTaskCompleted(
- scoped_refptr<Tile> tile,
+ scoped_refptr<ManagedTileState> mts,
scoped_ptr<ResourcePool::Resource> resource,
int manage_tiles_call_count_when_dispatched);
- void DidFinishTileInitialization(Tile* tile);
- void DidTileRasterStateChange(Tile* tile, TileRasterState state);
- void DidTileBinChange(Tile* tile,
+ void DidFinishTileInitialization(ManagedTileState* mts);
+ void DidTileRasterStateChange(ManagedTileState* mts, TileRasterState state);
+ void DidTileBinChange(ManagedTileState* mts,
TileManagerBin bin,
WhichTree tree);
scoped_ptr<Value> GetMemoryRequirementsAsValue() const;
@@ -173,11 +209,16 @@ class CC_EXPORT TileManager {
GlobalStateThatImpactsTilePriority global_state_;
- typedef std::vector<Tile*> TileVector;
- TileVector tiles_;
+ typedef base::hash_set<Tile*> TileSet;
+ TileSet tiles_;
+
+ typedef std::vector<scoped_refptr<ManagedTileState> > ManagedTileVector;
+ ManagedTileVector managed_tiles_;
+
+ typedef std::vector<ManagedTileState*> TileVector;
TileVector tiles_that_need_to_be_rasterized_;
- typedef std::list<Tile*> TileList;
+ typedef std::list<ManagedTileState*> TileList;
// Tiles with image decoding tasks. These tiles need to be rasterized
// when all the image decoding tasks finish.
TileList tiles_with_image_decoding_tasks_;
@@ -185,7 +226,7 @@ class CC_EXPORT TileManager {
typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap;
PixelRefMap pending_decode_tasks_;
- typedef std::queue<scoped_refptr<Tile> > TileQueue;
+ typedef std::queue<scoped_refptr<ManagedTileState> > TileQueue;
TileQueue tiles_with_pending_set_pixels_;
size_t bytes_pending_set_pixels_;
bool ever_exceeded_memory_budget_;
« no previous file with comments | « cc/tile.h ('k') | cc/tile_manager.cc » ('j') | cc/tile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698