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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // 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; |
| 71 virtual std::string GetExtensions() OVERRIDE; |
70 virtual gfx::Size GetSize() OVERRIDE; | 72 virtual gfx::Size GetSize() OVERRIDE; |
71 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 73 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
72 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 74 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
73 virtual void SetVisible(bool visible) OVERRIDE; | 75 virtual void SetVisible(bool visible) OVERRIDE; |
74 | 76 |
75 protected: | 77 protected: |
76 // ImageTransportSurface implementation | 78 // ImageTransportSurface implementation |
77 virtual void OnNewSurfaceACK( | 79 virtual void OnNewSurfaceACK( |
78 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 80 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
79 virtual void OnBuffersSwappedACK() OVERRIDE; | 81 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 82 virtual void OnPostSubBufferACK() OVERRIDE; |
80 virtual void OnResizeViewACK() OVERRIDE; | 83 virtual void OnResizeViewACK() OVERRIDE; |
81 virtual void OnResize(gfx::Size size) OVERRIDE; | 84 virtual void OnResize(gfx::Size size) OVERRIDE; |
82 | 85 |
83 private: | 86 private: |
84 virtual ~EGLImageTransportSurface() OVERRIDE; | 87 virtual ~EGLImageTransportSurface() OVERRIDE; |
85 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); | 88 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); |
86 | 89 |
87 uint32 fbo_id_; | 90 uint32 fbo_id_; |
88 | 91 |
89 scoped_refptr<EGLAcceleratedSurface> back_surface_; | 92 scoped_refptr<EGLAcceleratedSurface> back_surface_; |
(...skipping 14 matching lines...) Expand all Loading... |
104 public: | 107 public: |
105 GLXImageTransportSurface(GpuChannelManager* manager, | 108 GLXImageTransportSurface(GpuChannelManager* manager, |
106 int32 render_view_id, | 109 int32 render_view_id, |
107 int32 renderer_id, | 110 int32 renderer_id, |
108 int32 command_buffer_id); | 111 int32 command_buffer_id); |
109 | 112 |
110 // gfx::GLSurface implementation: | 113 // gfx::GLSurface implementation: |
111 virtual bool Initialize() OVERRIDE; | 114 virtual bool Initialize() OVERRIDE; |
112 virtual void Destroy() OVERRIDE; | 115 virtual void Destroy() OVERRIDE; |
113 virtual bool SwapBuffers() OVERRIDE; | 116 virtual bool SwapBuffers() OVERRIDE; |
| 117 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
114 virtual gfx::Size GetSize() OVERRIDE; | 118 virtual gfx::Size GetSize() OVERRIDE; |
115 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 119 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
116 virtual void SetVisible(bool visible) OVERRIDE; | 120 virtual void SetVisible(bool visible) OVERRIDE; |
117 | 121 |
118 protected: | 122 protected: |
119 // ImageTransportSurface implementation: | 123 // ImageTransportSurface implementation: |
120 virtual void OnNewSurfaceACK( | 124 virtual void OnNewSurfaceACK( |
121 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 125 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
122 virtual void OnBuffersSwappedACK() OVERRIDE; | 126 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 127 virtual void OnPostSubBufferACK() OVERRIDE; |
123 virtual void OnResizeViewACK() OVERRIDE; | 128 virtual void OnResizeViewACK() OVERRIDE; |
124 virtual void OnResize(gfx::Size size) OVERRIDE; | 129 virtual void OnResize(gfx::Size size) OVERRIDE; |
125 | 130 |
126 private: | 131 private: |
127 virtual ~GLXImageTransportSurface(); | 132 virtual ~GLXImageTransportSurface(); |
128 | 133 |
129 // Tell the browser to release the surface. | 134 // Tell the browser to release the surface. |
130 void ReleaseSurface(); | 135 void ReleaseSurface(); |
131 | 136 |
132 XID dummy_parent_; | 137 XID dummy_parent_; |
(...skipping 22 matching lines...) Expand all Loading... |
155 OSMesaImageTransportSurface(GpuChannelManager* manager, | 160 OSMesaImageTransportSurface(GpuChannelManager* manager, |
156 int32 render_view_id, | 161 int32 render_view_id, |
157 int32 renderer_id, | 162 int32 renderer_id, |
158 int32 command_buffer_id); | 163 int32 command_buffer_id); |
159 | 164 |
160 // gfx::GLSurface implementation: | 165 // gfx::GLSurface implementation: |
161 virtual bool Initialize() OVERRIDE; | 166 virtual bool Initialize() OVERRIDE; |
162 virtual void Destroy() OVERRIDE; | 167 virtual void Destroy() OVERRIDE; |
163 virtual bool IsOffscreen() OVERRIDE; | 168 virtual bool IsOffscreen() OVERRIDE; |
164 virtual bool SwapBuffers() OVERRIDE; | 169 virtual bool SwapBuffers() OVERRIDE; |
| 170 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
| 171 virtual std::string GetExtensions() OVERRIDE; |
165 virtual gfx::Size GetSize() OVERRIDE; | 172 virtual gfx::Size GetSize() OVERRIDE; |
166 | 173 |
167 protected: | 174 protected: |
168 // ImageTransportSurface implementation: | 175 // ImageTransportSurface implementation: |
169 virtual void OnNewSurfaceACK( | 176 virtual void OnNewSurfaceACK( |
170 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 177 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
171 virtual void OnBuffersSwappedACK() OVERRIDE; | 178 virtual void OnBuffersSwappedACK() OVERRIDE; |
| 179 virtual void OnPostSubBufferACK() OVERRIDE; |
172 virtual void OnResizeViewACK() OVERRIDE; | 180 virtual void OnResizeViewACK() OVERRIDE; |
173 virtual void OnResize(gfx::Size size) OVERRIDE; | 181 virtual void OnResize(gfx::Size size) OVERRIDE; |
174 | 182 |
175 private: | 183 private: |
176 virtual ~OSMesaImageTransportSurface(); | 184 virtual ~OSMesaImageTransportSurface(); |
177 | 185 |
178 // Tell the browser to release the surface. | 186 // Tell the browser to release the surface. |
179 void ReleaseSurface(); | 187 void ReleaseSurface(); |
180 | 188 |
181 scoped_ptr<TransportDIB> shared_mem_; | 189 scoped_ptr<TransportDIB> shared_mem_; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, | 364 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, |
357 GL_COLOR_ATTACHMENT0, | 365 GL_COLOR_ATTACHMENT0, |
358 GL_TEXTURE_2D, | 366 GL_TEXTURE_2D, |
359 back_surface_->texture(), | 367 back_surface_->texture(), |
360 0); | 368 0); |
361 } | 369 } |
362 helper_->SetScheduled(false); | 370 helper_->SetScheduled(false); |
363 return true; | 371 return true; |
364 } | 372 } |
365 | 373 |
| 374 bool EGLImageTransportSurface::PostSubBuffer( |
| 375 int x, int y, int width, int height) { |
| 376 NOTREACHED(); |
| 377 return false; |
| 378 } |
| 379 |
| 380 std::string EGLImageTransportSurface::GetExtensions() { |
| 381 return GLSurface::GetExtensions(); |
| 382 } |
| 383 |
366 gfx::Size EGLImageTransportSurface::GetSize() { | 384 gfx::Size EGLImageTransportSurface::GetSize() { |
367 return back_surface_->size(); | 385 return back_surface_->size(); |
368 } | 386 } |
369 | 387 |
370 void EGLImageTransportSurface::OnNewSurfaceACK( | 388 void EGLImageTransportSurface::OnNewSurfaceACK( |
371 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { | 389 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { |
372 DCHECK_EQ(back_surface_->pixmap(), surface_id); | 390 DCHECK_EQ(back_surface_->pixmap(), surface_id); |
373 helper_->SetScheduled(true); | 391 helper_->SetScheduled(true); |
374 } | 392 } |
375 | 393 |
376 void EGLImageTransportSurface::OnBuffersSwappedACK() { | 394 void EGLImageTransportSurface::OnBuffersSwappedACK() { |
377 helper_->SetScheduled(true); | 395 helper_->SetScheduled(true); |
378 } | 396 } |
379 | 397 |
| 398 void EGLImageTransportSurface::OnPostSubBufferACK() { |
| 399 NOTREACHED(); |
| 400 } |
380 | 401 |
381 void EGLImageTransportSurface::OnResizeViewACK() { | 402 void EGLImageTransportSurface::OnResizeViewACK() { |
382 NOTREACHED(); | 403 NOTREACHED(); |
383 } | 404 } |
384 | 405 |
385 GLXImageTransportSurface::GLXImageTransportSurface( | 406 GLXImageTransportSurface::GLXImageTransportSurface( |
386 GpuChannelManager* manager, | 407 GpuChannelManager* manager, |
387 int32 render_view_id, | 408 int32 render_view_id, |
388 int32 renderer_id, | 409 int32 renderer_id, |
389 int32 command_buffer_id) | 410 int32 command_buffer_id) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 } | 527 } |
507 | 528 |
508 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 529 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
509 params.surface_id = window_; | 530 params.surface_id = window_; |
510 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 531 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
511 | 532 |
512 helper_->SetScheduled(false); | 533 helper_->SetScheduled(false); |
513 return true; | 534 return true; |
514 } | 535 } |
515 | 536 |
| 537 bool GLXImageTransportSurface::PostSubBuffer( |
| 538 int x, int y, int width, int height) { |
| 539 gfx::NativeViewGLSurfaceGLX::PostSubBuffer(x, y, width, height); |
| 540 glFlush(); |
| 541 |
| 542 if (needs_resize_) { |
| 543 GpuHostMsg_AcceleratedSurfaceNew_Params params; |
| 544 params.width = size_.width(); |
| 545 params.height = size_.height(); |
| 546 params.surface_id = window_; |
| 547 helper_->SendAcceleratedSurfaceNew(params); |
| 548 bound_ = true; |
| 549 needs_resize_ = false; |
| 550 } |
| 551 |
| 552 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; |
| 553 params.surface_id = window_; |
| 554 params.x = x; |
| 555 params.y = y; |
| 556 params.width = width; |
| 557 params.height = height; |
| 558 |
| 559 helper_->SendAcceleratedSurfacePostSubBuffer(params); |
| 560 |
| 561 helper_->SetScheduled(false); |
| 562 return true; |
| 563 } |
| 564 |
516 gfx::Size GLXImageTransportSurface::GetSize() { | 565 gfx::Size GLXImageTransportSurface::GetSize() { |
517 return size_; | 566 return size_; |
518 } | 567 } |
519 | 568 |
520 bool GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { | 569 bool GLXImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { |
521 if (made_current_) | 570 if (made_current_) |
522 return true; | 571 return true; |
523 | 572 |
524 // Check for driver support. | 573 // Check for driver support. |
525 Display* dpy = static_cast<Display*>(GetDisplay()); | 574 Display* dpy = static_cast<Display*>(GetDisplay()); |
(...skipping 14 matching lines...) Expand all Loading... |
540 } | 589 } |
541 | 590 |
542 void GLXImageTransportSurface::OnNewSurfaceACK( | 591 void GLXImageTransportSurface::OnNewSurfaceACK( |
543 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { | 592 uint64 surface_id, TransportDIB::Handle /*surface_handle*/) { |
544 } | 593 } |
545 | 594 |
546 void GLXImageTransportSurface::OnBuffersSwappedACK() { | 595 void GLXImageTransportSurface::OnBuffersSwappedACK() { |
547 helper_->SetScheduled(true); | 596 helper_->SetScheduled(true); |
548 } | 597 } |
549 | 598 |
| 599 void GLXImageTransportSurface::OnPostSubBufferACK() { |
| 600 helper_->SetScheduled(true); |
| 601 } |
| 602 |
550 void GLXImageTransportSurface::OnResizeViewACK() { | 603 void GLXImageTransportSurface::OnResizeViewACK() { |
551 NOTREACHED(); | 604 NOTREACHED(); |
552 } | 605 } |
553 | 606 |
554 OSMesaImageTransportSurface::OSMesaImageTransportSurface( | 607 OSMesaImageTransportSurface::OSMesaImageTransportSurface( |
555 GpuChannelManager* manager, | 608 GpuChannelManager* manager, |
556 int32 render_view_id, | 609 int32 render_view_id, |
557 int32 renderer_id, | 610 int32 renderer_id, |
558 int32 command_buffer_id) | 611 int32 command_buffer_id) |
559 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), | 612 : gfx::GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); | 694 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); |
642 | 695 |
643 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 696 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
644 params.surface_id = shared_id_; | 697 params.surface_id = shared_id_; |
645 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 698 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
646 | 699 |
647 helper_->SetScheduled(false); | 700 helper_->SetScheduled(false); |
648 return true; | 701 return true; |
649 } | 702 } |
650 | 703 |
| 704 bool OSMesaImageTransportSurface::PostSubBuffer( |
| 705 int x, int y, int width, int height) { |
| 706 NOTREACHED(); |
| 707 return false; |
| 708 } |
| 709 |
| 710 std::string OSMesaImageTransportSurface::GetExtensions() { |
| 711 return GLSurface::GetExtensions(); |
| 712 } |
| 713 |
651 void OSMesaImageTransportSurface::OnBuffersSwappedACK() { | 714 void OSMesaImageTransportSurface::OnBuffersSwappedACK() { |
652 helper_->SetScheduled(true); | 715 helper_->SetScheduled(true); |
653 } | 716 } |
654 | 717 |
| 718 void OSMesaImageTransportSurface::OnPostSubBufferACK() { |
| 719 NOTREACHED(); |
| 720 } |
| 721 |
655 gfx::Size OSMesaImageTransportSurface::GetSize() { | 722 gfx::Size OSMesaImageTransportSurface::GetSize() { |
656 return size_; | 723 return size_; |
657 } | 724 } |
658 | 725 |
659 } // namespace | 726 } // namespace |
660 | 727 |
661 // static | 728 // static |
662 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 729 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
663 GpuChannelManager* manager, | 730 GpuChannelManager* manager, |
664 int32 render_view_id, | 731 int32 render_view_id, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 command_buffer_id, | 768 command_buffer_id, |
702 surface.get()); | 769 surface.get()); |
703 #endif | 770 #endif |
704 if (surface->Initialize()) | 771 if (surface->Initialize()) |
705 return surface; | 772 return surface; |
706 else | 773 else |
707 return NULL; | 774 return NULL; |
708 } | 775 } |
709 | 776 |
710 #endif // defined(USE_GPU) | 777 #endif // defined(USE_GPU) |
OLD | NEW |