| 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.h" | 8 #include "base/message_loop.h" |
| 9 #include "content/browser/android/in_process/synchronous_input_event_filter.h" | 9 #include "content/browser/android/in_process/synchronous_input_event_filter.h" |
| 10 #include "content/public/browser/android/synchronous_compositor_client.h" | 10 #include "content/public/browser/android/synchronous_compositor_client.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/renderer/android/synchronous_compositor_factory.h" | 14 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 15 #include "webkit/common/gpu/context_provider_in_process.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 int GetInProcessRendererId() { | 21 int GetInProcessRendererId() { |
| 21 content::RenderProcessHost::iterator it = | 22 content::RenderProcessHost::iterator it = |
| 22 content::RenderProcessHost::AllHostsIterator(); | 23 content::RenderProcessHost::AllHostsIterator(); |
| 23 if (it.IsAtEnd()) { | 24 if (it.IsAtEnd()) { |
| 24 // There should always be one RPH in single process mode. | 25 // There should always be one RPH in single process mode. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 52 } | 53 } |
| 53 | 54 |
| 54 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE { | 55 virtual InputHandlerManagerClient* GetInputHandlerManagerClient() OVERRIDE { |
| 55 return synchronous_input_event_filter(); | 56 return synchronous_input_event_filter(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 SynchronousInputEventFilter* synchronous_input_event_filter() { | 59 SynchronousInputEventFilter* synchronous_input_event_filter() { |
| 59 return &synchronous_input_event_filter_; | 60 return &synchronous_input_event_filter_; |
| 60 } | 61 } |
| 61 | 62 |
| 63 virtual scoped_refptr<cc::ContextProvider> |
| 64 GetOffscreenContextProviderForMainThread() OVERRIDE { |
| 65 NOTIMPLEMENTED() |
| 66 << "Synchronous compositor does not support main thread context yet."; |
| 67 return scoped_refptr<cc::ContextProvider>(); |
| 68 } |
| 69 |
| 70 virtual scoped_refptr<cc::ContextProvider> |
| 71 GetOffscreenContextProviderForCompositorThread() OVERRIDE { |
| 72 if (!offscreen_context_for_compositor_thread_ || |
| 73 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { |
| 74 offscreen_context_for_compositor_thread_ = |
| 75 webkit::gpu::ContextProviderInProcess::Create(); |
| 76 } |
| 77 return offscreen_context_for_compositor_thread_; |
| 78 } |
| 79 |
| 62 private: | 80 private: |
| 63 SynchronousInputEventFilter synchronous_input_event_filter_; | 81 SynchronousInputEventFilter synchronous_input_event_filter_; |
| 82 scoped_refptr<cc::ContextProvider> offscreen_context_for_compositor_thread_; |
| 64 }; | 83 }; |
| 65 | 84 |
| 66 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = | 85 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = |
| 67 LAZY_INSTANCE_INITIALIZER; | 86 LAZY_INSTANCE_INITIALIZER; |
| 68 | 87 |
| 69 } // namespace | 88 } // namespace |
| 70 | 89 |
| 71 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); | 90 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); |
| 72 | 91 |
| 73 // static | 92 // static |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 g_factory.Get(); // Ensure it's initialized. | 198 g_factory.Get(); // Ensure it's initialized. |
| 180 SynchronousCompositorImpl::CreateForWebContents(contents); | 199 SynchronousCompositorImpl::CreateForWebContents(contents); |
| 181 } | 200 } |
| 182 if (SynchronousCompositorImpl* instance = | 201 if (SynchronousCompositorImpl* instance = |
| 183 SynchronousCompositorImpl::FromWebContents(contents)) { | 202 SynchronousCompositorImpl::FromWebContents(contents)) { |
| 184 instance->SetClient(client); | 203 instance->SetClient(client); |
| 185 } | 204 } |
| 186 } | 205 } |
| 187 | 206 |
| 188 } // namespace content | 207 } // namespace content |
| OLD | NEW |