blob: 52738de7395f747657fefcd680bbbed653554445 [file] [log] [blame]
[email protected]4bedba72010-04-20 22:08:541// 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
3// found in the LICENSE file.
4
[email protected]5a6db6c2010-04-22 18:32:065#ifndef APP_GFX_GL_GL_CONTEXT_OSMESA_H_
6#define APP_GFX_GL_GL_CONTEXT_OSMESA_H_
[email protected]4bedba72010-04-20 22:08:547
8#include "base/scoped_ptr.h"
9#include "gfx/size.h"
[email protected]5a6db6c2010-04-22 18:32:0610#include "app/gfx/gl/gl_context.h"
[email protected]4bedba72010-04-20 22:08:5411
[email protected]5a6db6c2010-04-22 18:32:0612typedef struct osmesa_context *OSMesaContext;
13
14namespace gfx {
[email protected]4bedba72010-04-20 22:08:5415
16// Encapsulates an OSMesa OpenGL context that uses software rendering.
17class OSMesaGLContext : public GLContext {
18 public:
19 OSMesaGLContext();
20 virtual ~OSMesaGLContext();
21
22 // Initialize an OSMesa GL context with the default 1 x 1 initial size.
23 bool Initialize(void* shared_handle);
24
25 // Implement GLContext.
26 virtual void Destroy();
27 virtual bool MakeCurrent();
28 virtual bool IsCurrent();
29 virtual bool IsOffscreen();
30 virtual void SwapBuffers();
31 virtual gfx::Size GetSize();
32 virtual void* GetHandle();
33
34 // Resize the back buffer, preserving the old content. Does nothing if the
35 // size is unchanged.
36 void Resize(const gfx::Size& new_size);
37
38 const void* buffer() const {
39 return buffer_.get();
40 }
41
42 protected:
43 bool InitializeCommon();
44
45 private:
46#if !defined(UNIT_TEST)
47 gfx::Size size_;
48 scoped_array<int32> buffer_;
49 OSMesaContext context_;
50#endif
51
52 DISALLOW_COPY_AND_ASSIGN(OSMesaGLContext);
53};
54
[email protected]5a6db6c2010-04-22 18:32:0655} // namespace gfx
[email protected]4bedba72010-04-20 22:08:5456
[email protected]5a6db6c2010-04-22 18:32:0657#endif // APP_GFX_GL_GL_CONTEXT_OSMESA_H_