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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 virtual gfx::Size GetSize() OVERRIDE; | 49 virtual gfx::Size GetSize() OVERRIDE; |
50 virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 50 virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
51 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 51 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
52 | 52 |
53 protected: | 53 protected: |
54 // ImageTransportSurface implementation | 54 // ImageTransportSurface implementation |
55 virtual void OnNewSurfaceACK( | 55 virtual void OnNewSurfaceACK( |
56 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 56 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
57 virtual void OnBuffersSwappedACK() OVERRIDE; | 57 virtual void OnBuffersSwappedACK() OVERRIDE; |
58 virtual void OnResize(gfx::Size size) OVERRIDE; | 58 virtual void OnResize(gfx::Size size) OVERRIDE; |
59 virtual void OnSurfaceVisible(bool visible) OVERRIDE; | |
59 | 60 |
60 private: | 61 private: |
61 virtual ~EGLImageTransportSurface() OVERRIDE; | 62 virtual ~EGLImageTransportSurface() OVERRIDE; |
62 void ReleaseSurface(scoped_refptr<AcceleratedSurface>* surface); | 63 void ReleaseSurface(scoped_refptr<AcceleratedSurface>* surface); |
63 | 64 |
64 uint32 fbo_id_; | 65 uint32 fbo_id_; |
65 | 66 |
66 scoped_refptr<AcceleratedSurface> back_surface_; | 67 scoped_refptr<AcceleratedSurface> back_surface_; |
67 scoped_refptr<AcceleratedSurface> front_surface_; | 68 scoped_refptr<AcceleratedSurface> front_surface_; |
68 | 69 |
(...skipping 18 matching lines...) Expand all Loading... | |
87 virtual bool SwapBuffers() OVERRIDE; | 88 virtual bool SwapBuffers() OVERRIDE; |
88 virtual gfx::Size GetSize() OVERRIDE; | 89 virtual gfx::Size GetSize() OVERRIDE; |
89 virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 90 virtual void OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
90 | 91 |
91 protected: | 92 protected: |
92 // ImageTransportSurface implementation: | 93 // ImageTransportSurface implementation: |
93 virtual void OnNewSurfaceACK( | 94 virtual void OnNewSurfaceACK( |
94 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 95 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
95 virtual void OnBuffersSwappedACK() OVERRIDE; | 96 virtual void OnBuffersSwappedACK() OVERRIDE; |
96 virtual void OnResize(gfx::Size size) OVERRIDE; | 97 virtual void OnResize(gfx::Size size) OVERRIDE; |
98 virtual void OnSurfaceVisible(bool visible) OVERRIDE; | |
97 | 99 |
98 private: | 100 private: |
99 virtual ~GLXImageTransportSurface(); | 101 virtual ~GLXImageTransportSurface(); |
100 | 102 |
101 // Tell the browser to release the surface. | 103 // Tell the browser to release the surface. |
102 void ReleaseSurface(); | 104 void ReleaseSurface(); |
103 | 105 |
104 XID dummy_parent_; | 106 XID dummy_parent_; |
105 gfx::Size size_; | 107 gfx::Size size_; |
106 | 108 |
(...skipping 26 matching lines...) Expand all Loading... | |
133 virtual bool SwapBuffers() OVERRIDE; | 135 virtual bool SwapBuffers() OVERRIDE; |
134 virtual gfx::Size GetSize() OVERRIDE; | 136 virtual gfx::Size GetSize() OVERRIDE; |
135 virtual void* GetHandle() OVERRIDE; | 137 virtual void* GetHandle() OVERRIDE; |
136 | 138 |
137 protected: | 139 protected: |
138 // ImageTransportSurface implementation: | 140 // ImageTransportSurface implementation: |
139 virtual void OnNewSurfaceACK( | 141 virtual void OnNewSurfaceACK( |
140 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; | 142 uint64 surface_id, TransportDIB::Handle surface_handle) OVERRIDE; |
141 virtual void OnBuffersSwappedACK() OVERRIDE; | 143 virtual void OnBuffersSwappedACK() OVERRIDE; |
142 virtual void OnResize(gfx::Size size) OVERRIDE; | 144 virtual void OnResize(gfx::Size size) OVERRIDE; |
145 virtual void OnSurfaceVisible(bool visible) OVERRIDE; | |
143 | 146 |
144 private: | 147 private: |
145 virtual ~OSMesaImageTransportSurface(); | 148 virtual ~OSMesaImageTransportSurface(); |
146 | 149 |
147 // Tell the browser to release the surface. | 150 // Tell the browser to release the surface. |
148 void ReleaseSurface(); | 151 void ReleaseSurface(); |
149 | 152 |
150 scoped_ptr<TransportDIB> shared_mem_; | 153 scoped_ptr<TransportDIB> shared_mem_; |
151 uint32 shared_id_; | 154 uint32 shared_id_; |
152 gfx::Size size_; | 155 gfx::Size size_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 | 242 |
240 GpuHostMsg_AcceleratedSurfaceNew_Params params; | 243 GpuHostMsg_AcceleratedSurfaceNew_Params params; |
241 params.width = size.width(); | 244 params.width = size.width(); |
242 params.height = size.height(); | 245 params.height = size.height(); |
243 params.surface_id = back_surface_->pixmap(); | 246 params.surface_id = back_surface_->pixmap(); |
244 helper_->SendAcceleratedSurfaceNew(params); | 247 helper_->SendAcceleratedSurfaceNew(params); |
245 | 248 |
246 helper_->SetScheduled(false); | 249 helper_->SetScheduled(false); |
247 } | 250 } |
248 | 251 |
252 void EGLImageTransportSurface::OnSurfaceVisible(bool visible) { | |
253 if (!visible && back_surface_.get() && front_surface_.get()) { | |
254 ReleaseSurface(&back_surface_); | |
255 } else if (visible && !back_surface_.get() && front_surface_.get()) { | |
256 // Leverage the OnResize hook because it does exactly what we want | |
257 OnResize(front_surface_->size()); | |
258 } | |
259 } | |
260 | |
249 bool EGLImageTransportSurface::SwapBuffers() { | 261 bool EGLImageTransportSurface::SwapBuffers() { |
250 front_surface_.swap(back_surface_); | 262 front_surface_.swap(back_surface_); |
251 DCHECK_NE(front_surface_.get(), static_cast<AcceleratedSurface*>(NULL)); | 263 DCHECK_NE(front_surface_.get(), static_cast<AcceleratedSurface*>(NULL)); |
252 glFlush(); | 264 glFlush(); |
253 | 265 |
254 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 266 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
255 params.surface_id = front_surface_->pixmap(); | 267 params.surface_id = front_surface_->pixmap(); |
256 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 268 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
257 | 269 |
258 gfx::Size expected_size = front_surface_->size(); | 270 gfx::Size expected_size = front_surface_->size(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 | 394 |
383 GpuHostMsg_AcceleratedSurfaceNew_Params params; | 395 GpuHostMsg_AcceleratedSurfaceNew_Params params; |
384 params.width = size_.width(); | 396 params.width = size_.width(); |
385 params.height = size_.height(); | 397 params.height = size_.height(); |
386 params.surface_id = window_; | 398 params.surface_id = window_; |
387 helper_->SendAcceleratedSurfaceNew(params); | 399 helper_->SendAcceleratedSurfaceNew(params); |
388 | 400 |
389 helper_->SetScheduled(false); | 401 helper_->SetScheduled(false); |
390 } | 402 } |
391 | 403 |
404 void GLXImageTransportSurface::OnSurfaceVisible(bool visible) { | |
405 NOTREACHED(); | |
jonathan.backer
2011/10/07 15:48:37
Probably will be reached?
You'll need to add this
| |
406 } | |
407 | |
392 bool GLXImageTransportSurface::SwapBuffers() { | 408 bool GLXImageTransportSurface::SwapBuffers() { |
393 gfx::NativeViewGLSurfaceGLX::SwapBuffers(); | 409 gfx::NativeViewGLSurfaceGLX::SwapBuffers(); |
394 glFlush(); | 410 glFlush(); |
395 | 411 |
396 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 412 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; |
397 params.surface_id = window_; | 413 params.surface_id = window_; |
398 helper_->SendAcceleratedSurfaceBuffersSwapped(params); | 414 helper_->SendAcceleratedSurfaceBuffersSwapped(params); |
399 | 415 |
400 helper_->SetScheduled(false); | 416 helper_->SetScheduled(false); |
401 return true; | 417 return true; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 | 502 |
487 GpuHostMsg_AcceleratedSurfaceNew_Params params; | 503 GpuHostMsg_AcceleratedSurfaceNew_Params params; |
488 params.width = size_.width(); | 504 params.width = size_.width(); |
489 params.height = size_.height(); | 505 params.height = size_.height(); |
490 params.surface_id = 0; // id comes from the browser with the shared mem | 506 params.surface_id = 0; // id comes from the browser with the shared mem |
491 helper_->SendAcceleratedSurfaceNew(params); | 507 helper_->SendAcceleratedSurfaceNew(params); |
492 | 508 |
493 helper_->SetScheduled(false); | 509 helper_->SetScheduled(false); |
494 } | 510 } |
495 | 511 |
512 void OSMesaImageTransportSurface::OnSurfaceVisible(bool visible) { | |
513 NOTREACHED(); | |
514 } | |
515 | |
496 void OSMesaImageTransportSurface::OnNewSurfaceACK( | 516 void OSMesaImageTransportSurface::OnNewSurfaceACK( |
497 uint64 surface_id, TransportDIB::Handle surface_handle) { | 517 uint64 surface_id, TransportDIB::Handle surface_handle) { |
498 shared_id_ = surface_id; | 518 shared_id_ = surface_id; |
499 shared_mem_.reset(TransportDIB::Map(surface_handle)); | 519 shared_mem_.reset(TransportDIB::Map(surface_handle)); |
500 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 520 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
501 | 521 |
502 // When we get the shared memory buffer back we can use that for OSMesa to | 522 // When we get the shared memory buffer back we can use that for OSMesa to |
503 // write in, so we give it to OSMesa. | 523 // write in, so we give it to OSMesa. |
504 helper_->MakeCurrent(); | 524 helper_->MakeCurrent(); |
505 | 525 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 NOTREACHED(); | 588 NOTREACHED(); |
569 return NULL; | 589 return NULL; |
570 } | 590 } |
571 if (surface->Initialize()) | 591 if (surface->Initialize()) |
572 return surface; | 592 return surface; |
573 else | 593 else |
574 return NULL; | 594 return NULL; |
575 } | 595 } |
576 | 596 |
577 #endif // defined(USE_GPU) | 597 #endif // defined(USE_GPU) |
OLD | NEW |