Re: [waffle] [PATCH 4/8] cmake: use the relative path in the install targets

2014-05-30 Thread Chad Versace
Committed to master.

On Sat, May 24, 2014 at 11:51:31PM +0100, Emil Velikov wrote:
 Otherwise make DESTDIR=... install will not function properly.
 
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---
  CMakeLists.txt| 4 ++--
  doc/CMakeLists.txt| 4 ++--
  examples/CMakeLists.txt   | 2 +-
  include/CMakeLists.txt| 2 +-
  man/html.cmake| 2 +-
  man/manpages.cmake| 6 +++---
  src/waffle/CMakeLists.txt | 2 +-
  7 files changed, 11 insertions(+), 11 deletions(-)
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 5/8] cmake: reformat/update install targets

2014-05-30 Thread Emil Velikov
On 31/05/14 01:43, Chad Versace wrote:
 On Sat, May 24, 2014 at 11:51:32PM +0100, Emil Velikov wrote:
 Cleanup the formatting and add component for each build target.
 The latter will allow us to use CPack to create a component
 based installer for Windows.
 
 I've never used CPack, so my review here is a little uninformed.
 I have one small request.
 
 
 diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
 index b89fde3..a2d46e6 100644
 --- a/doc/CMakeLists.txt
 +++ b/doc/CMakeLists.txt
 @@ -1,7 +1,14 @@
 -install(FILES ${CMAKE_SOURCE_DIR}/README.txt
 -  ${CMAKE_SOURCE_DIR}/LICENSE.txt
 -DESTINATION ${CMAKE_INSTALL_DOCDIR})
 +install(
 +FILES
 +${CMAKE_SOURCE_DIR}/README.txt
 +${CMAKE_SOURCE_DIR}/LICENSE.txt
 +DESTINATION ${CMAKE_INSTALL_DOCDIR}
 +COMPONENT coredocs
 +)
 
 
 
 diff --git a/man/html.cmake b/man/html.cmake
 index ea55600..efe3887 100644
 --- a/man/html.cmake
 +++ b/man/html.cmake
 @@ -92,5 +92,8 @@ add_custom_target(html
  DEPENDS ${html_outputs}
  )
  
 -install(DIRECTORY ${html_out_dir}
 -DESTINATION ${CMAKE_INSTALL_DOCDIR}/html)
 +install(
 +DIRECTORY ${html_out_dir}
 +DESTINATION ${CMAKE_INSTALL_DOCDIR}/html
 +COMPONENT docs
 +)
 
 
 I find the name 'docs' confusing, relative to 'coredocs',  because
 I usually interpreet 'foo' as a superset of '${qualifier}_foo'. I'd like
 to rename it to 'htmldocs', which is a more accurate name anyway. Will
 that confuse CPack or the Windows installer?
 
AFAIU the names are only symbolic and it should not make any difference.

htmldocs sounds good to me, although I will need to rethink the idea of having
an CPack/installer due to the binary libraries (mingw build). Not sure if I
can make the cmake pick them up.

-Emil
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 6/8] waffle: move WAFFLE_API out of the API header

2014-05-30 Thread Chad Versace
On Sat, May 24, 2014 at 11:51:33PM +0100, Emil Velikov wrote:
 WAFFLE_API is used to define the symbol visibility and
 all functions provided by the API must be non-hidden.
 Thus the define should be used internally in conjunction
 with the compiler used in order to properly annotate the
 symbols.
 
 Resolves #12: https://github.com/waffle-gl/waffle/issues/12
 
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

Thanks for the fix. Committed to master and issue #12 closed.

I verified the patch by diffing the output of nm before and after.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 0/8] Move WAFFLE_API out of the public header + misc patches

2014-05-30 Thread Chad Versace
Patch 7 is committed to master. I added an r-b tag for Jose.

