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

Side by Side Diff: android_webview/browser/hardware_renderer.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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ 5 #ifndef ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
6 #define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ 6 #define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "android_webview/browser/gl_view_renderer_manager.h" 10 #include "android_webview/browser/gl_view_renderer_manager.h"
11 #include "android_webview/browser/global_tile_manager.h"
11 #include "android_webview/browser/shared_renderer_state.h" 12 #include "android_webview/browser/shared_renderer_state.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "content/public/browser/android/synchronous_compositor.h" 14 #include "content/public/browser/android/synchronous_compositor.h"
14 15
15 struct AwDrawGLInfo; 16 struct AwDrawGLInfo;
16 17
17 namespace android_webview { 18 namespace android_webview {
18 19
19 class AwGLSurface; 20 class AwGLSurface;
20 class BrowserViewRendererClient; 21 class BrowserViewRendererClient;
21 22
22 namespace internal { 23 namespace internal {
23 class DeferredGpuCommandService; 24 class DeferredGpuCommandService;
24 } // namespace internal 25 } // namespace internal
25 26
26 class HardwareRenderer { 27 class HardwareRenderer {
27 public: 28 public:
28 explicit HardwareRenderer(SharedRendererState* state); 29 explicit HardwareRenderer(SharedRendererState* state);
29 ~HardwareRenderer(); 30 ~HardwareRenderer();
30 31
31 static void CalculateTileMemoryPolicy(); 32 static void CalculateTileMemoryPolicy();
32 33
33 bool DrawGL(AwDrawGLInfo* draw_info, DrawGLResult* result); 34 bool DrawGL(AwDrawGLInfo* draw_info, DrawGLResult* result);
34 bool TrimMemory(int level, bool visible); 35 bool TrimMemory(int level, bool visible);
35 36
37 size_t ForceDropTiles();
38
39 // If the hardware renderer gets hungry for more than kStarvedTimes in a row,
40 // it becomes starved.
41 bool IsStarved();
42
36 private: 43 private:
37 friend class internal::DeferredGpuCommandService; 44 friend class internal::DeferredGpuCommandService;
38 45
39 void SetMemoryPolicy(content::SynchronousCompositorMemoryPolicy& new_policy); 46 void SetMemoryPolicy(content::SynchronousCompositorMemoryPolicy& new_policy);
40
41 SharedRendererState* shared_renderer_state_; 47 SharedRendererState* shared_renderer_state_;
42 48
43 typedef void* EGLContext; 49 typedef void* EGLContext;
44 EGLContext last_egl_context_; 50 EGLContext last_egl_context_;
45 51
46 scoped_refptr<AwGLSurface> gl_surface_; 52 scoped_refptr<AwGLSurface> gl_surface_;
47 content::SynchronousCompositorMemoryPolicy memory_policy_; 53 content::SynchronousCompositorMemoryPolicy memory_policy_;
48 54
49 GLViewRendererManager::Key manager_key_; 55 GLViewRendererManager::Key renderer_manager_key_;
56 GlobalTileManager::Key tile_manager_key_;
57
58 // Number of times the hardware renderer gets the tile allocation less than
59 // kGrallocHungryLimit
60 size_t num_hungry_;
50 61
51 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); 62 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer);
52 }; 63 };
53 64
54 namespace internal { 65 namespace internal {
55 66
56 class ScopedAllowGL { 67 class ScopedAllowGL {
57 public: 68 public:
58 ScopedAllowGL(); 69 ScopedAllowGL();
59 ~ScopedAllowGL(); 70 ~ScopedAllowGL();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 107
97 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; 108 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_;
98 DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService); 109 DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService);
99 }; 110 };
100 111
101 } // namespace internal 112 } // namespace internal
102 113
103 } // namespace android_webview 114 } // namespace android_webview
104 115
105 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ 116 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698