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 "content/browser/android/in_process/synchronous_compositor_impl.h" | 5 #include "content/browser/android/in_process/synchronous_compositor_impl.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "cc/input/input_handler.h" | 10 #include "cc/input/input_handler.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 SynchronousInputEventFilter* synchronous_input_event_filter() { | 64 SynchronousInputEventFilter* synchronous_input_event_filter() { |
65 return &synchronous_input_event_filter_; | 65 return &synchronous_input_event_filter_; |
66 } | 66 } |
67 | 67 |
68 virtual scoped_refptr<cc::ContextProvider> | 68 virtual scoped_refptr<cc::ContextProvider> |
69 GetOffscreenContextProviderForMainThread() OVERRIDE { | 69 GetOffscreenContextProviderForMainThread() OVERRIDE { |
70 if (!offscreen_context_for_main_thread_.get() || | 70 if (!offscreen_context_for_main_thread_.get() || |
71 offscreen_context_for_main_thread_->DestroyedOnMainThread()) { | 71 offscreen_context_for_main_thread_->DestroyedOnMainThread()) { |
72 offscreen_context_for_main_thread_ = | 72 offscreen_context_for_main_thread_ = |
73 webkit::gpu::ContextProviderInProcess::Create(); | 73 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); |
74 if (offscreen_context_for_main_thread_.get() && | 74 if (offscreen_context_for_main_thread_.get() && |
75 !offscreen_context_for_main_thread_->BindToCurrentThread()) | 75 !offscreen_context_for_main_thread_->BindToCurrentThread()) |
76 offscreen_context_for_main_thread_ = NULL; | 76 offscreen_context_for_main_thread_ = NULL; |
77 } | 77 } |
78 return offscreen_context_for_main_thread_; | 78 return offscreen_context_for_main_thread_; |
79 } | 79 } |
80 | 80 |
81 // This is called on both renderer main thread (offscreen context creation | 81 // This is called on both renderer main thread (offscreen context creation |
82 // path shared between cross-process and in-process platforms) and renderer | 82 // path shared between cross-process and in-process platforms) and renderer |
83 // compositor impl thread (InitializeHwDraw) in order to support Android | 83 // compositor impl thread (InitializeHwDraw) in order to support Android |
84 // WebView synchronously enable and disable hardware mode multiple times in | 84 // WebView synchronously enable and disable hardware mode multiple times in |
85 // the same task. This is ok because in-process WGC3D creation may happen on | 85 // the same task. This is ok because in-process WGC3D creation may happen on |
86 // any thread and is lightweight. | 86 // any thread and is lightweight. |
87 virtual scoped_refptr<cc::ContextProvider> | 87 virtual scoped_refptr<cc::ContextProvider> |
88 GetOffscreenContextProviderForCompositorThread() OVERRIDE { | 88 GetOffscreenContextProviderForCompositorThread() OVERRIDE { |
89 base::AutoLock lock(offscreen_context_for_compositor_thread_creation_lock_); | 89 base::AutoLock lock(offscreen_context_for_compositor_thread_creation_lock_); |
90 if (!offscreen_context_for_compositor_thread_.get() || | 90 if (!offscreen_context_for_compositor_thread_.get() || |
91 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { | 91 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { |
92 offscreen_context_for_compositor_thread_ = | 92 offscreen_context_for_compositor_thread_ = |
93 webkit::gpu::ContextProviderInProcess::Create(); | 93 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); |
94 } | 94 } |
95 return offscreen_context_for_compositor_thread_; | 95 return offscreen_context_for_compositor_thread_; |
96 } | 96 } |
97 | 97 |
98 private: | 98 private: |
99 SynchronousInputEventFilter synchronous_input_event_filter_; | 99 SynchronousInputEventFilter synchronous_input_event_filter_; |
100 | 100 |
101 // Only guards construction of |offscreen_context_for_compositor_thread_|, | 101 // Only guards construction of |offscreen_context_for_compositor_thread_|, |
102 // not usage. | 102 // not usage. |
103 base::Lock offscreen_context_for_compositor_thread_creation_lock_; | 103 base::Lock offscreen_context_for_compositor_thread_creation_lock_; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 g_factory.Get(); // Ensure it's initialized. | 287 g_factory.Get(); // Ensure it's initialized. |
288 SynchronousCompositorImpl::CreateForWebContents(contents); | 288 SynchronousCompositorImpl::CreateForWebContents(contents); |
289 } | 289 } |
290 if (SynchronousCompositorImpl* instance = | 290 if (SynchronousCompositorImpl* instance = |
291 SynchronousCompositorImpl::FromWebContents(contents)) { | 291 SynchronousCompositorImpl::FromWebContents(contents)) { |
292 instance->SetClient(client); | 292 instance->SetClient(client); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 } // namespace content | 296 } // namespace content |
OLD | NEW |