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

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

Issue 8591006: 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 21 matching lines...) Expand all
111 virtual void Destroy() OVERRIDE; 112 virtual void Destroy() OVERRIDE;
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 116
116 protected: 117 protected:
117 // ImageTransportSurface implementation: 118 // ImageTransportSurface implementation:
118 virtual void OnNewSurfaceACK( 119 virtual void OnNewSurfaceACK(
119 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 120 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
120 virtual void OnBuffersSwappedACK() OVERRIDE; 121 virtual void OnBuffersSwappedACK() OVERRIDE;
122 virtual void OnResizeViewACK() OVERRIDE;
121 virtual void OnResize(gfx::Size size) OVERRIDE; 123 virtual void OnResize(gfx::Size size) OVERRIDE;
122 124
123 private: 125 private:
124 virtual ~GLXImageTransportSurface(); 126 virtual ~GLXImageTransportSurface();
125 127
126 // Tell the browser to release the surface. 128 // Tell the browser to release the surface.
127 void ReleaseSurface(); 129 void ReleaseSurface();
128 130
129 XID dummy_parent_; 131 XID dummy_parent_;
130 gfx::Size size_; 132 gfx::Size size_;
(...skipping 28 matching lines...) Expand all
159 virtual void Destroy() OVERRIDE; 161 virtual void Destroy() OVERRIDE;
160 virtual bool IsOffscreen() OVERRIDE; 162 virtual bool IsOffscreen() OVERRIDE;
161 virtual bool SwapBuffers() OVERRIDE; 163 virtual bool SwapBuffers() OVERRIDE;
162 virtual gfx::Size GetSize() OVERRIDE; 164 virtual gfx::Size GetSize() OVERRIDE;
163 165
164 protected: 166 protected:
165 // ImageTransportSurface implementation: 167 // ImageTransportSurface implementation:
166 virtual void OnNewSurfaceACK( 168 virtual void OnNewSurfaceACK(
167 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; 169 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE;
168 virtual void OnBuffersSwappedACK() OVERRIDE; 170 virtual void OnBuffersSwappedACK() OVERRIDE;
171 virtual void OnResizeViewACK() OVERRIDE;
169 virtual void OnResize(gfx::Size size) OVERRIDE; 172 virtual void OnResize(gfx::Size size) OVERRIDE;
170 173
171 private: 174 private:
172 virtual ~OSMesaImageTransportSurface(); 175 virtual ~OSMesaImageTransportSurface();
173 176
174 // Tell the browser to release the surface. 177 // Tell the browser to release the surface.
175 void ReleaseSurface(); 178 void ReleaseSurface();
176 179
177 scoped_ptr<TransportDIB> shared_mem_; 180 scoped_ptr<TransportDIB> shared_mem_;
178 uint32 shared_id_; 181 uint32 shared_id_;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 void EGLImageTransportSurface::OnNewSurfaceACK( 369 void EGLImageTransportSurface::OnNewSurfaceACK(
367 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { 370 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) {
368 DCHECK_EQ(back_surface_->pixmap(), surface_id); 371 DCHECK_EQ(back_surface_->pixmap(), surface_id);
369 helper_->SetScheduled(true); 372 helper_->SetScheduled(true);
370 } 373 }
371 374
372 void EGLImageTransportSurface::OnBuffersSwappedACK() { 375 void EGLImageTransportSurface::OnBuffersSwappedACK() {
373 helper_->SetScheduled(true); 376 helper_->SetScheduled(true);
374 } 377 }
375 378
379
380 void EGLImageTransportSurface::OnResizeViewACK() {
381 NOTREACHED();
382 }
383
376 GLXImageTransportSurface::GLXImageTransportSurface( 384 GLXImageTransportSurface::GLXImageTransportSurface(
377 GpuChannelManager* manager, 385 GpuChannelManager* manager,
378 int32 render_view_id, 386 int32 render_view_id,
379 int32 renderer_id, 387 int32 renderer_id,
380 int32 command_buffer_id) 388 int32 command_buffer_id)
381 : gfx::NativeViewGLSurfaceGLX(), 389 : gfx::NativeViewGLSurfaceGLX(),
382 dummy_parent_(0), 390 dummy_parent_(0),
383 size_(1, 1), 391 size_(1, 1),
384 bound_(false), 392 bound_(false),
385 needs_resize_(false), 393 needs_resize_(false),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 528 }
521 529
522 void GLXImageTransportSurface::OnNewSurfaceACK( 530 void GLXImageTransportSurface::OnNewSurfaceACK(
523 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { 531 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) {
524 } 532 }
525 533
526 void GLXImageTransportSurface::OnBuffersSwappedACK() { 534 void GLXImageTransportSurface::OnBuffersSwappedACK() {
527 helper_->SetScheduled(true); 535 helper_->SetScheduled(true);
528 } 536 }
529 537
538 void GLXImageTransportSurface::OnResizeViewACK() {
539 NOTREACHED();
540 }
541
530 OSMesaImageTransportSurface::OSMesaImageTransportSurface( 542 OSMesaImageTransportSurface::OSMesaImageTransportSurface(
531 GpuChannelManager* manager, 543 GpuChannelManager* manager,
532 int32 render_view_id, 544 int32 render_view_id,
533 int32 renderer_id, 545 int32 renderer_id,
534 int32 command_buffer_id) 546 int32 command_buffer_id)
535 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), 547 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)),
536 size_(gfx::Size(1, 1)) { 548 size_(gfx::Size(1, 1)) {
537 helper_.reset(new ImageTransportHelper(this, 549 helper_.reset(new ImageTransportHelper(this,
538 manager, 550 manager,
539 render_view_id, 551 render_view_id,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 610
599 void OSMesaImageTransportSurface::OnNewSurfaceACK( 611 void OSMesaImageTransportSurface::OnNewSurfaceACK(
600 uint64 surface_id, TransportDIB::Handle surface_handle) { 612 uint64 surface_id, TransportDIB::Handle surface_handle) {
601 shared_id_ = surface_id; 613 shared_id_ = surface_id;
602 shared_mem_.reset(TransportDIB::Map(surface_handle)); 614 shared_mem_.reset(TransportDIB::Map(surface_handle));
603 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); 615 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL));
604 616
605 helper_->SetScheduled(true); 617 helper_->SetScheduled(true);
606 } 618 }
607 619
620 void OSMesaImageTransportSurface::OnResizeViewACK() {
621 NOTREACHED();
622 }
623
608 bool OSMesaImageTransportSurface::SwapBuffers() { 624 bool OSMesaImageTransportSurface::SwapBuffers() {
609 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); 625 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL));
610 626
611 // Copy the OSMesa buffer to the shared memory 627 // Copy the OSMesa buffer to the shared memory
612 glFinish(); 628 glFinish();
613 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); 629 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4);
614 630
615 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 631 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
616 params.surface_id = shared_id_; 632 params.surface_id = shared_id_;
617 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 633 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
(...skipping 11 matching lines...) Expand all
629 } 645 }
630 646
631 } // namespace 647 } // namespace
632 648
633 // static 649 // static
634 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( 650 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
635 GpuChannelManager* manager, 651 GpuChannelManager* manager,
636 int32 render_view_id, 652 int32 render_view_id,
637 int32 renderer_id, 653 int32 renderer_id,
638 int32 command_buffer_id, 654 int32 command_buffer_id,
639 gfx::PluginWindowHandle /* handle */) { 655 gfx::PluginWindowHandle handle) {
640 scoped_refptr<gfx::GLSurface> surface; 656 scoped_refptr<gfx::GLSurface> surface;
657 #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT)
641 switch (gfx::GetGLImplementation()) { 658 switch (gfx::GetGLImplementation()) {
642 case gfx::kGLImplementationDesktopGL: 659 case gfx::kGLImplementationDesktopGL:
643 surface = new GLXImageTransportSurface(manager, 660 surface = new GLXImageTransportSurface(manager,
644 render_view_id, 661 render_view_id,
645 renderer_id, 662 renderer_id,
646 command_buffer_id); 663 command_buffer_id);
647 break; 664 break;
648 case gfx::kGLImplementationEGLGLES2: 665 case gfx::kGLImplementationEGLGLES2:
649 surface = new EGLImageTransportSurface(manager, 666 surface = new EGLImageTransportSurface(manager,
650 render_view_id, 667 render_view_id,
651 renderer_id, 668 renderer_id,
652 command_buffer_id); 669 command_buffer_id);
653 break; 670 break;
654 case gfx::kGLImplementationOSMesaGL: 671 case gfx::kGLImplementationOSMesaGL:
655 surface = new OSMesaImageTransportSurface(manager, 672 surface = new OSMesaImageTransportSurface(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 default: 677 default:
661 NOTREACHED(); 678 NOTREACHED();
662 return NULL; 679 return NULL;
663 } 680 }
681 #else
682 surface = gfx::GLSurface::CreateViewGLSurface(false, handle);
683 if (!surface.get())
684 return NULL;
685
686 surface = new PassThroughImageTransportSurface(manager,
687 render_view_id,
688 renderer_id,
689 command_buffer_id,
690 surface.get());
691 #endif
664 if (surface->Initialize()) 692 if (surface->Initialize())
665 return surface; 693 return surface;
666 else 694 else
667 return NULL; 695 return NULL;
668 } 696 }
669 697
670 #endif // defined(USE_GPU) 698 #endif // defined(USE_GPU)
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface.cc ('k') | content/common/gpu/image_transport_surface_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698