Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 | 59 |
| 60 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE { | 60 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE { |
| 61 return synchronous_input_event_filter(); | 61 return synchronous_input_event_filter(); |
| 62 } | 62 } |
| 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 NOTIMPLEMENTED() | 70 if (!offscreen_context_for_main_thread_.get() || |
| 71 << "Synchronous compositor does not support main thread context yet."; | 71 offscreen_context_for_main_thread_->DestroyedOnMainThread()) { |
| 72 return scoped_refptr<cc::ContextProvider>(); | 72 offscreen_context_for_main_thread_ = |
| 73 webkit::gpu::ContextProviderInProcess::Create(); | |
| 74 if (offscreen_context_for_main_thread_.get() && | |
| 75 !offscreen_context_for_main_thread_->BindToCurrentThread()) | |
| 76 offscreen_context_for_main_thread_ = NULL; | |
| 77 } | |
| 78 return offscreen_context_for_main_thread_; | |
| 73 } | 79 } |
|
joth
2013/08/10 01:43:44
time for this class to become out-of-line eh? (and
| |
| 74 | 80 |
| 75 // This is called on both renderer main thread (offscreen context creation | 81 // This is called on both renderer main thread (offscreen context creation |
| 76 // path shared between cross-process and in-process platforms) and renderer | 82 // path shared between cross-process and in-process platforms) and renderer |
| 77 // compositor impl thread (InitializeHwDraw) in order to support Android | 83 // compositor impl thread (InitializeHwDraw) in order to support Android |
| 78 // WebView synchronously enable and disable hardware mode multiple times in | 84 // WebView synchronously enable and disable hardware mode multiple times in |
| 79 // 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 |
| 80 // any thread and is lightweight. | 86 // any thread and is lightweight. |
| 81 virtual scoped_refptr<cc::ContextProvider> | 87 virtual scoped_refptr<cc::ContextProvider> |
| 82 GetOffscreenContextProviderForCompositorThread() OVERRIDE { | 88 GetOffscreenContextProviderForCompositorThread() OVERRIDE { |
| 83 base::AutoLock lock(offscreen_context_for_compositor_thread_creation_lock_); | 89 base::AutoLock lock(offscreen_context_for_compositor_thread_creation_lock_); |
| 84 if (!offscreen_context_for_compositor_thread_.get() || | 90 if (!offscreen_context_for_compositor_thread_.get() || |
| 85 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { | 91 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { |
| 86 offscreen_context_for_compositor_thread_ = | 92 offscreen_context_for_compositor_thread_ = |
| 87 webkit::gpu::ContextProviderInProcess::Create(); | 93 webkit::gpu::ContextProviderInProcess::Create(); |
| 88 } | 94 } |
| 89 return offscreen_context_for_compositor_thread_; | 95 return offscreen_context_for_compositor_thread_; |
| 90 } | 96 } |
| 91 | 97 |
| 92 private: | 98 private: |
| 93 SynchronousInputEventFilter synchronous_input_event_filter_; | 99 SynchronousInputEventFilter synchronous_input_event_filter_; |
| 94 | 100 |
| 95 // Only guards construction of |offscreen_context_for_compositor_thread_|, | 101 // Only guards construction of |offscreen_context_for_compositor_thread_|, |
| 96 // not usage. | 102 // not usage. |
| 97 base::Lock offscreen_context_for_compositor_thread_creation_lock_; | 103 base::Lock offscreen_context_for_compositor_thread_creation_lock_; |
| 104 scoped_refptr<cc::ContextProvider> offscreen_context_for_main_thread_; | |
| 98 scoped_refptr<cc::ContextProvider> offscreen_context_for_compositor_thread_; | 105 scoped_refptr<cc::ContextProvider> offscreen_context_for_compositor_thread_; |
| 99 }; | 106 }; |
| 100 | 107 |
| 101 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = | 108 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = |
| 102 LAZY_INSTANCE_INITIALIZER; | 109 LAZY_INSTANCE_INITIALIZER; |
| 103 | 110 |
| 104 } // namespace | 111 } // namespace |
| 105 | 112 |
| 106 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); | 113 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); |
| 107 | 114 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 g_factory.Get(); // Ensure it's initialized. | 287 g_factory.Get(); // Ensure it's initialized. |
| 281 SynchronousCompositorImpl::CreateForWebContents(contents); | 288 SynchronousCompositorImpl::CreateForWebContents(contents); |
| 282 } | 289 } |
| 283 if (SynchronousCompositorImpl* instance = | 290 if (SynchronousCompositorImpl* instance = |
| 284 SynchronousCompositorImpl::FromWebContents(contents)) { | 291 SynchronousCompositorImpl::FromWebContents(contents)) { |
| 285 instance->SetClient(client); | 292 instance->SetClient(client); |
| 286 } | 293 } |
| 287 } | 294 } |
| 288 | 295 |
| 289 } // namespace content | 296 } // namespace content |
| OLD | NEW |