blob: 473425396dc44dd566cec1971045eb5626dcac0e (
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
|
// 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.
#include "ui/gl/gl_surface.h"
#include <EGL/egl.h>
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "ui/gl/android_native_window.h"
#include "ui/gl/egl_util.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_surface_stub.h"
using ui::GetLastEGLErrorString;
namespace gfx {
bool GLSurface::InitializeOneOffInternal() {
static bool initialized = false;
if (initialized)
return true;
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2:
if (!GLSurfaceEGL::InitializeOneOff()) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
return false;
}
break;
default:
NOTREACHED();
break;
}
initialized = true;
return true;
}
// static
scoped_refptr<GLSurface>
GLSurface::CreateViewGLSurface(bool software, gfx::AcceleratedWidget window) {
if (software)
return NULL;
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2: {
scoped_refptr<GLSurface> surface;
if (window)
surface = new NativeViewGLSurfaceEGL(false, window);
else
surface = new GLSurfaceStub();
if (!surface->Initialize())
return NULL;
return surface;
}
default:
NOTREACHED();
return NULL;
}
}
// static
scoped_refptr<GLSurface>
GLSurface::CreateOffscreenGLSurface(bool software, const gfx::Size& size) {
if (software)
return NULL;
switch (GetGLImplementation()) {
case kGLImplementationEGLGLES2: {
scoped_refptr<PbufferGLSurfaceEGL> surface(
new PbufferGLSurfaceEGL(false, size));
if (!surface->Initialize())
return NULL;
return surface;
}
default:
NOTREACHED();
return NULL;
}
}
} // namespace gfx
|