On Thu, May 29, 2014 at 11:17:55AM -0700, Jose Fonseca wrote:
 The Windows specifc change (patch 7) looks good.
 
 The rest looks sensible too FWIW, but I'm not the best person to comment, as 
 I'm not yet familiar with the code base.
 
 Jose
 
 - Original Message -
  Hi all,
  
  Here is a small selection of patches - mostly bugfixes, while going
  though waffle's existing implementations and working on wgl.
  
  The series is available in the for-upstream branch at my github repo
  https://urldefense.proofpoint.com/v1/url?u=https://github.com/evelikov/wafflek=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0Am=PKFidBoUqDS1VL09U57pR%2Btw2qErP3G1%2B%2B6XjsEUCE8%3D%0As=f2626a50efbe287b107032398cfe8476bdd29d71fac039eebfec609cd9f97b2f
  
  Comments, tips and suggestions are greatly appreciated.
  
  Cheers,
  Emil
  ___
  waffle mailing list
  waffle@lists.freedesktop.org
  https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/wafflek=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0Am=PKFidBoUqDS1VL09U57pR%2Btw2qErP3G1%2B%2B6XjsEUCE8%3D%0As=bf956564e315c2ca8e8da1e6e0c16a7758a2c1e8ef7bb1b9c3bfcdf84825b038
  
 ___
 waffle mailing list
 waffle@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/waffle
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 8/8] core: update wcore_enum_to_string()

2014-05-30 Thread Chad Versace
On Sat, May 24, 2014 at 11:51:35PM +0100, Emil Velikov wrote:
 Add a couple of missing cases - PLATFORM_GBM and DL_OPENGL_ES3.
 
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---
  src/waffle/core/wcore_util.c | 2 ++
  1 file changed, 2 insertions(+)

Committed to master.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 08/10] cgl: avoid leaking the PixelFormat

2014-05-30 Thread Emil Velikov
According to apple developer page, starting with OS X v10.5 the
pixelformat is reference counted. The object is created at
CGLChoosePixelFormat and should be unrefeferenced via
CGLReleasePixelFormat/CGLDestroyPixelFormat.

The latter two are identical accoring to the documentation.

Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
 src/waffle/cgl/cgl_config.m | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/waffle/cgl/cgl_config.m b/src/waffle/cgl/cgl_config.m
index 7a74438..5252e12 100644
--- a/src/waffle/cgl/cgl_config.m
+++ b/src/waffle/cgl/cgl_config.m
@@ -50,6 +50,9 @@ cgl_config_destroy(struct wcore_config *wc_self)
 if (wc_self == NULL)
 return ok;
 
+if (self-pixel_format)
+CGLReleasePixelFormat(self-pixel_format);
+
 ok = wcore_config_teardown(wc_self);
 free(cgl_config(wc_self));
 return ok;
@@ -248,6 +251,7 @@ cgl_config_choose(struct wcore_platform *wc_plat,
 if (!ok)
 goto error;
 
+// Starting with OS X v10.5, pixel format objects are reference counted.
 error = CGLChoosePixelFormat(pixel_attrs, self-pixel_format, ignore);
 if (error) {
 cgl_error_failed_func(CGLChoosePixelFormat, error);
-- 
1.9.3

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 04/10] cmake: add autodetection for waffle_has_egl, glx...

2014-05-30 Thread Emil Velikov
Silence the pkg_check_modules and check set the default
options depending on the packages found.

Error out if the user has selected an option and it's
requirements are not met.

Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
 CMakeLists.txt |  2 +-
 Options.cmake  | 29 +
 cmake/Modules/WaffleFindDependencies.cmake | 30 ++
 cmake/Modules/WaffleValidateOptions.cmake  | 21 +
 4 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b32b3d1..cf19929 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,12 +30,12 @@ cmake_minimum_required(VERSION 2.8)
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
 
 include(WaffleDefineOS)
+include(WaffleFindDependencies)
 include(Options.cmake)
 include(WaffleDefineInternalOptions)
 include(WaffleValidateOptions)
 include(WaffleDefineVersion)
 include(WaffleDefineCompilerFlags)
-include(WaffleFindDependencies)
 include(GNUInstallDirs)
 
 if(waffle_build_tests)
diff --git a/Options.cmake b/Options.cmake
index 7f694e3..3a36a5d 100644
--- a/Options.cmake
+++ b/Options.cmake
@@ -1,9 +1,30 @@
+set(glx_default OFF)
+set(wayland_default OFF)
+set(x11_egl_default OFF)
+set(gbm_default OFF)
+
 if(waffle_on_linux)
+if(gl_FOUND AND x11-xcb_FOUND)
+set(glx_default ON)
+endif()
+
+if(wayland-client_FOUND AND wayland-egl_FOUND AND egl_FOUND)
+set(wayland_default ON)
+endif()
+
+if(x11-xcb_FOUND AND egl_FOUND)
+set(x11_egl_default ON)
+endif()
+
+if(gbm_FOUND AND libudev_FOUND AND egl_FOUND)
+set(gbm_default ON)
+endif()
+
 # On Linux, you must enable at least one of the below options.
-option(waffle_has_glx Build support for GLX OFF)
-option(waffle_has_wayland Build support for Wayland OFF)
-option(waffle_has_x11_egl Build support for X11/EGL OFF)
-option(waffle_has_gbm Build support for GBM OFF)
+option(waffle_has_glx Build support for GLX ${glx_default})
+option(waffle_has_wayland Build support for Wayland ${wayland_default})
+option(waffle_has_x11_egl Build support for X11/EGL ${x11_egl_default})
+option(waffle_has_gbm Build support for GBM ${gbm_default})
 endif()
 
 option(waffle_build_tests Build tests ON)
diff --git a/cmake/Modules/WaffleFindDependencies.cmake 
b/cmake/Modules/WaffleFindDependencies.cmake
index 527e01f..42725ec 100644
--- a/cmake/Modules/WaffleFindDependencies.cmake
+++ b/cmake/Modules/WaffleFindDependencies.cmake
@@ -61,24 +61,22 @@ if(waffle_on_mac)
 find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation REQUIRED)
 endif()
 
