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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // We are backed by an Pbuffer offscreen surface for the purposes of creating a | 55 // We are backed by an Pbuffer offscreen surface for the purposes of creating a |
56 // context, but use FBOs to render to X Pixmap backed EGLImages. | 56 // context, but use FBOs to render to X Pixmap backed EGLImages. |
57 class EGLImageTransportSurface : public ImageTransportSurface, | 57 class EGLImageTransportSurface : public ImageTransportSurface, |
58 public gfx::PbufferGLSurfaceEGL { | 58 public gfx::PbufferGLSurfaceEGL { |
59 public: | 59 public: |
60 EGLImageTransportSurface(GpuChannelManager* manager, | 60 EGLImageTransportSurface(GpuChannelManager* manager, |
61 int32 render_view_id, | 61 int32 render_view_id, |
62 int32 renderer_id, | 62 int32 renderer_id, |
63 int32 command_buffer_id); | 63 int32 command_buffer_id); |
64 | 64 |
65 // GLSurface implementation | 65 // gfx::GLSurface implementation |
66 virtual bool Initialize() OVERRIDE; | 66 virtual bool Initialize() OVERRIDE; |
67 virtual void Destroy() OVERRIDE; | 67 virtual void Destroy() OVERRIDE; |
68 virtual bool IsOffscreen() OVERRIDE; | 68 virtual bool IsOffscreen() OVERRIDE; |
69 virtual bool SwapBuffers() OVERRIDE; | 69 virtual bool SwapBuffers() OVERRIDE; |
70 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 70 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
71 virtual std::string GetExtensions() OVERRIDE; | 71 virtual std::string GetExtensions() OVERRIDE; |
72 virtual gfx::Size GetSize() OVERRIDE; | 72 virtual gfx::Size GetSize() OVERRIDE; |
73 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 73 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
74 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 74 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
75 virtual void SetVisible(bool visible) OVERRIDE; | 75 virtual void SetVisible(bool visible) OVERRIDE; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 GLXImageTransportSurface(GpuChannelManager* manager, | 108 GLXImageTransportSurface(GpuChannelManager* manager, |
109 int32 render_view_id, | 109 int32 render_view_id, |
110 int32 renderer_id, | 110 int32 renderer_id, |
111 int32 command_buffer_id); | 111 int32 command_buffer_id); |
112 | 112 |
113 // gfx::GLSurface implementation: | 113 // gfx::GLSurface implementation: |
114 virtual bool Initialize() OVERRIDE; | 114 virtual bool Initialize() OVERRIDE; |
115 virtual void Destroy() OVERRIDE; | 115 virtual void Destroy() OVERRIDE; |
116 virtual bool SwapBuffers() OVERRIDE; | 116 virtual bool SwapBuffers() OVERRIDE; |
117 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 117 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
| 118 virtual std::string GetExtensions(); |
118 virtual gfx::Size GetSize() OVERRIDE; | 119 virtual gfx::Size GetSize() OVERRIDE; |
119 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 120 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
120 virtual void SetVisible(bool visible) OVERRIDE; | 121 virtual void SetVisible(bool visible) OVERRIDE; |
121 | 122 |
122 protected: | 123 protected: |
123 // ImageTransportSurface implementation: | 124 // ImageTransportSurface implementation: |
124 virtual void OnNewSurfaceACK( | 125 virtual void OnNewSurfaceACK( |
125 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 126 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
126 virtual void OnBuffersSwappedACK() OVERRIDE; | 127 virtual void OnBuffersSwappedACK() OVERRIDE; |
127 virtual void OnPostSubBufferACK() OVERRIDE; | 128 virtual void OnPostSubBufferACK() OVERRIDE; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 gfx::kNullPluginWindow)); | 248 gfx::kNullPluginWindow)); |
248 } | 249 } |
249 | 250 |
250 EGLImageTransportSurface::~EGLImageTransportSurface() { | 251 EGLImageTransportSurface::~EGLImageTransportSurface() { |
251 Destroy(); | 252 Destroy(); |
252 } | 253 } |
253 | 254 |
254 bool EGLImageTransportSurface::Initialize() { | 255 bool EGLImageTransportSurface::Initialize() { |
255 if (!helper_->Initialize()) | 256 if (!helper_->Initialize()) |
256 return false; | 257 return false; |
257 return PbufferGLSurfaceEGL::Initialize(); | 258 return gfx::PbufferGLSurfaceEGL::Initialize(); |
258 } | 259 } |
259 | 260 |
260 void EGLImageTransportSurface::Destroy() { | 261 void EGLImageTransportSurface::Destroy() { |
261 if (back_surface_.get()) | 262 if (back_surface_.get()) |
262 ReleaseSurface(&back_surface_); | 263 ReleaseSurface(&back_surface_); |
263 if (front_surface_.get()) | 264 if (front_surface_.get()) |
264 ReleaseSurface(&front_surface_); | 265 ReleaseSurface(&front_surface_); |
265 | 266 |
266 helper_->Destroy(); | 267 helper_->Destroy(); |
267 PbufferGLSurfaceEGL::Destroy(); | 268 gfx::PbufferGLSurfaceEGL::Destroy(); |
268 } | 269 } |
269 | 270 |
270 // Make sure that buffer swaps occur for the surface, so we can send the data | 271 // Make sure that buffer swaps occur for the surface, so we can send the data |
271 // to the actual onscreen surface in the browser | 272 // to the actual onscreen surface in the browser |
272 bool EGLImageTransportSurface::IsOffscreen() { | 273 bool EGLImageTransportSurface::IsOffscreen() { |
273 return false; | 274 return false; |
274 } | 275 } |
275 | 276 |
276 bool EGLImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 277 bool EGLImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
277 if (made_current_) | 278 if (made_current_) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 return true; | 372 return true; |
372 } | 373 } |
373 | 374 |
374 bool EGLImageTransportSurface::PostSubBuffer( | 375 bool EGLImageTransportSurface::PostSubBuffer( |
375 int x, int y, int width, int height) { | 376 int x, int y, int width, int height) { |
376 NOTREACHED(); | 377 NOTREACHED(); |
377 return false; | 378 return false; |
378 } | 379 } |
379 | 380 |
380 std::string EGLImageTransportSurface::GetExtensions() { | 381 std::string EGLImageTransportSurface::GetExtensions() { |
381 return GLSurface::GetExtensions(); | 382 std::string extensions = gfx::GLSurface::GetExtensions(); |
| 383 extensions += extensions.empty() ? "" : " "; |
| 384 extensions += "GL_CHROMIUM_front_buffer_cached"; |
| 385 return extensions; |
382 } | 386 } |
383 | 387 |
384 gfx::Size EGLImageTransportSurface::GetSize() { | 388 gfx::Size EGLImageTransportSurface::GetSize() { |
385 return back_surface_->size(); | 389 return back_surface_->size(); |
386 } | 390 } |
387 | 391 |
388 void EGLImageTransportSurface::OnNewSurfaceACK( | 392 void EGLImageTransportSurface::OnNewSurfaceACK( |
389 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { | 393 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { |
390 DCHECK_EQ(back_surface_->pixmap(), surface_id); | 394 DCHECK_EQ(back_surface_->pixmap(), surface_id); |
391 helper_->SetScheduled(true); | 395 helper_->SetScheduled(true); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 params.y = y; | 559 params.y = y; |
556 params.width = width; | 560 params.width = width; |
557 params.height = height; | 561 params.height = height; |
558 | 562 |
559 helper_->SendAcceleratedSurfacePostSubBuffer(params); | 563 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
560 | 564 |
561 helper_->SetScheduled(false); | 565 helper_->SetScheduled(false); |
562 return true; | 566 return true; |
563 } | 567 } |
564 | 568 |
| 569 std::string GLXImageTransportSurface::GetExtensions() { |
| 570 std::string extensions = gfx::NativeViewGLSurfaceGLX::GetExtensions(); |
| 571 extensions += extensions.empty() ? "" : " "; |
| 572 extensions += "GL_CHROMIUM_front_buffer_cached"; |
| 573 return extensions; |
| 574 } |
| 575 |
565 gfx::Size GLXImageTransportSurface::GetSize() { | 576 gfx::Size GLXImageTransportSurface::GetSize() { |
566 return size_; | 577 return size_; |
567 } | 578 } |
568 | 579 |
569 bool GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 580 bool GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
570 if (made_current_) | 581 if (made_current_) |
571 return true; | 582 return true; |
572 | 583 |
573 // Check for driver support. | 584 // Check for driver support. |
574 Display* dpy = static_cast<Display*>(GetDisplay()); | 585 Display* dpy = static_cast<Display*>(GetDisplay()); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 return true; | 712 return true; |
702 } | 713 } |
703 | 714 |
704 bool OSMesaImageTransportSurface::PostSubBuffer( | 715 bool OSMesaImageTransportSurface::PostSubBuffer( |
705 int x, int y, int width, int height) { | 716 int x, int y, int width, int height) { |
706 NOTREACHED(); | 717 NOTREACHED(); |
707 return false; | 718 return false; |
708 } | 719 } |
709 | 720 |
710 std::string OSMesaImageTransportSurface::GetExtensions() { | 721 std::string OSMesaImageTransportSurface::GetExtensions() { |
711 return GLSurface::GetExtensions(); | 722 std::string extensions = gfx::GLSurface::GetExtensions(); |
| 723 extensions += extensions.empty() ? "" : " "; |
| 724 extensions += "GL_CHROMIUM_front_buffer_cached"; |
| 725 return extensions; |
712 } | 726 } |
713 | 727 |
714 void OSMesaImageTransportSurface::OnBuffersSwappedACK() { | 728 void OSMesaImageTransportSurface::OnBuffersSwappedACK() { |
715 helper_->SetScheduled(true); | 729 helper_->SetScheduled(true); |
716 } | 730 } |
717 | 731 |
718 void OSMesaImageTransportSurface::OnPostSubBufferACK() { | 732 void OSMesaImageTransportSurface::OnPostSubBufferACK() { |
719 NOTREACHED(); | 733 NOTREACHED(); |
720 } | 734 } |
721 | 735 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 command_buffer_id, | 782 command_buffer_id, |
769 surface.get()); | 783 surface.get()); |
770 #endif | 784 #endif |
771 if (surface->Initialize()) | 785 if (surface->Initialize()) |
772 return surface; | 786 return surface; |
773 else | 787 else |
774 return NULL; | 788 return NULL; |
775 } | 789 } |
776 | 790 |
777 #endif // defined(USE_GPU) | 791 #endif // defined(USE_GPU) |
OLD | NEW |