Changeset 53639 in webkit


Ignore:
Timestamp:
Jan 21, 2010 12:56:25 PM (14 years ago)
Author:
jpetsovits@rim.com
Message:

2010-01-21 Jakob Petsovits <jpetsovits@rim.com>

Reviewed by Adam Treat.

Don't call vgGetError()/eglGetError() repeatedly
https://bugs.webkit.org/show_bug.cgi?id=33959

For vgGetError(), I missed the part of the spec where
it says that calling that function clears the error
and subsequent calls will return VG_NO_ERROR again.

For eglGetError(), the specification doesn't mention
that kind of behavior, and interpretations seem to
differ between EGL implementations (even within
Khronos: the OpenVG reference implementation doesn't
reset the error code - and even mentions the difference
to vgGetError() in a comment - whereas the online
OpenGL ES API document explicitly specifies clearing
the error code).

It thus makes sense not to call either of the two
error functions more than once for checking a single
EGL/OpenVG call. This patch adapts assertions to
accommodate for this behavior, and also needs to
change surface creation methods as they previously
relied on multiple calls of eglGetError().

  • platform/graphics/openvg/EGLDisplayOpenVG.cpp: (WebCore::EGLDisplayOpenVG::sharedPlatformSurface): (WebCore::EGLDisplayOpenVG::createPbufferSurface):
  • platform/graphics/openvg/EGLDisplayOpenVG.h:
  • platform/graphics/openvg/EGLUtils.h:
  • platform/graphics/openvg/SurfaceOpenVG.cpp: (WebCore::SurfaceOpenVG::SurfaceOpenVG):
  • platform/graphics/openvg/SurfaceOpenVG.h:
  • platform/graphics/openvg/VGUtils.h:
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53637 r53639  
     12010-01-21  Jakob Petsovits  <jpetsovits@rim.com>
     2
     3        Reviewed by Adam Treat.
     4
     5        Don't call vgGetError()/eglGetError() repeatedly
     6        https://bugs.webkit.org/show_bug.cgi?id=33959
     7
     8        For vgGetError(), I missed the part of the spec where
     9        it says that calling that function clears the error
     10        and subsequent calls will return VG_NO_ERROR again.
     11
     12        For eglGetError(), the specification doesn't mention
     13        that kind of behavior, and interpretations seem to
     14        differ between EGL implementations (even within
     15        Khronos: the OpenVG reference implementation doesn't
     16        reset the error code - and even mentions the difference
     17        to vgGetError() in a comment - whereas the online
     18        OpenGL ES API document explicitly specifies clearing
     19        the error code).
     20
     21        It thus makes sense not to call either of the two
     22        error functions more than once for checking a single
     23        EGL/OpenVG call. This patch adapts assertions to
     24        accommodate for this behavior, and also needs to
     25        change surface creation methods as they previously
     26        relied on multiple calls of eglGetError().
     27
     28        * platform/graphics/openvg/EGLDisplayOpenVG.cpp:
     29        (WebCore::EGLDisplayOpenVG::sharedPlatformSurface):
     30        (WebCore::EGLDisplayOpenVG::createPbufferSurface):
     31        * platform/graphics/openvg/EGLDisplayOpenVG.h:
     32        * platform/graphics/openvg/EGLUtils.h:
     33        * platform/graphics/openvg/SurfaceOpenVG.cpp:
     34        (WebCore::SurfaceOpenVG::SurfaceOpenVG):
     35        * platform/graphics/openvg/SurfaceOpenVG.h:
     36        * platform/graphics/openvg/VGUtils.h:
     37
    1382010-01-20  Simon Fraser  <simon.fraser@apple.com>
    239
  • trunk/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.cpp

    r53499 r53639  
    223223        EGLConfig config = defaultPbufferConfig();
    224224        EGLSurface surface = createPbufferSurface(IntSize(1, 1), config);
    225         ASSERT_EGL_NO_ERROR();
    226225
    227226        EGLContext context = eglCreateContext(m_display, config, EGL_NO_CONTEXT, 0);
     
    238237}
    239238
    240 EGLSurface EGLDisplayOpenVG::createPbufferSurface(const IntSize& size, const EGLConfig& config)
     239EGLSurface EGLDisplayOpenVG::createPbufferSurface(const IntSize& size, const EGLConfig& config, EGLint* errorCode)
    241240{
    242241    const EGLint attribList[] = {
     
    246245    };
    247246    EGLSurface surface = eglCreatePbufferSurface(m_display, config, attribList);
    248     if (eglGetError() != EGL_SUCCESS)
     247
     248    if (errorCode)
     249        *errorCode = eglGetError();
     250    else
     251        ASSERT_EGL_NO_ERROR();
     252
     253    if (surface == EGL_NO_SURFACE)
    249254        return EGL_NO_SURFACE;
    250255
  • trunk/WebCore/platform/graphics/openvg/EGLDisplayOpenVG.h

    r53499 r53639  
    4848    /** Creates a pbuffer surface using the given config. If no surface
    4949     * could be created, EGL_NO_SURFACE is returned and errors can be
    50      * caught with eglGetError() (respectively ASSERT_EGL_NO_ERROR()). */
    51     EGLSurface createPbufferSurface(const IntSize&, const EGLConfig&);
     50     * checked with the value that is written to the errorCode parameter
     51     * If no surface could be created and errorCode is zero, this method
     52     * will trigger an assertion by itself. */
     53    EGLSurface createPbufferSurface(const IntSize&, const EGLConfig&, EGLint* errorCode = 0);
    5254
    5355    EGLSurface surfaceForWindow(EGLNativeWindowType, const EGLConfig&);
  • trunk/WebCore/platform/graphics/openvg/EGLUtils.h

    r53499 r53639  
    6363#define ASSERT_EGL_NO_ERROR() ((void)0)
    6464#else
    65 #define ASSERT_EGL_NO_ERROR() \
    66     ASSERT_WITH_MESSAGE(eglGetError() == VG_NO_ERROR, "Found %s", toEGLErrorConstant(eglGetError()))
     65#define ASSERT_EGL_NO_ERROR() do { \
     66    EGLint eglErrorCode = eglGetError(); \
     67    ASSERT_WITH_MESSAGE(eglErrorCode == EGL_SUCCESS, "Found %s", toEGLErrorConstant(eglErrorCode)); \
     68} while (0)
    6769#endif
    6870
  • trunk/WebCore/platform/graphics/openvg/SurfaceOpenVG.cpp

    r53499 r53639  
    4545
    4646#if PLATFORM(EGL)
    47 SurfaceOpenVG::SurfaceOpenVG(const IntSize& size, const EGLDisplay& display, EGLConfig* confPtr)
     47SurfaceOpenVG::SurfaceOpenVG(const IntSize& size, const EGLDisplay& display, EGLConfig* confPtr, EGLint* errorCode)
    4848    : m_eglDisplay(display)
    4949    , m_eglSurface(EGL_NO_SURFACE)
     
    5454    EGLDisplayOpenVG* displayManager = EGLDisplayOpenVG::forDisplay(m_eglDisplay);
    5555    EGLConfig config = confPtr ? (*confPtr) : displayManager->defaultPbufferConfig();
    56     m_eglSurface = displayManager->createPbufferSurface(size, config);
     56    m_eglSurface = displayManager->createPbufferSurface(size, config, errorCode);
    5757
    5858    if (m_eglSurface == EGL_NO_SURFACE)
     
    7373    EGLConfig config = confPtr ? (*confPtr) : displayManager->defaultWindowConfig();
    7474    m_eglSurface = displayManager->surfaceForWindow(window, config);
    75 
    76     if (m_eglSurface == EGL_NO_SURFACE)
    77         return;
     75    ASSERT(m_eglSurface != EGL_NO_SURFACE);
    7876
    7977    m_eglContext = displayManager->contextForSurface(m_eglSurface);
  • trunk/WebCore/platform/graphics/openvg/SurfaceOpenVG.h

    r53499 r53639  
    5555     * pbuffer config is used.
    5656     *
    57      * For reasons of recoverability (e.g. ImageBuffer's "bool success"
    58      * return value), this constructor won't assert if creation of the surface
    59      * fails. Make sure to check successful surface creation with either
    60      * ASSERT_EGL_NO_ERROR() or the surface's isValid() method.
     57     * This constructor will trigger an assertion if creation of the surface
     58     * fails, unless you pledge to manually process the error code by passing
     59     * a non-zero pointer as errorCode parameter. The error code returned by
     60     * eglGetError() will be written to that variable.
    6161     */
    62     SurfaceOpenVG(const IntSize& size, const EGLDisplay& display, EGLConfig* config = 0);
     62    SurfaceOpenVG(const IntSize& size, const EGLDisplay& display, EGLConfig* config = 0, EGLint* errorCode = 0);
    6363
    6464    /**
     
    6666     * and config on the given display. If config is not specified, the
    6767     * display's default window config is used.
    68      *
    69      * For reasons of recoverability, this constructor won't assert if creation
    70      * of the surface fails. Make sure to check successful surface creation
    71      * with either ASSERT_EGL_NO_ERROR() or the surface's isValid() method.
    7268     */
    7369    SurfaceOpenVG(EGLNativeWindowType window, const EGLDisplay& display, EGLConfig* config = 0);
  • trunk/WebCore/platform/graphics/openvg/VGUtils.h

    r53499 r53639  
    5151#define ASSERT_VG_NO_ERROR() ((void)0)
    5252#else
    53 #define ASSERT_VG_NO_ERROR() \
    54     ASSERT_WITH_MESSAGE(vgGetError() == VG_NO_ERROR, "Found %s", toVGErrorConstant(vgGetError()))
     53#define ASSERT_VG_NO_ERROR() do { \
     54    VGErrorCode vgErrorCode = vgGetError(); \
     55    ASSERT_WITH_MESSAGE(vgErrorCode == VG_NO_ERROR, "Found %s", toVGErrorConstant(vgErrorCode)); \
     56} while (0)
    5557#endif
    5658
Note: See TracChangeset for help on using the changeset viewer.