Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Side by Side Diff: runtime/embedders/openglui/android/android_graphics_handler.cc

Issue 25081002: Remove openglui embedder code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "embedders/openglui/android/android_graphics_handler.h"
6 #include "embedders/openglui/common/log.h"
7
8 AndroidGraphicsHandler::AndroidGraphicsHandler(android_app* application,
9 const char* resource_path)
10 : GraphicsHandler(resource_path),
11 application_(application),
12 display_(EGL_NO_DISPLAY),
13 surface_(EGL_NO_SURFACE),
14 context_(EGL_NO_CONTEXT) {
15 }
16
17 int32_t AndroidGraphicsHandler::Start() {
18 EGLint format, numConfigs;
19 EGLConfig config;
20 const EGLint attributes[] = {
21 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
22 EGL_NONE
23 };
24 static const EGLint ctx_attribs[] = {
25 EGL_CONTEXT_CLIENT_VERSION, 2,
26 EGL_NONE
27 };
28
29 display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
30 if (display_ != EGL_NO_DISPLAY) {
31 LOGI("eglInitialize");
32 if (eglInitialize(display_, NULL, NULL)) {
33 LOGI("eglChooseConfig");
34 if (eglChooseConfig(display_, attributes, &config, 1, &numConfigs) &&
35 numConfigs > 0) {
36 LOGI("eglGetConfigAttrib returned %d configs\n", numConfigs);
37 if (eglGetConfigAttrib(display_, config,
38 EGL_NATIVE_VISUAL_ID, &format)) {
39 ANativeWindow_setBuffersGeometry(application_->window, 0, 0, format);
40 surface_ = eglCreateWindowSurface(display_, config,
41 (EGLNativeWindowType)application_->window, NULL);
42 if (surface_ != EGL_NO_SURFACE) {
43 LOGI("eglCreateContext");
44 context_ = eglCreateContext(display_, config, EGL_NO_CONTEXT,
45 ctx_attribs);
46 if (context_ != EGL_NO_CONTEXT) {
47 if (eglMakeCurrent(display_, surface_, surface_, context_) &&
48 eglQuerySurface(display_, surface_, EGL_WIDTH, &width_) &&
49 width_ > 0 &&
50 eglQuerySurface(display_, surface_, EGL_HEIGHT, &height_) &&
51 height_ > 0) {
52 LOGI("Got dimensions %d x %d\n", width_, height_);
53 SetViewport(0, 0, width_, height_);
54 LOGI("GL version %s\n", glGetString(GL_VERSION));
55 LOGI("GLSL version: %s\n",
56 glGetString(GL_SHADING_LANGUAGE_VERSION));
57 return GraphicsHandler::Start();
58 }
59 }
60 }
61 }
62 }
63 }
64 }
65 LOGE("Error starting graphics");
66 Stop();
67 return -1;
68 }
69
70 void AndroidGraphicsHandler::Stop() {
71 LOGI("Stopping graphics");
72 GraphicsHandler::Stop();
73 if (display_ != EGL_NO_DISPLAY) {
74 eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
75 if (context_ != EGL_NO_CONTEXT) {
76 eglDestroyContext(display_, context_);
77 context_ = EGL_NO_CONTEXT;
78 }
79 if (surface_ != EGL_NO_SURFACE) {
80 eglDestroySurface(display_, surface_);
81 surface_ = EGL_NO_SURFACE;
82 }
83 eglTerminate(display_);
84 display_ = EGL_NO_DISPLAY;
85 }
86 }
87
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698