-if(waffle_has_egl)
-waffle_pkg_config(egl REQUIRED egl)
-endif()
 
-if(waffle_has_glx)
-waffle_pkg_config(gl REQUIRED gl)
-endif()
+if(waffle_on_linux)
+# waffle_has_egl
+waffle_pkg_config(egl QUIET egl)
 
-if(waffle_has_wayland)
-waffle_pkg_config(wayland-client REQUIRED wayland-client=1)
-waffle_pkg_config(wayland-egl REQUIRED wayland-egl=9.1)
-endif()
+# waffle_has_glx
+waffle_pkg_config(gl QUIET gl)
 
-if(waffle_has_x11)
-waffle_pkg_config(x11-xcb REQUIRED x11-xcb)
-endif()
+# waffle_has_wayland
+waffle_pkg_config(wayland-client QUIET wayland-client=1)
+waffle_pkg_config(wayland-egl QUIET wayland-egl=9.1)
+
+# waffle_has_x11
+waffle_pkg_config(x11-xcb QUIET x11-xcb)
 
-if(waffle_has_gbm)
-waffle_pkg_config(gbm REQUIRED gbm)
-waffle_pkg_config(libudev REQUIRED libudev)
+# waffle_has_gbm
+waffle_pkg_config(gbm QUIET gbm)
+waffle_pkg_config(libudev QUIET libudev)
 endif()
diff --git a/cmake/Modules/WaffleValidateOptions.cmake 
b/cmake/Modules/WaffleValidateOptions.cmake
index 03eb4ba..f87f5b1 100644
--- a/cmake/Modules/WaffleValidateOptions.cmake
+++ b/cmake/Modules/WaffleValidateOptions.cmake
@@ -52,6 +52,27 @@ if(waffle_on_linux)
 waffle_has_glx, waffle_has_wayland, 
 waffle_has_x11_egl, waffle_has_gbm.)
 endif()
+if(waffle_has_gbm)
+if(NOT gbm_FOUND OR NOT libudev_FOUND OR NOT egl_FOUND)
+message(FATAL_ERROR gbm requirements are not met.)
+endif()
+endif()
+if(waffle_has_glx)
+if(NOT gl_FOUND OR NOT x11-xcb_FOUND)
+message(FATAL_ERROR glx requirements are not met.)
+endif()
+endif()
+if(waffle_has_wayland)
+if(NOT wayland-client_FOUND OR
+   NOT wayland-egl_FOUND OR NOT egl_FOUND)
+message(FATAL_ERROR wayland requirements are not met.)
+endif()
+endif()
+if(waffle_has_x11_egl)
+if(NOT x11-xcb_FOUND OR NOT egl_FOUND)
+message(FATAL_ERROR x11_egl requirements are not met.)
+endif()
+endif()
 elseif(waffle_on_mac)
 if(waffle_has_gbm)
 message(FATAL_ERROR Option is not supported on Darwin: 
waffle_has_gbm.)
-- 
1.9.3


[waffle] [PATCH 05/10] waffle: remove found_platform from waffle_init_parse_attrib_list

