Bug 136831 - [GTK] Add Wayland support to GLContext
Summary: [GTK] Add Wayland support to GLContext
Status: RESOLVED DUPLICATE of bug 115803
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
Depends on: 136849
Blocks: 142879
  Show dependency treegraph
 
Reported: 2014-09-15 12:31 PDT by Zan Dobersek
Modified: 2016-08-17 00:35 PDT (History)
7 users (show)

See Also:


Attachments
Patch (4.64 KB, patch)
2014-09-15 12:50 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (3.82 KB, patch)
2014-09-16 02:30 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (3.86 KB, patch)
2014-09-16 02:39 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (3.86 KB, patch)
2014-09-16 13:31 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (3.85 KB, patch)
2014-09-17 05:41 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (3.80 KB, patch)
2015-03-19 13:26 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews203 for win-future (14.79 MB, application/zip)
2015-03-20 12:29 PDT, Build Bot
no flags Details
Patch (4.07 KB, patch)
2015-04-14 00:13 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2014-09-15 12:31:27 PDT
[GTK] Add Wayland support to GLContext
Comment 1 Zan Dobersek 2014-09-15 12:50:27 PDT
Created attachment 238138 [details]
Patch
Comment 2 WebKit Commit Bot 2014-09-15 12:57:18 PDT
Attachment 238138 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/GLContext.h:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Martin Robinson 2014-09-15 18:43:57 PDT
Comment on attachment 238138 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=238138&action=review

> Source/WebCore/platform/graphics/GLContext.cpp:75
> +#if PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)
> +    if (!WaylandDisplay::instance())
> +        return nullptr;
> +    DEPRECATED_DEFINE_STATIC_LOCAL(OwnPtr<GLContext>, sharing, (WaylandDisplay::instance()->createSharingGLContext()));
> +#else
>      DEPRECATED_DEFINE_STATIC_LOCAL(OwnPtr<GLContext>, sharing, (createOffscreenContext()));
> +#endif
>      return sharing.get();

Can't you move this into createOffscreenContext? This seems like the wrong place, because it requires duplicating some things.

> Source/WebCore/platform/graphics/GLContext.cpp:82
> +    if (WaylandDisplay::instance())
> +        return WaylandDisplay::instance()->nativeDisplay();

Why not just use this directly instead of creating and intermediary in another class? Or create a static WaylandDisplay::nativeDisplay()?

> Source/WebCore/platform/graphics/GLContext.h:77
> +#if PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)
> +    static struct wl_display* sharedWaylandDisplay();
> +#endif
> +

Why is this a static method? Is it used outside GLContext?
Comment 4 Zan Dobersek 2014-09-16 00:27:36 PDT
Comment on attachment 238138 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=238138&action=review

>> Source/WebCore/platform/graphics/GLContext.cpp:75
>>      return sharing.get();
> 
> Can't you move this into createOffscreenContext? This seems like the wrong place, because it requires duplicating some things.

It doesn't really fit into createOffscreenContext(). I'll modify this method to remove DEPRECATED_DEFINE_STATIC_LOCAL() but still use WaylandDisplay::createSharingGLContext() when actually running under Wayland, and fall back to createOffscreenContext() otherwise.

>> Source/WebCore/platform/graphics/GLContext.cpp:82
>> +        return WaylandDisplay::instance()->nativeDisplay();
> 
> Why not just use this directly instead of creating and intermediary in another class? Or create a static WaylandDisplay::nativeDisplay()?

As it stands this is only called in GLContextEGL, so I'll change the code there to call ::nativeDisplay() directly.
Comment 5 Zan Dobersek 2014-09-16 02:30:45 PDT
Created attachment 238163 [details]
Patch
Comment 6 WebKit Commit Bot 2014-09-16 02:32:13 PDT
Attachment 238163 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/GLContext.h:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Zan Dobersek 2014-09-16 02:39:18 PDT
Created attachment 238165 [details]
Patch
Comment 8 WebKit Commit Bot 2014-09-16 02:41:28 PDT
Attachment 238165 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/GLContext.h:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Zan Dobersek 2014-09-16 13:31:05 PDT
Created attachment 238199 [details]
Patch
Comment 10 WebKit Commit Bot 2014-09-16 13:33:32 PDT
Attachment 238199 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/GLContext.h:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Zan Dobersek 2014-09-17 05:41:32 PDT
Created attachment 238249 [details]
Patch
Comment 12 WebKit Commit Bot 2014-09-17 05:42:53 PDT
Attachment 238249 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/GLContext.h:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Brent Fulgham 2014-10-31 12:41:47 PDT
Comment on attachment 238249 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=238249&action=review

> Source/WebCore/platform/graphics/GLContext.cpp:69
> +    static OwnPtr<GLContext> context;

Could this be a unique_ptr?
Comment 14 Zan Dobersek 2015-03-19 13:25:48 PDT
Comment on attachment 238249 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=238249&action=review

>> Source/WebCore/platform/graphics/GLContext.cpp:69
>> +    static OwnPtr<GLContext> context;
> 
> Could this be a unique_ptr?

The current DEPRECATED_DEFINE_STATIC_LOCAL() code switched to using std::unique_ptr<>, so the new patch will use that as well.
Comment 15 Zan Dobersek 2015-03-19 13:26:38 PDT
Created attachment 249057 [details]
Patch
Comment 16 WebKit Commit Bot 2015-03-19 13:29:55 PDT
Attachment 249057 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/GLContext.h:31:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 17 Sergio Villar Senin 2015-03-20 02:44:16 PDT
Comment on attachment 249057 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249057&action=review

