| OLD | NEW |
| 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 #include "android_webview/browser/hardware_renderer.h" | 5 #include "android_webview/browser/hardware_renderer.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_gl_surface.h" | 7 #include "android_webview/browser/aw_gl_surface.h" |
| 8 #include "android_webview/browser/browser_view_renderer_client.h" | 8 #include "android_webview/browser/browser_view_renderer_client.h" |
| 9 #include "android_webview/browser/gl_view_renderer_manager.h" | 9 #include "android_webview/browser/gl_view_renderer_manager.h" |
| 10 #include "android_webview/browser/scoped_app_gl_state_restore.h" | 10 #include "android_webview/browser/scoped_app_gl_state_restore.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT); | 66 ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT); |
| 67 internal::ScopedAllowGL allow_gl; | 67 internal::ScopedAllowGL allow_gl; |
| 68 | 68 |
| 69 shared_renderer_state_->GetCompositor()->ReleaseHwDraw(); | 69 shared_renderer_state_->GetCompositor()->ReleaseHwDraw(); |
| 70 gl_surface_ = NULL; | 70 gl_surface_ = NULL; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info, DrawGLResult* result) { | 73 bool HardwareRenderer::DrawGL(AwDrawGLInfo* draw_info, DrawGLResult* result) { |
| 74 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); | 74 TRACE_EVENT0("android_webview", "HardwareRenderer::DrawGL"); |
| 75 GLViewRendererManager::GetInstance()->DidDrawGL(manager_key_); | 75 GLViewRendererManager::GetInstance()->DidDrawGL(manager_key_); |
| 76 const DrawGLInput input = shared_renderer_state_->GetDrawGLInput(); | |
| 77 | 76 |
| 78 // We need to watch if the current Android context has changed and enforce | 77 // We need to watch if the current Android context has changed and enforce |
| 79 // a clean-up in the compositor. | 78 // a clean-up in the compositor. |
| 80 EGLContext current_context = eglGetCurrentContext(); | 79 EGLContext current_context = eglGetCurrentContext(); |
| 81 if (!current_context) { | 80 if (!current_context) { |
| 82 DLOG(ERROR) << "DrawGL called without EGLContext"; | 81 DLOG(ERROR) << "DrawGL called without EGLContext"; |
| 83 return false; | 82 return false; |
| 84 } | 83 } |
| 85 | 84 |
| 86 // TODO(boliu): Handle context loss. | 85 // TODO(boliu): Handle context loss. |
| 87 if (last_egl_context_ != current_context) | 86 if (last_egl_context_ != current_context) |
| 88 DLOG(WARNING) << "EGLContextChanged"; | 87 DLOG(WARNING) << "EGLContextChanged"; |
| 89 | 88 |
| 90 ScopedAppGLStateRestore state_restore(ScopedAppGLStateRestore::MODE_DRAW); | 89 ScopedAppGLStateRestore state_restore(ScopedAppGLStateRestore::MODE_DRAW); |
| 91 internal::ScopedAllowGL allow_gl; | 90 internal::ScopedAllowGL allow_gl; |
| 92 | 91 |
| 93 if (draw_info->mode == AwDrawGLInfo::kModeProcess) | 92 if (draw_info->mode != AwDrawGLInfo::kModeDraw) |
| 94 return false; | 93 return false; |
| 95 | 94 |
| 95 // Should only need to access SharedRendererState in kModeDraw and kModeSync. |
| 96 const DrawGLInput input = shared_renderer_state_->GetDrawGLInput(); |
| 97 |
| 96 // Update memory budget. This will no-op in compositor if the policy has not | 98 // Update memory budget. This will no-op in compositor if the policy has not |
| 97 // changed since last draw. | 99 // changed since last draw. |
| 98 content::SynchronousCompositorMemoryPolicy policy; | 100 content::SynchronousCompositorMemoryPolicy policy; |
| 99 policy.bytes_limit = g_memory_multiplier * kBytesPerPixel * | 101 policy.bytes_limit = g_memory_multiplier * kBytesPerPixel * |
| 100 input.global_visible_rect.width() * | 102 input.global_visible_rect.width() * |
| 101 input.global_visible_rect.height(); | 103 input.global_visible_rect.height(); |
| 102 // Round up to a multiple of kMemoryAllocationStep. | 104 // Round up to a multiple of kMemoryAllocationStep. |
| 103 policy.bytes_limit = | 105 policy.bytes_limit = |
| 104 (policy.bytes_limit / kMemoryAllocationStep + 1) * kMemoryAllocationStep; | 106 (policy.bytes_limit / kMemoryAllocationStep + 1) * kMemoryAllocationStep; |
| 105 policy.num_resources_limit = g_num_gralloc_limit; | 107 policy.num_resources_limit = g_num_gralloc_limit; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); | 296 base::RefCountedThreadSafe<DeferredGpuCommandService>::AddRef(); |
| 295 } | 297 } |
| 296 | 298 |
| 297 void DeferredGpuCommandService::Release() const { | 299 void DeferredGpuCommandService::Release() const { |
| 298 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); | 300 base::RefCountedThreadSafe<DeferredGpuCommandService>::Release(); |
| 299 } | 301 } |
| 300 | 302 |
| 301 } // namespace internal | 303 } // namespace internal |
| 302 | 304 |
| 303 } // namespace android_webview | 305 } // namespace android_webview |
| OLD | NEW |