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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 void OnLostContext(); | 230 void OnLostContext(); |
231 ui::Compositor* compositor_; | 231 ui::Compositor* compositor_; |
232 GpuProcessTransportFactory* factory_; | 232 GpuProcessTransportFactory* factory_; |
233 | 233 |
234 DISALLOW_COPY_AND_ASSIGN(CompositorSwapClient); | 234 DISALLOW_COPY_AND_ASSIGN(CompositorSwapClient); |
235 }; | 235 }; |
236 | 236 |
237 class BrowserCompositorOutputSurface; | 237 class BrowserCompositorOutputSurface; |
238 | 238 |
239 // Directs vsync updates to the appropriate BrowserCompositorOutputSurface. | 239 // Directs vsync updates to the appropriate BrowserCompositorOutputSurface. |
240 class BrowserCompositorOutputSurfaceProxy : | 240 class BrowserCompositorOutputSurfaceProxy |
241 public base::RefCountedThreadSafe<BrowserCompositorOutputSurfaceProxy> { | 241 : public base::RefCountedThreadSafe<BrowserCompositorOutputSurfaceProxy> { |
242 public: | 242 public: |
243 BrowserCompositorOutputSurfaceProxy() | 243 BrowserCompositorOutputSurfaceProxy() |
244 : message_handler_set_(false) { | 244 : message_handler_set_(false) { |
245 } | 245 } |
246 | 246 |
247 void AddSurface(BrowserCompositorOutputSurface* surface, int surface_id) { | 247 void AddSurface(BrowserCompositorOutputSurface* surface, int surface_id) { |
248 if (!message_handler_set_) { | 248 if (!message_handler_set_) { |
249 uint32 messages_to_filter[] = {GpuHostMsg_UpdateVSyncParameters::ID}; | 249 uint32 messages_to_filter[] = {GpuHostMsg_UpdateVSyncParameters::ID}; |
250 BrowserGpuChannelHostFactory::instance()->SetHandlerForControlMessages( | 250 BrowserGpuChannelHostFactory::instance()->SetHandlerForControlMessages( |
251 messages_to_filter, | 251 messages_to_filter, |
(...skipping 28 matching lines...) Expand all Loading... |
280 IDMap<BrowserCompositorOutputSurface> surface_map_; | 280 IDMap<BrowserCompositorOutputSurface> surface_map_; |
281 bool message_handler_set_; | 281 bool message_handler_set_; |
282 | 282 |
283 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOutputSurfaceProxy); | 283 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorOutputSurfaceProxy); |
284 }; | 284 }; |
285 | 285 |
286 | 286 |
287 // Adapts a WebGraphicsContext3DCommandBufferImpl into a | 287 // Adapts a WebGraphicsContext3DCommandBufferImpl into a |
288 // cc::OutputSurface that also handles vsync parameter updates | 288 // cc::OutputSurface that also handles vsync parameter updates |
289 // arriving from the GPU process. | 289 // arriving from the GPU process. |
290 class BrowserCompositorOutputSurface : | 290 class BrowserCompositorOutputSurface |
291 public cc::OutputSurface, | 291 : public cc::OutputSurface, |
292 public base::NonThreadSafe { | 292 public base::NonThreadSafe { |
293 public: | 293 public: |
294 explicit BrowserCompositorOutputSurface( | 294 explicit BrowserCompositorOutputSurface( |
295 WebGraphicsContext3DCommandBufferImpl* context, | 295 WebGraphicsContext3DCommandBufferImpl* context, |
296 int surface_id, | 296 int surface_id, |
297 BrowserCompositorOutputSurfaceProxy* output_surface_proxy) | 297 BrowserCompositorOutputSurfaceProxy* output_surface_proxy) |
298 : context3D_(context), | 298 : context3D_(context), |
299 surface_id_(surface_id), | 299 surface_id_(surface_id), |
300 client_(NULL), | 300 client_(NULL), |
301 output_surface_proxy_(output_surface_proxy) { | 301 output_surface_proxy_(output_surface_proxy) { |
302 DetachFromThread(); | 302 DetachFromThread(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; | 358 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; |
359 }; | 359 }; |
360 | 360 |
361 void BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParameters( | 361 void BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParameters( |
362 int surface_id, base::TimeTicks timebase, base::TimeDelta interval) { | 362 int surface_id, base::TimeTicks timebase, base::TimeDelta interval) { |
363 BrowserCompositorOutputSurface* surface = surface_map_.Lookup(surface_id); | 363 BrowserCompositorOutputSurface* surface = surface_map_.Lookup(surface_id); |
364 if (surface) | 364 if (surface) |
365 surface->OnUpdateVSyncParameters(timebase, interval); | 365 surface->OnUpdateVSyncParameters(timebase, interval); |
366 } | 366 } |
367 | 367 |
368 class GpuProcessTransportFactory : | 368 class GpuProcessTransportFactory |
369 public ui::ContextFactory, | 369 : public ui::ContextFactory, |
370 public ImageTransportFactory, | 370 public ImageTransportFactory, |
371 public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 371 public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
372 public: | 372 public: |
373 GpuProcessTransportFactory() | 373 GpuProcessTransportFactory() |
374 : ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { | 374 : ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { |
375 output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy(); | 375 output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy(); |
376 } | 376 } |
377 | 377 |
378 virtual ~GpuProcessTransportFactory() { | 378 virtual ~GpuProcessTransportFactory() { |
379 DCHECK(per_compositor_data_.empty()); | 379 DCHECK(per_compositor_data_.empty()); |
380 } | 380 } |
381 | 381 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 delete g_factory; | 636 delete g_factory; |
637 g_factory = NULL; | 637 g_factory = NULL; |
638 } | 638 } |
639 | 639 |
640 // static | 640 // static |
641 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 641 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
642 return g_factory; | 642 return g_factory; |
643 } | 643 } |
644 | 644 |
645 } // namespace content | 645 } // namespace content |
OLD | NEW |