> Source/WebCore/platform/graphics/GLContext.cpp:79
> +    return context.get();

You're forgetting to remove the DEPRECATED_DEFINE_STATIC_LOCAL

Also I guess you could a static LazyNeverDestroyed + std::call_once() ?
Comment 18 Zan Dobersek 2015-03-20 03:12:30 PDT
Comment on attachment 249057 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249057&action=review

>> Source/WebCore/platform/graphics/GLContext.cpp:79
>> +    return context.get();
> 
> You're forgetting to remove the DEPRECATED_DEFINE_STATIC_LOCAL
> 
> Also I guess you could a static LazyNeverDestroyed + std::call_once() ?

Oops.

std::call_once() isn't ideal here since this isn't cross-thread code (yet?), and you have to use a static std::once_flag (and the accompanying guard variable), so that's some additional overhead.
Comment 19 Sergio Villar Senin 2015-03-20 03:20:40 PDT
(In reply to comment #18)
> Comment on attachment 249057 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=249057&action=review
> 
> >> Source/WebCore/platform/graphics/GLContext.cpp:79
> >> +    return context.get();
> > 
> > You're forgetting to remove the DEPRECATED_DEFINE_STATIC_LOCAL
> > 
> > Also I guess you could a static LazyNeverDestroyed + std::call_once() ?
> 
> Oops.
> 
> std::call_once() isn't ideal here since this isn't cross-thread code (yet?),
> and you have to use a static std::once_flag (and the accompanying guard
> variable), so that's some additional overhead.

Yeah well you can use the null check anyway, but NeverDestroyed is the natural replacement for DEPRECATED_DEFINE_STATIC_LOCAL.
Comment 20 Build Bot 2015-03-20 12:29:34 PDT
Comment on attachment 249057 [details]
Patch

Attachment 249057 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/6030012943695872

Number of test failures exceeded the failure limit.
Comment 21 Build Bot 2015-03-20 12:29:39 PDT
Created attachment 249128 [details]
Archive of layout-test-results from ews203 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews203  Port: win-future  Platform: CYGWIN_NT-6.1-WOW64-1.7.20-0.266-5-3-i686-32bit
Comment 22 Zan Dobersek 2015-03-25 02:25:36 PDT
Comment on attachment 249057 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249057&action=review

>>>> Source/WebCore/platform/graphics/GLContext.cpp:79
>>>> +    return context.get();
>>> 
>>> You're forgetting to remove the DEPRECATED_DEFINE_STATIC_LOCAL
>>> 
>>> Also I guess you could a static LazyNeverDestroyed + std::call_once() ?
>> 
>> Oops.
>> 
>> std::call_once() isn't ideal here since this isn't cross-thread code (yet?), and you have to use a static std::once_flag (and the accompanying guard variable), so that's some additional overhead.
> 
> Yeah well you can use the null check anyway, but NeverDestroyed is the natural replacement for DEPRECATED_DEFINE_STATIC_LOCAL.

I'll very likely go with std::call_once(), because paranoia. NeverDestroyed should probably be used as well.
Comment 23 Zan Dobersek 2015-04-14 00:13:07 PDT
Created attachment 250697 [details]
Patch
Comment 24 WebKit Commit Bot 2015-04-14 00:15:18 PDT
Attachment 250697 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/GLContext.h:31:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 25 Martin Robinson 2015-04-17 16:32:04 PDT
Comment on attachment 250697 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250697&action=review

Looks good to me, apart from one small question:

> Source/WebCore/platform/graphics/GLContext.cpp:31
> +#include <wtf/NeverDestroyed.h>
>  #include <wtf/ThreadSpecific.h>

These should move above #if USE(EGL)

> Source/WebCore/platform/graphics/GLContext.cpp:-153
> -#if PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2) && defined(GDK_WINDOWING_WAYLAND) && USE(EGL)
> -    GdkDisplay* display = gdk_display_manager_get_default_display(gdk_display_manager_get());
> -
> -    if (GDK_IS_WAYLAND_DISPLAY(display)) {
> -        if (auto eglContext = GLContextEGL::createContext(windowHandle, sharingContext))
> -            return WTF::move(eglContext);
> -        return nullptr;
> -    }
> -#endif

This breaks things doesn't it? It looks like GLX contexts will be preferred even when a Wayland display is active...
Comment 26 Carlos Alberto Lopez Perez 2015-06-04 04:01:39 PDT
Comment on attachment 250697 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250697&action=review

> Source/WebCore/platform/graphics/GLContext.h:33
> +#elif PLATFORM(GTK) && PLATFORM(WAYLAND) && !defined(GTK_API_VERSION_2)
> +#include <wayland-egl.h>
> +#include <EGL/eglplatform.h>
> +typedef EGLNativeWindowType GLNativeWindowType;

This 4 lines on GlContext.h were just committed on http://trac.webkit.org/changeset/185198
I guess you need to rebase the patch.
Comment 27 Carlos Garcia Campos 2016-08-17 00:35:39 PDT
Let's track this in bug #115803 instead.

*** This bug has been marked as a duplicate of bug 115803 ***