| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 ScopedAllowGL::~ScopedAllowGL() { | 166 ScopedAllowGL::~ScopedAllowGL() { |
| 167 allow_gl = false; | 167 allow_gl = false; |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool ScopedAllowGL::allow_gl = false; | 170 bool ScopedAllowGL::allow_gl = false; |
| 171 | 171 |
| 172 base::LazyInstance<GLViewRendererManager>::Leaky g_view_renderer_manager; | 172 base::LazyInstance<GLViewRendererManager>::Leaky g_view_renderer_manager; |
| 173 | 173 |
| 174 void RequestProcessGLOnUIThread() { |
| 175 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 176 BrowserThread::PostTask( |
| 177 BrowserThread::UI, FROM_HERE, base::Bind(&RequestProcessGLOnUIThread)); |
| 178 return; |
| 179 } |
| 180 |
| 181 InProcessViewRenderer* renderer = static_cast<InProcessViewRenderer*>( |
| 182 g_view_renderer_manager.Get().GetMostRecentlyDrawn()); |
| 183 if (!renderer || !renderer->RequestProcessGL()) { |
| 184 LOG(ERROR) << "Failed to request GL process. Deadlock likely: " |
| 185 << !!renderer; |
| 186 } |
| 187 } |
| 188 |
| 174 } // namespace | 189 } // namespace |
| 175 | 190 |
| 176 // Called from different threads! | 191 // Called from different threads! |
| 177 static void ScheduleGpuWork() { | 192 static void ScheduleGpuWork() { |
| 178 if (ScopedAllowGL::IsAllowed()) { | 193 if (ScopedAllowGL::IsAllowed()) { |
| 179 gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread(); | 194 gpu::InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread(); |
| 180 } else { | 195 } else { |
| 181 InProcessViewRenderer* renderer = static_cast<InProcessViewRenderer*>( | 196 RequestProcessGLOnUIThread(); |
| 182 g_view_renderer_manager.Get().GetMostRecentlyDrawn()); | |
| 183 if (!renderer || !renderer->RequestProcessGL()) { | |
| 184 LOG(ERROR) << "Failed to request DrawGL. Probably going to deadlock."; | |
| 185 } | |
| 186 } | 197 } |
| 187 } | 198 } |
| 188 | 199 |
| 189 // static | 200 // static |
| 190 void BrowserViewRenderer::SetAwDrawSWFunctionTable( | 201 void BrowserViewRenderer::SetAwDrawSWFunctionTable( |
| 191 AwDrawSWFunctionTable* table) { | 202 AwDrawSWFunctionTable* table) { |
| 192 g_sw_draw_functions = table; | 203 g_sw_draw_functions = table; |
| 193 gpu::InProcessCommandBuffer::SetScheduleCallback( | 204 gpu::InProcessCommandBuffer::SetScheduleCallback( |
| 194 base::Bind(&ScheduleGpuWork)); | 205 base::Bind(&ScheduleGpuWork)); |
| 195 } | 206 } |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 787 |
| 777 // Unretained here is safe because the callback is cancelled when | 788 // Unretained here is safe because the callback is cancelled when |
| 778 // |fallback_tick_| is destroyed. | 789 // |fallback_tick_| is destroyed. |
| 779 fallback_tick_.Reset(base::Bind(&InProcessViewRenderer::FallbackTickFired, | 790 fallback_tick_.Reset(base::Bind(&InProcessViewRenderer::FallbackTickFired, |
| 780 base::Unretained(this))); | 791 base::Unretained(this))); |
| 781 | 792 |
| 782 // No need to reschedule fallback tick if compositor does not need to be | 793 // No need to reschedule fallback tick if compositor does not need to be |
| 783 // ticked. This can happen if this is reached because | 794 // ticked. This can happen if this is reached because |
| 784 // invalidate_ignore_compositor is true. | 795 // invalidate_ignore_compositor is true. |
| 785 if (compositor_needs_continuous_invalidate_) { | 796 if (compositor_needs_continuous_invalidate_) { |
| 786 base::MessageLoop::current()->PostDelayedTask( | 797 BrowserThread::PostDelayedTask( |
| 798 BrowserThread::UI, |
| 787 FROM_HERE, | 799 FROM_HERE, |
| 788 fallback_tick_.callback(), | 800 fallback_tick_.callback(), |
| 789 base::TimeDelta::FromMilliseconds( | 801 base::TimeDelta::FromMilliseconds( |
| 790 kFallbackTickTimeoutInMilliseconds)); | 802 kFallbackTickTimeoutInMilliseconds)); |
| 791 } | 803 } |
| 792 } | 804 } |
| 793 | 805 |
| 794 void InProcessViewRenderer::FallbackTickFired() { | 806 void InProcessViewRenderer::FallbackTickFired() { |
| 795 TRACE_EVENT1("android_webview", | 807 TRACE_EVENT1("android_webview", |
| 796 "InProcessViewRenderer::FallbackTickFired", | 808 "InProcessViewRenderer::FallbackTickFired", |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 base::StringAppendF(&str, | 871 base::StringAppendF(&str, |
| 860 "surface width height: [%d %d] ", | 872 "surface width height: [%d %d] ", |
| 861 draw_info->width, | 873 draw_info->width, |
| 862 draw_info->height); | 874 draw_info->height); |
| 863 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 875 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
| 864 } | 876 } |
| 865 return str; | 877 return str; |
| 866 } | 878 } |
| 867 | 879 |
| 868 } // namespace android_webview | 880 } // namespace android_webview |
| OLD | NEW |