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

Side by Side Diff: ui/gl/gl_surface_egl.cc

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 7 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This include must be here so that the includes provided transitively 5 // This include must be here so that the includes provided transitively
6 // by gl_surface_egl.h don't make it impossible to compile this code. 6 // by gl_surface_egl.h don't make it impossible to compile this code.
7 #include "third_party/mesa/src/include/GL/osmesa.h" 7 #include "third_party/mesa/src/include/GL/osmesa.h"
8 8
9 #include "ui/gl/gl_surface_egl.h" 9 #include "ui/gl/gl_surface_egl.h"
10 10
11 #if defined(OS_ANDROID) 11 #if defined(OS_ANDROID)
12 #include "base/android/sys_utils.h"
12 #include <android/native_window_jni.h> 13 #include <android/native_window_jni.h>
13 #endif 14 #endif
14 15
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
18 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "ui/gl/egl_util.h" 21 #include "ui/gl/egl_util.h"
21 #include "ui/gl/gl_context.h" 22 #include "ui/gl/gl_context.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (!g_display) { 119 if (!g_display) {
119 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString(); 120 LOG(ERROR) << "eglGetDisplay failed with error " << GetLastEGLErrorString();
120 return false; 121 return false;
121 } 122 }
122 123
123 if (!eglInitialize(g_display, NULL, NULL)) { 124 if (!eglInitialize(g_display, NULL, NULL)) {
124 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString(); 125 LOG(ERROR) << "eglInitialize failed with error " << GetLastEGLErrorString();
125 return false; 126 return false;
126 } 127 }
127 128
129 bool use_16bit_surface = false;
130 #if defined(OS_ANDROID)
131 use_16bit_surface = base::android::SysUtils::IsLowEndDevice();
132 #endif
133
128 // Choose an EGL configuration. 134 // Choose an EGL configuration.
129 // On X this is only used for PBuffer surfaces. 135 // On X this is only used for PBuffer surfaces.
130 static const EGLint kConfigAttribs[] = { 136 static const EGLint kConfigAttribs[] = {
131 EGL_BUFFER_SIZE, 32, 137 EGL_BUFFER_SIZE, 32,
132 EGL_ALPHA_SIZE, 8, 138 EGL_ALPHA_SIZE, 8,
133 EGL_BLUE_SIZE, 8, 139 EGL_BLUE_SIZE, 8,
134 EGL_GREEN_SIZE, 8, 140 EGL_GREEN_SIZE, 8,
135 EGL_RED_SIZE, 8, 141 EGL_RED_SIZE, 8,
136 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 142 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
137 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, 143 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
138 EGL_NONE 144 EGL_NONE
139 }; 145 };
140 146
147 static const EGLint kConfigAttribs16bit[] = {
148 EGL_BUFFER_SIZE, 16,
149 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
150 EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
151 EGL_NONE
152 };
153
141 EGLint num_configs; 154 EGLint num_configs;
142 if (!eglChooseConfig(g_display, 155 if (!eglChooseConfig(g_display,
143 kConfigAttribs, 156 use_16bit_surface ? kConfigAttribs16bit : kConfigAttribs,
144 NULL, 157 NULL,
145 0, 158 0,
146 &num_configs)) { 159 &num_configs)) {
147 LOG(ERROR) << "eglChooseConfig failed with error " 160 LOG(ERROR) << "eglChooseConfig failed with error "
148 << GetLastEGLErrorString(); 161 << GetLastEGLErrorString();
149 return false; 162 return false;
150 } 163 }
151 164
152 if (num_configs == 0) { 165 if (num_configs == 0) {
153 LOG(ERROR) << "No suitable EGL configs found."; 166 LOG(ERROR) << "No suitable EGL configs found.";
154 return false; 167 return false;
155 } 168 }
156 169
157 if (!eglChooseConfig(g_display, 170 if (!eglChooseConfig(g_display,
158 kConfigAttribs, 171 use_16bit_surface ? kConfigAttribs16bit : kConfigAttribs,
159 &g_config, 172 &g_config,
160 1, 173 1,
161 &num_configs)) { 174 &num_configs)) {
162 LOG(ERROR) << "eglChooseConfig failed with error " 175 LOG(ERROR) << "eglChooseConfig failed with error "
163 << GetLastEGLErrorString(); 176 << GetLastEGLErrorString();
164 return false; 177 return false;
165 } 178 }
166 179
180 if (use_16bit_surface) {
181 EGLint red_size, green_size, blue_size;
182 eglGetConfigAttrib(g_display, g_config, EGL_RED_SIZE, &red_size);
183 eglGetConfigAttrib(g_display, g_config, EGL_GREEN_SIZE, &green_size);
184 eglGetConfigAttrib(g_display, g_config, EGL_BLUE_SIZE, &blue_size);
185
186 DCHECK_EQ(5, red_size);
Sami 2013/08/08 10:11:01 The implementation might not support RGB565 so che
187 DCHECK_EQ(6, green_size);
188 DCHECK_EQ(5, blue_size);
189 }
190
167 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); 191 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS);
168 g_egl_create_context_robustness_supported = 192 g_egl_create_context_robustness_supported =
169 HasEGLExtension("EGL_EXT_create_context_robustness"); 193 HasEGLExtension("EGL_EXT_create_context_robustness");
170 g_egl_sync_control_supported = 194 g_egl_sync_control_supported =
171 HasEGLExtension("EGL_CHROMIUM_sync_control"); 195 HasEGLExtension("EGL_CHROMIUM_sync_control");
172 196
173 initialized = true; 197 initialized = true;
174 198
175 return true; 199 return true;
176 } 200 }
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 698 }
675 default: 699 default:
676 NOTREACHED(); 700 NOTREACHED();
677 return NULL; 701 return NULL;
678 } 702 }
679 } 703 }
680 704
681 #endif 705 #endif
682 706
683 } // namespace gfx 707 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698