diff options
Diffstat (limited to 'ui/gfx/gl/gl_context_osmesa.h')
-rw-r--r-- | ui/gfx/gl/gl_context_osmesa.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ui/gfx/gl/gl_context_osmesa.h b/ui/gfx/gl/gl_context_osmesa.h new file mode 100644 index 0000000..77ca820 --- /dev/null +++ b/ui/gfx/gl/gl_context_osmesa.h @@ -0,0 +1,54 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_GL_GL_CONTEXT_OSMESA_H_ +#define UI_GFX_GL_GL_CONTEXT_OSMESA_H_ +#pragma once + +#include "base/memory/scoped_ptr.h" +#include "ui/gfx/gl/gl_context.h" +#include "ui/gfx/size.h" + +typedef struct osmesa_context *OSMesaContext; + +namespace gfx { + +// Encapsulates an OSMesa OpenGL context that uses software rendering. +class OSMesaGLContext : public GLContext { + public: + OSMesaGLContext(); + virtual ~OSMesaGLContext(); + + // Initialize an OSMesa GL context with the default 1 x 1 initial size. + bool Initialize(GLuint format, GLContext* shared_context); + + // Resize the back buffer, preserving the old content. Does nothing if the + // size is unchanged. + void Resize(const gfx::Size& new_size); + + const void* buffer() const { + return buffer_.get(); + } + + // Implement GLContext. + virtual void Destroy(); + virtual bool MakeCurrent(); + virtual bool IsCurrent(); + virtual bool IsOffscreen(); + virtual bool SwapBuffers(); + virtual gfx::Size GetSize(); + virtual void* GetHandle(); + virtual void SetSwapInterval(int interval); + + private: + gfx::Size size_; + scoped_array<int32> buffer_; + OSMesaContext context_; + + DISALLOW_COPY_AND_ASSIGN(OSMesaGLContext); +}; + +} // namespace gfx + +#endif // UI_GFX_GL_GL_CONTEXT_OSMESA_H_ |