Chromium Code Reviews| Index: android_webview/browser/in_process_view_renderer.cc |
| diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc |
| index 39bd2f6b889b0d7338ee44320991b894ca6dca9e..30e2eedb54ac1484e36866ba354606e38bdcca8e 100644 |
| --- a/android_webview/browser/in_process_view_renderer.cc |
| +++ b/android_webview/browser/in_process_view_renderer.cc |
| @@ -316,6 +316,37 @@ bool InProcessViewRenderer::RequestProcessGL() { |
| return client_->RequestDrawGL(NULL); |
| } |
| +void InProcessViewRenderer::TrimMemory(int level) { |
|
joth
2013/10/02 10:47:01
not using level param?
ideas:
if level < 10 ret
boliu
2013/10/02 14:09:55
Not done yet. I'll have to play with this when I g
|
| + // Nothing to drop. |
| + if (!attached_to_window_ || !hardware_initialized_ || !compositor_) |
| + return; |
| + |
| + // Do not release resources on view we expect to get DrawGL soon. |
| + client_->UpdateGlobalVisibleRect(); |
| + if (view_visible_ && window_visible_ && |
| + !cached_global_visible_rect_.IsEmpty()) { |
| + return; |
| + } |
| + |
| + if (!eglGetCurrentContext()) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + |
| + TRACE_EVENT0("android_webview", "InProcessViewRenderer::TrimMemory"); |
| + ScopedAppGLStateRestore state_restore(ScopedAppGLStateRestore::MODE_ON_TRIM); |
| + gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread(); |
| + ScopedAllowGL allow_gl; |
| + |
| + // Just set the memory limit to 0 and drop all tiles. This will be reset to |
| + // normal levels in the next DrawGL call. |
| + content::SynchronousCompositorMemoryPolicy policy; |
| + policy.bytes_limit = 0; |
| + policy.num_resources_limit = 0; |
| + compositor_->SetMemoryPolicy(policy); |
| + ForceCompositeSW(); |
| +} |
| + |
| void InProcessViewRenderer::UpdateCachedGlobalVisibleRect() { |
| client_->UpdateGlobalVisibleRect(); |
| } |
| @@ -342,8 +373,9 @@ bool InProcessViewRenderer::InitializeHwDraw() { |
| hardware_failed_ = !compositor_->InitializeHwDraw(gl_surface_); |
| hardware_initialized_ = true; |
| - if (hardware_failed_) |
| + if (hardware_failed_) { |
| gl_surface_ = NULL; |
| + } |
|
joth
2013/10/02 10:47:01
intended change?
boliu
2013/10/02 14:09:55
Reverted.
|
| return !hardware_failed_; |
| } |
| @@ -373,8 +405,7 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
| } |
| if (draw_info->mode == AwDrawGLInfo::kModeProcess) { |
| - TRACE_EVENT_INSTANT0( |
| - "android_webview", "EarlyOut_ModeProcess", TRACE_EVENT_SCOPE_THREAD); |
| + TRACE_EVENT0("android_webview", "EarlyOut_ModeProcess"); |
| return; |
| } |
| @@ -869,11 +900,15 @@ void InProcessViewRenderer::FallbackTickFired() { |
| // This should only be called if OnDraw or DrawGL did not come in time, which |
| // means block_invalidates_ must still be true. |
| DCHECK(block_invalidates_); |
| - if (compositor_needs_continuous_invalidate_ && compositor_) { |
| - SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 1, 1); |
| - SkCanvas canvas(&device); |
| - CompositeSW(&canvas); |
| - } |
| + if (compositor_needs_continuous_invalidate_ && compositor_) |
| + ForceCompositeSW(); |
| +} |
| + |
| +void InProcessViewRenderer::ForceCompositeSW() { |
| + DCHECK(compositor_); |
| + SkBitmapDevice device(SkBitmap::kARGB_8888_Config, 1, 1); |
| + SkCanvas canvas(&device); |
| + CompositeSW(&canvas); |
| } |
| bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { |