summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/x_utils.h
blob: ea478a63d8d8642d36f50f860a39839606f94268 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2009 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.

// This file declares the XWindowWrapper class.

#ifndef GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_
#define GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_

#include <GL/glx.h>
#include "base/basictypes.h"
#include "gpu/command_buffer/common/logging.h"

namespace gpu {

// This class is a wrapper around an X Window and associated GL context. It is
// useful to isolate intrusive X headers, since it can be forward declared
// (Window and GLXContext can't).
class XWindowWrapper {
 public:
  XWindowWrapper(Display *display, Window window)
      : display_(display),
        window_(window) {
    DCHECK(display_);
    DCHECK(window_);
  }
  // Initializes the GL context.
  bool Initialize();

  // Destroys the GL context.
  void Destroy();

  // Makes the GL context current on the current thread.
  bool MakeCurrent();

  // Swaps front and back buffers.
  void SwapBuffers();

 private:
  Display *display_;
  Window window_;
  GLXContext context_;
  DISALLOW_COPY_AND_ASSIGN(XWindowWrapper);
};

}  // namespace gpu

#endif  // GPU_COMMAND_BUFFER_SERVICE_X_UTILS_H_