2014-05-30 Thread Emil Velikov
Whenever a platform is missing a case statement, the default will
kick in throwing an error and exiting the function.

Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
 src/waffle/api/waffle_init.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c
index b45c3ba..9baf271 100644
--- a/src/waffle/api/waffle_init.c
+++ b/src/waffle/api/waffle_init.c
@@ -40,8 +40,6 @@ waffle_init_parse_attrib_list(
 const int32_t attrib_list[],
 int *platform)
 {
-bool found_platform = false;
-
 for (const int32_t *i = attrib_list; *i != 0; i += 2) {
 const int32_t attr = i[0];
 const int32_t value = i[1];
@@ -51,7 +49,6 @@ waffle_init_parse_attrib_list(
 switch (value) {
 #define CASE_DEFINED_PLATFORM(name) \
 case WAFFLE_PLATFORM_##name : \
-found_platform = true; \
 *platform = value; \
 break;
 
@@ -116,12 +113,6 @@ waffle_init_parse_attrib_list(
 }
 }
 
-if (!found_platform) {
-wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
- attribute list is missing WAFFLE_PLATFORM);
-return false;
-}
-
 return true;
 }
 
-- 
1.9.3

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 03/10] waffle: remove restrict keyword from public API

2014-05-30 Thread Emil Velikov
We should have never defined the restrict keyword in
the waffle.h header. The word is used as a hint to the
compiler to provide optimisations re: pointer aliasing.

Keep the symbol around, so that the compiler can still
optimise the library.

v2: Move the symbol definition to its user and update the
man pages.

Resolves #11: https://github.com/waffle-gl/waffle/issues/11

Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
 include/waffle/waffle.h | 8 ++--
 man/waffle_is_extension_in_string.3.xml | 4 ++--
 src/waffle/api/waffle_gl_misc.c | 4 
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
index d43ddcf..91f3434 100644
--- a/include/waffle/waffle.h
+++ b/include/waffle/waffle.h
@@ -36,10 +36,6 @@
 extern C {
 #endif
 
-#if __STDC_VERSION__  199901L
-#   define restrict
-#endif
-
 struct waffle_display;
 struct waffle_config;
 struct waffle_context;
@@ -172,8 +168,8 @@ void*
 waffle_get_proc_address(const char *name);
 
 bool
-waffle_is_extension_in_string(const char *restrict extension_string,
-  const char *restrict extension_name);
+waffle_is_extension_in_string(const char *extension_string,
+  const char *extension_name);
 
 // ---
 // waffle_display
diff --git a/man/waffle_is_extension_in_string.3.xml 
b/man/waffle_is_extension_in_string.3.xml
index 0aa215a..2734ea2 100644
--- a/man/waffle_is_extension_in_string.3.xml
+++ b/man/waffle_is_extension_in_string.3.xml
@@ -43,8 +43,8 @@
 
   funcprototype
 funcdefbool 
functionwaffle_is_extension_in_string/function/funcdef
-paramdefconst char *restrict 
parameterextension_string/parameter/paramdef
-paramdefconst char *restrict 
parameterextension_name/parameter/paramdef
+paramdefconst char * 
parameterextension_string/parameter/paramdef
+paramdefconst char * parameterextension_name/parameter/paramdef
   /funcprototype
 
 /funcsynopsis
diff --git a/src/waffle/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c
index f94b34b..10b4da5 100644
--- a/src/waffle/api/waffle_gl_misc.c
+++ b/src/waffle/api/waffle_gl_misc.c
@@ -34,6 +34,10 @@
 #include wcore_platform.h
 #include wcore_window.h
 
+#if __STDC_VERSION__  199901L
+#   define restrict
+#endif
+
 WAFFLE_API bool
 waffle_is_extension_in_string(
 const char *restrict extension_string,
-- 
1.9.3

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 10/10] glx: glx_context_create_native returns GLXContext not bool

2014-05-30 Thread Emil Velikov
Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
 src/waffle/glx/glx_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c
index c7a7d91..62573dc 100644
--- a/src/waffle/glx/glx_context.c
+++ b/src/waffle/glx/glx_context.c
@@ -167,7 +167,7 @@ glx_context_create_native(struct glx_config *config,
 
 ok = glx_context_fill_attrib_list(config, attrib_list);
 if (!ok)
-return false;
+return NULL;
 
 ctx = wrapped_glXCreateContextAttribsARB(platform,
  dpy-x11.xlib,
-- 
1.9.3

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle