OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "android_webview/browser/in_process_view_renderer.h" | 5 #include "android_webview/browser/in_process_view_renderer.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "android_webview/browser/aw_gl_surface.h" | 9 #include "android_webview/browser/aw_gl_surface.h" |
10 #include "android_webview/browser/scoped_app_gl_state_restore.h" | 10 #include "android_webview/browser/scoped_app_gl_state_restore.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 std::stringstream size; | 309 std::stringstream size; |
310 size << default_tile_size; | 310 size << default_tile_size; |
311 cl->AppendSwitchASCII(switches::kDefaultTileWidth, size.str()); | 311 cl->AppendSwitchASCII(switches::kDefaultTileWidth, size.str()); |
312 cl->AppendSwitchASCII(switches::kDefaultTileHeight, size.str()); | 312 cl->AppendSwitchASCII(switches::kDefaultTileHeight, size.str()); |
313 } | 313 } |
314 | 314 |
315 bool InProcessViewRenderer::RequestProcessGL() { | 315 bool InProcessViewRenderer::RequestProcessGL() { |
316 return client_->RequestDrawGL(NULL); | 316 return client_->RequestDrawGL(NULL); |
317 } | 317 } |
318 | 318 |
319 void InProcessViewRenderer::OnMemoryPressure( | |
320 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { | |
321 // Nothing to release. | |
322 if (!attached_to_window_ || !compositor_ || !hardware_initialized_) | |
323 return; | |
324 | |
325 // Do not release resources on view we expect to get DrawGL soon. | |
326 if (view_visible_ && window_visible_) | |
327 return; | |
328 | |
329 TRACE_EVENT_INSTANT0( | |
330 "android_webview", "OnMemoryPressure", TRACE_EVENT_SCOPE_THREAD); | |
331 ScopedAppGLStateRestore state_restore(ScopedAppGLStateRestore::MODE_ON_TRIM); | |
332 gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread(); | |
333 ScopedAllowGL allow_gl; | |
joth
2013/10/01 11:10:46
GL not valid if this is a 'fake' memory pressure?
| |
334 | |
335 content::SynchronousCompositorMemoryPolicy policy; | |
336 policy.bytes_limit = 0; | |
337 policy.num_resources_limit = 0; | |
338 compositor_->SetMemoryPolicy(policy); | |
joth
2013/10/01 11:10:46
comment this will get set back upward on the next
| |
339 } | |
340 | |
319 void InProcessViewRenderer::UpdateCachedGlobalVisibleRect() { | 341 void InProcessViewRenderer::UpdateCachedGlobalVisibleRect() { |
320 client_->UpdateGlobalVisibleRect(); | 342 client_->UpdateGlobalVisibleRect(); |
321 } | 343 } |
322 | 344 |
323 bool InProcessViewRenderer::OnDraw(jobject java_canvas, | 345 bool InProcessViewRenderer::OnDraw(jobject java_canvas, |
324 bool is_hardware_canvas, | 346 bool is_hardware_canvas, |
325 const gfx::Vector2d& scroll, | 347 const gfx::Vector2d& scroll, |
326 const gfx::Rect& clip) { | 348 const gfx::Rect& clip) { |
327 scroll_at_start_of_frame_ = scroll; | 349 scroll_at_start_of_frame_ = scroll; |
328 if (is_hardware_canvas && attached_to_window_ && HardwareEnabled()) { | 350 if (is_hardware_canvas && attached_to_window_ && HardwareEnabled()) { |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
926 base::StringAppendF(&str, | 948 base::StringAppendF(&str, |
927 "surface width height: [%d %d] ", | 949 "surface width height: [%d %d] ", |
928 draw_info->width, | 950 draw_info->width, |
929 draw_info->height); | 951 draw_info->height); |
930 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 952 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
931 } | 953 } |
932 return str; | 954 return str; |
933 } | 955 } |
934 | 956 |
935 } // namespace android_webview | 957 } // namespace android_webview |
OLD | NEW |