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

Unified Diff: android_webview/browser/browser_view_renderer.h

Issue 226363004: Global GPU memory manager for android webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use command line switch and move that from HR to BVR. 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/browser_view_renderer.h
diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h
index da82fce8ae253a37c78bfd484f6dd17108d80c87..d671d27d251907be740b2bd1eb11b0581dba2e8d 100644
--- a/android_webview/browser/browser_view_renderer.h
+++ b/android_webview/browser/browser_view_renderer.h
@@ -5,6 +5,8 @@
#ifndef ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_
#define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_
+#include "android_webview/browser/global_tile_manager.h"
+#include "android_webview/browser/global_tile_manager_client.h"
#include "android_webview/browser/shared_renderer_state.h"
#include "base/android/scoped_java_ref.h"
#include "base/callback.h"
@@ -22,6 +24,7 @@ struct AwDrawSWFunctionTable;
namespace content {
class ContentViewCore;
class SynchronousCompositor;
+struct SynchronousCompositorMemoryPolicy;
class WebContents;
}
@@ -52,8 +55,11 @@ class BrowserViewRendererJavaHelper {
// Interface for all the WebView-specific content rendering operations.
// Provides software and hardware rendering and the Capture Picture API.
-class BrowserViewRenderer : public content::SynchronousCompositorClient {
+class BrowserViewRenderer : public content::SynchronousCompositorClient,
+ public GlobalTileManagerClient {
public:
+ static void CalculateTileMemoryPolicy();
+
BrowserViewRenderer(
BrowserViewRendererClient* client,
SharedRendererState* shared_renderer_state,
@@ -106,6 +112,14 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
// compositor that are not directly exposed here.
void ForceFakeCompositeSW();
+ // Set the memory policy in shared renderer state and request the tiles from
+ // GlobalTileManager. The actually amount of memory allowed by
+ // GlobalTileManager may not be equal to what's requested in |policy|.
+ void RequestMemoryPolicy(content::SynchronousCompositorMemoryPolicy& policy,
+ bool effective_immediately);
+
+ void TrimMemory(const int level, const bool visible);
+
// SynchronousCompositorClient overrides
virtual void DidInitializeCompositor(
content::SynchronousCompositor* compositor) OVERRIDE;
@@ -127,6 +141,11 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
gfx::Vector2dF latest_overscroll_delta,
gfx::Vector2dF current_fling_velocity) OVERRIDE;
+ // GlobalTileManagerClient overrides
+ virtual size_t GetNumTiles() const OVERRIDE;
+ virtual void SetNumTiles(size_t num_tiles,
+ bool effective_immediately) OVERRIDE;
+
private:
// Checks the continuous invalidate and block invalidate state, and schedule
// invalidates appropriately. If |force_invalidate| is true, then send a view
@@ -142,6 +161,9 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
gfx::Vector2d max_scroll_offset() const;
+ content::SynchronousCompositorMemoryPolicy CalculateDesiredMemoryPolicy();
+ size_t CalculateTileRequest(size_t global_visible_width,
+ size_t global_visible_height) const;
// For debug tracing or logging. Return the string representation of this
// view renderer's state and the |draw_info| if provided.
std::string ToString(AwDrawGLInfo* draw_info) const;
@@ -199,6 +221,13 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
// spot over a period of time).
gfx::Vector2dF overscroll_rounding_error_;
+ GlobalTileManager::Key tile_manager_key_;
+
+ // The following 2 are used to construct a memory policy and set the memory
+ // policy on the shared_renderer_state_ atomically.
+ size_t num_tiles_;
+ size_t num_bytes_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer);
};

Powered by Google App Engine
This is Rietveld 408576698