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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // cc::OutputSurface that also handles vsync parameter updates | 289 // cc::OutputSurface that also handles vsync parameter updates |
290 // arriving from the GPU process. | 290 // arriving from the GPU process. |
291 class BrowserCompositorOutputSurface | 291 class BrowserCompositorOutputSurface |
292 : public cc::OutputSurface, | 292 : public cc::OutputSurface, |
293 public base::NonThreadSafe { | 293 public base::NonThreadSafe { |
294 public: | 294 public: |
295 explicit BrowserCompositorOutputSurface( | 295 explicit BrowserCompositorOutputSurface( |
296 WebGraphicsContext3DCommandBufferImpl* context, | 296 WebGraphicsContext3DCommandBufferImpl* context, |
297 int surface_id, | 297 int surface_id, |
298 BrowserCompositorOutputSurfaceProxy* output_surface_proxy) | 298 BrowserCompositorOutputSurfaceProxy* output_surface_proxy) |
299 : context3D_(context), | 299 : OutputSurface(scoped_ptr<WebKit::WebGraphicsContext3D>(context)), |
300 surface_id_(surface_id), | 300 surface_id_(surface_id), |
301 client_(NULL), | |
302 output_surface_proxy_(output_surface_proxy) { | 301 output_surface_proxy_(output_surface_proxy) { |
303 DetachFromThread(); | 302 DetachFromThread(); |
304 } | 303 } |
305 | 304 |
306 virtual ~BrowserCompositorOutputSurface() { | 305 virtual ~BrowserCompositorOutputSurface() { |
307 DCHECK(CalledOnValidThread()); | 306 DCHECK(CalledOnValidThread()); |
308 if (!client_) | 307 if (!client_) |
309 return; | 308 return; |
310 output_surface_proxy_->RemoveSurface(surface_id_); | 309 output_surface_proxy_->RemoveSurface(surface_id_); |
311 } | 310 } |
312 | 311 |
313 virtual bool BindToClient( | 312 virtual bool BindToClient( |
314 cc::OutputSurfaceClient* client) OVERRIDE { | 313 cc::OutputSurfaceClient* client) OVERRIDE { |
315 DCHECK(CalledOnValidThread()); | 314 DCHECK(CalledOnValidThread()); |
316 DCHECK(client); | |
317 DCHECK(!client_); | |
318 if (context3D_.get()) { | |
319 if (!context3D_->makeContextCurrent()) | |
320 return false; | |
321 } | |
322 | 315 |
323 client_ = client; | 316 if (!OutputSurface::BindToClient(client)) |
| 317 return false; |
| 318 |
324 output_surface_proxy_->AddSurface(this, surface_id_); | 319 output_surface_proxy_->AddSurface(this, surface_id_); |
325 return true; | 320 return true; |
326 } | 321 } |
327 | 322 |
328 virtual const struct Capabilities& Capabilities() const OVERRIDE { | |
329 DCHECK(CalledOnValidThread()); | |
330 return capabilities_; | |
331 } | |
332 | |
333 virtual WebKit::WebGraphicsContext3D* Context3D() const OVERRIDE { | |
334 DCHECK(CalledOnValidThread()); | |
335 return context3D_.get(); | |
336 } | |
337 | |
338 virtual cc::SoftwareOutputDevice* SoftwareDevice() const OVERRIDE { | |
339 DCHECK(CalledOnValidThread()); | |
340 return NULL; | |
341 } | |
342 | |
343 virtual void SendFrameToParentCompositor( | |
344 cc::CompositorFrame*) OVERRIDE { | |
345 } | |
346 | |
347 void OnUpdateVSyncParameters( | 323 void OnUpdateVSyncParameters( |
348 base::TimeTicks timebase, base::TimeDelta interval) { | 324 base::TimeTicks timebase, base::TimeDelta interval) { |
349 DCHECK(CalledOnValidThread()); | 325 DCHECK(CalledOnValidThread()); |
350 DCHECK(client_); | 326 DCHECK(client_); |
351 client_->OnVSyncParametersChanged(timebase, interval); | 327 client_->OnVSyncParametersChanged(timebase, interval); |
352 } | 328 } |
353 | 329 |
354 private: | 330 private: |
355 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3D_; | |
356 int surface_id_; | 331 int surface_id_; |
357 struct Capabilities capabilities_; | |
358 cc::OutputSurfaceClient* client_; | |
359 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; | 332 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; |
360 }; | 333 }; |
361 | 334 |
362 void BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParameters( | 335 void BrowserCompositorOutputSurfaceProxy::OnUpdateVSyncParameters( |
363 int surface_id, base::TimeTicks timebase, base::TimeDelta interval) { | 336 int surface_id, base::TimeTicks timebase, base::TimeDelta interval) { |
364 BrowserCompositorOutputSurface* surface = surface_map_.Lookup(surface_id); | 337 BrowserCompositorOutputSurface* surface = surface_map_.Lookup(surface_id); |
365 if (surface) | 338 if (surface) |
366 surface->OnUpdateVSyncParameters(timebase, interval); | 339 surface->OnUpdateVSyncParameters(timebase, interval); |
367 } | 340 } |
368 | 341 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 delete g_factory; | 611 delete g_factory; |
639 g_factory = NULL; | 612 g_factory = NULL; |
640 } | 613 } |
641 | 614 |
642 // static | 615 // static |
643 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 616 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
644 return g_factory; | 617 return g_factory; |
645 } | 618 } |
646 | 619 |
647 } // namespace content | 620 } // namespace content |
OLD | NEW |