tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.083420 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:56:16 +0000 (22:56 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:56:16 +0000 (22:56 +0900)
12 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
include/X11/extensions/hwc.h [new file with mode: 0755]
libhwc.manifest [new file with mode: 0644]
libhwc.pc.in [new file with mode: 0644]
packaging/libhwc.spec [new file with mode: 0644]
src/Makefile.am [new file with mode: 0644]
src/hwc.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..93798a9
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+SangJin Lee <lsj119@samsung.com>
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..256fa91
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,23 @@
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is fur-
+nished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the XFree86 Project shall not
+be used in advertising or otherwise to promote the sale, use or other deal-
+ings in this Software without prior written authorization from the XFree86
+Project.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..76a459c
--- /dev/null
@@ -0,0 +1,9 @@
+
+AUTOMAKE_OPTIONS = foreign
+SUBDIRS = src
+
+pkgconfigdir = @pkgconfigdir@
+
+pkgconfig_DATA = libhwc.pc 
+
+EXTRA_DIST = libhwc.pc.in 
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..904cd67
--- /dev/null
@@ -0,0 +1,12 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+autoreconf -v --install || exit 1
+cd $ORIGDIR || exit $?
+
+$srcdir/configure --enable-maintainer-mode "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..cbc2750
--- /dev/null
@@ -0,0 +1,30 @@
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.61)
+AC_INIT(libhwc, 0.1.0, [http://])
+AC_CONFIG_SRCDIR([src/hwc.c])
+AC_CONFIG_HEADER([config.h])
+
+AM_INIT_AUTOMAKE([dist-bzip2])
+
+# Checks for programs.
+AC_PROG_LIBTOOL
+AC_PROG_CC
+
+# Checks for pkg-configs
+PKG_CHECK_MODULES(XLIBS, x11 xext)
+AC_SUBST(XLIBS_CFLAGS)
+AC_SUBST(XLIBS_LIBS)
+
+PKG_CHECK_MODULES(HWCPROTO, hwcproto)
+AC_SUBST(HWCPROTO_CFLAGS)
+AC_SUBST(HWCPROTO_LIBS)
+
+pkgconfigdir=${libdir}/pkgconfig/
+AC_SUBST(pkgconfigdir)
+
+
+AC_CONFIG_FILES([Makefile
+                               src/Makefile
+                               libhwc.pc])
+AC_OUTPUT
diff --git a/include/X11/extensions/hwc.h b/include/X11/extensions/hwc.h
new file mode 100755 (executable)
index 0000000..890998c
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Origin Authors:
+ *   Sangjin Lee <lsj119@samsung.com>
+ */
+
+#ifndef _HWC_H_
+#define _HWC_H_
+
+#include <X11/extensions/hwctokens.h>
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xlib.h>
+
+_XFUNCPROTOBEGIN
+
+extern Bool
+HWCQueryVersion(Display * display, int *major, int *minor);
+
+extern Bool
+HWCOpen(Display * dpy, Window window, int *maxLayer);
+
+extern void
+HWCSetDrawables(Display * dpy, Window window, Drawable *drawables, XRectangle *srcRect, XRectangle *dstRect, int count);
+
+extern void
+HWCSelectInput(Display * dpy, Window window, int mask);
+
+typedef struct
+{
+    int            evtype;
+    int            maxLayer;
+} HWCConfigureNotifyCookie;
+
+_XFUNCPROTOEND
+
+#endif
diff --git a/libhwc.manifest b/libhwc.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/libhwc.pc.in b/libhwc.pc.in
new file mode 100644 (file)
index 0000000..b7fc114
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libhwc
+Description: HWC X library for the X Client
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lhwc
+Cflags: -I${includedir}
diff --git a/packaging/libhwc.spec b/packaging/libhwc.spec
new file mode 100644 (file)
index 0000000..88ad2eb
--- /dev/null
@@ -0,0 +1,55 @@
+Name:       libhwc
+Summary:    X.Org HWC Extension client library
+Version:    0.1.1
+Release:    13
+Group:      System/Libraries
+License:    MIT
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  pkgconfig(hwcproto)
+BuildRequires:  pkgconfig(x11)
+BuildRequires:  pkgconfig(xext)
+
+
+%description
+HWC Extension client library
+
+
+%package devel
+Summary:    X.Org HWC Extension client library (development library)
+Group:      System/Libraries
+Requires:   %{name} = %{version}-%{release}
+Requires:   pkgconfig(hwcproto)
+
+%description devel
+HWC Extension client library (development library)
+
+%prep
+%setup -q
+
+
+%build
+
+%reconfigure --disable-static
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp -af COPYING %{buildroot}/usr/share/license/%{name}
+%make_install
+
+
+%files
+%manifest libhwc.manifest
+%defattr(-,root,root,-)
+/usr/share/license/%{name}
+%{_libdir}/libhwc.so.*
+
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/libhwc.so
+%{_includedir}/X11/extensions/*
+%{_libdir}/pkgconfig/*
+
+
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..a92adf2
--- /dev/null
@@ -0,0 +1,15 @@
+libhwc_la_LTLIBRARIES = libhwc.la
+libhwc_ladir = $(libdir)
+libhwc_la_LDFLAGS = ${XLIBS_CFLAGS}
+libhwc_la_LIBADD = -lX11 -lXext
+libhwc_la_CFLAGS = ${XLIBS_CFLAGS}
+
+AM_CPPFLAGS = -I$(top_srcdir)/src \
+       -I$(top_srcdir)/include/X11 \
+       -I$(top_srcdir)/include/X11/extensions
+
+libhwc_la_SOURCES = hwc.c
+
+libhwcincludedir = ${includedir}/X11/extensions
+libhwcinclude_HEADERS = $(top_srcdir)/include/X11/extensions/hwc.h 
+
diff --git a/src/hwc.c b/src/hwc.c
new file mode 100755 (executable)
index 0000000..8d15b05
--- /dev/null
+++ b/src/hwc.c
@@ -0,0 +1,320 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Sangjin Lee <lsj119@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Origin Authors:
+ *   Sangjin Lee (lsj119@samsung.com)
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/hwcproto.h>
+#include "hwc.h"
+
+static char hwcExtensionName[] = HWC_NAME;
+static XExtensionInfo *hwcInfo;
+
+static int
+HWCCloseDisplay(Display *dpy, XExtCodes *codes);
+static int
+HWCError(Display *display, xError *err, XExtCodes *codes, int *ret_code);
+static Bool
+HWCWireToCookie(Display        *dpy,XGenericEventCookie *cookie, xEvent        *event);
+static Bool
+HWCCopyCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out);
+
+static /* const */ XExtensionHooks hwcExtensionHooks = {
+  NULL,                   /* create_gc */
+  NULL,                   /* copy_gc */
+  NULL,                   /* flush_gc */
+  NULL,                   /* free_gc */
+  NULL,                   /* create_font */
+  NULL,                   /* free_font */
+  HWCCloseDisplay,       /* close_display */
+  NULL,        /* wire_to_event */
+  NULL,        /* event_to_wire */
+  HWCError,              /* error */
+  NULL,                   /* error_string */
+};
+
+static XExtDisplayInfo *
+HWCFindDisplay (Display *dpy)
+{
+    XExtDisplayInfo *dpyinfo;
+    if (!hwcInfo)
+    {
+        if (!(hwcInfo = XextCreateExtension()))
+            return NULL;
+    }
+
+    if (!(dpyinfo = XextFindDisplay (hwcInfo, dpy)))
+    {
+        dpyinfo = XextAddDisplay (hwcInfo,dpy,hwcExtensionName,&hwcExtensionHooks,0,NULL);
+        if (!dpyinfo)
+        {
+            fprintf(stderr,"HWCFindDisplay: fail to AddDisplay\n");
+            return NULL;
+        }
+
+        if (dpyinfo->codes) /* NULL if HWC doesn't exist on the server */
+        {
+            XESetWireToEventCookie(dpy, dpyinfo->codes->major_opcode, HWCWireToCookie);
+            XESetCopyEventCookie(dpy, dpyinfo->codes->major_opcode, HWCCopyCookie);
+        }
+    }
+
+    return dpyinfo;
+}
+
+static int
+HWCCloseDisplay(Display *dpy, XExtCodes *codes)
+{
+   return XextRemoveDisplay (hwcInfo, dpy);
+}
+
+static int
+HWCError(Display *display, xError *err, XExtCodes *codes, int *ret_code)
+{
+    return False;
+}
+
+static Bool
+HWCWireToCookie(Display        *dpy, XGenericEventCookie *cookie, xEvent       *event)
+{
+    XExtDisplayInfo *info = HWCFindDisplay(dpy);
+    xGenericEvent* ge = (xGenericEvent*)event;
+
+    if (!info)
+    {
+        fprintf(stderr,"HWCWireToCookie: fail to find display info\n");
+        return False;
+    }
+
+    if (ge->extension != info->codes->major_opcode)
+    {
+        fprintf(stderr, "HWCWireToCookie: wrong extension opcode %d\n",
+                ge->extension);
+        return False;
+    }
+
+    cookie->type = ge->type;
+    cookie->serial = _XSetLastRequestRead(dpy, (xGenericReply *) event);
+    cookie->send_event = ((event->u.u.type & 0x80) != 0);
+    cookie->display = dpy;
+    cookie->extension = ge->extension;
+    cookie->evtype = ge->evtype;
+
+    /*Fill cookie data*/
+    switch(ge->evtype)
+    {
+        case HWCConfigureNotify:
+        {
+            xHWCConfigureNotify *in = (xHWCConfigureNotify*)event;
+            HWCConfigureNotifyCookie* data;
+
+            cookie->data = data = malloc(sizeof(HWCConfigureNotifyCookie));
+            if (!data)
+            {
+                fprintf(stderr, "HWCWireToCookie: Fail to malloc ConfigureNotifyCookie\n");
+                return False;
+            }
+
+            data->evtype = HWCConfigureNotify;
+            data->maxLayer = in->maxLayer;
+            return True;
+        }
+        default:
+            printf("HWCWireToCookie: Unknown generic event. type %d\n", ge->evtype);
+    }
+
+    return False;
+}
+
+static Bool
+HWCCopyCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out)
+{
+    XExtDisplayInfo *info = HWCFindDisplay(dpy);
+
+    if (!info)
+    {
+        fprintf(stderr,"HWCCopyCookie: fail to find display info\n");
+        return False;
+    }
+
+    if (in->extension != info->codes->major_opcode)
+    {
+        fprintf(stderr,"HWCCopyCookie: wrong extension opcode %d\n",
+                in->extension);
+        return False;
+    }
+
+    *out = *in;
+    out->data = NULL;
+    out->cookie = 0;
+
+    switch(in->evtype) {
+        case HWCConfigureNotify:
+        {
+            HWCConfigureNotifyCookie *_in, *_out;
+
+            _in = (HWCConfigureNotifyCookie *)in->data;
+            _out = malloc(sizeof(HWCConfigureNotifyCookie));
+            if (!_out)
+            {
+                fprintf(stderr, "HWCCopyCookie: Failed to malloc Cookie out\n");
+                return False;
+            }
+
+            *_out = *_in;
+            out->data = (void*)_out;
+            return True;
+        }
+        default:
+            fprintf(stderr, "HWCCopyCookie: Failed to copy evtype %d", in->evtype);
+            break;
+    }
+
+    return False;
+}
+
+Bool
+HWCQueryVersion(Display * dpy, int *major, int *minor)
+{
+   XExtDisplayInfo *info = HWCFindDisplay(dpy);
+   xHWCQueryVersionReply rep;
+   xHWCQueryVersionReq *req;
+
+   XextCheckExtension(dpy, info, hwcExtensionName, False);
+
+   LockDisplay(dpy);
+   GetReq(HWCQueryVersion, req);
+   req->reqType = info->codes->major_opcode;
+   req->hwcReqType = X_HWCQueryVersion;
+   req->majorVersion = HWC_MAJOR;
+   req->minorVersion = HWC_MINOR;
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+   *major = rep.majorVersion;
+   *minor = rep.minorVersion;
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return True;
+}
+
+Bool
+HWCOpen(Display * dpy, Window window, int *maxLayer)
+{
+   XExtDisplayInfo *info = HWCFindDisplay(dpy);
+   xHWCOpenReply rep;
+   xHWCOpenReq *req;
+
+   XextCheckExtension(dpy, info, hwcExtensionName, False);
+
+   LockDisplay(dpy);
+   GetReq(HWCOpen, req);
+   req->reqType = info->codes->major_opcode;
+   req->hwcReqType = X_HWCOpen;
+   req->window = window;
+
+   if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+      UnlockDisplay(dpy);
+      SyncHandle();
+      return False;
+   }
+
+   *maxLayer = rep.maxLayer;
+
+   UnlockDisplay(dpy);
+   SyncHandle();
+
+   return True;
+}
+
+void
+HWCSetDrawables(Display * dpy, Window window, Drawable *drawables, XRectangle *srcRect, XRectangle *dstRect, int count)
+{
+    XExtDisplayInfo *info = HWCFindDisplay(dpy);
+    xHWCSetDrawablesReq *req;
+    xHWCDrawInfo *p;
+    int i;
+
+    XextSimpleCheckExtension(dpy, info, hwcExtensionName);
+    LockDisplay(dpy);
+
+    GetReqExtra(HWCSetDrawables, count * SIZEOF(xHWCDrawInfo), req);
+
+    req->reqType = info->codes->major_opcode;
+    req->hwcReqType = X_HWCSetDrawables;
+    req->window = window;
+    req->count = count;
+    p = (xHWCDrawInfo *) & req[1];
+    for (i = 0; i < count; i++)
+    {
+        p[i].drawable = drawables[i];
+        p[i].srcX = srcRect[i].x;
+        p[i].srcY = srcRect[i].y;
+        p[i].srcWidth = srcRect[i].width;
+        p[i].srcHeight = srcRect[i].height;
+        p[i].dstX = dstRect[i].x;
+        p[i].dstY = dstRect[i].y;
+        p[i].dstWidth = dstRect[i].width;
+        p[i].dstHeight = dstRect[i].height;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+void
+HWCSelectInput(Display * dpy, Window window, int mask)
+{
+    XExtDisplayInfo *info = HWCFindDisplay(dpy);
+    xHWCSelectInputReq *req;
+
+    XextSimpleCheckExtension(dpy, info, hwcExtensionName);
+    LockDisplay(dpy);
+
+    GetReq(HWCSelectInput, req);
+    req->reqType = info->codes->major_opcode;
+    req->hwcReqType = X_HWCSelectInput;
+    req->window = window;
+    req->eventMask = mask;
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+