Initialize X11-specific wxGLContextAttrs members They didn't seem to be initialized anywhere at all, so do initialize them in their declaration, even if this is unnecessary in most of the ports where they are not used -- but as long as they're declared there, it's simpler and better to still initialize them.
Don't assign to unused wxGLContextAttrs::renderTypeRGBA in wxQt This field is only used in GLX-based implementation, it doesn't make sense to set it in wxQt.
Only define GLX-specific wxGLContextAttrs members when using GLX They're not used otherwise, so don't even declare them to avoid mistakes such as the one fixed by the parent commit.
Simplify context attributes initialization in wxGLCanvas EGL code There is no need to check if GetGLAttrs() returns nullptr before using it, as we just pass nullptr to eglCreateContext() if there are no attributes anyhow, so just use its result directly. No real changes.
Fix OpenGL ES creation in EGL-based wxGLCanvas implementation The existing code tried to use EGL_RENDERABLE_TYPE as context attribute, but it is not supported there. Use eglBindAPI() instead, which also should be called even when not using ES. To make this work, add a new EGL-specific member to wxGLContextAttrs: this is a bit ugly, but not more so than the existing GLX-specific members and is much simpler than any alternative. See #26012. Co-authored-by: Timothy Lee <timothy...@gmail.com>
Avoid codespell false positive for "useES" member variable It shouldn't replaced with "uses".
Don't refresh empty rectangle in generic wxHeaderCtrl This is useless and just provides pixman warnings with wxGTK.
Get rid of unused variable in wxHeaderCtrl::OnPaint() There is no need to have "count" when it's exactly the same as "m_numColumns".
Optimize generic wxHeaderCtrl drawing and work around wxOSX bug Don't draw all the columns, there is no need to do it for those scrolled out of view. As a side effect, don't rely on wxDC::SetDeviceOrigin() for the coordinates translation but do it ourselves in the drawing code: this is pretty trivial in this case and avoids a bug in wxOSX which doesn't seem to honour device origin in its wxRendererNative implementation, somehow. Closes #26014.
Relax configure check for EGL version to accept 1.4 This should have been part of 602b80d896 (Support EGL 1.4 instead of previously required 1.5, 2025-11-23). See #22325, #25986.
Merge branch 'header-ctrl-fixes' Some fixes for generic wxHeaderCtrl. See #26016.
Fix native cell rendering using wrong clipping region in wxOSX The NSCell drawing routines seem to use a different clipping area than the one of the current context. This workaround undoes the offsetting of the dc but then moves the drawing frame accordingly. See #26014. Closes #26018.
Merge branch 'opengl-es' Fix OpenGL ES support in EGL implementation and some cleanups. See #26015.
| ... | ... | @@ -735,7 +735,6 @@ COND_TOOLKIT_GTK |
| 735 | 735 | COND_TOOLKIT_DFB_USE_GUI_1
|
| 736 | 736 | COND_TOOLKIT_DFB
|
| 737 | 737 | COND_TOOLKIT_COCOA
|
| 738 | -COND_TOOLKIT_
|
|
| 739 | 738 | COND_SHARED_1_USE_GUI_1_USE_OPENGL_1
|
| 740 | 739 | COND_SHARED_1_USE_GUI_1
|
| 741 | 740 | COND_SHARED_1
|
| ... | ... | @@ -31302,19 +31301,19 @@ fi |
| 31302 | 31301 | if test "$wxUSE_GLCANVAS_EGL" != "no"; then
|
| 31303 | 31302 | |
| 31304 | 31303 | pkg_failed=no
|
| 31305 | -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egl >= 1.5" >&5
|
|
| 31306 | -$as_echo_n "checking for egl >= 1.5... " >&6; }
|
|
| 31304 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egl >= 1.4" >&5
|
|
| 31305 | +$as_echo_n "checking for egl >= 1.4... " >&6; }
|
|
| 31307 | 31306 | |
| 31308 | 31307 | if test -n "$EGL_CFLAGS"; then
|
| 31309 | 31308 | pkg_cv_EGL_CFLAGS="$EGL_CFLAGS"
|
| 31310 | 31309 | elif test -n "$PKG_CONFIG"; then
|
| 31311 | 31310 | if test -n "$PKG_CONFIG" && \
|
| 31312 | - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"egl >= 1.5\""; } >&5
|
|
| 31313 | - ($PKG_CONFIG --exists --print-errors "egl >= 1.5") 2>&5
|
|
| 31311 | + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"egl >= 1.4\""; } >&5
|
|
| 31312 | + ($PKG_CONFIG --exists --print-errors "egl >= 1.4") 2>&5
|
|
| 31314 | 31313 | ac_status=$?
|
| 31315 | 31314 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
| 31316 | 31315 | test $ac_status = 0; }; then
|
| 31317 | - pkg_cv_EGL_CFLAGS=`$PKG_CONFIG --cflags "egl >= 1.5" 2>/dev/null`
|
|
| 31316 | + pkg_cv_EGL_CFLAGS=`$PKG_CONFIG --cflags "egl >= 1.4" 2>/dev/null`
|
|
| 31318 | 31317 | test "x$?" != "x0" && pkg_failed=yes
|
| 31319 | 31318 | else
|
| 31320 | 31319 | pkg_failed=yes
|
| ... | ... | @@ -31326,12 +31325,12 @@ if test -n "$EGL_LIBS"; then |
| 31326 | 31325 | pkg_cv_EGL_LIBS="$EGL_LIBS"
|
| 31327 | 31326 | elif test -n "$PKG_CONFIG"; then
|
| 31328 | 31327 | if test -n "$PKG_CONFIG" && \
|
| 31329 | - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"egl >= 1.5\""; } >&5
|
|
| 31330 | - ($PKG_CONFIG --exists --print-errors "egl >= 1.5") 2>&5
|
|
| 31328 | + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"egl >= 1.4\""; } >&5
|
|
| 31329 | + ($PKG_CONFIG --exists --print-errors "egl >= 1.4") 2>&5
|
|
| 31331 | 31330 | ac_status=$?
|
| 31332 | 31331 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
| 31333 | 31332 | test $ac_status = 0; }; then
|
| 31334 | - pkg_cv_EGL_LIBS=`$PKG_CONFIG --libs "egl >= 1.5" 2>/dev/null`
|
|
| 31333 | + pkg_cv_EGL_LIBS=`$PKG_CONFIG --libs "egl >= 1.4" 2>/dev/null`
|
|
| 31335 | 31334 | test "x$?" != "x0" && pkg_failed=yes
|
| 31336 | 31335 | else
|
| 31337 | 31336 | pkg_failed=yes
|
| ... | ... | @@ -31352,24 +31351,24 @@ else |
| 31352 | 31351 | _pkg_short_errors_supported=no
|
| 31353 | 31352 | fi
|
| 31354 | 31353 | if test $_pkg_short_errors_supported = yes; then
|
| 31355 | - EGL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "egl >= 1.5" 2>&1`
|
|
| 31354 | + EGL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "egl >= 1.4" 2>&1`
|
|
| 31356 | 31355 | else
|
| 31357 | - EGL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "egl >= 1.5" 2>&1`
|
|
| 31356 | + EGL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "egl >= 1.4" 2>&1`
|
|
| 31358 | 31357 | fi
|
| 31359 | 31358 | # Put the nasty error message in config.log where it belongs
|
| 31360 | 31359 | echo "$EGL_PKG_ERRORS" >&5
|
| 31361 | 31360 | |
| 31362 | 31361 | |
| 31363 | - { $as_echo "$as_me:${as_lineno-$LINENO}: EGL 1.5+ not available. Will use GLX." >&5
|
|
| 31364 | -$as_echo "$as_me: EGL 1.5+ not available. Will use GLX." >&6;}
|
|
| 31362 | + { $as_echo "$as_me:${as_lineno-$LINENO}: EGL 1.4+ not available. Will use GLX." >&5
|
|
| 31363 | +$as_echo "$as_me: EGL 1.4+ not available. Will use GLX." >&6;}
|
|
| 31365 | 31364 | |
| 31366 | 31365 | |
| 31367 | 31366 | elif test $pkg_failed = untried; then
|
| 31368 | 31367 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
| 31369 | 31368 | $as_echo "no" >&6; }
|
| 31370 | 31369 | |
| 31371 | - { $as_echo "$as_me:${as_lineno-$LINENO}: EGL 1.5+ not available. Will use GLX." >&5
|
|
| 31372 | -$as_echo "$as_me: EGL 1.5+ not available. Will use GLX." >&6;}
|
|
| 31370 | + { $as_echo "$as_me:${as_lineno-$LINENO}: EGL 1.4+ not available. Will use GLX." >&5
|
|
| 31371 | +$as_echo "$as_me: EGL 1.4+ not available. Will use GLX." >&6;}
|
|
| 31373 | 31372 | |
| 31374 | 31373 | |
| 31375 | 31374 | else
|
| ... | ... | @@ -43500,11 +43499,6 @@ EOF |
| 43500 | 43499 | COND_SHARED_1_USE_GUI_1_USE_OPENGL_1=""
|
| 43501 | 43500 | fi
|
| 43502 | 43501 | |
| 43503 | - COND_TOOLKIT_="#"
|
|
| 43504 | - if test "x$TOOLKIT" = "x" ; then
|
|
| 43505 | - COND_TOOLKIT_=""
|
|
| 43506 | - fi
|
|
| 43507 | - |
|
| 43508 | 43502 | COND_TOOLKIT_COCOA="#"
|
| 43509 | 43503 | if test "x$TOOLKIT" = "xCOCOA" ; then
|
| 43510 | 43504 | COND_TOOLKIT_COCOA=""
|
| ... | ... | @@ -3458,7 +3458,7 @@ if test "$wxUSE_OPENGL" = "yes" -o "$wxUSE_OPENGL" = "auto"; then |
| 3458 | 3458 | |
| 3459 | 3459 | if test "$WXGTK3" = 1; then
|
| 3460 | 3460 | if test "$wxUSE_GLCANVAS_EGL" != "no"; then
|
| 3461 | - PKG_CHECK_MODULES(EGL, [egl >= 1.5],
|
|
| 3461 | + PKG_CHECK_MODULES(EGL, [egl >= 1.4],
|
|
| 3462 | 3462 | [
|
| 3463 | 3463 | OPENGL_LIBS="$OPENGL_LIBS $EGL_LIBS"
|
| 3464 | 3464 | AC_DEFINE(wxUSE_GLCANVAS_EGL)
|
| ... | ... | @@ -3473,7 +3473,7 @@ if test "$wxUSE_OPENGL" = "yes" -o "$wxUSE_OPENGL" = "auto"; then |
| 3473 | 3473 | )
|
| 3474 | 3474 | ],
|
| 3475 | 3475 | [
|
| 3476 | - AC_MSG_NOTICE([EGL 1.5+ not available. Will use GLX.])
|
|
| 3476 | + AC_MSG_NOTICE([EGL 1.4+ not available. Will use GLX.])
|
|
| 3477 | 3477 | ]
|
| 3478 | 3478 | )
|
| 3479 | 3479 | if test "$have_wayland" != 1; then
|
| ... | ... | @@ -18,6 +18,18 @@ |
| 18 | 18 | #include "wx/palette.h"
|
| 19 | 19 | #include "wx/window.h"
|
| 20 | 20 | |
| 21 | +// Most ports have a single implementation of wxGLCanvas, but wxGTK has two:
|
|
| 22 | +// legacy GLX-based one (also used by wxX11) and EGL-based one which is used
|
|
| 23 | +// when enabled by wxUSE_GLCANVAS_EGL. Although it is not user-settable, define
|
|
| 24 | +// wxUSE_GLCANVAS_GLX for consistency.
|
|
| 25 | +#if defined(__WXX11__)
|
|
| 26 | + #define wxUSE_GLCANVAS_GLX 1
|
|
| 27 | +#elif defined(__WXGTK__)
|
|
| 28 | + #define wxUSE_GLCANVAS_GLX (!wxUSE_GLCANVAS_EGL)
|
|
| 29 | +#else
|
|
| 30 | + #define wxUSE_GLCANVAS_GLX 0
|
|
| 31 | +#endif
|
|
| 32 | + |
|
| 21 | 33 | class WXDLLIMPEXP_FWD_GL wxGLCanvas;
|
| 22 | 34 | class WXDLLIMPEXP_FWD_GL wxGLContext;
|
| 23 | 35 | |
| ... | ... | @@ -134,9 +146,16 @@ public: |
| 134 | 146 | wxGLContextAttrs& PlatformDefaults();
|
| 135 | 147 | void EndList(); // No more values can be chained
|
| 136 | 148 | |
| 149 | +#if wxUSE_GLCANVAS_GLX
|
|
| 137 | 150 | // Currently only used for X11 context creation
|
| 138 | - bool x11Direct; // X11 direct render
|
|
| 139 | - bool renderTypeRGBA;
|
|
| 151 | + bool x11Direct = false; // X11 direct render
|
|
| 152 | + bool renderTypeRGBA = false;
|
|
| 153 | +#endif // wxUSE_GLCANVAS_GLX
|
|
| 154 | + |
|
| 155 | +#if wxUSE_GLCANVAS_EGL
|
|
| 156 | + // Used to select the kind of API used with EGL (OpenGL or OpenGL ES).
|
|
| 157 | + bool useES = false;
|
|
| 158 | +#endif // wxUSE_GLCANVAS_EGL
|
|
| 140 | 159 | };
|
| 141 | 160 | |
| 142 | 161 | // ----------------------------------------------------------------------------
|
| ... | ... | @@ -32,3 +32,4 @@ expressions</em> (BRE). EREs are roughly those of the traditional @e egrep, |
| 32 | 32 | bool AtLeast(int major, int minor = 0, int micro = 0) const
|
| 33 | 33 | bool AtLeast(int major, int minor = 0, int micro = 0) const;
|
| 34 | 34 | return AtLeast(0) || !m_name.empty() || !m_description.empty();
|
| 35 | + bool useES = false; |
| ... | ... | @@ -247,6 +247,8 @@ void wxHeaderCtrl::RefreshColsAfter(unsigned int idx) |
| 247 | 247 | {
|
| 248 | 248 | wxRect rect = GetClientRect();
|
| 249 | 249 | const int ofs = GetColStart(idx);
|
| 250 | + if ( ofs >= rect.width )
|
|
| 251 | + return;
|
|
| 250 | 252 | rect.x += ofs;
|
| 251 | 253 | rect.width -= ofs;
|
| 252 | 254 | |
| ... | ... | @@ -523,19 +525,22 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 523 | 525 | wxAutoBufferedPaintDC dc(this);
|
| 524 | 526 | dc.Clear();
|
| 525 | 527 | |
| 526 | - // account for the horizontal scrollbar offset in the parent window
|
|
| 527 | - dc.SetDeviceOrigin(m_scrollOffset, 0);
|
|
| 528 | - |
|
| 529 | - const unsigned int count = m_numColumns;
|
|
| 530 | - int xpos = 0;
|
|
| 531 | - for ( unsigned int i = 0; i < count; i++ )
|
|
| 528 | + int xpos = m_scrollOffset;
|
|
| 529 | + for ( unsigned int i = 0; i < m_numColumns; i++ )
|
|
| 532 | 530 | {
|
| 533 | 531 | const unsigned idx = m_colIndices[i];
|
| 534 | 532 | const wxHeaderColumn& col = GetColumn(idx);
|
| 535 | 533 | if ( col.IsHidden() )
|
| 536 | 534 | continue;
|
| 537 | 535 | |
| 538 | - int colWidth = col.GetWidth();
|
|
| 536 | + const int colWidth = col.GetWidth();
|
|
| 537 | + if ( xpos + colWidth < 0 )
|
|
| 538 | + {
|
|
| 539 | + // This column is not shown on screen because it is to the left of
|
|
| 540 | + // the shown area, don't bother drawing it.
|
|
| 541 | + xpos += colWidth;
|
|
| 542 | + continue;
|
|
| 543 | + }
|
|
| 539 | 544 | |
| 540 | 545 | wxHeaderSortIconType sortArrow;
|
| 541 | 546 | if ( col.IsSortKey() )
|
| ... | ... | @@ -568,7 +573,7 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 568 | 573 | params.m_labelAlignment = col.GetAlignment();
|
| 569 | 574 | |
| 570 | 575 | #ifdef __WXGTK__
|
| 571 | - if (i == count-1 && xpos + colWidth >= w)
|
|
| 576 | + if (i == m_numColumns - 1 && xpos + colWidth >= w)
|
|
| 572 | 577 | {
|
| 573 | 578 | state |= wxCONTROL_DIRTY;
|
| 574 | 579 | }
|
| ... | ... | @@ -585,6 +590,12 @@ void wxHeaderCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 585 | 590 | );
|
| 586 | 591 | |
| 587 | 592 | xpos += colWidth;
|
| 593 | + if ( xpos > w )
|
|
| 594 | + {
|
|
| 595 | + // Next column and all the others are beyond the right border of
|
|
| 596 | + // the window, no need to continue.
|
|
| 597 | + break;
|
|
| 598 | + }
|
|
| 588 | 599 | }
|
| 589 | 600 | if (xpos < w)
|
| 590 | 601 | {
|
| ... | ... | @@ -657,6 +657,19 @@ void wxRendererMac::ApplyMacControlFlags(wxWindow* win, NSCell* cell, int flags) |
| 657 | 657 | cell.controlTint = (flags & wxCONTROL_FOCUSED) ? NSColor.currentControlTint : NSClearControlTint;
|
| 658 | 658 | }
|
| 659 | 659 | |
| 660 | +namespace
|
|
| 661 | +{
|
|
| 662 | + |
|
| 663 | +// Cell Drawing seems to run into problems with clipping when the device origin has changed
|
|
| 664 | +// so undo this and restore with GState later
|
|
| 665 | +void CellDrawHelper ( wxDC& dc, CGContextRef cgContext, NSRect& controlRect )
|
|
| 666 | +{
|
|
| 667 | + wxPoint offset = dc.GetDeviceOrigin();
|
|
| 668 | + CGContextTranslateCTM( cgContext, -offset.x, -offset.y );
|
|
| 669 | + controlRect = NSOffsetRect(controlRect, offset.x, offset.y);
|
|
| 670 | +}
|
|
| 671 | + |
|
| 672 | +} // anonymous namespace
|
|
| 660 | 673 | |
| 661 | 674 | void wxRendererMac::DrawMacCell(wxWindow *win,
|
| 662 | 675 | wxDC& dc,
|
| ... | ... | @@ -688,6 +701,8 @@ void wxRendererMac::DrawMacCell(wxWindow *win, |
| 688 | 701 | |
| 689 | 702 | CGContextSaveGState(cgContext);
|
| 690 | 703 | |
| 704 | + CellDrawHelper( dc, cgContext, controlRect );
|
|
| 705 | + |
|
| 691 | 706 | NSGraphicsContext* formerContext = NSGraphicsContext.currentContext;
|
| 692 | 707 | NSGraphicsContext.currentContext = [NSGraphicsContext graphicsContextWithCGContext:cgContext
|
| 693 | 708 | flipped:YES];
|
| ... | ... | @@ -762,6 +777,8 @@ void wxRendererMac::DrawMacHeaderCell(wxWindow *win, |
| 762 | 777 | |
| 763 | 778 | CGContextSaveGState(cgContext);
|
| 764 | 779 | |
| 780 | + CellDrawHelper( dc, cgContext, controlRect );
|
|
| 781 | + |
|
| 765 | 782 | NSGraphicsContext* formerContext = NSGraphicsContext.currentContext;
|
| 766 | 783 | NSGraphicsContext.currentContext = [NSGraphicsContext graphicsContextWithCGContext:cgContext
|
| 767 | 784 | flipped:YES];
|
| ... | ... | @@ -154,7 +154,6 @@ wxGLContextAttrs& wxGLContextAttrs::ReleaseFlush(int val) |
| 154 | 154 | |
| 155 | 155 | wxGLContextAttrs& wxGLContextAttrs::PlatformDefaults()
|
| 156 | 156 | {
|
| 157 | - renderTypeRGBA = true;
|
|
| 158 | 157 | return *this;
|
| 159 | 158 | }
|
| 160 | 159 |
| ... | ... | @@ -96,8 +96,7 @@ wxGLContextAttrs& wxGLContextAttrs::ForwardCompatible() |
| 96 | 96 | |
| 97 | 97 | wxGLContextAttrs& wxGLContextAttrs::ES2()
|
| 98 | 98 | {
|
| 99 | - AddAttribBits(EGL_RENDERABLE_TYPE,
|
|
| 100 | - EGL_OPENGL_ES2_BIT);
|
|
| 99 | + useES = true;
|
|
| 101 | 100 | return *this;
|
| 102 | 101 | }
|
| 103 | 102 | |
| ... | ... | @@ -288,26 +287,26 @@ wxGLContext::wxGLContext(wxGLCanvas *win, |
| 288 | 287 | const wxGLContextAttrs *ctxAttrs)
|
| 289 | 288 | : m_glContext(nullptr)
|
| 290 | 289 | {
|
| 291 | - const int* contextAttribs = nullptr;
|
|
| 290 | + // Fall back to OpenGL context parameters set at wxGLCanvas ctor if any.
|
|
| 291 | + const wxGLContextAttrs& attrs = ctxAttrs ? *ctxAttrs
|
|
| 292 | + : win->GetGLCTXAttrs();
|
|
| 292 | 293 | |
| 293 | - if ( ctxAttrs )
|
|
| 294 | - {
|
|
| 295 | - contextAttribs = ctxAttrs->GetGLAttrs();
|
|
| 296 | - }
|
|
| 297 | - else if ( win->GetGLCTXAttrs().GetGLAttrs() )
|
|
| 294 | + m_isOk = false;
|
|
| 295 | + |
|
| 296 | + if ( !eglBindAPI(attrs.useES ? EGL_OPENGL_ES_API : EGL_OPENGL_API) )
|
|
| 298 | 297 | {
|
| 299 | - // If OpenGL context parameters were set at wxGLCanvas ctor, get them now
|
|
| 300 | - contextAttribs = win->GetGLCTXAttrs().GetGLAttrs();
|
|
| 298 | + // This is really not supposed to happen, so don't use wxLogError()
|
|
| 299 | + // here, there is nothing the user can do about it if it does happen.
|
|
| 300 | + wxFAIL_MSG("eglBindAPI() failed unexpectedly");
|
|
| 301 | + return;
|
|
| 301 | 302 | }
|
| 302 | 303 | |
| 303 | - m_isOk = false;
|
|
| 304 | - |
|
| 305 | 304 | EGLConfig fbc = win->GetEGLConfig();
|
| 306 | 305 | wxCHECK_RET( fbc, "Invalid EGLConfig for OpenGL" );
|
| 307 | 306 | |
| 308 | 307 | m_glContext = eglCreateContext(wxGLCanvasEGL::GetDisplay(), fbc,
|
| 309 | 308 | other ? other->m_glContext : EGL_NO_CONTEXT,
|
| 310 | - contextAttribs);
|
|
| 309 | + attrs.GetGLAttrs());
|
|
| 311 | 310 | |
| 312 | 311 | if ( !m_glContext )
|
| 313 | 312 | wxLogMessage(_("Couldn't create OpenGL context"));
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help