OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/common/gpu/image_transport_surface.h" | 5 #include "content/common/gpu/image_transport_surface.h" |
6 | 6 |
7 // This conflicts with the defines in Xlib.h and must come first. | 7 // This conflicts with the defines in Xlib.h and must come first. |
8 #include "content/common/gpu/gpu_messages.h" | 8 #include "content/common/gpu/gpu_messages.h" |
9 | 9 |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; | 96 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; |
97 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; | 97 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
98 | 98 |
99 protected: | 99 protected: |
100 // ImageTransportSurface implementation | 100 // ImageTransportSurface implementation |
101 virtual void OnNewSurfaceACK( | 101 virtual void OnNewSurfaceACK( |
102 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; | 102 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
103 virtual void OnBuffersSwappedACK() OVERRIDE; | 103 virtual void OnBuffersSwappedACK() OVERRIDE; |
104 virtual void OnPostSubBufferACK() OVERRIDE; | 104 virtual void OnPostSubBufferACK() OVERRIDE; |
105 virtual void OnResizeViewACK() OVERRIDE; | 105 virtual void OnResizeViewACK() OVERRIDE; |
| 106 virtual void OnSetFrontSurfaceIsProtected(bool is_protected) OVERRIDE; |
106 virtual void OnResize(gfx::Size size) OVERRIDE; | 107 virtual void OnResize(gfx::Size size) OVERRIDE; |
107 | 108 |
108 private: | 109 private: |
109 virtual ~EGLImageTransportSurface() OVERRIDE; | 110 virtual ~EGLImageTransportSurface() OVERRIDE; |
110 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); | 111 void ReleaseSurface(scoped_refptr<EGLAcceleratedSurface>* surface); |
111 void SendBuffersSwapped(); | 112 void SendBuffersSwapped(); |
112 void SendPostSubBuffer(int x, int y, int width, int height); | 113 void SendPostSubBuffer(int x, int y, int width, int height); |
113 | 114 |
114 // Tracks the current buffer allocation state. | 115 // Tracks the current buffer allocation state. |
115 bool backbuffer_suggested_allocation_; | 116 bool backbuffer_suggested_allocation_; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; | 154 virtual void SetBackbufferAllocation(bool allocated) OVERRIDE; |
154 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; | 155 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
155 | 156 |
156 protected: | 157 protected: |
157 // ImageTransportSurface implementation: | 158 // ImageTransportSurface implementation: |
158 virtual void OnNewSurfaceACK( | 159 virtual void OnNewSurfaceACK( |
159 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; | 160 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
160 virtual void OnBuffersSwappedACK() OVERRIDE; | 161 virtual void OnBuffersSwappedACK() OVERRIDE; |
161 virtual void OnPostSubBufferACK() OVERRIDE; | 162 virtual void OnPostSubBufferACK() OVERRIDE; |
162 virtual void OnResizeViewACK() OVERRIDE; | 163 virtual void OnResizeViewACK() OVERRIDE; |
| 164 virtual void OnSetFrontSurfaceIsProtected(bool is_protected) OVERRIDE; |
163 virtual void OnResize(gfx::Size size) OVERRIDE; | 165 virtual void OnResize(gfx::Size size) OVERRIDE; |
164 | 166 |
165 private: | 167 private: |
166 virtual ~GLXImageTransportSurface(); | 168 virtual ~GLXImageTransportSurface(); |
167 | 169 |
168 // Tell the browser to release the surface. | 170 // Tell the browser to release the surface. |
169 void ReleaseSurface(); | 171 void ReleaseSurface(); |
170 | 172 |
171 void SendBuffersSwapped(); | 173 void SendBuffersSwapped(); |
172 void SendPostSubBuffer(int x, int y, int width, int height); | 174 void SendPostSubBuffer(int x, int y, int width, int height); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 virtual std::string GetExtensions() OVERRIDE; | 214 virtual std::string GetExtensions() OVERRIDE; |
213 virtual gfx::Size GetSize() OVERRIDE; | 215 virtual gfx::Size GetSize() OVERRIDE; |
214 | 216 |
215 protected: | 217 protected: |
216 // ImageTransportSurface implementation: | 218 // ImageTransportSurface implementation: |
217 virtual void OnNewSurfaceACK( | 219 virtual void OnNewSurfaceACK( |
218 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; | 220 uint64 surface_handle, TransportDIB::Handle shm_handle) OVERRIDE; |
219 virtual void OnBuffersSwappedACK() OVERRIDE; | 221 virtual void OnBuffersSwappedACK() OVERRIDE; |
220 virtual void OnPostSubBufferACK() OVERRIDE; | 222 virtual void OnPostSubBufferACK() OVERRIDE; |
221 virtual void OnResizeViewACK() OVERRIDE; | 223 virtual void OnResizeViewACK() OVERRIDE; |
| 224 virtual void OnSetFrontSurfaceIsProtected(bool is_protected) OVERRIDE; |
222 virtual void OnResize(gfx::Size size) OVERRIDE; | 225 virtual void OnResize(gfx::Size size) OVERRIDE; |
223 | 226 |
224 private: | 227 private: |
225 virtual ~OSMesaImageTransportSurface(); | 228 virtual ~OSMesaImageTransportSurface(); |
226 | 229 |
227 // Tell the browser to release the surface. | 230 // Tell the browser to release the surface. |
228 void ReleaseSurface(); | 231 void ReleaseSurface(); |
229 | 232 |
230 scoped_ptr<TransportDIB> shared_mem_; | 233 scoped_ptr<TransportDIB> shared_mem_; |
231 uint32 shared_id_; | 234 uint32 shared_id_; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 gfx::Size EGLImageTransportSurface::GetSize() { | 515 gfx::Size EGLImageTransportSurface::GetSize() { |
513 return back_surface_->size(); | 516 return back_surface_->size(); |
514 } | 517 } |
515 | 518 |
516 void EGLImageTransportSurface::OnNewSurfaceACK( | 519 void EGLImageTransportSurface::OnNewSurfaceACK( |
517 uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) { | 520 uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) { |
518 DCHECK_EQ(back_surface_->pixmap(), surface_handle); | 521 DCHECK_EQ(back_surface_->pixmap(), surface_handle); |
519 helper_->SetScheduled(true); | 522 helper_->SetScheduled(true); |
520 } | 523 } |
521 | 524 |
| 525 void EGLImageTransportSurface::OnSetFrontSurfaceIsProtected( |
| 526 bool is_protected) { |
| 527 } |
| 528 |
522 void EGLImageTransportSurface::OnBuffersSwappedACK() { | 529 void EGLImageTransportSurface::OnBuffersSwappedACK() { |
523 helper_->SetScheduled(true); | 530 helper_->SetScheduled(true); |
524 } | 531 } |
525 | 532 |
526 void EGLImageTransportSurface::OnPostSubBufferACK() { | 533 void EGLImageTransportSurface::OnPostSubBufferACK() { |
527 helper_->SetScheduled(true); | 534 helper_->SetScheduled(true); |
528 } | 535 } |
529 | 536 |
530 void EGLImageTransportSurface::OnResizeViewACK() { | 537 void EGLImageTransportSurface::OnResizeViewACK() { |
531 NOTREACHED(); | 538 NOTREACHED(); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 context->SetSwapInterval(0); | 760 context->SetSwapInterval(0); |
754 | 761 |
755 made_current_ = true; | 762 made_current_ = true; |
756 return true; | 763 return true; |
757 } | 764 } |
758 | 765 |
759 void GLXImageTransportSurface::OnNewSurfaceACK( | 766 void GLXImageTransportSurface::OnNewSurfaceACK( |
760 uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) { | 767 uint64 surface_handle, TransportDIB::Handle /*shm_handle*/) { |
761 } | 768 } |
762 | 769 |
| 770 void GLXImageTransportSurface::OnSetFrontSurfaceIsProtected( |
| 771 bool is_protected) { |
| 772 } |
| 773 |
763 void GLXImageTransportSurface::OnBuffersSwappedACK() { | 774 void GLXImageTransportSurface::OnBuffersSwappedACK() { |
764 helper_->SetScheduled(true); | 775 helper_->SetScheduled(true); |
765 } | 776 } |
766 | 777 |
767 void GLXImageTransportSurface::OnPostSubBufferACK() { | 778 void GLXImageTransportSurface::OnPostSubBufferACK() { |
768 helper_->SetScheduled(true); | 779 helper_->SetScheduled(true); |
769 } | 780 } |
770 | 781 |
771 void GLXImageTransportSurface::OnResizeViewACK() { | 782 void GLXImageTransportSurface::OnResizeViewACK() { |
772 NOTREACHED(); | 783 NOTREACHED(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 | 850 |
840 void OSMesaImageTransportSurface::OnNewSurfaceACK( | 851 void OSMesaImageTransportSurface::OnNewSurfaceACK( |
841 uint64 surface_handle, TransportDIB::Handle shm_handle) { | 852 uint64 surface_handle, TransportDIB::Handle shm_handle) { |
842 shared_id_ = surface_handle; | 853 shared_id_ = surface_handle; |
843 shared_mem_.reset(TransportDIB::Map(shm_handle)); | 854 shared_mem_.reset(TransportDIB::Map(shm_handle)); |
844 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 855 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
845 | 856 |
846 helper_->SetScheduled(true); | 857 helper_->SetScheduled(true); |
847 } | 858 } |
848 | 859 |
| 860 void OSMesaImageTransportSurface::OnSetFrontSurfaceIsProtected( |
| 861 bool is_protected) { |
| 862 } |
| 863 |
849 void OSMesaImageTransportSurface::OnResizeViewACK() { | 864 void OSMesaImageTransportSurface::OnResizeViewACK() { |
850 NOTREACHED(); | 865 NOTREACHED(); |
851 } | 866 } |
852 | 867 |
853 bool OSMesaImageTransportSurface::SwapBuffers() { | 868 bool OSMesaImageTransportSurface::SwapBuffers() { |
854 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 869 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
855 | 870 |
856 // Copy the OSMesa buffer to the shared memory | 871 // Copy the OSMesa buffer to the shared memory |
857 glFinish(); | 872 glFinish(); |
858 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); | 873 memcpy(shared_mem_->memory(), GetHandle(), size_.GetArea() * 4); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 stub, | 965 stub, |
951 surface.get(), | 966 surface.get(), |
952 handle.transport); | 967 handle.transport); |
953 } | 968 } |
954 | 969 |
955 if (surface->Initialize()) | 970 if (surface->Initialize()) |
956 return surface; | 971 return surface; |
957 else | 972 else |
958 return NULL; | 973 return NULL; |
959 } | 974 } |
OLD | NEW |