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

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: Remove unnecessary code 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..018cecd263e56f1a4a54d98844fe23d3d33ce7ed 100644
--- a/android_webview/browser/browser_view_renderer.h
+++ b/android_webview/browser/browser_view_renderer.h
@@ -5,7 +5,9 @@
#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/shared_renderer_state.h"
+#include "android_webview/browser/tile_resource_consumer.h"
#include "base/android/scoped_java_ref.h"
#include "base/callback.h"
#include "base/cancelable_callback.h"
@@ -22,6 +24,7 @@ struct AwDrawSWFunctionTable;
namespace content {
class ContentViewCore;
class SynchronousCompositor;
+class SynchronousCompositorMemoryPolicy;
class WebContents;
}
@@ -35,7 +38,6 @@ class BrowserViewRendererJavaHelper {
static BrowserViewRendererJavaHelper* GetInstance();
typedef base::Callback<bool(SkCanvas*)> RenderMethod;
-
boliu 2014/04/28 22:22:15 spurious delete
hush (inactive) 2014/04/30 20:50:17 Done.
// Try obtaining the native SkCanvas from |java_canvas| and call
// |render_source| with it. If that fails, allocate an auxilary bitmap
// for |render_source| to render into, then copy the bitmap into
@@ -52,7 +54,8 @@ 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 TileResourceConsumer {
public:
BrowserViewRenderer(
BrowserViewRendererClient* client,
@@ -101,11 +104,18 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
bool IsVisible() const;
gfx::Rect GetScreenRect() const;
+
boliu 2014/04/28 22:22:15 spurious new line
hush (inactive) 2014/04/30 20:50:17 Done.
// Force invoke the compositor to run produce a 1x1 software frame that is
// immediately discarded. This is a hack to force invoke parts of the
// compositor that are not directly exposed here.
void ForceFakeCompositeSW();
+ // Request memory from GLViewRendererManager. The actually amount of memory
+ // allowed by GLViewRendererManager may not be equal to what's requested in
+ // |policy|.
+ void SetMemoryPolicy(content::SynchronousCompositorMemoryPolicy& policy);
boliu 2014/04/28 22:22:15 Comment does not match function at all
hush (inactive) 2014/04/30 20:50:17 Changed comments On 2014/04/28 22:22:15, boliu wro
+
+ void TrimMemory();
// SynchronousCompositorClient overrides
virtual void DidInitializeCompositor(
content::SynchronousCompositor* compositor) OVERRIDE;
@@ -127,6 +137,15 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
gfx::Vector2dF latest_overscroll_delta,
gfx::Vector2dF current_fling_velocity) OVERRIDE;
+ // TileResourceConsumer overrides
+ // Calculate how many tiles are needed.
+ size_t CalculateTileRequest() OVERRIDE;
boliu 2014/04/28 22:22:15 virtual, and move comments to the interface
hush (inactive) 2014/04/30 20:50:17 Done.
+ // Force drop the hardware tiles in gpu.
+ size_t ForceDropTiles() OVERRIDE;
+ // If the BrowserViewRenderer gets hungry for more than kStarvedTimes in a
+ // row, it becomes starved.
+ bool IsStarved() 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,7 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
gfx::Vector2d max_scroll_offset() const;
+ content::SynchronousCompositorMemoryPolicy CalculateMemoryPolicy();
// 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 +219,11 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient {
// spot over a period of time).
gfx::Vector2dF overscroll_rounding_error_;
+ // Number of times the BrowserViewRenderer gets the tile allocation less than
+ // kGrallocHungryLimit.
boliu 2014/04/28 22:22:15 s/kGrallocHungryLimit/CalculateTileRequest/
hush (inactive) 2014/04/30 20:50:17 CalculateTileRequest returns kNumGrallocLimit (150
+ size_t num_hungry_;
boliu 2014/04/28 22:22:15 num_consecutive_hungry_frames_?
hush (inactive) 2014/04/30 20:50:17 Done.
+ GlobalTileManager::Key tile_manager_key_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserViewRenderer);
};

Powered by Google App Engine
This is Rietveld 408576698