| 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 "ui/gfx/gl/gl_surface.h" | 5 #include "ui/gfx/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #if !defined(USE_WAYLAND) | 10 #if !defined(USE_WAYLAND) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #if !defined(USE_WAYLAND) | 24 #if !defined(USE_WAYLAND) |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 Display* g_osmesa_display; | 27 Display* g_osmesa_display; |
| 28 } // namespace anonymous | 28 } // namespace anonymous |
| 29 | 29 |
| 30 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a | 30 // This OSMesa GL surface can use XLib to swap the contents of the buffer to a |
| 31 // view. | 31 // view. |
| 32 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { | 32 class NativeViewGLSurfaceOSMesa : public GLSurfaceOSMesa { |
| 33 public: | 33 public: |
| 34 explicit NativeViewGLSurfaceOSMesa(gfx::PluginWindowHandle window); | 34 explicit NativeViewGLSurfaceOSMesa(gfx::AcceleratedWidget window); |
| 35 virtual ~NativeViewGLSurfaceOSMesa(); | 35 virtual ~NativeViewGLSurfaceOSMesa(); |
| 36 | 36 |
| 37 static bool InitializeOneOff(); | 37 static bool InitializeOneOff(); |
| 38 | 38 |
| 39 // Implement a subset of GLSurface. | 39 // Implement a subset of GLSurface. |
| 40 virtual bool Initialize() OVERRIDE; | 40 virtual bool Initialize() OVERRIDE; |
| 41 virtual void Destroy() OVERRIDE; | 41 virtual void Destroy() OVERRIDE; |
| 42 virtual bool Resize(const gfx::Size& new_size) OVERRIDE; | 42 virtual bool Resize(const gfx::Size& new_size) OVERRIDE; |
| 43 virtual bool IsOffscreen() OVERRIDE; | 43 virtual bool IsOffscreen() OVERRIDE; |
| 44 virtual bool SwapBuffers() OVERRIDE; | 44 virtual bool SwapBuffers() OVERRIDE; |
| 45 virtual std::string GetExtensions() OVERRIDE; | 45 virtual std::string GetExtensions() OVERRIDE; |
| 46 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 46 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 GC window_graphics_context_; | 49 GC window_graphics_context_; |
| 50 gfx::PluginWindowHandle window_; | 50 gfx::AcceleratedWidget window_; |
| 51 GC pixmap_graphics_context_; | 51 GC pixmap_graphics_context_; |
| 52 Pixmap pixmap_; | 52 Pixmap pixmap_; |
| 53 | 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceOSMesa); | 54 DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceOSMesa); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 #endif // !USE_WAYLAND | 57 #endif // !USE_WAYLAND |
| 58 | 58 |
| 59 bool GLSurface::InitializeOneOffInternal() { | 59 bool GLSurface::InitializeOneOffInternal() { |
| 60 switch (GetGLImplementation()) { | 60 switch (GetGLImplementation()) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 81 default: | 81 default: |
| 82 break; | 82 break; |
| 83 } | 83 } |
| 84 | 84 |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 | 87 |
| 88 #if !defined(USE_WAYLAND) | 88 #if !defined(USE_WAYLAND) |
| 89 | 89 |
| 90 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( | 90 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( |
| 91 gfx::PluginWindowHandle window) | 91 gfx::AcceleratedWidget window) |
| 92 : GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)), | 92 : GLSurfaceOSMesa(OSMESA_BGRA, gfx::Size(1, 1)), |
| 93 window_graphics_context_(0), | 93 window_graphics_context_(0), |
| 94 window_(window), | 94 window_(window), |
| 95 pixmap_graphics_context_(0), | 95 pixmap_graphics_context_(0), |
| 96 pixmap_(0) { | 96 pixmap_(0) { |
| 97 DCHECK(window); | 97 DCHECK(window); |
| 98 } | 98 } |
| 99 | 99 |
| 100 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { | 100 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { |
| 101 Destroy(); | 101 Destroy(); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 width, height, | 269 width, height, |
| 270 x, y); | 270 x, y); |
| 271 | 271 |
| 272 return true; | 272 return true; |
| 273 } | 273 } |
| 274 | 274 |
| 275 #endif // !USE_WAYLAND | 275 #endif // !USE_WAYLAND |
| 276 | 276 |
| 277 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 277 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| 278 bool software, | 278 bool software, |
| 279 gfx::PluginWindowHandle window) { | 279 gfx::AcceleratedWidget window) { |
| 280 if (software) | 280 if (software) |
| 281 return NULL; | 281 return NULL; |
| 282 | 282 |
| 283 switch (GetGLImplementation()) { | 283 switch (GetGLImplementation()) { |
| 284 #if !defined(USE_WAYLAND) | 284 #if !defined(USE_WAYLAND) |
| 285 case kGLImplementationOSMesaGL: { | 285 case kGLImplementationOSMesaGL: { |
| 286 scoped_refptr<GLSurface> surface( | 286 scoped_refptr<GLSurface> surface( |
| 287 new NativeViewGLSurfaceOSMesa(window)); | 287 new NativeViewGLSurfaceOSMesa(window)); |
| 288 if (!surface->Initialize()) | 288 if (!surface->Initialize()) |
| 289 return NULL; | 289 return NULL; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 } | 348 } |
| 349 case kGLImplementationMockGL: | 349 case kGLImplementationMockGL: |
| 350 return new GLSurfaceStub; | 350 return new GLSurfaceStub; |
| 351 default: | 351 default: |
| 352 NOTREACHED(); | 352 NOTREACHED(); |
| 353 return NULL; | 353 return NULL; |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace gfx | 357 } // namespace gfx |
| OLD | NEW |