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

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

Issue 49533003: Add support for Khr_surfaceless_context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | no next file » | 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 // 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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 namespace { 48 namespace {
49 49
50 EGLConfig g_config; 50 EGLConfig g_config;
51 EGLDisplay g_display; 51 EGLDisplay g_display;
52 EGLNativeDisplayType g_native_display; 52 EGLNativeDisplayType g_native_display;
53 53
54 const char* g_egl_extensions = NULL; 54 const char* g_egl_extensions = NULL;
55 bool g_egl_create_context_robustness_supported = false; 55 bool g_egl_create_context_robustness_supported = false;
56 bool g_egl_sync_control_supported = false; 56 bool g_egl_sync_control_supported = false;
57 bool g_egl_surfaceless_context = false;
piman 2013/10/31 20:07:54 nit: g_egl_surfaceless_context_supported for consi
kalyank 2013/10/31 22:15:27 fixed.
57 58
58 class EGLSyncControlVSyncProvider 59 class EGLSyncControlVSyncProvider
59 : public gfx::SyncControlVSyncProvider { 60 : public gfx::SyncControlVSyncProvider {
60 public: 61 public:
61 explicit EGLSyncControlVSyncProvider(EGLSurface surface) 62 explicit EGLSyncControlVSyncProvider(EGLSurface surface)
62 : SyncControlVSyncProvider(), 63 : SyncControlVSyncProvider(),
63 surface_(surface) { 64 surface_(surface) {
64 } 65 }
65 66
66 virtual ~EGLSyncControlVSyncProvider() { } 67 virtual ~EGLSyncControlVSyncProvider() { }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 << GetLastEGLErrorString(); 178 << GetLastEGLErrorString();
178 return false; 179 return false;
179 } 180 }
180 181
181 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); 182 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS);
182 g_egl_create_context_robustness_supported = 183 g_egl_create_context_robustness_supported =
183 HasEGLExtension("EGL_EXT_create_context_robustness"); 184 HasEGLExtension("EGL_EXT_create_context_robustness");
184 g_egl_sync_control_supported = 185 g_egl_sync_control_supported =
185 HasEGLExtension("EGL_CHROMIUM_sync_control"); 186 HasEGLExtension("EGL_CHROMIUM_sync_control");
186 187
188 // Check if SurfacelessEGL is supported.
189 g_egl_surfaceless_context = HasEGLExtension("EGL_KHR_surfaceless_context");
190 if (g_egl_surfaceless_context) {
191 // EGL_KHR_surfaceless_context is supported but ensure
192 // GL_OES_surfaceless_context is also supported. We need a current context
193 // to query for supported GL extensions.
194 scoped_refptr<GLSurface> surface = new SurfacelessEGL(Size(1, 1));
195 scoped_refptr<GLContext> context = GLContext::CreateGLContext(
196 NULL, surface.get(), PreferIntegratedGpu);
197 if (!context->MakeCurrent(surface.get()))
198 g_egl_surfaceless_context = false;
199
200 // Ensure context supports GL_OES_surfaceless_context.
201 if (g_egl_surfaceless_context) {
202 g_egl_surfaceless_context = context->HasExtension(
203 "GL_OES_surfaceless_context");
204 context->ReleaseCurrent(surface.get());
205 }
206 }
207
187 initialized = true; 208 initialized = true;
188 209
189 return true; 210 return true;
190 } 211 }
191 212
192 EGLDisplay GLSurfaceEGL::GetDisplay() { 213 EGLDisplay GLSurfaceEGL::GetDisplay() {
193 return g_display; 214 return g_display;
194 } 215 }
195 216
196 EGLDisplay GLSurfaceEGL::GetHardwareDisplay() { 217 EGLDisplay GLSurfaceEGL::GetHardwareDisplay() {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 607 }
587 608
588 return handle; 609 return handle;
589 #endif 610 #endif
590 } 611 }
591 612
592 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { 613 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {
593 Destroy(); 614 Destroy();
594 } 615 }
595 616
617 SurfacelessEGL::SurfacelessEGL(const gfx::Size& size)
618 : size_(size) {
619 }
620
621 bool SurfacelessEGL::Initialize() {
622 return true;
623 }
624
625 void SurfacelessEGL::Destroy() {
626 }
627
628 EGLConfig SurfacelessEGL::GetConfig() {
629 return g_config;
630 }
631
632 bool SurfacelessEGL::IsOffscreen() {
633 return true;
634 }
635
636 bool SurfacelessEGL::SwapBuffers() {
637 NOTREACHED() << "Attempted to call SwapBuffers with SurfacelessEGL.";
piman 2013/10/31 20:07:54 note: technically it can be reached if the (untrus
kalyank 2013/10/31 22:15:27 fixed.
638 return false;
639 }
640
641 gfx::Size SurfacelessEGL::GetSize() {
642 return size_;
643 }
644
645 bool SurfacelessEGL::Resize(const gfx::Size& size) {
646 size_ = size;
647 return true;
648 }
649
650 EGLSurface SurfacelessEGL::GetHandle() {
651 return EGL_NO_SURFACE;
652 }
653
654 void* SurfacelessEGL::GetShareHandle() {
655 return NULL;
656 }
657
658 SurfacelessEGL::~SurfacelessEGL() {
659 }
660
596 #if defined(ANDROID) || defined(USE_OZONE) 661 #if defined(ANDROID) || defined(USE_OZONE)
597 662
598 // A thin subclass of |GLSurfaceOSMesa| that can be used in place 663 // A thin subclass of |GLSurfaceOSMesa| that can be used in place
599 // of a native hardware-provided surface when a native surface 664 // of a native hardware-provided surface when a native surface
600 // provider is not available. 665 // provider is not available.
601 class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa { 666 class GLSurfaceOSMesaHeadless : public GLSurfaceOSMesa {
602 public: 667 public:
603 explicit GLSurfaceOSMesaHeadless(gfx::AcceleratedWidget window); 668 explicit GLSurfaceOSMesaHeadless(gfx::AcceleratedWidget window);
604 669
605 virtual bool IsOffscreen() OVERRIDE; 670 virtual bool IsOffscreen() OVERRIDE;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { 739 GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) {
675 switch (GetGLImplementation()) { 740 switch (GetGLImplementation()) {
676 case kGLImplementationOSMesaGL: { 741 case kGLImplementationOSMesaGL: {
677 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size)); 742 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size));
678 if (!surface->Initialize()) 743 if (!surface->Initialize())
679 return NULL; 744 return NULL;
680 745
681 return surface; 746 return surface;
682 } 747 }
683 case kGLImplementationEGLGLES2: { 748 case kGLImplementationEGLGLES2: {
684 scoped_refptr<PbufferGLSurfaceEGL> surface( 749 scoped_refptr<GLSurface> surface;
685 new PbufferGLSurfaceEGL(size)); 750 if (g_egl_surfaceless_context)
751 surface = new SurfacelessEGL(size);
piman 2013/10/31 20:07:54 So, what if the client really meant to have an off
kalyank 2013/10/31 22:15:27 I for now added the checks with 1,1 size. If no on
752 else
753 surface = new PbufferGLSurfaceEGL(size);
754
686 if (!surface->Initialize()) 755 if (!surface->Initialize())
687 return NULL; 756 return NULL;
688 return surface; 757 return surface;
689 } 758 }
690 default: 759 default:
691 NOTREACHED(); 760 NOTREACHED();
692 return NULL; 761 return NULL;
693 } 762 }
694 } 763 }
695 764
696 #endif 765 #endif
697 766
698 } // namespace gfx 767 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698