summaryrefslogtreecommitdiffstats
path: root/ui/gfx/gl/gl_surface_egl.h
blob: 19e7f4feefcc7492cdc5c73cd42133264b1cd38c (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// 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_SURFACE_EGL_H_
#define UI_GFX_GL_GL_SURFACE_EGL_H_
#pragma once

#if defined(OS_WIN)
#include <windows.h>
#endif

#include "ui/gfx/gl/gl_surface.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"

typedef void* EGLConfig;
typedef void* EGLDisplay;
typedef void* EGLSurface;

#if defined(OS_WIN)
typedef HDC EGLNativeDisplayType;
#else
typedef struct _XDisplay* EGLNativeDisplayType;
#endif

namespace gfx {

// Interface for EGL surface.
class GLSurfaceEGL : public GLSurface {
 public:
  GLSurfaceEGL();
  virtual ~GLSurfaceEGL();

  static bool InitializeOneOff();
  EGLDisplay GetDisplay();
  EGLConfig GetConfig();
  static EGLDisplay GetHardwareDisplay();
  static EGLDisplay GetSoftwareDisplay();
  static EGLNativeDisplayType GetNativeDisplay();

protected:
  bool software_;

 private:
  DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL);
};

// Encapsulates an EGL surface bound to a view.
class NativeViewGLSurfaceEGL : public GLSurfaceEGL {
 public:
  explicit NativeViewGLSurfaceEGL(bool software,
                                  gfx::PluginWindowHandle window);
  virtual ~NativeViewGLSurfaceEGL();

  // Implement GLSurface.
  virtual bool Initialize();
  virtual void Destroy();
  virtual bool IsOffscreen();
  virtual bool SwapBuffers();
  virtual gfx::Size GetSize();
  virtual EGLSurface GetHandle();

 private:
  gfx::PluginWindowHandle window_;
  EGLSurface surface_;

  DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL);
};

// Encapsulates a pbuffer EGL surface.
class PbufferGLSurfaceEGL : public GLSurfaceEGL {
 public:
  explicit PbufferGLSurfaceEGL(bool software, const gfx::Size& size);
  virtual ~PbufferGLSurfaceEGL();

  // Implement GLSurface.
  virtual bool Initialize();
  virtual void Destroy();
  virtual bool IsOffscreen();
  virtual bool SwapBuffers();
  virtual gfx::Size GetSize();
  virtual EGLSurface GetHandle();

 private:
  gfx::Size size_;
  EGLSurface surface_;

  DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL);
};

}  // namespace gfx

#endif  // UI_GFX_GL_GL_SURFACE_EGL_H_