OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef APP_GFX_GL_GL_CONTEXT_OSMESA_H_ | 5 #ifndef APP_GFX_GL_GL_CONTEXT_OSMESA_H_ |
6 #define APP_GFX_GL_GL_CONTEXT_OSMESA_H_ | 6 #define APP_GFX_GL_GL_CONTEXT_OSMESA_H_ |
7 | 7 |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "gfx/size.h" | 9 #include "gfx/size.h" |
10 #include "app/gfx/gl/gl_context.h" | 10 #include "app/gfx/gl/gl_context.h" |
11 | 11 |
12 typedef struct osmesa_context *OSMesaContext; | 12 typedef struct osmesa_context *OSMesaContext; |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 | 15 |
16 // Encapsulates an OSMesa OpenGL context that uses software rendering. | 16 // Encapsulates an OSMesa OpenGL context that uses software rendering. |
17 class OSMesaGLContext : public GLContext { | 17 class OSMesaGLContext : public GLContext { |
18 public: | 18 public: |
19 OSMesaGLContext(); | 19 OSMesaGLContext(); |
20 virtual ~OSMesaGLContext(); | 20 virtual ~OSMesaGLContext(); |
21 | 21 |
22 // Initialize an OSMesa GL context with the default 1 x 1 initial size. | 22 // Initialize an OSMesa GL context with the default 1 x 1 initial size. |
23 bool Initialize(void* shared_handle); | 23 bool Initialize(GLContext* shared_context); |
24 | 24 |
25 // Implement GLContext. | 25 // Implement GLContext. |
26 virtual void Destroy(); | 26 virtual void Destroy(); |
27 virtual bool MakeCurrent(); | 27 virtual bool MakeCurrent(); |
28 virtual bool IsCurrent(); | 28 virtual bool IsCurrent(); |
29 virtual bool IsOffscreen(); | 29 virtual bool IsOffscreen(); |
30 virtual void SwapBuffers(); | 30 virtual void SwapBuffers(); |
31 virtual gfx::Size GetSize(); | 31 virtual gfx::Size GetSize(); |
32 virtual void* GetHandle(); | 32 virtual void* GetHandle(); |
33 | 33 |
34 // Resize the back buffer, preserving the old content. Does nothing if the | 34 // Resize the back buffer, preserving the old content. Does nothing if the |
35 // size is unchanged. | 35 // size is unchanged. |
36 void Resize(const gfx::Size& new_size); | 36 void Resize(const gfx::Size& new_size); |
37 | 37 |
38 const void* buffer() const { | 38 const void* buffer() const { |
39 return buffer_.get(); | 39 return buffer_.get(); |
40 } | 40 } |
41 | 41 |
42 private: | 42 private: |
43 #if !defined(UNIT_TEST) | |
44 gfx::Size size_; | 43 gfx::Size size_; |
45 scoped_array<int32> buffer_; | 44 scoped_array<int32> buffer_; |
46 OSMesaContext context_; | 45 OSMesaContext context_; |
47 #endif | |
48 | 46 |
49 DISALLOW_COPY_AND_ASSIGN(OSMesaGLContext); | 47 DISALLOW_COPY_AND_ASSIGN(OSMesaGLContext); |
50 }; | 48 }; |
51 | 49 |
52 } // namespace gfx | 50 } // namespace gfx |
53 | 51 |
54 #endif // APP_GFX_GL_GL_CONTEXT_OSMESA_H_ | 52 #endif // APP_GFX_GL_GL_CONTEXT_OSMESA_H_ |
OLD | NEW |