blob: 06b14ca0e29e7521d2bb22ad0ea018243b1692c2 [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
5#ifndef GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_OSMESA_H_
6#define GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_OSMESA_H_
7
8// Ensure that gl_utils.h is included before any GL headers.
9#include "gpu/command_buffer/service/gl_utils.h"
10
11#include "base/scoped_ptr.h"
12#include "gfx/size.h"
13#include "gpu/command_buffer/service/gl_context.h"
14
15namespace gpu {
16
17// Encapsulates an OSMesa OpenGL context that uses software rendering.
18class OSMesaGLContext : public GLContext {
19 public:
20 OSMesaGLContext();
21 virtual ~OSMesaGLContext();
22
23 // Initialize an OSMesa GL context with the default 1 x 1 initial size.
24 bool Initialize(void* shared_handle);
25
26 // Implement GLContext.
27 virtual void Destroy();
28 virtual bool MakeCurrent();
29 virtual bool IsCurrent();
30 virtual bool IsOffscreen();
31 virtual void SwapBuffers();
32 virtual gfx::Size GetSize();
33 virtual void* GetHandle();
34
35 // Resize the back buffer, preserving the old content. Does nothing if the
36 // size is unchanged.
37 void Resize(const gfx::Size& new_size);
38
39 const void* buffer() const {
40 return buffer_.get();
41 }
42
43 protected:
44 bool InitializeCommon();
45
46 private:
47#if !defined(UNIT_TEST)
48 gfx::Size size_;
49 scoped_array<int32> buffer_;
50 OSMesaContext context_;
51#endif
52
53 DISALLOW_COPY_AND_ASSIGN(OSMesaGLContext);
54};
55
56} // namespace gpu
57
58#endif // GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_OSMESA_H_