blob: bce22061d2759d83f200bd784c4632ecef0aef4f (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// Copyright (c) 2012 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_GL_GL_SURFACE_EGL_H_
#define UI_GL_GL_SURFACE_EGL_H_
#pragma once
#if defined(OS_WIN)
#include <windows.h>
#endif
#include "base/compiler_specific.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"
#include "ui/gl/gl_surface.h"
typedef void* EGLConfig;
typedef void* EGLDisplay;
typedef void* EGLSurface;
#if defined(OS_ANDROID)
typedef void* EGLNativeDisplayType;
#elif defined(OS_WIN)
typedef HDC EGLNativeDisplayType;
#else
typedef struct _XDisplay* EGLNativeDisplayType;
#endif
namespace gfx {
// Interface for EGL surface.
class GL_EXPORT GLSurfaceEGL : public GLSurface {
public:
GLSurfaceEGL();
// Implement GLSurface.
virtual EGLDisplay GetDisplay() OVERRIDE;
static bool InitializeOneOff();
static EGLDisplay GetHardwareDisplay();
static EGLDisplay GetSoftwareDisplay();
static EGLNativeDisplayType GetNativeDisplay();
protected:
virtual ~GLSurfaceEGL();
bool software_;
private:
DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGL);
};
// Encapsulates an EGL surface bound to a view.
class NativeViewGLSurfaceEGL : public GLSurfaceEGL {
public:
NativeViewGLSurfaceEGL(bool software, gfx::AcceleratedWidget window);
// Implement GLSurface.
virtual EGLConfig GetConfig() OVERRIDE;
virtual bool Initialize() OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual bool IsOffscreen() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual EGLSurface GetHandle() OVERRIDE;
virtual std::string GetExtensions() OVERRIDE;
virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE;
protected:
virtual ~NativeViewGLSurfaceEGL();
void SetHandle(EGLSurface surface);
private:
gfx::AcceleratedWidget window_;
EGLSurface surface_;
bool supports_post_sub_buffer_;
EGLConfig config_;
DISALLOW_COPY_AND_ASSIGN(NativeViewGLSurfaceEGL);
};
// Encapsulates a pbuffer EGL surface.
class GL_EXPORT PbufferGLSurfaceEGL : public GLSurfaceEGL {
public:
PbufferGLSurfaceEGL(bool software, const gfx::Size& size);
// Implement GLSurface.
virtual EGLConfig GetConfig() OVERRIDE;
virtual bool Initialize() OVERRIDE;
virtual void Destroy() OVERRIDE;
virtual bool IsOffscreen() OVERRIDE;
virtual bool SwapBuffers() OVERRIDE;
virtual gfx::Size GetSize() OVERRIDE;
virtual bool Resize(const gfx::Size& size) OVERRIDE;
virtual EGLSurface GetHandle() OVERRIDE;
virtual void* GetShareHandle() OVERRIDE;
protected:
virtual ~PbufferGLSurfaceEGL();
private:
gfx::Size size_;
EGLSurface surface_;
DISALLOW_COPY_AND_ASSIGN(PbufferGLSurfaceEGL);
};
} // namespace gfx
#endif // UI_GL_GL_SURFACE_EGL_H_
|