[Title] Avoid unnecessary MakeCurrent calls before locking surface.
authorKondapally Kalyan <kalyan.kondapally@intel.com>
Wed, 8 May 2013 10:52:46 +0000 (13:52 +0300)
committerKondapally Kalyan <kalyan.kondapally@intel.com>
Wed, 8 May 2013 10:52:46 +0000 (13:52 +0300)
[Issue#] TZSP-5951
[Problem] Redundant EGLMakeCurrent calls on IA before locking surface.
[Solution] A call to make surface and context as current before locking the surface
was introduced to fix issues for Qualcomm(as per the changelog). This causes
a un-necessary regression on IA side. This patch ensures that the makecurrent
call is skipped for Imagination, arm and mesa drivers.

Source/WebCore/platform/graphics/efl/tizen/SharedPlatformSurfaceTizen.cpp

index 5e76b59..84b5a22 100755 (executable)
@@ -36,6 +36,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
 #include <wtf/StdLibExtras.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 static PFNEGLLOCKSURFACEKHRPROC eglLockSurfaceKHR = 0;
 static PFNEGLUNLOCKSURFACEKHRPROC eglUnlockSurfaceKHR = 0;
 
+static bool vendorNeedsMakeCurrent(const EGLDisplay display)
+{
+    static bool queryDone = false;
+    static bool needsMakeCurrent = true;
+
+    if (!queryDone) {
+        queryDone = true;
+        String vendor = eglQueryString(display, EGL_VENDOR);
+        Vector<String> vendorComponents;
+        vendor.lower().split(' ', vendorComponents);
+
+        if (vendorComponents.contains("imagination") || vendorComponents.contains("mesa") || vendorComponents.contains("arm"))
+            needsMakeCurrent = false;
+    }
+
+    return needsMakeCurrent;
+}
+
 namespace WebCore {
 
 Display* g_nativeDisplay;
@@ -279,8 +298,7 @@ bool PixmapContextTizen::lockSurface(EGLSurface surface)
     if (!eglLockSurfaceKHR)
         eglLockSurfaceKHR = (PFNEGLLOCKSURFACEKHRPROC)eglGetProcAddress("eglLockSurfaceKHR");
 
-    static bool needsMakeCurrent = strcmp(eglQueryString(m_display, EGL_VENDOR), "ARM") != 0;
-    if (needsMakeCurrent)
+    if (vendorNeedsMakeCurrent(m_display))
         eglMakeCurrent(m_display, surface, surface, m_context);
 
     if (eglLockSurfaceKHR(m_display, surface, lockAttrib) != EGL_TRUE) {