OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/image_transport_factory.h" | 5 #include "content/browser/renderer_host/image_transport_factory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 virtual void OnViewContextSwapBuffersComplete() OVERRIDE { | 226 virtual void OnViewContextSwapBuffersComplete() OVERRIDE { |
227 compositor_->OnSwapBuffersComplete(); | 227 compositor_->OnSwapBuffersComplete(); |
228 } | 228 } |
229 | 229 |
230 virtual void OnViewContextSwapBuffersAborted() OVERRIDE { | 230 virtual void OnViewContextSwapBuffersAborted() OVERRIDE { |
231 // Recreating contexts directly from here causes issues, so post a task | 231 // Recreating contexts directly from here causes issues, so post a task |
232 // instead. | 232 // instead. |
233 // TODO(piman): Fix the underlying issues. | 233 // TODO(piman): Fix the underlying issues. |
234 MessageLoop::current()->PostTask(FROM_HERE, | 234 base::MessageLoop::current()->PostTask( |
| 235 FROM_HERE, |
235 base::Bind(&CompositorSwapClient::OnLostContext, this->AsWeakPtr())); | 236 base::Bind(&CompositorSwapClient::OnLostContext, this->AsWeakPtr())); |
236 } | 237 } |
237 | 238 |
238 private: | 239 private: |
239 void OnLostContext(); | 240 void OnLostContext(); |
240 ui::Compositor* compositor_; | 241 ui::Compositor* compositor_; |
241 GpuProcessTransportFactory* factory_; | 242 GpuProcessTransportFactory* factory_; |
242 | 243 |
243 DISALLOW_COPY_AND_ASSIGN(CompositorSwapClient); | 244 DISALLOW_COPY_AND_ASSIGN(CompositorSwapClient); |
244 }; | 245 }; |
245 | 246 |
246 class BrowserCompositorOutputSurface; | 247 class BrowserCompositorOutputSurface; |
247 | 248 |
248 // Directs vsync updates to the appropriate BrowserCompositorOutputSurface. | 249 // Directs vsync updates to the appropriate BrowserCompositorOutputSurface. |
249 class BrowserCompositorOutputSurfaceProxy | 250 class BrowserCompositorOutputSurfaceProxy |
250 : public base::RefCountedThreadSafe<BrowserCompositorOutputSurfaceProxy> { | 251 : public base::RefCountedThreadSafe<BrowserCompositorOutputSurfaceProxy> { |
251 public: | 252 public: |
252 BrowserCompositorOutputSurfaceProxy() | 253 BrowserCompositorOutputSurfaceProxy() |
253 : message_handler_set_(false) { | 254 : message_handler_set_(false) { |
254 } | 255 } |
255 | 256 |
256 void AddSurface(BrowserCompositorOutputSurface* surface, int surface_id) { | 257 void AddSurface(BrowserCompositorOutputSurface* surface, int surface_id) { |
257 if (!message_handler_set_) { | 258 if (!message_handler_set_) { |
258 uint32 messages_to_filter[] = {GpuHostMsg_UpdateVSyncParameters::ID}; | 259 uint32 messages_to_filter[] = {GpuHostMsg_UpdateVSyncParameters::ID}; |
259 BrowserGpuChannelHostFactory::instance()->SetHandlerForControlMessages( | 260 BrowserGpuChannelHostFactory::instance()->SetHandlerForControlMessages( |
260 messages_to_filter, | 261 messages_to_filter, |
261 arraysize(messages_to_filter), | 262 arraysize(messages_to_filter), |
262 base::Bind(&BrowserCompositorOutputSurfaceProxy::OnMessageReceived, | 263 base::Bind(&BrowserCompositorOutputSurfaceProxy::OnMessageReceived, |
263 this), | 264 this), |
264 MessageLoop::current()->message_loop_proxy()); | 265 base::MessageLoop::current()->message_loop_proxy()); |
265 message_handler_set_ = true; | 266 message_handler_set_ = true; |
266 } | 267 } |
267 surface_map_.AddWithID(surface, surface_id); | 268 surface_map_.AddWithID(surface, surface_id); |
268 } | 269 } |
269 | 270 |
270 void RemoveSurface(int surface_id) { | 271 void RemoveSurface(int surface_id) { |
271 surface_map_.Remove(surface_id); | 272 surface_map_.Remove(surface_id); |
272 } | 273 } |
273 | 274 |
274 private: | 275 private: |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 explicit MainThreadContextProvider(GpuProcessTransportFactory* factory) | 589 explicit MainThreadContextProvider(GpuProcessTransportFactory* factory) |
589 : factory_(factory) {} | 590 : factory_(factory) {} |
590 virtual ~MainThreadContextProvider() {} | 591 virtual ~MainThreadContextProvider() {} |
591 | 592 |
592 virtual scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | 593 virtual scoped_ptr<WebGraphicsContext3DCommandBufferImpl> |
593 CreateOffscreenContext3d() OVERRIDE { | 594 CreateOffscreenContext3d() OVERRIDE { |
594 return make_scoped_ptr(factory_->CreateOffscreenContext()); | 595 return make_scoped_ptr(factory_->CreateOffscreenContext()); |
595 } | 596 } |
596 | 597 |
597 virtual void OnLostContext() OVERRIDE { | 598 virtual void OnLostContext() OVERRIDE { |
598 MessageLoop::current()->PostTask( | 599 base::MessageLoop::current()->PostTask( |
599 FROM_HERE, | 600 FROM_HERE, |
600 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, | 601 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext, |
601 factory_->callback_factory_.GetWeakPtr())); | 602 factory_->callback_factory_.GetWeakPtr())); |
602 } | 603 } |
603 | 604 |
604 private: | 605 private: |
605 GpuProcessTransportFactory* factory_; | 606 GpuProcessTransportFactory* factory_; |
606 }; | 607 }; |
607 | 608 |
608 virtual scoped_refptr<cc::ContextProvider> | 609 virtual scoped_refptr<cc::ContextProvider> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 delete g_factory; | 761 delete g_factory; |
761 g_factory = NULL; | 762 g_factory = NULL; |
762 } | 763 } |
763 | 764 |
764 // static | 765 // static |
765 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 766 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
766 return g_factory; | 767 return g_factory; |
767 } | 768 } |
768 | 769 |
769 } // namespace content | 770 } // namespace content |
OLD | NEW |