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() { | |
jonathan.backer
2011/11/03 23:09:07
NOTREACHED?
| |
377 } | |
378 | |
372 GLXImageTransportSurface::GLXImageTransportSurface( | 379 GLXImageTransportSurface::GLXImageTransportSurface( |
373 GpuChannelManager* manager, | 380 GpuChannelManager* manager, |
374 int32 render_view_id, | 381 int32 render_view_id, |
375 int32 renderer_id, | 382 int32 renderer_id, |
376 int32 command_buffer_id) | 383 int32 command_buffer_id) |
377 : gfx::NativeViewGLSurfaceGLX(), | 384 : gfx::NativeViewGLSurfaceGLX(), |
378 dummy_parent_(0), | 385 dummy_parent_(0), |
379 size_(1, 1), | 386 size_(1, 1), |
380 bound_(false), | 387 bound_(false), |
381 made_current_(false) { | 388 made_current_(false) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { | 524 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { |
518 DCHECK(!bound_); | 525 DCHECK(!bound_); |
519 bound_ = true; | 526 bound_ = true; |
520 helper_->SetScheduled(true); | 527 helper_->SetScheduled(true); |
521 } | 528 } |
522 | 529 |
523 void GLXImageTransportSurface::OnBuffersSwappedACK() { | 530 void GLXImageTransportSurface::OnBuffersSwappedACK() { |
524 helper_->SetScheduled(true); | 531 helper_->SetScheduled(true); |
525 } | 532 } |
526 | 533 |
534 void GLXImageTransportSurface::OnResizeViewACK() { | |
535 } | |
jonathan.backer
2011/11/03 23:09:07
NOTREACHED()
| |
536 | |
527 OSMesaImageTransportSurface::OSMesaImageTransportSurface( | 537 OSMesaImageTransportSurface::OSMesaImageTransportSurface( |
528 GpuChannelManager* manager, | 538 GpuChannelManager* manager, |
529 int32 render_view_id, | 539 int32 render_view_id, |
530 int32 renderer_id, | 540 int32 renderer_id, |
531 int32 command_buffer_id) | 541 int32 command_buffer_id) |
532 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), | 542 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), |
533 size_(gfx::Size(1, 1)) { | 543 size_(gfx::Size(1, 1)) { |
534 helper_.reset(new ImageTransportHelper(this, | 544 helper_.reset(new ImageTransportHelper(this, |
535 manager, | 545 manager, |
536 render_view_id, | 546 render_view_id, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 | 605 |
596 void OSMesaImageTransportSurface::OnNewSurfaceACK( | 606 void OSMesaImageTransportSurface::OnNewSurfaceACK( |
597 uint64 surface_id, TransportDIB::Handle surface_handle) { | 607 uint64 surface_id, TransportDIB::Handle surface_handle) { |
598 shared_id_ = surface_id; | 608 shared_id_ = surface_id; |
599 shared_mem_.reset(TransportDIB::Map(surface_handle)); | 609 shared_mem_.reset(TransportDIB::Map(surface_handle)); |
600 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 610 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
601 | 611 |
602 helper_->SetScheduled(true); | 612 helper_->SetScheduled(true); |
603 } | 613 } |
604 | 614 |
615 void OSMesaImageTransportSurface::OnResizeViewACK() { | |
616 } | |
617 | |
jonathan.backer
2011/11/03 23:09:07
NOTREACHED()
| |
605 bool OSMesaImageTransportSurface::SwapBuffers() { | 618 bool OSMesaImageTransportSurface::SwapBuffers() { |
606 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 619 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
607 | 620 |
608 // Copy the OSMesa buffer to the shared memory | 621 // Copy the OSMesa buffer to the shared memory |
609 glFinish(); | 622 glFinish(); |
610 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); | 623 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); |
611 | 624 |
612 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 625 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
613 params.surface_id = shared_id_; | 626 params.surface_id = shared_id_; |
614 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 627 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
(...skipping 11 matching lines...) Expand all Loading... | |
626 } | 639 } |
627 | 640 |
628 } // namespace | 641 } // namespace |
629 | 642 |
630 // static | 643 // static |
631 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 644 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
632 GpuChannelManager* manager, | 645 GpuChannelManager* manager, |
633 int32 render_view_id, | 646 int32 render_view_id, |
634 int32 renderer_id, | 647 int32 renderer_id, |
635 int32 command_buffer_id, | 648 int32 command_buffer_id, |
636 gfx::PluginWindowHandle /* handle */) { | 649 gfx::PluginWindowHandle handle) { |
637 scoped_refptr<gfx::GLSurface> surface; | 650 scoped_refptr<gfx::GLSurface> surface; |
651 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | |
638 switch (gfx::GetGLImplementation()) { | 652 switch (gfx::GetGLImplementation()) { |
639 case gfx::kGLImplementationDesktopGL: | 653 case gfx::kGLImplementationDesktopGL: |
640 surface = new GLXImageTransportSurface(manager, | 654 surface = new GLXImageTransportSurface(manager, |
641 render_view_id, | 655 render_view_id, |
642 renderer_id, | 656 renderer_id, |
643 command_buffer_id); | 657 command_buffer_id); |
644 break; | 658 break; |
645 case gfx::kGLImplementationEGLGLES2: | 659 case gfx::kGLImplementationEGLGLES2: |
646 surface = new EGLImageTransportSurface(manager, | 660 surface = new EGLImageTransportSurface(manager, |
647 render_view_id, | 661 render_view_id, |
648 renderer_id, | 662 renderer_id, |
649 command_buffer_id); | 663 command_buffer_id); |
650 break; | 664 break; |
651 case gfx::kGLImplementationOSMesaGL: | 665 case gfx::kGLImplementationOSMesaGL: |
652 surface = new OSMesaImageTransportSurface(manager, | 666 surface = new OSMesaImageTransportSurface(manager, |
653 render_view_id, | 667 render_view_id, |
654 renderer_id, | 668 renderer_id, |
655 command_buffer_id); | 669 command_buffer_id); |
656 break; | 670 break; |
657 default: | 671 default: |
658 NOTREACHED(); | 672 NOTREACHED(); |
659 return NULL; | 673 return NULL; |
660 } | 674 } |
675 #else | |
676 surface = gfx::GLSurface::CreateViewGLSurface(false, handle); | |
677 if (!surface.get()) | |
678 return NULL; | |
679 | |
680 surface = new PassThroughImageTransportSurface(manager, | |
681 render_view_id, | |
682 renderer_id, | |
683 command_buffer_id, | |
684 surface.get()); | |
685 #endif | |
661 if (surface->Initialize()) | 686 if (surface->Initialize()) |
662 return surface; | 687 return surface; |
663 else | 688 else |
664 return NULL; | 689 return NULL; |
665 } | 690 } |
666 | 691 |
667 #endif // defined(USE_GPU) | 692 #endif // defined(USE_GPU) |
OLD | NEW |