16d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
26d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters// Use of this source code is governed by a BSD-style license that can be
36d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters// found in the LICENSE file.
46d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters
56d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters#ifndef BENCH_GL_EGL_STUFF_H_
66d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters#define BENCH_GL_EGL_STUFF_H_
76d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters
8aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison#include "base/logging.h"
97f840e726dd0455d4ef338de4de89adcf2118534Simon Que#include "glinterface.h"
10aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison#include <EGL/egl.h>
116d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters
127f840e726dd0455d4ef338de4de89adcf2118534Simon Queclass EGLInterface : public GLInterface {
137f840e726dd0455d4ef338de4de89adcf2118534Simon Que public:
14aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison
157f840e726dd0455d4ef338de4de89adcf2118534Simon Que  EGLInterface() : display_(EGL_NO_DISPLAY),
167f840e726dd0455d4ef338de4de89adcf2118534Simon Que                   config_(NULL),
177f840e726dd0455d4ef338de4de89adcf2118534Simon Que                   surface_(NULL),
18aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison                   context_(NULL) { }
197f840e726dd0455d4ef338de4de89adcf2118534Simon Que  virtual ~EGLInterface() {}
207f840e726dd0455d4ef338de4de89adcf2118534Simon Que
217f840e726dd0455d4ef338de4de89adcf2118534Simon Que  virtual bool Init();
22068608273fa39b4032003d3a1f00d4125cc321e3Simon Que  virtual void Cleanup();
237f840e726dd0455d4ef338de4de89adcf2118534Simon Que  virtual XVisualInfo* GetXVisual();
247f840e726dd0455d4ef338de4de89adcf2118534Simon Que
257f840e726dd0455d4ef338de4de89adcf2118534Simon Que  virtual void SwapBuffers();
267f840e726dd0455d4ef338de4de89adcf2118534Simon Que  virtual bool SwapInterval(int interval);
277f840e726dd0455d4ef338de4de89adcf2118534Simon Que
28aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison  virtual void CheckError();
29aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison
30068608273fa39b4032003d3a1f00d4125cc321e3Simon Que  virtual bool MakeCurrent(const GLContext& context);
31068608273fa39b4032003d3a1f00d4125cc321e3Simon Que  virtual const GLContext CreateContext();
32068608273fa39b4032003d3a1f00d4125cc321e3Simon Que  virtual void DeleteContext(const GLContext& context);
33068608273fa39b4032003d3a1f00d4125cc321e3Simon Que  virtual const GLContext& GetMainContext() {
34068608273fa39b4032003d3a1f00d4125cc321e3Simon Que    return context_;
35068608273fa39b4032003d3a1f00d4125cc321e3Simon Que  }
36068608273fa39b4032003d3a1f00d4125cc321e3Simon Que
377f840e726dd0455d4ef338de4de89adcf2118534Simon Que  void TerminateGL();
387f840e726dd0455d4ef338de4de89adcf2118534Simon Que
397f840e726dd0455d4ef338de4de89adcf2118534Simon Que  const EGLDisplay display() const {
407f840e726dd0455d4ef338de4de89adcf2118534Simon Que    return display_;
417f840e726dd0455d4ef338de4de89adcf2118534Simon Que  }
427f840e726dd0455d4ef338de4de89adcf2118534Simon Que
43aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison  const EGLSurface surface() const {
44aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison    return surface_;
45aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison  }
46aa6dea876d0bf7f393e16505408bc3767a3ce7efRyan Harrison
477f840e726dd0455d4ef338de4de89adcf2118534Simon Que private:
487f840e726dd0455d4ef338de4de89adcf2118534Simon Que  EGLDisplay display_;
497f840e726dd0455d4ef338de4de89adcf2118534Simon Que  EGLConfig config_;
507f840e726dd0455d4ef338de4de89adcf2118534Simon Que  EGLSurface surface_;
517f840e726dd0455d4ef338de4de89adcf2118534Simon Que  EGLContext context_;
527f840e726dd0455d4ef338de4de89adcf2118534Simon Que};
536d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters
546d9545fddc7efb53b32c2c725245a93a51041535Kenneth Waters#endif  // BENCH_GL_EGL_STUFF_H_
55