OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "content/common/gpu/image_transport_surface.h" | 7 #include "content/common/gpu/image_transport_surface.h" |
8 | 8 |
9 // This conflicts with the defines in Xlib.h and must come first. | 9 // This conflicts with the defines in Xlib.h and must come first. |
10 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 virtual gfx::Size GetSize() OVERRIDE; | 69 virtual gfx::Size GetSize() OVERRIDE; |
70 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 70 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
71 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 71 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
72 virtual void SetVisible(bool visible) OVERRIDE; | 72 virtual void SetVisible(bool visible) OVERRIDE; |
73 | 73 |
74 protected: | 74 protected: |
75 // ImageTransportSurface implementation | 75 // ImageTransportSurface implementation |
76 virtual void OnNewSurfaceACK( | 76 virtual void OnNewSurfaceACK( |
77 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 77 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
78 virtual void OnBuffersSwappedACK() OVERRIDE; | 78 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 79 virtual void OnResizeViewACK() OVERRIDE; |
79 virtual void OnResize(gfx::Size size) OVERRIDE; | 80 virtual void OnResize(gfx::Size size) OVERRIDE; |
80 | 81 |
81 private: | 82 private: |
82 virtual ~EGLImageTransportSurface() OVERRIDE; | 83 virtual ~EGLImageTransportSurface() OVERRIDE; |
83 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); | 84 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); |
84 | 85 |
85 uint32 fbo_id_; | 86 uint32 fbo_id_; |
86 | 87 |
87 scoped_refptr<EGLAcceleratedSurface> back_surface_; | 88 scoped_refptr<EGLAcceleratedSurface> back_surface_; |
88 scoped_refptr<EGLAcceleratedSurface> front_surface_; | 89 scoped_refptr<EGLAcceleratedSurface> front_surface_; |
(...skipping 21 matching lines...) Expand all Loading... |
110 virtual void Destroy() OVERRIDE; | 111 virtual void Destroy() OVERRIDE; |
111 virtual bool SwapBuffers() OVERRIDE; | 112 virtual bool SwapBuffers() OVERRIDE; |
112 virtual gfx::Size GetSize() OVERRIDE; | 113 virtual gfx::Size GetSize() OVERRIDE; |
113 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 114 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
114 | 115 |
115 protected: | 116 protected: |
116 // ImageTransportSurface implementation: | 117 // ImageTransportSurface implementation: |
117 virtual void OnNewSurfaceACK( | 118 virtual void OnNewSurfaceACK( |
118 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 119 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
119 virtual void OnBuffersSwappedACK() OVERRIDE; | 120 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 121 virtual void OnResizeViewACK() OVERRIDE; |
120 virtual void OnResize(gfx::Size size) OVERRIDE; | 122 virtual void OnResize(gfx::Size size) OVERRIDE; |
121 | 123 |
122 private: | 124 private: |
123 virtual ~GLXImageTransportSurface(); | 125 virtual ~GLXImageTransportSurface(); |
124 | 126 |
125 // Tell the browser to release the surface. | 127 // Tell the browser to release the surface. |
126 void ReleaseSurface(); | 128 void ReleaseSurface(); |
127 | 129 |
128 XID dummy_parent_; | 130 XID dummy_parent_; |
129 gfx::Size size_; | 131 gfx::Size size_; |
(...skipping 25 matching lines...) Expand all Loading... |
155 virtual void Destroy() OVERRIDE; | 157 virtual void Destroy() OVERRIDE; |
156 virtual bool IsOffscreen() OVERRIDE; | 158 virtual bool IsOffscreen() OVERRIDE; |
157 virtual bool SwapBuffers() OVERRIDE; | 159 virtual bool SwapBuffers() OVERRIDE; |
158 virtual gfx::Size GetSize() OVERRIDE; | 160 virtual gfx::Size GetSize() OVERRIDE; |
159 | 161 |
160 protected: | 162 protected: |
161 // ImageTransportSurface implementation: | 163 // ImageTransportSurface implementation: |
162 virtual void OnNewSurfaceACK( | 164 virtual void OnNewSurfaceACK( |
163 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 165 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
164 virtual void OnBuffersSwappedACK() OVERRIDE; | 166 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 167 virtual void OnResizeViewACK() OVERRIDE; |
165 virtual void OnResize(gfx::Size size) OVERRIDE; | 168 virtual void OnResize(gfx::Size size) OVERRIDE; |
166 | 169 |
167 private: | 170 private: |
168 virtual ~OSMesaImageTransportSurface(); | 171 virtual ~OSMesaImageTransportSurface(); |
169 | 172 |
170 // Tell the browser to release the surface. | 173 // Tell the browser to release the surface. |
171 void ReleaseSurface(); | 174 void ReleaseSurface(); |
172 | 175 |
173 scoped_ptr<TransportDIB> shared_mem_; | 176 scoped_ptr<TransportDIB> shared_mem_; |
174 uint32 shared_id_; | 177 uint32 shared_id_; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 void EGLImageTransportSurface::OnNewSurfaceACK( | 365 void EGLImageTransportSurface::OnNewSurfaceACK( |
363 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { | 366 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { |
364 DCHECK_EQ(back_surface_->pixmap(), surface_id); | 367 DCHECK_EQ(back_surface_->pixmap(), surface_id); |
365 helper_->SetScheduled(true); | 368 helper_->SetScheduled(true); |
366 } | 369 } |
367 | 370 |
368 void EGLImageTransportSurface::OnBuffersSwappedACK() { | 371 void EGLImageTransportSurface::OnBuffersSwappedACK() { |
369 helper_->SetScheduled(true); | 372 helper_->SetScheduled(true); |
370 } | 373 } |
371 | 374 |
| 375 |
| 376 void EGLImageTransportSurface::OnResizeViewACK() { |
| 377 NOTREACHED(); |
| 378 } |
| 379 |
372 GLXImageTransportSurface::GLXImageTransportSurface( | 380 GLXImageTransportSurface::GLXImageTransportSurface( |
373 GpuChannelManager* manager, | 381 GpuChannelManager* manager, |
374 int32 render_view_id, | 382 int32 render_view_id, |
375 int32 renderer_id, | 383 int32 renderer_id, |
376 int32 command_buffer_id) | 384 int32 command_buffer_id) |
377 : gfx::NativeViewGLSurfaceGLX(), | 385 : gfx::NativeViewGLSurfaceGLX(), |
378 dummy_parent_(0), | 386 dummy_parent_(0), |
379 size_(1, 1), | 387 size_(1, 1), |
380 bound_(false), | 388 bound_(false), |
381 made_current_(false) { | 389 made_current_(false) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { | 525 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { |
518 DCHECK(!bound_); | 526 DCHECK(!bound_); |
519 bound_ = true; | 527 bound_ = true; |
520 helper_->SetScheduled(true); | 528 helper_->SetScheduled(true); |
521 } | 529 } |
522 | 530 |
523 void GLXImageTransportSurface::OnBuffersSwappedACK() { | 531 void GLXImageTransportSurface::OnBuffersSwappedACK() { |
524 helper_->SetScheduled(true); | 532 helper_->SetScheduled(true); |
525 } | 533 } |
526 | 534 |
| 535 void GLXImageTransportSurface::OnResizeViewACK() { |
| 536 NOTREACHED(); |
| 537 } |
| 538 |
527 OSMesaImageTransportSurface::OSMesaImageTransportSurface( | 539 OSMesaImageTransportSurface::OSMesaImageTransportSurface( |
528 GpuChannelManager* manager, | 540 GpuChannelManager* manager, |
529 int32 render_view_id, | 541 int32 render_view_id, |
530 int32 renderer_id, | 542 int32 renderer_id, |
531 int32 command_buffer_id) | 543 int32 command_buffer_id) |
532 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), | 544 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), |
533 size_(gfx::Size(1, 1)) { | 545 size_(gfx::Size(1, 1)) { |
534 helper_.reset(new ImageTransportHelper(this, | 546 helper_.reset(new ImageTransportHelper(this, |
535 manager, | 547 manager, |
536 render_view_id, | 548 render_view_id, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 | 607 |
596 void OSMesaImageTransportSurface::OnNewSurfaceACK( | 608 void OSMesaImageTransportSurface::OnNewSurfaceACK( |
597 uint64 surface_id, TransportDIB::Handle surface_handle) { | 609 uint64 surface_id, TransportDIB::Handle surface_handle) { |
598 shared_id_ = surface_id; | 610 shared_id_ = surface_id; |
599 shared_mem_.reset(TransportDIB::Map(surface_handle)); | 611 shared_mem_.reset(TransportDIB::Map(surface_handle)); |
600 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 612 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
601 | 613 |
602 helper_->SetScheduled(true); | 614 helper_->SetScheduled(true); |
603 } | 615 } |
604 | 616 |
| 617 void OSMesaImageTransportSurface::OnResizeViewACK() { |
| 618 NOTREACHED(); |
| 619 } |
| 620 |
605 bool OSMesaImageTransportSurface::SwapBuffers() { | 621 bool OSMesaImageTransportSurface::SwapBuffers() { |
606 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 622 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
607 | 623 |
608 // Copy the OSMesa buffer to the shared memory | 624 // Copy the OSMesa buffer to the shared memory |
609 glFinish(); | 625 glFinish(); |
610 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); | 626 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); |
611 | 627 |
612 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 628 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
613 params.surface_id = shared_id_; | 629 params.surface_id = shared_id_; |
614 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 630 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
(...skipping 11 matching lines...) Expand all Loading... |
626 } | 642 } |
627 | 643 |
628 } // namespace | 644 } // namespace |
629 | 645 |
630 // static | 646 // static |
631 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 647 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
632 GpuChannelManager* manager, | 648 GpuChannelManager* manager, |
633 int32 render_view_id, | 649 int32 render_view_id, |
634 int32 renderer_id, | 650 int32 renderer_id, |
635 int32 command_buffer_id, | 651 int32 command_buffer_id, |
636 gfx::PluginWindowHandle /* handle */) { | 652 gfx::PluginWindowHandle handle) { |
637 scoped_refptr<gfx::GLSurface> surface; | 653 scoped_refptr<gfx::GLSurface> surface; |
| 654 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
638 switch (gfx::GetGLImplementation()) { | 655 switch (gfx::GetGLImplementation()) { |
639 case gfx::kGLImplementationDesktopGL: | 656 case gfx::kGLImplementationDesktopGL: |
640 surface = new GLXImageTransportSurface(manager, | 657 surface = new GLXImageTransportSurface(manager, |
641 render_view_id, | 658 render_view_id, |
642 renderer_id, | 659 renderer_id, |
643 command_buffer_id); | 660 command_buffer_id); |
644 break; | 661 break; |
645 case gfx::kGLImplementationEGLGLES2: | 662 case gfx::kGLImplementationEGLGLES2: |
646 surface = new EGLImageTransportSurface(manager, | 663 surface = new EGLImageTransportSurface(manager, |
647 render_view_id, | 664 render_view_id, |
648 renderer_id, | 665 renderer_id, |
649 command_buffer_id); | 666 command_buffer_id); |
650 break; | 667 break; |
651 case gfx::kGLImplementationOSMesaGL: | 668 case gfx::kGLImplementationOSMesaGL: |
652 surface = new OSMesaImageTransportSurface(manager, | 669 surface = new OSMesaImageTransportSurface(manager, |
653 render_view_id, | 670 render_view_id, |
654 renderer_id, | 671 renderer_id, |
655 command_buffer_id); | 672 command_buffer_id); |
656 break; | 673 break; |
657 default: | 674 default: |
658 NOTREACHED(); | 675 NOTREACHED(); |
659 return NULL; | 676 return NULL; |
660 } | 677 } |
| 678 #else |
| 679 surface = gfx::GLSurface::CreateViewGLSurface(false, handle); |
| 680 if (!surface.get()) |
| 681 return NULL; |
| 682 |
| 683 surface = new PassThroughImageTransportSurface(manager, |
| 684 render_view_id, |
| 685 renderer_id, |
| 686 command_buffer_id, |
| 687 surface.get()); |
| 688 #endif |
661 if (surface->Initialize()) | 689 if (surface->Initialize()) |
662 return surface; | 690 return surface; |
663 else | 691 else |
664 return NULL; | 692 return NULL; |
665 } | 693 } |
666 | 694 |
667 #endif // defined(USE_GPU) | 695 #endif // defined(USE_GPU) |
OLD | NEW |