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

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

Issue 17110007: Delete usage and support for EGL_ANGLE_software_display extension. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_surface_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/gl/gl_surface_egl.h" 5 #include "ui/gl/gl_surface_egl.h"
6 6
7 #if defined(OS_ANDROID) 7 #if defined(OS_ANDROID)
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #endif 9 #endif
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 using ui::GetLastEGLErrorString; 31 using ui::GetLastEGLErrorString;
32 32
33 namespace gfx { 33 namespace gfx {
34 34
35 namespace { 35 namespace {
36 36
37 EGLConfig g_config; 37 EGLConfig g_config;
38 EGLDisplay g_display; 38 EGLDisplay g_display;
39 EGLNativeDisplayType g_native_display; 39 EGLNativeDisplayType g_native_display;
40 EGLConfig g_software_config;
41 EGLDisplay g_software_display;
42 EGLNativeDisplayType g_software_native_display;
43 40
44 const char* g_egl_extensions = NULL; 41 const char* g_egl_extensions = NULL;
45 bool g_egl_create_context_robustness_supported = false; 42 bool g_egl_create_context_robustness_supported = false;
46 bool g_egl_sync_control_supported = false; 43 bool g_egl_sync_control_supported = false;
47 44
48 class EGLSyncControlVSyncProvider 45 class EGLSyncControlVSyncProvider
49 : public gfx::SyncControlVSyncProvider { 46 : public gfx::SyncControlVSyncProvider {
50 public: 47 public:
51 explicit EGLSyncControlVSyncProvider(EGLSurface surface) 48 explicit EGLSyncControlVSyncProvider(EGLSurface surface)
52 : SyncControlVSyncProvider(), 49 : SyncControlVSyncProvider(),
(...skipping 23 matching lines...) Expand all
76 } 73 }
77 74
78 private: 75 private:
79 EGLSurface surface_; 76 EGLSurface surface_;
80 77
81 DISALLOW_COPY_AND_ASSIGN(EGLSyncControlVSyncProvider); 78 DISALLOW_COPY_AND_ASSIGN(EGLSyncControlVSyncProvider);
82 }; 79 };
83 80
84 } // namespace 81 } // namespace
85 82
86 GLSurfaceEGL::GLSurfaceEGL() : software_(false) {} 83 GLSurfaceEGL::GLSurfaceEGL() {}
87 84
88 bool GLSurfaceEGL::InitializeOneOff() { 85 bool GLSurfaceEGL::InitializeOneOff() {
89 static bool initialized = false; 86 static bool initialized = false;
90 if (initialized) 87 if (initialized)
91 return true; 88 return true;
92 89
93 #if defined (USE_OZONE) 90 #if defined (USE_OZONE)
94 ui::SurfaceFactoryOzone::GetInstance()->InitializeHardware(); 91 ui::SurfaceFactoryOzone::GetInstance()->InitializeHardware();
95 #endif 92 #endif
96 93
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 147 }
151 148
152 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); 149 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS);
153 g_egl_create_context_robustness_supported = 150 g_egl_create_context_robustness_supported =
154 HasEGLExtension("EGL_EXT_create_context_robustness"); 151 HasEGLExtension("EGL_EXT_create_context_robustness");
155 g_egl_sync_control_supported = 152 g_egl_sync_control_supported =
156 HasEGLExtension("EGL_CHROMIUM_sync_control"); 153 HasEGLExtension("EGL_CHROMIUM_sync_control");
157 154
158 initialized = true; 155 initialized = true;
159 156
160 #if defined(USE_X11) || defined(OS_ANDROID) \
161 || defined(USE_OZONE)
162 return true;
163 #else
164 g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE;
165 #endif
166 g_software_display = eglGetDisplay(g_software_native_display);
167 if (!g_software_display) {
168 return true;
169 }
170
171 if (!eglInitialize(g_software_display, NULL, NULL)) {
172 return true;
173 }
174
175 if (!eglChooseConfig(g_software_display,
176 kConfigAttribs,
177 NULL,
178 0,
179 &num_configs)) {
180 g_software_display = NULL;
181 return true;
182 }
183
184 if (num_configs == 0) {
185 g_software_display = NULL;
186 return true;
187 }
188
189 if (!eglChooseConfig(g_software_display,
190 kConfigAttribs,
191 &g_software_config,
192 1,
193 &num_configs)) {
194 g_software_display = NULL;
195 return false;
196 }
197
198 return true; 157 return true;
199 } 158 }
200 159
201 EGLDisplay GLSurfaceEGL::GetDisplay() { 160 EGLDisplay GLSurfaceEGL::GetDisplay() {
202 return software_ ? g_software_display : g_display; 161 return g_display;
203 } 162 }
204 163
205 EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { 164 EGLDisplay GLSurfaceEGL::GetHardwareDisplay() {
206 return g_display; 165 return g_display;
207 } 166 }
208 167
209 EGLDisplay GLSurfaceEGL::GetSoftwareDisplay() {
210 return g_software_display;
211 }
212
213 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { 168 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() {
214 return g_native_display; 169 return g_native_display;
215 } 170 }
216 171
217 const char* GLSurfaceEGL::GetEGLExtensions() { 172 const char* GLSurfaceEGL::GetEGLExtensions() {
218 return g_egl_extensions; 173 return g_egl_extensions;
219 } 174 }
220 175
221 bool GLSurfaceEGL::HasEGLExtension(const char* name) { 176 bool GLSurfaceEGL::HasEGLExtension(const char* name) {
222 return ExtensionsContain(GetEGLExtensions(), name); 177 return ExtensionsContain(GetEGLExtensions(), name);
223 } 178 }
224 179
225 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { 180 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() {
226 return g_egl_create_context_robustness_supported; 181 return g_egl_create_context_robustness_supported;
227 } 182 }
228 183
229 GLSurfaceEGL::~GLSurfaceEGL() {} 184 GLSurfaceEGL::~GLSurfaceEGL() {}
230 185
231 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, 186 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(gfx::AcceleratedWidget window)
232 gfx::AcceleratedWidget window)
233 : window_(window), 187 : window_(window),
234 surface_(NULL), 188 surface_(NULL),
235 supports_post_sub_buffer_(false), 189 supports_post_sub_buffer_(false),
236 config_(NULL) { 190 config_(NULL) {
237 software_ = software;
238 #if defined(OS_ANDROID) 191 #if defined(OS_ANDROID)
239 if (window) 192 if (window)
240 ANativeWindow_acquire(window); 193 ANativeWindow_acquire(window);
241 #endif 194 #endif
242 } 195 }
243 196
244 bool NativeViewGLSurfaceEGL::Initialize() { 197 bool NativeViewGLSurfaceEGL::Initialize() {
245 return Initialize(NULL); 198 return Initialize(NULL);
246 } 199 }
247 200
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (!eglDestroySurface(GetDisplay(), surface_)) { 251 if (!eglDestroySurface(GetDisplay(), surface_)) {
299 LOG(ERROR) << "eglDestroySurface failed with error " 252 LOG(ERROR) << "eglDestroySurface failed with error "
300 << GetLastEGLErrorString(); 253 << GetLastEGLErrorString();
301 } 254 }
302 surface_ = NULL; 255 surface_ = NULL;
303 } 256 }
304 } 257 }
305 258
306 EGLConfig NativeViewGLSurfaceEGL::GetConfig() { 259 EGLConfig NativeViewGLSurfaceEGL::GetConfig() {
307 #if !defined(USE_X11) 260 #if !defined(USE_X11)
308 return software_ ? g_software_config : g_config; 261 return g_config;
309 #else 262 #else
310 if (!config_) { 263 if (!config_) {
311 // Get a config compatible with the window 264 // Get a config compatible with the window
312 DCHECK(window_); 265 DCHECK(window_);
313 XWindowAttributes win_attribs; 266 XWindowAttributes win_attribs;
314 if (!XGetWindowAttributes(GetNativeDisplay(), window_, &win_attribs)) { 267 if (!XGetWindowAttributes(GetNativeDisplay(), window_, &win_attribs)) {
315 return NULL; 268 return NULL;
316 } 269 }
317 270
318 // Try matching the window depth with an alpha channel, 271 // Try matching the window depth with an alpha channel,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 #if defined(OS_ANDROID) 426 #if defined(OS_ANDROID)
474 if (window_) 427 if (window_)
475 ANativeWindow_release(window_); 428 ANativeWindow_release(window_);
476 #endif 429 #endif
477 } 430 }
478 431
479 void NativeViewGLSurfaceEGL::SetHandle(EGLSurface surface) { 432 void NativeViewGLSurfaceEGL::SetHandle(EGLSurface surface) {
480 surface_ = surface; 433 surface_ = surface;
481 } 434 }
482 435
483 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) 436 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size)
484 : size_(size), 437 : size_(size),
485 surface_(NULL) { 438 surface_(NULL) {
486 software_ = software;
487 } 439 }
488 440
489 bool PbufferGLSurfaceEGL::Initialize() { 441 bool PbufferGLSurfaceEGL::Initialize() {
490 EGLSurface old_surface = surface_; 442 EGLSurface old_surface = surface_;
491 443
492 EGLDisplay display = GetDisplay(); 444 EGLDisplay display = GetDisplay();
493 if (!display) { 445 if (!display) {
494 LOG(ERROR) << "Trying to create surface with invalid display."; 446 LOG(ERROR) << "Trying to create surface with invalid display.";
495 return false; 447 return false;
496 } 448 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 if (surface_) { 483 if (surface_) {
532 if (!eglDestroySurface(GetDisplay(), surface_)) { 484 if (!eglDestroySurface(GetDisplay(), surface_)) {
533 LOG(ERROR) << "eglDestroySurface failed with error " 485 LOG(ERROR) << "eglDestroySurface failed with error "
534 << GetLastEGLErrorString(); 486 << GetLastEGLErrorString();
535 } 487 }
536 surface_ = NULL; 488 surface_ = NULL;
537 } 489 }
538 } 490 }
539 491
540 EGLConfig PbufferGLSurfaceEGL::GetConfig() { 492 EGLConfig PbufferGLSurfaceEGL::GetConfig() {
541 return software_ ? g_software_config : g_config; 493 return g_config;
542 } 494 }
543 495
544 bool PbufferGLSurfaceEGL::IsOffscreen() { 496 bool PbufferGLSurfaceEGL::IsOffscreen() {
545 return true; 497 return true;
546 } 498 }
547 499
548 bool PbufferGLSurfaceEGL::SwapBuffers() { 500 bool PbufferGLSurfaceEGL::SwapBuffers() {
549 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; 501 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL.";
550 return false; 502 return false;
551 } 503 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 568
617 if (!GLSurfaceEGL::InitializeOneOff()) { 569 if (!GLSurfaceEGL::InitializeOneOff()) {
618 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; 570 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
619 return false; 571 return false;
620 } 572 }
621 return true; 573 return true;
622 } 574 }
623 575
624 // static 576 // static
625 scoped_refptr<GLSurface> 577 scoped_refptr<GLSurface>
626 GLSurface::CreateViewGLSurface(bool software, gfx::AcceleratedWidget window) { 578 GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window) {
627 if (software)
628 return NULL;
629
630 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2); 579 DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
631 if (window) { 580 if (window) {
632 scoped_refptr<NativeViewGLSurfaceEGL> surface; 581 scoped_refptr<NativeViewGLSurfaceEGL> surface;
633 VSyncProvider* sync_provider = NULL; 582 VSyncProvider* sync_provider = NULL;
634 #if defined(USE_OZONE) 583 #if defined(USE_OZONE)
635 window = ui::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget( 584 window = ui::SurfaceFactoryOzone::GetInstance()->RealizeAcceleratedWidget(
636 window); 585 window);
637 sync_provider = 586 sync_provider =
638 ui::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window); 587 ui::SurfaceFactoryOzone::GetInstance()->GetVSyncProvider(window);
639 #endif 588 #endif
640 surface = new NativeViewGLSurfaceEGL(false, window); 589 surface = new NativeViewGLSurfaceEGL(window);
641 if(surface->Initialize(sync_provider)) 590 if(surface->Initialize(sync_provider))
642 return surface; 591 return surface;
643 } else { 592 } else {
644 scoped_refptr<GLSurface> surface = new GLSurfaceStub(); 593 scoped_refptr<GLSurface> surface = new GLSurfaceStub();
645 if (surface->Initialize()) 594 if (surface->Initialize())
646 return surface; 595 return surface;
647 } 596 }
648 return NULL; 597 return NULL;
649 } 598 }
650 599
651 // static 600 // static
652 scoped_refptr<GLSurface> 601 scoped_refptr<GLSurface>
653 GLSurface::CreateOffscreenGLSurface(bool software, const gfx::Size& size) { 602 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) {
654 if (software)
655 return NULL;
656
657 switch (GetGLImplementation()) { 603 switch (GetGLImplementation()) {
658 case kGLImplementationEGLGLES2: { 604 case kGLImplementationEGLGLES2: {
659 scoped_refptr<PbufferGLSurfaceEGL> surface( 605 scoped_refptr<PbufferGLSurfaceEGL> surface(
660 new PbufferGLSurfaceEGL(false, size)); 606 new PbufferGLSurfaceEGL(size));
661 if (!surface->Initialize()) 607 if (!surface->Initialize())
662 return NULL; 608 return NULL;
663 return surface; 609 return surface;
664 } 610 }
665 default: 611 default:
666 NOTREACHED(); 612 NOTREACHED();
667 return NULL; 613 return NULL;
668 } 614 }
669 } 615 }
670 616
671 #endif 617 #endif
672 618
673 } // namespace gfx 619 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_surface_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698