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 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 virtual bool SwapBuffers() OVERRIDE; | 36 virtual bool SwapBuffers() OVERRIDE; |
37 virtual gfx::Size GetSize() OVERRIDE; | 37 virtual gfx::Size GetSize() OVERRIDE; |
38 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 38 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
39 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 39 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
40 | 40 |
41 protected: | 41 protected: |
42 // ImageTransportSurface implementation | 42 // ImageTransportSurface implementation |
43 virtual void OnNewSurfaceACK(uint64 surface_id, | 43 virtual void OnNewSurfaceACK(uint64 surface_id, |
44 TransportDIB::Handle shm_handle) OVERRIDE; | 44 TransportDIB::Handle shm_handle) OVERRIDE; |
45 virtual void OnBuffersSwappedACK() OVERRIDE; | 45 virtual void OnBuffersSwappedACK() OVERRIDE; |
46 virtual void OnResizeViewACK() OVERRIDE; | |
47 virtual void OnResize(gfx::Size size) OVERRIDE; | 46 virtual void OnResize(gfx::Size size) OVERRIDE; |
48 | 47 |
49 private: | 48 private: |
50 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; | 49 virtual ~IOSurfaceImageTransportSurface() OVERRIDE; |
51 | 50 |
52 uint32 fbo_id_; | 51 uint32 fbo_id_; |
53 GLuint texture_id_; | 52 GLuint texture_id_; |
54 | 53 |
55 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; | 54 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; |
56 | 55 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 virtual bool SwapBuffers() OVERRIDE; | 87 virtual bool SwapBuffers() OVERRIDE; |
89 virtual gfx::Size GetSize() OVERRIDE; | 88 virtual gfx::Size GetSize() OVERRIDE; |
90 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; | 89 virtual bool OnMakeCurrent(gfx::GLContext* context) OVERRIDE; |
91 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 90 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
92 | 91 |
93 protected: | 92 protected: |
94 // ImageTransportSurface implementation | 93 // ImageTransportSurface implementation |
95 virtual void OnBuffersSwappedACK() OVERRIDE; | 94 virtual void OnBuffersSwappedACK() OVERRIDE; |
96 virtual void OnNewSurfaceACK(uint64 surface_id, | 95 virtual void OnNewSurfaceACK(uint64 surface_id, |
97 TransportDIB::Handle shm_handle) OVERRIDE; | 96 TransportDIB::Handle shm_handle) OVERRIDE; |
98 virtual void OnResizeViewACK() OVERRIDE; | |
99 virtual void OnResize(gfx::Size size) OVERRIDE; | 97 virtual void OnResize(gfx::Size size) OVERRIDE; |
100 | 98 |
101 private: | 99 private: |
102 virtual ~TransportDIBImageTransportSurface() OVERRIDE; | 100 virtual ~TransportDIBImageTransportSurface() OVERRIDE; |
103 | 101 |
104 uint32 fbo_id_; | 102 uint32 fbo_id_; |
105 GLuint render_buffer_id_; | 103 GLuint render_buffer_id_; |
106 | 104 |
107 scoped_ptr<TransportDIB> shared_mem_; | 105 scoped_ptr<TransportDIB> shared_mem_; |
108 | 106 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 helper_->SetScheduled(true); | 232 helper_->SetScheduled(true); |
235 } | 233 } |
236 | 234 |
237 void IOSurfaceImageTransportSurface::OnNewSurfaceACK( | 235 void IOSurfaceImageTransportSurface::OnNewSurfaceACK( |
238 uint64 surface_id, | 236 uint64 surface_id, |
239 TransportDIB::Handle /* shm_handle */) { | 237 TransportDIB::Handle /* shm_handle */) { |
240 DCHECK_EQ(io_surface_id_, surface_id); | 238 DCHECK_EQ(io_surface_id_, surface_id); |
241 helper_->SetScheduled(true); | 239 helper_->SetScheduled(true); |
242 } | 240 } |
243 | 241 |
244 void IOSurfaceImageTransportSurface::OnResizeViewACK() { | |
245 NOTREACHED(); | |
246 } | |
247 | |
248 void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { | 242 void IOSurfaceImageTransportSurface::OnResize(gfx::Size size) { |
249 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 243 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
250 | 244 |
251 // Caching |context_| from OnMakeCurrent. It should still be current. | 245 // Caching |context_| from OnMakeCurrent. It should still be current. |
252 DCHECK(context_->IsCurrent(this)); | 246 DCHECK(context_->IsCurrent(this)); |
253 | 247 |
254 size_ = size; | 248 size_ = size; |
255 | 249 |
256 if (texture_id_) { | 250 if (texture_id_) { |
257 glDeleteTextures(1, &texture_id_); | 251 glDeleteTextures(1, &texture_id_); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 436 |
443 void TransportDIBImageTransportSurface::OnNewSurfaceACK( | 437 void TransportDIBImageTransportSurface::OnNewSurfaceACK( |
444 uint64 surface_id, | 438 uint64 surface_id, |
445 TransportDIB::Handle shm_handle) { | 439 TransportDIB::Handle shm_handle) { |
446 helper_->SetScheduled(true); | 440 helper_->SetScheduled(true); |
447 | 441 |
448 shared_mem_.reset(TransportDIB::Map(shm_handle)); | 442 shared_mem_.reset(TransportDIB::Map(shm_handle)); |
449 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); | 443 DCHECK_NE(shared_mem_.get(), static_cast<void*>(NULL)); |
450 } | 444 } |
451 | 445 |
452 void TransportDIBImageTransportSurface::OnResizeViewACK() { | |
453 NOTREACHED(); | |
454 } | |
455 | |
456 void TransportDIBImageTransportSurface::OnResize(gfx::Size size) { | 446 void TransportDIBImageTransportSurface::OnResize(gfx::Size size) { |
457 size_ = size; | 447 size_ = size; |
458 | 448 |
459 if (!render_buffer_id_) | 449 if (!render_buffer_id_) |
460 glGenRenderbuffersEXT(1, &render_buffer_id_); | 450 glGenRenderbuffersEXT(1, &render_buffer_id_); |
461 | 451 |
462 GLint previous_fbo_id = 0; | 452 GLint previous_fbo_id = 0; |
463 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &previous_fbo_id); | 453 glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &previous_fbo_id); |
464 | 454 |
465 GLint previous_renderbuffer_id = 0; | 455 GLint previous_renderbuffer_id = 0; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 NOTREACHED(); | 511 NOTREACHED(); |
522 return NULL; | 512 return NULL; |
523 } | 513 } |
524 if (surface->Initialize()) | 514 if (surface->Initialize()) |
525 return surface; | 515 return surface; |
526 else | 516 else |
527 return NULL; | 517 return NULL; |
528 } | 518 } |
529 | 519 |
530 #endif // defined(USE_GPU) | 520 #endif // defined(USE_GPU) |
OLD | NEW |