Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1106)

Side by Side Diff: content/common/gpu/image_transport_surface_linux.cc

Issue 8622004: Reland 110355 - Use shared D3D9 texture to transport the compositor's backing buffer to the brows... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 virtual gfx::Size GetSize() OVERRIDE; 70 virtual gfx::Size GetSize() OVERRIDE;
71 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 71 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
72 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; 72 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE;
73 virtual void SetVisible(bool visible) OVERRIDE; 73 virtual void SetVisible(bool visible) OVERRIDE;
74 74
75 protected: 75 protected:
76 // ImageTransportSurface implementation 76 // ImageTransportSurface implementation
77 virtual void OnNewSurfaceACK( 77 virtual void OnNewSurfaceACK(
78 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 78 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
79 virtual void OnBuffersSwappedACK() OVERRIDE; 79 virtual void OnBuffersSwappedACK() OVERRIDE;
80 virtual void OnResizeViewACK() OVERRIDE;
80 virtual void OnResize(gfx::Size size) OVERRIDE; 81 virtual void OnResize(gfx::Size size) OVERRIDE;
81 82
82 private: 83 private:
83 virtual ~EGLImageTransportSurface() OVERRIDE; 84 virtual ~EGLImageTransportSurface() OVERRIDE;
84 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); 85 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface);
85 86
86 uint32 fbo_id_; 87 uint32 fbo_id_;
87 88
88 scoped_refptr<EGLAcceleratedSurface> back_surface_; 89 scoped_refptr<EGLAcceleratedSurface> back_surface_;
89 scoped_refptr<EGLAcceleratedSurface> front_surface_; 90 scoped_refptr<EGLAcceleratedSurface> front_surface_;
(...skipping 22 matching lines...) Expand all
112 virtual bool SwapBuffers() OVERRIDE; 113 virtual bool SwapBuffers() OVERRIDE;
113 virtual gfx::Size GetSize() OVERRIDE; 114 virtual gfx::Size GetSize() OVERRIDE;
114 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; 115 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE;
115 virtual void SetVisible(bool visible) OVERRIDE; 116 virtual void SetVisible(bool visible) OVERRIDE;
116 117
117 protected: 118 protected:
118 // ImageTransportSurface implementation: 119 // ImageTransportSurface implementation:
119 virtual void OnNewSurfaceACK( 120 virtual void OnNewSurfaceACK(
120 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 121 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
121 virtual void OnBuffersSwappedACK() OVERRIDE; 122 virtual void OnBuffersSwappedACK() OVERRIDE;
123 virtual void OnResizeViewACK() OVERRIDE;
122 virtual void OnResize(gfx::Size size) OVERRIDE; 124 virtual void OnResize(gfx::Size size) OVERRIDE;
123 125
124 private: 126 private:
125 virtual ~GLXImageTransportSurface(); 127 virtual ~GLXImageTransportSurface();
126 128
127 // Tell the browser to release the surface. 129 // Tell the browser to release the surface.
128 void ReleaseSurface(); 130 void ReleaseSurface();
129 131
130 XID dummy_parent_; 132 XID dummy_parent_;
131 gfx::Size size_; 133 gfx::Size size_;
(...skipping 28 matching lines...) Expand all
160 virtual void Destroy() OVERRIDE; 162 virtual void Destroy() OVERRIDE;
161 virtual bool IsOffscreen() OVERRIDE; 163 virtual bool IsOffscreen() OVERRIDE;
162 virtual bool SwapBuffers() OVERRIDE; 164 virtual bool SwapBuffers() OVERRIDE;
163 virtual gfx::Size GetSize() OVERRIDE; 165 virtual gfx::Size GetSize() OVERRIDE;
164 166
165 protected: 167 protected:
166 // ImageTransportSurface implementation: 168 // ImageTransportSurface implementation:
167 virtual void OnNewSurfaceACK( 169 virtual void OnNewSurfaceACK(
168 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 170 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
169 virtual void OnBuffersSwappedACK() OVERRIDE; 171 virtual void OnBuffersSwappedACK() OVERRIDE;
172 virtual void OnResizeViewACK() OVERRIDE;
170 virtual void OnResize(gfx::Size size) OVERRIDE; 173 virtual void OnResize(gfx::Size size) OVERRIDE;
171 174
172 private: 175 private:
173 virtual ~OSMesaImageTransportSurface(); 176 virtual ~OSMesaImageTransportSurface();
174 177
175 // Tell the browser to release the surface. 178 // Tell the browser to release the surface.
176 void ReleaseSurface(); 179 void ReleaseSurface();
177 180
178 scoped_ptr<TransportDIB> shared_mem_; 181 scoped_ptr<TransportDIB> shared_mem_;
179 uint32 shared_id_; 182 uint32 shared_id_;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 void EGLImageTransportSurface::OnNewSurfaceACK( 370 void EGLImageTransportSurface::OnNewSurfaceACK(
368 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { 371 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) {
369 DCHECK_EQ(back_surface_->pixmap(), surface_id); 372 DCHECK_EQ(back_surface_->pixmap(), surface_id);
370 helper_->SetScheduled(true); 373 helper_->SetScheduled(true);
371 } 374 }
372 375
373 void EGLImageTransportSurface::OnBuffersSwappedACK() { 376 void EGLImageTransportSurface::OnBuffersSwappedACK() {
374 helper_->SetScheduled(true); 377 helper_->SetScheduled(true);
375 } 378 }
376 379
380
381 void EGLImageTransportSurface::OnResizeViewACK() {
382 NOTREACHED();
383 }
384
377 GLXImageTransportSurface::GLXImageTransportSurface( 385 GLXImageTransportSurface::GLXImageTransportSurface(
378 GpuChannelManager* manager, 386 GpuChannelManager* manager,
379 int32 render_view_id, 387 int32 render_view_id,
380 int32 renderer_id, 388 int32 renderer_id,
381 int32 command_buffer_id) 389 int32 command_buffer_id)
382 : gfx::NativeViewGLSurfaceGLX(), 390 : gfx::NativeViewGLSurfaceGLX(),
383 dummy_parent_(0), 391 dummy_parent_(0),
384 size_(1, 1), 392 size_(1, 1),
385 bound_(false), 393 bound_(false),
386 needs_resize_(false), 394 needs_resize_(false),
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 540 }
533 541
534 void GLXImageTransportSurface::OnNewSurfaceACK( 542 void GLXImageTransportSurface::OnNewSurfaceACK(
535 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { 543 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) {
536 } 544 }
537 545
538 void GLXImageTransportSurface::OnBuffersSwappedACK() { 546 void GLXImageTransportSurface::OnBuffersSwappedACK() {
539 helper_->SetScheduled(true); 547 helper_->SetScheduled(true);
540 } 548 }
541 549
550 void GLXImageTransportSurface::OnResizeViewACK() {
551 NOTREACHED();
552 }
553
542 OSMesaImageTransportSurface::OSMesaImageTransportSurface( 554 OSMesaImageTransportSurface::OSMesaImageTransportSurface(
543 GpuChannelManager* manager, 555 GpuChannelManager* manager,
544 int32 render_view_id, 556 int32 render_view_id,
545 int32 renderer_id, 557 int32 renderer_id,
546 int32 command_buffer_id) 558 int32 command_buffer_id)
547 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), 559 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)),
548 size_(gfx::Size(1, 1)) { 560 size_(gfx::Size(1, 1)) {
549 helper_.reset(new ImageTransportHelper(this, 561 helper_.reset(new ImageTransportHelper(this,
550 manager, 562 manager,
551 render_view_id, 563 render_view_id,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 622
611 void OSMesaImageTransportSurface::OnNewSurfaceACK( 623 void OSMesaImageTransportSurface::OnNewSurfaceACK(
612 uint64 surface_id, TransportDIB::Handle surface_handle) { 624 uint64 surface_id, TransportDIB::Handle surface_handle) {
613 shared_id_ = surface_id; 625 shared_id_ = surface_id;
614 shared_mem_.reset(TransportDIB::Map(surface_handle)); 626 shared_mem_.reset(TransportDIB::Map(surface_handle));
615 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); 627 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL));
616 628
617 helper_->SetScheduled(true); 629 helper_->SetScheduled(true);
618 } 630 }
619 631
632 void OSMesaImageTransportSurface::OnResizeViewACK() {
633 NOTREACHED();
634 }
635
620 bool OSMesaImageTransportSurface::SwapBuffers() { 636 bool OSMesaImageTransportSurface::SwapBuffers() {
621 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); 637 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL));
622 638
623 // Copy the OSMesa buffer to the shared memory 639 // Copy the OSMesa buffer to the shared memory
624 glFinish(); 640 glFinish();
625 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); 641 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4);
626 642
627 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 643 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
628 params.surface_id = shared_id_; 644 params.surface_id = shared_id_;
629 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 645 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
(...skipping 11 matching lines...) Expand all
641 } 657 }
642 658
643 } // namespace 659 } // namespace
644 660
645 // static 661 // static
646 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( 662 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
647 GpuChannelManager* manager, 663 GpuChannelManager* manager,
648 int32 render_view_id, 664 int32 render_view_id,
649 int32 renderer_id, 665 int32 renderer_id,
650 int32 command_buffer_id, 666 int32 command_buffer_id,
651 gfx::PluginWindowHandle /* handle */) { 667 gfx::PluginWindowHandle handle) {
652 scoped_refptr<gfx::GLSurface> surface; 668 scoped_refptr<gfx::GLSurface> surface;
669 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
653 switch (gfx::GetGLImplementation()) { 670 switch (gfx::GetGLImplementation()) {
654 case gfx::kGLImplementationDesktopGL: 671 case gfx::kGLImplementationDesktopGL:
655 surface = new GLXImageTransportSurface(manager, 672 surface = new GLXImageTransportSurface(manager,
656 render_view_id, 673 render_view_id,
657 renderer_id, 674 renderer_id,
658 command_buffer_id); 675 command_buffer_id);
659 break; 676 break;
660 case gfx::kGLImplementationEGLGLES2: 677 case gfx::kGLImplementationEGLGLES2:
661 surface = new EGLImageTransportSurface(manager, 678 surface = new EGLImageTransportSurface(manager,
662 render_view_id, 679 render_view_id,
663 renderer_id, 680 renderer_id,
664 command_buffer_id); 681 command_buffer_id);
665 break; 682 break;
666 case gfx::kGLImplementationOSMesaGL: 683 case gfx::kGLImplementationOSMesaGL:
667 surface = new OSMesaImageTransportSurface(manager, 684 surface = new OSMesaImageTransportSurface(manager,
668 render_view_id, 685 render_view_id,
669 renderer_id, 686 renderer_id,
670 command_buffer_id); 687 command_buffer_id);
671 break; 688 break;
672 default: 689 default:
673 NOTREACHED(); 690 NOTREACHED();
674 return NULL; 691 return NULL;
675 } 692 }
693 #else
694 surface = gfx::GLSurface::CreateViewGLSurface(false, handle);
695 if (!surface.get())
696 return NULL;
697
698 surface = new PassThroughImageTransportSurface(manager,
699 render_view_id,
700 renderer_id,
701 command_buffer_id,
702 surface.get());
703 #endif
676 if (surface->Initialize()) 704 if (surface->Initialize())
677 return surface; 705 return surface;
678 else 706 else
679 return NULL; 707 return NULL;
680 } 708 }
681 709
682 #endif // defined(USE_GPU) 710 #endif // defined(USE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698