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.h" | 8 #include "base/message_loop.h" |
| 9 #include "content/public/browser/android/synchronous_compositor_client.h" | 9 #include "content/public/browser/android/synchronous_compositor_client.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 12 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/renderer/android/synchronous_compositor_factory.h" | 13 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 14 #include "webkit/common/gpu/context_provider_in_process.h" | |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 int GetInProcessRendererId() { | 20 int GetInProcessRendererId() { |
| 20 content::RenderProcessHost::iterator it = | 21 content::RenderProcessHost::iterator it = |
| 21 content::RenderProcessHost::AllHostsIterator(); | 22 content::RenderProcessHost::AllHostsIterator(); |
| 22 if (it.IsAtEnd()) { | 23 if (it.IsAtEnd()) { |
| 23 // There should always be one RPH in single process mode. | 24 // There should always be one RPH in single process mode. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 42 GetCompositorMessageLoop() OVERRIDE { | 43 GetCompositorMessageLoop() OVERRIDE { |
| 43 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 44 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
| 44 } | 45 } |
| 45 | 46 |
| 46 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 47 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
| 47 int routing_id) OVERRIDE { | 48 int routing_id) OVERRIDE { |
| 48 scoped_ptr<SynchronousCompositorOutputSurface> output_surface( | 49 scoped_ptr<SynchronousCompositorOutputSurface> output_surface( |
| 49 new SynchronousCompositorOutputSurface(routing_id)); | 50 new SynchronousCompositorOutputSurface(routing_id)); |
| 50 return output_surface.PassAs<cc::OutputSurface>(); | 51 return output_surface.PassAs<cc::OutputSurface>(); |
| 51 } | 52 } |
| 53 | |
| 54 virtual scoped_refptr<cc::ContextProvider> | |
| 55 GetOffscreenContextProviderForMainThread() OVERRIDE { | |
| 56 // Synchronous compositor does not support main thread context yet. | |
|
joth
2013/06/07 17:41:18
NOTIMPLEMENTED() ?
| |
| 57 return scoped_refptr<cc::ContextProvider>(); | |
| 58 } | |
| 59 | |
| 60 virtual scoped_refptr<cc::ContextProvider> | |
| 61 GetOffscreenContextProviderForCompositorThread() OVERRIDE { | |
| 62 if (!offscreen_context_for_compositor_thread_ || | |
| 63 offscreen_context_for_compositor_thread_->DestroyedOnMainThread()) { | |
| 64 offscreen_context_for_compositor_thread_ = | |
| 65 webkit::gpu::ContextProviderInProcess::Create(); | |
| 66 } | |
| 67 return offscreen_context_for_compositor_thread_; | |
| 68 } | |
| 69 | |
| 70 private: | |
| 71 scoped_refptr<cc::ContextProvider> offscreen_context_for_compositor_thread_; | |
| 52 }; | 72 }; |
| 53 | 73 |
| 54 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = | 74 base::LazyInstance<SynchronousCompositorFactoryImpl>::Leaky g_factory = |
| 55 LAZY_INSTANCE_INITIALIZER; | 75 LAZY_INSTANCE_INITIALIZER; |
| 56 | 76 |
| 57 } // namespace | 77 } // namespace |
| 58 | 78 |
| 59 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); | 79 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SynchronousCompositorImpl); |
| 60 | 80 |
| 61 // static | 81 // static |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 g_factory.Get(); // Ensure it's initialized. | 174 g_factory.Get(); // Ensure it's initialized. |
| 155 SynchronousCompositorImpl::CreateForWebContents(contents); | 175 SynchronousCompositorImpl::CreateForWebContents(contents); |
| 156 } | 176 } |
| 157 if (SynchronousCompositorImpl* instance = | 177 if (SynchronousCompositorImpl* instance = |
| 158 SynchronousCompositorImpl::FromWebContents(contents)) { | 178 SynchronousCompositorImpl::FromWebContents(contents)) { |
| 159 instance->SetClient(client); | 179 instance->SetClient(client); |
| 160 } | 180 } |
| 161 } | 181 } |
| 162 | 182 |
| 163 } // namespace content | 183 } // namespace content |
| OLD | NEW |