Bug 56555 - [Qt] Enable GraphicsContext3D only when the window surface support OpenGL
Summary: [Qt] Enable GraphicsContext3D only when the window surface support OpenGL
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P5 Normal
Assignee: Nobody
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2011-03-17 02:56 PDT by Jarkko Sakkinen
Modified: 2011-03-18 07:28 PDT (History)
4 users (show)

See Also:


Attachments
Bug fix. See the ChangeLog entry for more verbose description. (6.13 KB, patch)
2011-03-17 04:21 PDT, Jarkko Sakkinen
benjamin: review-
Details | Formatted Diff | Diff
Revised fix. Allows software fallback. (4.76 KB, patch)
2011-03-17 05:14 PDT, Jarkko Sakkinen
no flags Details | Formatted Diff | Diff
Fixed indentation (4.73 KB, patch)
2011-03-17 09:23 PDT, Jarkko Sakkinen
benjamin: review-
Details | Formatted Diff | Diff
Fixed rest of the indentations. (4.68 KB, patch)
2011-03-17 10:16 PDT, Jarkko Sakkinen
no flags Details | Formatted Diff | Diff
Check AC on creation of WebGLRenderingContext (5.08 KB, patch)
2011-03-17 23:06 PDT, Jarkko Sakkinen
kenneth: review+
Details | Formatted Diff | Diff
Removed unnecessary new line character (1.75 KB, patch)
2011-03-18 02:16 PDT, Jarkko Sakkinen
no flags Details | Formatted Diff | Diff
Mistake in taking diff in last submit (5.08 KB, patch)
2011-03-18 02:17 PDT, Jarkko Sakkinen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jarkko Sakkinen 2011-03-17 02:56:20 PDT
This bug was cause by this change:
https://bugs.webkit.org/show_bug.cgi?id=56339

Viewport widget should not be stored into member variable because
it might not stay valid for the full life-cycle of GraphicsContext3D.
Comment 1 Jarkko Sakkinen 2011-03-17 04:21:18 PDT
Created attachment 86043 [details]
Bug fix. See the ChangeLog entry for more verbose description.
Comment 2 Jarkko Sakkinen 2011-03-17 04:23:24 PDT
Adding Simon and Benjamin to CC list because this in a way related to:
https://bugs.webkit.org/show_bug.cgi?id=40884

After some thinking I completely support your choice of not supporting any kind of software fallback at this point.
Comment 3 Benjamin Poulain 2011-03-17 04:42:03 PDT
What about printing? Or rendering a particular frame to QImage? Wouldn't that disable the GraphicsContext3D for the following painting call?
Comment 4 Jarkko Sakkinen 2011-03-17 04:52:33 PDT
You're right. In order to support those cases software fallback *is* needed. *Also*, there should be a check before allowing texture mapping in GraphicsContext3DImpl::paint() that painter->paintDevice() == m_viewportGLWidget. If not use software fallback.

I think, because of cases that you mentioned, you should reconsider reopening 40884 (QImage and printing). I'll revise this patch.
Comment 5 Benjamin Poulain 2011-03-17 05:11:41 PDT
Comment on attachment 86043 [details]
Bug fix. See the ChangeLog entry for more verbose description.

I do not mind updating 40884.
Rejecting this for now.
Comment 6 Jarkko Sakkinen 2011-03-17 05:14:12 PDT
Created attachment 86048 [details]
Revised fix. Allows software fallback.
Comment 7 Benjamin Poulain 2011-03-17 05:48:11 PDT
Comment on attachment 86048 [details]
Revised fix. Allows software fallback.

Quick comment from a quick look: we are not limiting lines to 80 characters in WebKit, you don't have to split everything like this:
    PageClientQWidget* webPageClient
        = static_cast<PageClientQWidget*>(m_hostWindow->platformPageClient());
Comment 8 Jarkko Sakkinen 2011-03-17 09:23:36 PDT
Created attachment 86062 [details]
Fixed indentation
Comment 9 Jarkko Sakkinen 2011-03-17 09:28:53 PDT
Fixed indentation. This fixes now two issues:
- Crash does not occur when viewport is switched.
- Does only texture mapping if painter is associated to the viewport QGLWidget.

These are anyway valid fixes. Let's scope software fallback discussion out of this bug :)
Comment 10 Benjamin Poulain 2011-03-17 09:41:11 PDT
Comment on attachment 86062 [details]
Fixed indentation

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

> Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp:474
> +    PageClientQWidget* webPageClient
> +        = static_cast<PageClientQWidget*>(m_hostWindow->platformPageClient());

This should be on one line.

> Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp:488
> +    PageClientQWidget* webPageClient
> +        = static_cast<PageClientQWidget*>(m_hostWindow->platformPageClient());

This should be on one line.

> Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp:504
> +    QGLWidget* viewportGLWidget = getViewportGLWidget();
> +    if (testAcceleratedCompositing()
> +            && viewportGLWidget
> +            && viewportGLWidget == m_viewportGLWidget
> +            && viewportGLWidget == painter->device()) {

I would put those test as the first statements of the functions, and return if not true.

That way it is clear, if the initial condition are not correct, just return.
Comment 11 Benjamin Poulain 2011-03-17 09:41:43 PDT
I r- just for style issues, the patch looks good to me otherwise.
Comment 12 Benjamin Poulain 2011-03-17 09:47:45 PDT
Comment on attachment 86062 [details]
Fixed indentation

Thinking abou it...

Aren't the static_cast<PageClientQWidget*> wrong? You should use QWebPageClient. The return value of m_hostWindow->platformPageClient() is gonna be PageClientQGraphicsWidget for QGraphicsWebView.
Comment 13 Jarkko Sakkinen 2011-03-17 10:16:28 PDT
Created attachment 86066 [details]
Fixed rest of the indentations.

After that last if-statement that you commented comes the software fallback. Therefore, it is handled that way.
Comment 14 Jarkko Sakkinen 2011-03-17 23:06:14 PDT
Created attachment 86138 [details]
Check AC on creation of WebGLRenderingContext

See the ChangeLog entry for description.
Comment 15 Kenneth Rohde Christiansen 2011-03-18 02:00:18 PDT
Comment on attachment 86138 [details]
Check AC on creation of WebGLRenderingContext

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

> Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp:469
> +    QWebPageClient* webPageClient = m_hostWindow->platformPageClient();
> +
> +    QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget());

I would remove that unneeded newline

> Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp:472
> +    if (scrollArea)
> +        return qobject_cast<QGLWidget*>(scrollArea->viewport());

Doesn't casting 0 return a 0? Just wondered if you could do "return qobject..."
Comment 16 Jarkko Sakkinen 2011-03-18 02:11:10 PDT
The pointer scrollArea might be NULL. If it were, then scrollArea->viewport() would cause SEGFAULT.
Comment 17 Jarkko Sakkinen 2011-03-18 02:16:21 PDT
Created attachment 86149 [details]
Removed unnecessary new line character
Comment 18 Jarkko Sakkinen 2011-03-18 02:17:53 PDT
Created attachment 86150 [details]
Mistake in taking diff in last submit
Comment 19 WebKit Commit Bot 2011-03-18 07:28:21 PDT
Comment on attachment 86150 [details]
Mistake in taking diff in last submit

Clearing flags on attachment: 86150

Committed r81468: <http://trac.webkit.org/changeset/81468>
Comment 20 WebKit Commit Bot 2011-03-18 07:28:27 PDT
All reviewed patches have been landed.  Closing bug.