Closed Bug 950903 Opened 11 years ago Closed 10 years ago

Expose backend-specific GLContext subclasses, rather than exposing backend-specific notions in GLContext

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: jgilbert, Assigned: bjacob)

References

Details

(Whiteboard: [qa-])

Attachments

(9 files, 1 obsolete file)

27.98 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
16.79 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
10.13 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
12.46 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
5.05 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
18.25 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
1.90 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
1.52 KB, patch
jgilbert
: review+
Details | Diff | Splinter Review
81.02 KB, patch
Details | Diff | Splinter Review
We want a good way for external code presented with a GLContext to retrieve the GLContext{EGL,GLX,CGL,WGL}.

From talking with :bjacob we seemed to agree on: (or similar) ('proposal 1')
GLContext has no backend-specific functions
GLContext::GetNativeGLContext() returns a GLContext{EGL,GLX,CGL,WGL}
Backend-specific calls live on backend-specific GLContext implementations:
GLContextCGL::GetCGLContext() returns CGLContext
GLContextCGL::GetNSOpenGLContext() returns NSOpenGLContext

I would actually like to use something similar to SharedSurfaceFoo::Cast(), with the assert that gives us, which would shape the API as: ('proposal 2')

GLContext::GetBackendType returns {EGL, WGL, CGL, GLX}

static GLContextFoo* GLContextFoo::Cast(GLContext* gl) {
  MOZ_ASSERT(gl->GetBackendType() == Foo)
  return (GLContextFoo*)gl;
}
Depends on: 949814
Blocks: 942491
Taking. The part that I'm interested in, is exposing GLContextCGL and friends directly to remove the need to expose backend-specific things in GLContext itself. I'll adopt the Cast() API that you propose for that. The part that I'm less interested in, is changing the API inside of GLContextCGL and friends. I'll leave that unchanged.
Assignee: nobody → bjacob
Summary: Improve the API for retrieving the backend-specific implementation of GLContext → Expose backed-specific GLContext subclasses, rather than exposing backend-specific notions in GLContext
Oh, I see: there simply was no other API than GetNativeData to get the stuff in a GLContextCGL. OK, adding the API that you suggested. Patches coming.
Attachment #8355331 - Flags: review?(jgilbert)
Some build fixes.
Attachment #8355331 - Attachment is obsolete: true
Attachment #8355331 - Flags: review?(jgilbert)
Attachment #8355613 - Flags: review?(jgilbert)
I have no idea how this worked before. Looks like the old code was reinterpreting a WGLContext handle as a EGLContext handle. I had to fix that as the new Cast() methods assert that the context type is the right one. Was hitting this assertion failure on native-gl WebGL reftests on windows.
Attachment #8355905 - Flags: review?(jgilbert)
Attachment #8355322 - Attachment description: 1/6 - Expose GLContextEGL publicly → 1/8 - Expose GLContextEGL publicly
Attachment #8355324 - Attachment description: 2/6 - Expose GLContextGLX publicly → 2/8 - Expose GLContextGLX publicly
Attachment #8355327 - Attachment description: 3/6 - Expose GLContextCGL publicly → 3/8 - Expose GLContextCGL publicly
Attachment #8355328 - Attachment description: 4/6 - Expose GLContextWGL publicly → 4/8 - Expose GLContextWGL publicly
Attachment #8355329 - Attachment description: 5/6 - Add static Cast methods to allow getting the backend-specific object from a GLContext → 5/8 - Add static Cast methods to allow getting the backend-specific object from a GLContext
Summary: Expose backed-specific GLContext subclasses, rather than exposing backend-specific notions in GLContext → Expose backend-specific GLContext subclasses, rather than exposing backend-specific notions in GLContext
Attachment #8355615 - Attachment description: 7/7 - Simplifications around EGLSurface override → 7/8 - Simplifications around EGLSurface override
Attachment #8355613 - Attachment description: 6/6 - Remove GLContext::GetNativeData → 6/8 - Remove GLContext::GetNativeData
Attached patch Combined diffSplinter Review
As a reviewing helper. 

Also, here's the diff --stat:

$ hg diff --stat -r qparent:no-surfacefactoryangle-on-wgl
 dom/plugins/base/android/ANPOpenGL.cpp           |    4 +-                   
 gfx/gl/GLContext.h                               |    9 -                    
 gfx/gl/GLContextCGL.h                            |   69 ++                   
 gfx/gl/GLContextEGL.h                            |  133 ++++                 
 gfx/gl/GLContextGLX.h                            |   83 ++                   
 gfx/gl/GLContextProviderCGL.mm                   |  174 ++--                 
 gfx/gl/GLContextProviderEGL.cpp                  |  665 +++++++++----------- 
 gfx/gl/GLContextProviderGLX.cpp                  |  371 +++++------          
 gfx/gl/GLContextProviderWGL.cpp                  |  270 +++----
 gfx/gl/GLContextWGL.h                            |   84 ++
 gfx/gl/GLSharedHandleHelpers.cpp                 |    5 +-
 gfx/gl/SharedSurfaceANGLE.cpp                    |   10 +-
 gfx/gl/SharedSurfaceEGL.cpp                      |    6 +-
 gfx/gl/SharedSurfaceIO.cpp                       |    4 +-
 gfx/gl/WGLLibrary.h                              |    2 +
 gfx/gl/moz.build                                 |    8 +-
 gfx/layers/d3d10/CanvasLayerD3D10.cpp            |   12 +-
 gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp |    4 +-
 widget/cocoa/nsChildView.mm                      |    9 +-
 19 files changed, 1074 insertions(+), 848 deletions(-)
Attachment #8355322 - Flags: review?(jgilbert) → review+
Attachment #8355324 - Flags: review?(jgilbert) → review+
Attachment #8355327 - Flags: review?(jgilbert) → review+
Attachment #8355328 - Flags: review?(jgilbert) → review+
Comment on attachment 8355329 [details] [diff] [review]
5/8 - Add static Cast methods to allow getting the backend-specific object from a GLContext

Review of attachment 8355329 [details] [diff] [review]:
-----------------------------------------------------------------

No implied virtual overrides, please!

::: gfx/gl/GLContextCGL.h
@@ +28,5 @@
>                   bool isOffscreen = false);
>  
>      ~GLContextCGL();
>  
> +    GLContextType GetContextType() { return ContextTypeCGL; }

Add `virtual` and `MOZ_OVERRIDE`. ([1])

::: gfx/gl/GLContextEGL.h
@@ +37,5 @@
>                   EGLContext context);
>  
>      ~GLContextEGL();
>  
> +    GLContextType GetContextType() { return ContextTypeEGL; }

[1]

::: gfx/gl/GLContextGLX.h
@@ +30,5 @@
>                      gfxXlibSurface* pixmap = nullptr);
>  
>      ~GLContextGLX();
>  
> +    GLContextType GetContextType() { return ContextTypeGLX; }

[1]

::: gfx/gl/GLContextWGL.h
@@ +38,5 @@
>                   LibType aLibUsed);
>  
>      ~GLContextWGL();
>  
> +    GLContextType GetContextType() { return ContextTypeWGL; }

[1]
Attachment #8355329 - Flags: review?(jgilbert) → review+
Comment on attachment 8355613 [details] [diff] [review]
6/8 - Remove GLContext::GetNativeData

Review of attachment 8355613 [details] [diff] [review]:
-----------------------------------------------------------------

Woo!
Attachment #8355613 - Flags: review?(jgilbert) → review+
Attachment #8355615 - Flags: review?(jgilbert) → review+
Attachment #8355905 - Flags: review?(jgilbert) → review+
Whiteboard: [qa-]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: