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

Side by Side Diff: android_webview/browser/global_tile_manager.h

Issue 226363004: Global GPU memory manager for android webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove "HardwareRenderer::GetMemoryPolicy" declaration Created 6 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #ifndef ANDROID_WEBVIEW_BROWSER_GLOBAL_TILE_MANAGER_H_
6 #define ANDROID_WEBVIEW_BROWSER_GLOBAL_TILE_MANAGER_H_
7
8 #include <list>
9 #include "base/basictypes.h"
10 #include "base/lazy_instance.h"
11 #include "base/synchronization/lock.h"
12
13 namespace android_webview {
14
15 class HardwareRenderer;
16
17 // A global tile manager to keep track of the number of tile resources. Each
18 // tile needs file descriptors (typically 2) and there is a soft limit of 1024
19 // file descriptors per Android process. The GlobalTileManager does not keep
20 // track of how many tiles each individual view is actually using. The purpose
21 // of GlobalTileManager is to behave gracefully (as in not crashing) when the
22 // embedder of webview creates a lot of webviews and draw them at the same time.
23 class GlobalTileManager {
mkosiba (inactive) 2014/04/23 14:10:08 *cough* unittests *cough* :)
24 private:
25 typedef std::list<HardwareRenderer*> ListType;
26 public:
27 typedef ListType::iterator Key;
28 static GlobalTileManager* GetInstance();
29
30 // Requests the |num_of_tiles| from the available global pool. Returns the
31 // actual number of tiles granted to the requester. If |is_starved| is true,
32 // the GlobalTileManager will evict tiles allocated to other
33 // requesters.
34 size_t RequestTiles(size_t old_num_of_tiles, size_t new_num_of_tiles,
35 bool is_starved, Key key);
36
37 // Continues evicting the least recently drawn views until freeing up at least
38 // amount of memory specified by |desired_policy| to draw a view specified
39 // by |key|.
40 // Returns the amount of memory that was actually evicted.
41 // This function is called when a requester is starved.
42 size_t EvictUntilSatisfied(size_t desired_num_tiles, Key key);
43
44 Key PushBack(HardwareRenderer* hardware_renderer);
45
46 // |key| must be already in manager. Move renderer corresponding to |key| to
47 // most recent.
48 void DidDrawGL(Key key);
49
50 void Remove(Key key);
51 private:
52 friend struct base::DefaultLazyInstanceTraits<GlobalTileManager>;
53 GlobalTileManager();
54 ~GlobalTileManager();
55 size_t allocated_tiles_;
56 ListType mru_list_;
57 // The list of inactive views is from inactive_views_ to mru_list_end().
58 Key inactive_views_;
59
60 DISALLOW_COPY_AND_ASSIGN(GlobalTileManager);
61 };
62 } // namespace android_webview
63
64 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698