├── .clang-format ├── .gitignore ├── .travis.yml ├── Android.common.mk ├── Android.mk ├── Android.static.mk ├── CONTRIBUTING.md ├── Doxyfile ├── Makefile.am ├── Makefile.sources ├── README.md ├── autogen.sh ├── common ├── Android.mk ├── Makefile.am ├── Makefile.sources ├── compositor │ ├── compositionregion.h │ ├── compositor.cpp │ ├── compositor.h │ ├── compositordefs.h │ ├── compositorthread.cpp │ ├── compositorthread.h │ ├── factory.cpp │ ├── factory.h │ ├── gl │ │ ├── egloffscreencontext.cpp │ │ ├── egloffscreencontext.h │ │ ├── gl_shader_pre_built │ │ │ ├── bin_to_c_array.c │ │ │ ├── generate_c_arrays.sh │ │ │ ├── generate_shader_test.sh │ │ │ └── require.txt │ │ ├── glprogram.cpp │ │ ├── glprogram.h │ │ ├── glrenderer.cpp │ │ ├── glrenderer.h │ │ ├── glsurface.cpp │ │ ├── glsurface.h │ │ ├── nativeglresource.cpp │ │ ├── nativeglresource.h │ │ ├── shim.cpp │ │ └── shim.h │ ├── nativegpuresource.h │ ├── nativesurface.cpp │ ├── nativesurface.h │ ├── renderer.h │ ├── renderstate.cpp │ ├── renderstate.h │ ├── va │ │ ├── varenderer.cpp │ │ ├── varenderer.h │ │ ├── vautils.cpp │ │ └── vautils.h │ └── vk │ │ ├── nativevkresource.cpp │ │ ├── nativevkresource.h │ │ ├── vkcomp.frag │ │ ├── vkcomp.frag.h │ │ ├── vkcomp.vert │ │ ├── vkcomp.vert.h │ │ ├── vkprogram.cpp │ │ ├── vkprogram.h │ │ ├── vkrenderer.cpp │ │ ├── vkrenderer.h │ │ ├── vkshim.cpp │ │ ├── vkshim.h │ │ ├── vksurface.cpp │ │ └── vksurface.h ├── core │ ├── framebuffermanager.cpp │ ├── framebuffermanager.h │ ├── gpudevice.cpp │ ├── hwclayer.cpp │ ├── logicaldisplay.cpp │ ├── logicaldisplay.h │ ├── logicaldisplaymanager.cpp │ ├── logicaldisplaymanager.h │ ├── mosaicdisplay.cpp │ ├── mosaicdisplay.h │ ├── overlaylayer.cpp │ ├── overlaylayer.h │ ├── resourcemanager.cpp │ └── resourcemanager.h ├── display │ ├── displayplanemanager.cpp │ ├── displayplanemanager.h │ ├── displayplanestate.cpp │ ├── displayplanestate.h │ ├── displayqueue.cpp │ ├── displayqueue.h │ ├── hyperdmadisplay.h │ ├── vblankeventhandler.cpp │ ├── vblankeventhandler.h │ ├── virtualdisplay.cpp │ ├── virtualdisplay.h │ ├── virtualpanoramadisplay.cpp │ └── virtualpanoramadisplay.h └── utils │ ├── disjoint_layers.cpp │ ├── disjoint_layers.h │ ├── fdhandler.cpp │ ├── fdhandler.h │ ├── hwcevent.cpp │ ├── hwcevent.h │ ├── hwcthread.cpp │ ├── hwcthread.h │ ├── hwctrace.h │ ├── hwcutils.cpp │ ├── logentry.h │ ├── logview.cpp │ └── val │ ├── abstractcompositionchecker.h │ └── abstractlog.h ├── configure.ac ├── hwc_display.ini ├── hwc_display.kvm.ini ├── hwc_display_virt.ini ├── iahwc.pc.in ├── os ├── alios │ ├── hwf_alioshal.cpp │ ├── hwf_alioshal.h │ ├── platformdefines.cpp │ ├── platformdefines.h │ ├── utils_alios.h │ ├── yallocbufferhandler.cpp │ └── yallocbufferhandler.h ├── android │ ├── gralloc1bufferhandler.cpp │ ├── gralloc1bufferhandler.h │ ├── hwcservice.cpp │ ├── hwcservice.h │ ├── iahwc1.cpp │ ├── iahwc2.cpp │ ├── iahwc2.h │ ├── libhwcservice │ │ ├── Android.mk │ │ ├── hwcserviceapi.cpp │ │ ├── hwcserviceapi.h │ │ ├── hwcservicehelper.h │ │ ├── icontrols.cpp │ │ ├── icontrols.h │ │ ├── idiagnostic.cpp │ │ ├── idiagnostic.h │ │ ├── idisplayoverscancontrol.h │ │ ├── idisplayscalingcontrol.h │ │ ├── iservice.cpp │ │ ├── iservice.h │ │ └── test │ │ │ ├── Android.mk │ │ │ └── hwcservice_test.cpp │ ├── platformdefines.cpp │ ├── platformdefines.h │ └── utils_android.h ├── chromeos │ └── IA-Hardware-Composer-9999.ebuild ├── linux │ ├── gbmbufferhandler.cpp │ ├── gbmbufferhandler.h │ ├── iahwc.h │ ├── linux_frontend.cpp │ ├── linux_frontend.h │ ├── pixeluploader.cpp │ ├── pixeluploader.h │ ├── platformdefines.cpp │ ├── platformdefines.h │ └── weston │ │ ├── README.org │ │ ├── build_script.sh │ │ └── plugin │ │ ├── compositor-iahwc.c │ │ └── compositor-iahwc.h ├── platformcommondefines.h └── platformcommondrmdefines.cpp ├── public ├── gpudevice.h ├── hwcdefs.h ├── hwclayer.h ├── hwcmeta.h ├── hwcrect.h ├── hwcutils.h ├── nativebufferhandler.h ├── nativedisplay.h └── spinlock.h ├── tests ├── Android.mk ├── Makefile.am ├── apps │ ├── jsonlayerstest.cpp │ ├── linux_frontend_test.cpp │ ├── panorama_disable.sh │ └── panorama_enable.sh ├── common │ ├── cclayerrenderer.cpp │ ├── cclayerrenderer.h │ ├── esTransform.cpp │ ├── esUtil.h │ ├── glcubelayerrenderer.cpp │ ├── glcubelayerrenderer.h │ ├── gllayerrenderer.cpp │ ├── gllayerrenderer.h │ ├── igt.h │ ├── imagelayerrenderer.cpp │ ├── imagelayerrenderer.h │ ├── jsonhandlers.cpp │ ├── jsonhandlers.h │ ├── layerrenderer.cpp │ ├── layerrenderer.h │ ├── videolayerrenderer.cpp │ └── videolayerrenderer.h ├── jsonconfigs │ ├── colorcorrection.json │ ├── example.json │ ├── kmscube1layer.json │ ├── kmscube1layer_canvascolor.json │ ├── kmscube1layer_rot90.json │ ├── kmscube1layer_rot90flipx.json │ ├── kmscube1layer_rot90flipy.json │ ├── multiplelayers.json │ ├── multiplelayers_idle.json │ ├── multiplelayersnovideo.json │ ├── multiplelayersnovideo_powermode.json │ ├── powermode.json │ ├── video1layer_bgra.json │ └── video1layer_nv12.json └── third_party │ └── json-c │ ├── .editorconfig │ ├── .gitignore │ ├── .travis.yml │ ├── AUTHORS │ ├── Android.configure.mk │ ├── Android.mk │ ├── CMakeLists.txt │ ├── COPYING │ ├── ChangeLog │ ├── Doxyfile │ ├── Makefile.am │ ├── NEWS │ ├── README │ ├── README-WIN32.html │ ├── README.html │ ├── README.md │ ├── RELEASE_CHECKLIST.txt │ ├── STYLE.txt │ ├── appveyor.yml │ ├── arraylist.c │ ├── arraylist.h │ ├── autoconf-archive │ ├── README.txt │ └── m4 │ │ ├── ax_append_compile_flags.m4 │ │ ├── ax_append_flag.m4 │ │ ├── ax_check_compile_flag.m4 │ │ ├── ax_compile_check_sizeof.m4 │ │ └── ax_require_defined.m4 │ ├── autogen.sh │ ├── bits.h │ ├── config.h.win32 │ ├── configure.ac │ ├── debug.c │ ├── debug.h │ ├── json-c-uninstalled.pc.in │ ├── json-c.pc.in │ ├── json-c.vcproj │ ├── json-c.vcxproj │ ├── json-c.vcxproj.filters │ ├── json.h │ ├── json_c_version.c │ ├── json_c_version.h │ ├── json_config.h │ ├── json_config.h.in │ ├── json_config.h.win32 │ ├── json_inttypes.h │ ├── json_object.c │ ├── json_object.h │ ├── json_object_iterator.c │ ├── json_object_iterator.h │ ├── json_object_private.h │ ├── json_pointer.c │ ├── json_pointer.h │ ├── json_tokener.c │ ├── json_tokener.h │ ├── json_util.c │ ├── json_util.h │ ├── json_visit.c │ ├── json_visit.h │ ├── libjson.c │ ├── linkhash.c │ ├── linkhash.h │ ├── math_compat.h │ ├── printbuf.c │ ├── printbuf.h │ ├── random_seed.c │ ├── random_seed.h │ ├── strdup_compat.h │ ├── tests │ ├── Makefile.am │ ├── parse_flags.c │ ├── parse_flags.h │ ├── strerror_override.c │ ├── test-defs.sh │ ├── test1.c │ ├── test1.expected │ ├── test1.test │ ├── test1Formatted_plain.expected │ ├── test1Formatted_pretty.expected │ ├── test1Formatted_spaced.expected │ ├── test2.c │ ├── test2.expected │ ├── test2.test │ ├── test2Formatted_plain.expected │ ├── test2Formatted_pretty.expected │ ├── test2Formatted_spaced.expected │ ├── test4.c │ ├── test4.expected │ ├── test4.test │ ├── testReplaceExisting.c │ ├── testReplaceExisting.expected │ ├── testReplaceExisting.test │ ├── test_cast.c │ ├── test_cast.expected │ ├── test_cast.test │ ├── test_charcase.c │ ├── test_charcase.expected │ ├── test_charcase.test │ ├── test_compare.c │ ├── test_compare.expected │ ├── test_compare.test │ ├── test_double_serializer.c │ ├── test_double_serializer.expected │ ├── test_double_serializer.test │ ├── test_float.c │ ├── test_float.expected │ ├── test_float.test │ ├── test_json_pointer.c │ ├── test_json_pointer.expected │ ├── test_json_pointer.test │ ├── test_locale.c │ ├── test_locale.expected │ ├── test_locale.test │ ├── test_null.c │ ├── test_null.expected │ ├── test_null.test │ ├── test_parse.c │ ├── test_parse.expected │ ├── test_parse.test │ ├── test_parse_int64.c │ ├── test_parse_int64.expected │ ├── test_parse_int64.test │ ├── test_printbuf.c │ ├── test_printbuf.expected │ ├── test_printbuf.test │ ├── test_set_serializer.c │ ├── test_set_serializer.expected │ ├── test_set_serializer.test │ ├── test_set_value.c │ ├── test_set_value.expected │ ├── test_set_value.test │ ├── test_util_file.c │ ├── test_util_file.expected │ ├── test_util_file.test │ ├── test_visit.c │ ├── test_visit.expected │ ├── test_visit.test │ └── valid.json │ └── vasprintf_compat.h ├── tools └── colorformatter │ ├── Makefile.am │ ├── README.md │ ├── autogen.sh │ ├── colorformatter.cpp │ ├── configure.ac │ └── resources │ ├── commands.sh │ ├── resource.nv12 │ ├── resource.nv21 │ ├── resource.raw10 │ ├── resource.raw12 │ ├── resource.raw16 │ ├── resource.rawblob │ ├── resource.rawopaque │ ├── resource.y16 │ ├── resource.y8 │ ├── resource.ycbcr_422_888 │ ├── resource.ycbcr_422_sp │ ├── resource.ycbcr_444_888 │ ├── resource.yuv420p │ ├── resource.yuv420p16le │ ├── resource.yuv422p │ ├── resource.yuv444p │ ├── resource.yuyv422 │ ├── resource.yv12 │ ├── test.jpg │ ├── video1layer_nv12.json │ ├── video1layer_nv12_y_tiled_intel.json │ ├── video1layer_y16.json │ ├── video1layer_y8.json │ ├── video1layer_ycbcr_422_888.json │ ├── video1layer_ycbcr_422_i.json │ ├── video1layer_ycbcr_422_sp.json │ ├── video1layer_ycbcr_444_888.json │ ├── video1layer_ycrcb_420_sp.json │ └── video1layer_yv12.json ├── travisci ├── check_patch.py ├── realpath └── travisci.md ├── wsi ├── Android.mk ├── Makefile.am ├── Makefile.sources ├── displaymanager.h ├── displayplane.h ├── displayplanehandler.h ├── drm │ ├── commondrmutils.h │ ├── drmbuffer.cpp │ ├── drmbuffer.h │ ├── drmdisplay.cpp │ ├── drmdisplay.h │ ├── drmdisplaymanager.cpp │ ├── drmdisplaymanager.h │ ├── drmplane.cpp │ ├── drmplane.h │ ├── drmscopedtypes.cpp │ └── drmscopedtypes.h ├── overlaybuffer.h ├── physicaldisplay.cpp ├── physicaldisplay.h └── wsi_utils.h └── yunos.mk /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | AllowShortIfStatementsOnASingleLine: false 3 | AllowShortLoopsOnASingleLine: false 4 | AllowShortFunctionsOnASingleLine: None 5 | # Pointer alignment works for clang version 5.0 and up. 6 | PointerAlignment: Right 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | aclocal.m4 2 | autom4te.cache 3 | *Makefile.in 4 | *Makefile 5 | .deps 6 | .libs 7 | *.o 8 | *.lo 9 | *.la 10 | libtool 11 | *.pc 12 | config.log 13 | config.status 14 | config.guess 15 | config.h 16 | config.h.in 17 | config.sub 18 | config 19 | configure 20 | install-sh 21 | ltmain.sh 22 | missing 23 | stamp-h1 24 | depcomp 25 | .cproject 26 | .project 27 | .settings 28 | .lib 29 | tags 30 | TAGS 31 | *.make 32 | *.dirstamp 33 | m4 34 | testlayers 35 | linux_test 36 | compile 37 | !/tests/third_party/json-c/autoconf-archive/m4 38 | *.patch 39 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | ifeq ($(strip $(BOARD_USES_IA_HWCOMPOSER)), true) 17 | 18 | # Obtain root HWC source path 19 | HWC_PATH := $(call my-dir) 20 | include $(CLEAR_VARS) 21 | include $(HWC_PATH)/Android.common.mk 22 | 23 | LOCAL_WHOLE_STATIC_LIBRARIES := \ 24 | libhwcomposer_common \ 25 | libhwcomposer_wsi 26 | 27 | ifeq ($(strip $(TARGET_GFX_INTEL)), intel) 28 | LOCAL_MODULE := hwcomposer.$(TARGET_GFX_INTEL) 29 | else 30 | LOCAL_MODULE := hwcomposer.$(TARGET_BOARD_PLATFORM) 31 | endif 32 | 33 | LOCAL_MODULE_TAGS := optional 34 | # Preffered paths for all vendor hals /vendor/lib/hw 35 | LOCAL_PROPRIETARY_MODULE := true 36 | LOCAL_MODULE_RELATIVE_PATH := hw 37 | LOCAL_MODULE_CLASS := SHARED_LIBRARIES 38 | LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX) 39 | include $(BUILD_SHARED_LIBRARY) 40 | 41 | ifeq ($(strip $(TARGET_USES_HWC2)), true) 42 | # libhwcservice 43 | HWC_BUILD_DIRS := \ 44 | $(HWC_PATH)/os/android/libhwcservice/Android.mk \ 45 | $(HWC_PATH)/os/android/libhwcservice/test/Android.mk \ 46 | 47 | # Include tests only if eng build 48 | ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT))) 49 | #include $(HWC_PATH)/tests/hwc-val/tests/hwc/Android.mk 50 | endif 51 | 52 | include $(HWC_BUILD_DIRS) 53 | endif 54 | 55 | # Static lib: libhwcomposer_common and libhwcomposer_wsi 56 | include $(HWC_PATH)/common/Android.mk 57 | include $(HWC_PATH)/wsi/Android.mk 58 | 59 | endif 60 | -------------------------------------------------------------------------------- /Android.static.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | ifeq ($(strip $(BOARD_USES_IA_HWCOMPOSER)), true) 17 | # Obtain root HWC source path 18 | HWC_PATH := $(call my-dir) 19 | 20 | LOCAL_PATH := $(call my-dir) 21 | include $(CLEAR_VARS) 22 | include $(HWC_PATH)/Android.common.mk 23 | 24 | LOCAL_WHOLE_STATIC_LIBRARIES := \ 25 | libhwcomposer_common \ 26 | libhwcomposer_wsi 27 | 28 | LOCAL_MODULE := libhwcomposer.$(TARGET_BOARD_PLATFORM) 29 | include $(BUILD_STATIC_LIBRARY) 30 | 31 | # Static lib: libhwcomposer_common and libhwcomposer_wsi 32 | include $(HWC_PATH)/common/Android.mk 33 | include $(HWC_PATH)/wsi/Android.mk 34 | 35 | ifeq ($(strip $(TARGET_USES_HWC2)), true) 36 | # libhwcservice 37 | HWC_BUILD_DIRS := \ 38 | $(HWC_PATH)/os/android/libhwcservice/Android.mk \ 39 | 40 | include $(HWC_BUILD_DIRS) 41 | 42 | # Include tests only if eng build 43 | ifneq (,$(filter eng,$(TARGET_BUILD_VARIANT))) 44 | #include $(HWC_PATH)/tests/hwc-val/tests/hwc/Android.mk 45 | endif 46 | 47 | endif 48 | 49 | endif 50 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # IA-Hardware-Composer 2 | 3 | Please visit the [wiki](https://github.com/intel/IA-Hardware-Composer/wiki) 4 | for instructions on viewing the documentation, project 5 | conformance guidelines and examples of commit messages and documentation, 6 | as well as a walkthrough of how to contribute to the project. 7 | -------------------------------------------------------------------------------- /Makefile.sources: -------------------------------------------------------------------------------- 1 | hwc_SOURCES = \ 2 | os/platformcommondrmdefines.cpp \ 3 | os/linux/gbmbufferhandler.cpp \ 4 | os/linux/pixeluploader.cpp \ 5 | os/linux/platformdefines.cpp \ 6 | $(NULL) 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PROJECT NOT UNDER ACTIVE MANAGEMENT 2 | 3 | This project will no longer be maintained by Intel. 4 | 5 | Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project. 6 | 7 | Intel no longer accepts patches to this project. 8 | 9 | If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. 10 | 11 | Contact: webadmin@linux.intel.com 12 | Any security related issues should be reported by following the instructions here: 13 | https://01.org/security 14 | 15 | Please check the following Android documentation related to HWC2 API: 16 | https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/hwcomposer2.h 17 | 18 | ## Information 19 | update 20 | 21 | update 22 | 23 | For more information please refer to our wiki page on: 24 | * [Building the project on local](https://github.com/intel/IA-Hardware-Composer/wiki/Build) 25 | * [Conformance](https://github.com/intel/IA-Hardware-Composer/wiki/Conformance) 26 | * [Contribution guidelines](https://github.com/intel/IA-Hardware-Composer/wiki/Contributions) 27 | * [Viewing the Documentation](https://github.com/intel/IA-Hardware-Composer/wiki/Documentation) 28 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | srcdir=`dirname $0` 4 | test -z "$srcdir" && srcdir=. 5 | 6 | ORIGDIR=`pwd` 7 | cd $srcdir 8 | 9 | mkdir -p m4 10 | 11 | autoreconf -v --install -Itests/third_party/json-c/autoconf-archive/m4 || exit 1 12 | cd $ORIGDIR || exit $? 13 | 14 | if test -z "$NOCONFIGURE"; then 15 | $srcdir/configure "$@" 16 | fi 17 | -------------------------------------------------------------------------------- /common/Makefile.sources: -------------------------------------------------------------------------------- 1 | common_SOURCES = \ 2 | compositor/compositor.cpp \ 3 | compositor/compositorthread.cpp \ 4 | compositor/factory.cpp \ 5 | compositor/nativesurface.cpp \ 6 | compositor/renderstate.cpp \ 7 | core/framebuffermanager.cpp \ 8 | core/hwclayer.cpp \ 9 | core/resourcemanager.cpp \ 10 | core/overlaylayer.cpp \ 11 | core/gpudevice.cpp \ 12 | core/logicaldisplay.cpp \ 13 | core/logicaldisplaymanager.cpp \ 14 | core/mosaicdisplay.cpp \ 15 | display/displayqueue.cpp \ 16 | display/displayplanemanager.cpp \ 17 | display/displayplanestate.cpp \ 18 | display/vblankeventhandler.cpp \ 19 | display/virtualdisplay.cpp \ 20 | utils/fdhandler.cpp \ 21 | utils/hwcevent.cpp \ 22 | utils/hwcthread.cpp \ 23 | utils/hwcutils.cpp \ 24 | utils/disjoint_layers.cpp \ 25 | $(NULL) 26 | 27 | gl_SOURCES = \ 28 | compositor/gl/egloffscreencontext.cpp \ 29 | compositor/gl/glprogram.cpp \ 30 | compositor/gl/glrenderer.cpp \ 31 | compositor/gl/glsurface.cpp \ 32 | compositor/gl/nativeglresource.cpp \ 33 | compositor/gl/shim.cpp \ 34 | $(NULL) 35 | 36 | vk_SOURCES =\ 37 | compositor/vk/vkprogram.cpp \ 38 | compositor/vk/vkrenderer.cpp \ 39 | compositor/vk/vksurface.cpp \ 40 | compositor/vk/nativevkresource.cpp \ 41 | compositor/vk/vkshim.cpp \ 42 | $(NULL) 43 | 44 | va_SOURCES =\ 45 | compositor/va/varenderer.cpp \ 46 | compositor/va/vautils.cpp \ 47 | $(NULL) 48 | -------------------------------------------------------------------------------- /common/compositor/compositionregion.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_COMPOSITIONREGION_H_ 18 | #define COMMON_COMPOSITOR_COMPOSITIONREGION_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace hwcomposer { 25 | 26 | struct CompositionRegion { 27 | HwcRect frame; 28 | std::vector source_layers; 29 | }; 30 | 31 | } // namespace hwcomposer 32 | #endif // COMMON_COMPOSITOR_COMPOSITIONREGION_H_ 33 | -------------------------------------------------------------------------------- /common/compositor/factory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #include "factory.h" 18 | #include "platformdefines.h" 19 | 20 | #ifdef USE_DC 21 | #include "nativesurface.h" 22 | #elif USE_GL 23 | #include "glrenderer.h" 24 | #include "glsurface.h" 25 | #include "nativeglresource.h" 26 | #elif USE_VK 27 | #include "nativevkresource.h" 28 | #include "vkrenderer.h" 29 | #include "vksurface.h" 30 | #endif 31 | 32 | #ifndef DISABLE_VA 33 | #include "va/varenderer.h" 34 | #endif 35 | 36 | namespace hwcomposer { 37 | 38 | NativeSurface* Create3DSurface(uint32_t width, uint32_t height) { 39 | #ifdef USE_GL 40 | return new GLSurface(width, height); 41 | #elif USE_VK 42 | return new VKSurface(width, height); 43 | #else 44 | return NULL; 45 | #endif 46 | } 47 | 48 | NativeSurface* CreateVideoSurface(uint32_t width, uint32_t height) { 49 | return new NativeSurface(width, height); 50 | } 51 | 52 | Renderer* Create3DRenderer() { 53 | #ifdef USE_GL 54 | return new GLRenderer(); 55 | #elif USE_VK 56 | return new VKRenderer(); 57 | #else 58 | return NULL; 59 | #endif 60 | } 61 | 62 | Renderer* CreateMediaRenderer() { 63 | #ifdef USE_DC 64 | return NULL; 65 | #else 66 | #ifndef DISABLE_VA 67 | return new VARenderer(); 68 | #else 69 | return NULL; 70 | #endif 71 | #endif 72 | } 73 | 74 | NativeGpuResource* CreateNativeGpuResourceHandler() { 75 | #ifdef USE_GL 76 | return new NativeGLResource(); 77 | #elif USE_VK 78 | return new NativeVKResource(); 79 | #else 80 | return NULL; 81 | #endif 82 | } 83 | 84 | } // namespace hwcomposer 85 | -------------------------------------------------------------------------------- /common/compositor/factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_FACTORY_H_ 18 | #define COMMON_COMPOSITOR_FACTORY_H_ 19 | 20 | #include 21 | 22 | namespace hwcomposer { 23 | 24 | class NativeGpuResource; 25 | class NativeSurface; 26 | class Renderer; 27 | 28 | // Return buffer which can be used to render 3D content. 29 | NativeSurface* Create3DSurface(uint32_t width, uint32_t height); 30 | 31 | // Return buffer which can be used to render Media content. 32 | NativeSurface* CreateVideoSurface(uint32_t width, uint32_t height); 33 | 34 | // Return 3D renderer implementation to be used on this platform. 35 | Renderer* Create3DRenderer(); 36 | 37 | // Return Media renderer implementation to be used to composite Media 38 | // content. This can be Null and 3DRenderer will be used 39 | Renderer* CreateMediaRenderer(); 40 | 41 | NativeGpuResource* CreateNativeGpuResourceHandler(); 42 | 43 | } // namespace hwcomposer 44 | #endif // COMMON_COMPOSITOR_FACTORY_H_ 45 | -------------------------------------------------------------------------------- /common/compositor/gl/egloffscreencontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_GL_EGLOFFSCREENCONTEXT_H_ 18 | #define COMMON_COMPOSITOR_GL_EGLOFFSCREENCONTEXT_H_ 19 | 20 | #include "shim.h" 21 | 22 | namespace hwcomposer { 23 | 24 | class EGLOffScreenContext { 25 | public: 26 | EGLOffScreenContext(); 27 | ~EGLOffScreenContext(); 28 | 29 | bool Init(); 30 | 31 | EGLint GetSyncFD(bool onScreen); 32 | 33 | EGLDisplay GetDisplay() const { 34 | return egl_display_; 35 | } 36 | 37 | bool MakeCurrent(); 38 | 39 | private: 40 | EGLDisplay egl_display_; 41 | EGLContext egl_ctx_; 42 | EGLDisplay saved_egl_display_ = EGL_NO_DISPLAY; 43 | EGLContext saved_egl_ctx_ = EGL_NO_CONTEXT; 44 | EGLSurface saved_egl_read_ = EGL_NO_SURFACE; 45 | EGLSurface saved_egl_draw_ = EGL_NO_SURFACE; 46 | }; 47 | 48 | } // namespace hwcomposer 49 | #endif // COMMON_COMPOSITOR_GL_EGLOFFSCREENCONTEXT_H_ 50 | -------------------------------------------------------------------------------- /common/compositor/gl/gl_shader_pre_built/generate_c_arrays.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -eq 0 ] 4 | then 5 | echo "Need PCI-ID of the target" 6 | exit 7 | fi 8 | 9 | TEMP_LD_LIBRARY_PATH=$LD_LIBRARY_PATH 10 | unset LD_LIBRARY_PATH 11 | 12 | SHADER_PRE_BUILT_PATH=$PWD/compositor/gl/gl_shader_pre_built 13 | 14 | TARGET_I965=$WLD/lib/dri 15 | TARGET_PCI_ID=$1 16 | 17 | OUT_DIR=$SHADER_PRE_BUILT_PATH/shader_prog_arrays 18 | OUT_HEADER=$SHADER_PRE_BUILT_PATH/glprebuiltshaderarray.h 19 | 20 | SHADER_TEST_FILE_PREFIX=hwc_shader_prog_ 21 | SHADER_TEST_FOLDER=$SHADER_PRE_BUILT_PATH/shader-test 22 | BIN_TO_ARRAY=$SHADER_PRE_BUILT_PATH/bin_to_c_array 23 | SHADER_DB_DIR=$SHADER_PRE_BUILT_PATH/shader-db 24 | 25 | MAX_NUM_LAYERS=16 26 | GEN_SHADER_TEST=$SHADER_PRE_BUILT_PATH/generate_shader_test.sh 27 | 28 | #building bin_to_c_arrays 29 | gcc $BIN_TO_ARRAY.c -o $BIN_TO_ARRAY 30 | 31 | i=1 32 | 33 | #generate shader-tests 34 | while [ $i -le $MAX_NUM_LAYERS ] 35 | do 36 | $GEN_SHADER_TEST $i 37 | i=$(( $i + 1 )) 38 | done 39 | 40 | mkdir -p $SHADER_TEST_FOLDER 41 | mv *.shader_test $SHADER_TEST_FOLDER 42 | 43 | #pre-build shader-tests to generate shader program binary files 44 | export LIBGL_DRIVERS_PATH=$TARGET_I965 45 | export LD_PRELOAD=$SHADER_DB_DIR/intel_stub.so${LD_PRELOAD:+:${LD_PRELOAD}} 46 | $SHADER_DB_DIR/run -p $TARGET_PCI_ID -b $SHADER_TEST_FOLDER 47 | unset LIBGL_DRIVERS_PATH 48 | unset LD_PRELOAD 49 | mkdir -p $OUT_DIR 50 | 51 | #generate arrays of shader program binary 52 | 53 | i=1 54 | while [ $i -le $MAX_NUM_LAYERS ] 55 | do 56 | $BIN_TO_ARRAY $SHADER_TEST_FOLDER/$SHADER_TEST_FILE_PREFIX$i.shader_test.bin $OUT_DIR/$SHADER_TEST_FILE_PREFIX$i.h 57 | prebuilt_shader_header+="static uint8_t shader_prog_$i[] = {\n" 58 | prebuilt_shader_header+="#include "'"'"./gl_shader_pre_built/shader_prog_arrays/$SHADER_TEST_FILE_PREFIX$i.h"'"'"\n" 59 | prebuilt_shader_header+="};\n\n" 60 | i=$(( $i + 1 )) 61 | done 62 | 63 | prebuilt_shader_header+="static uint8_t *shader_prog_arrays[] = {\n" 64 | i=1 65 | while [ $i -le $MAX_NUM_LAYERS ] 66 | do 67 | prebuilt_shader_header+="shader_prog_$i,\n" 68 | i=$(( $i + 1 )) 69 | done 70 | prebuilt_shader_header+="};\n" 71 | 72 | echo -e $prebuilt_shader_header > $OUT_HEADER 73 | mv $OUT_HEADER $SHADER_PRE_BUILT_PATH/../ 74 | 75 | export LD_LIBRARY_PATH=$TEMP_LD_LIBRARY_PATH 76 | 77 | echo "ALL DONE" 78 | -------------------------------------------------------------------------------- /common/compositor/gl/gl_shader_pre_built/require.txt: -------------------------------------------------------------------------------- 1 | [require] 2 | GLSL ES >= 3.00 3 | BindAttribLoc vPosition 0 4 | BindAttribLoc vTexCords 1 5 | -------------------------------------------------------------------------------- /common/compositor/gl/glprogram.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_GL_GLPROGRAM_H_ 18 | #define COMMON_COMPOSITOR_GL_GLPROGRAM_H_ 19 | 20 | #include 21 | 22 | #include "shim.h" 23 | 24 | namespace hwcomposer { 25 | 26 | struct RenderState; 27 | 28 | class GLProgram { 29 | public: 30 | GLProgram(); 31 | GLProgram(const GLProgram& rhs) = delete; 32 | GLProgram& operator=(const GLProgram& rhs) = delete; 33 | 34 | ~GLProgram(); 35 | 36 | bool Init(unsigned texture_count); 37 | void UseProgram(const RenderState& cmd, GLuint viewport_width, 38 | GLuint viewport_height); 39 | 40 | private: 41 | GLint program_; 42 | GLint viewport_loc_; 43 | GLint crop_loc_; 44 | GLint alpha_loc_; 45 | GLint premult_loc_; 46 | GLint tex_matrix_loc_; 47 | GLint solid_color_loc_; 48 | bool initialized_; 49 | }; 50 | 51 | } // namespace hwcomposer 52 | #endif // COMMON_COMPOSITOR_GL_GLPROGRAM_H_ 53 | -------------------------------------------------------------------------------- /common/compositor/gl/glrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_GL_GLRENDERER_H_ 18 | #define COMMON_COMPOSITOR_GL_GLRENDERER_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "renderer.h" 24 | 25 | #include "egloffscreencontext.h" 26 | #include "glprogram.h" 27 | 28 | namespace hwcomposer { 29 | 30 | class GLRenderer : public Renderer { 31 | public: 32 | GLRenderer() = default; 33 | ~GLRenderer(); 34 | 35 | bool Init() override; 36 | bool Draw(const std::vector &commands, 37 | NativeSurface *surface) override; 38 | 39 | void InsertFence(int32_t kms_fence) override; 40 | 41 | void SetDisableExplicitSync(bool disable_explicit_sync) override; 42 | 43 | private: 44 | GLProgram *GetProgram(unsigned texture_count); 45 | 46 | EGLOffScreenContext context_; 47 | 48 | std::vector> programs_; 49 | GLuint vertex_array_ = 0; 50 | bool disable_explicit_sync_ = false; 51 | }; 52 | 53 | } // namespace hwcomposer 54 | #endif // COMMON_COMPOSITOR_GL_GLRENDERER_H_ 55 | -------------------------------------------------------------------------------- /common/compositor/gl/glsurface.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_GL_GLSURFACE_H_ 18 | #define COMMON_COMPOSITOR_GL_GLSURFACE_H_ 19 | 20 | #include "nativesurface.h" 21 | 22 | #include "shim.h" 23 | 24 | namespace hwcomposer { 25 | 26 | class GLSurface : public NativeSurface { 27 | public: 28 | GLSurface() = default; 29 | ~GLSurface() override; 30 | GLSurface(uint32_t width, uint32_t height); 31 | 32 | bool MakeCurrent() override; 33 | 34 | private: 35 | bool InitializeGPUResources(); 36 | GLuint fb_ = 0; 37 | }; 38 | 39 | } // namespace hwcomposer 40 | #endif // COMMON_COMPOSITOR_GL_GLSURFACE_H_ 41 | -------------------------------------------------------------------------------- /common/compositor/gl/nativeglresource.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_GL_NATIVEGLRESOURCE_H_ 18 | #define COMMON_COMPOSITOR_GL_NATIVEGLRESOURCE_H_ 19 | 20 | #include 21 | 22 | #include "nativegpuresource.h" 23 | #include "shim.h" 24 | 25 | namespace hwcomposer { 26 | 27 | struct OverlayLayer; 28 | 29 | class NativeGLResource : public NativeGpuResource { 30 | public: 31 | NativeGLResource() = default; 32 | ~NativeGLResource() override; 33 | 34 | bool PrepareResources(const std::vector& buffers) override; 35 | GpuResourceHandle GetResourceHandle(uint32_t layer_index) const override; 36 | 37 | void ReleaseGPUResources(const std::vector& handles) override; 38 | 39 | private: 40 | std::vector layer_textures_; 41 | }; 42 | 43 | } // namespace hwcomposer 44 | #endif // COMMON_COMPOSITOR_GL_NATIVEGLRESOURCE_H_ 45 | -------------------------------------------------------------------------------- /common/compositor/gl/shim.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_GL_SHIM_H_ 18 | #define COMMON_COMPOSITOR_GL_SHIM_H_ 19 | 20 | #define EGL_EGLEXT_PROTOTYPES 21 | 22 | #include 23 | #include 24 | 25 | #ifndef GL_GLEXT_PROTOTYPES 26 | #define GL_GLEXT_PROTOTYPES 27 | #endif 28 | 29 | #include 30 | #include 31 | 32 | namespace hwcomposer { 33 | bool InitializeShims(); 34 | 35 | extern PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; 36 | extern PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR; 37 | extern PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR; 38 | extern PFNEGLWAITSYNCKHRPROC eglWaitSyncKHR; 39 | extern PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; 40 | extern PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; 41 | extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOES; 42 | extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES; 43 | extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOES; 44 | extern PFNGLPROGRAMBINARYOESPROC glProgramBinaryOES; 45 | #ifndef USE_ANDROID_SHIM 46 | extern PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID; 47 | #endif 48 | } // namespace hwcomposer 49 | 50 | #endif // COMMON_COMPOSITOR_GL_SHIM_H_ 51 | -------------------------------------------------------------------------------- /common/compositor/nativegpuresource.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_NATIVEGPURESOURCE_H_ 18 | #define COMMON_COMPOSITOR_NATIVEGPURESOURCE_H_ 19 | 20 | #include 21 | 22 | #include "compositordefs.h" 23 | 24 | namespace hwcomposer { 25 | 26 | class OverlayBuffer; 27 | 28 | class NativeGpuResource { 29 | public: 30 | NativeGpuResource() = default; 31 | virtual ~NativeGpuResource() { 32 | } 33 | 34 | NativeGpuResource(const NativeGpuResource& rhs) = delete; 35 | NativeGpuResource(NativeGpuResource&& rhs) = delete; 36 | 37 | NativeGpuResource& operator=(const NativeGpuResource& rhs) = delete; 38 | 39 | NativeGpuResource& operator=(NativeGpuResource&& rhs) = delete; 40 | 41 | virtual bool PrepareResources(const std::vector& buffers) = 0; 42 | 43 | virtual GpuResourceHandle GetResourceHandle(uint32_t layer_index) const = 0; 44 | virtual void ReleaseGPUResources( 45 | const std::vector& handles) = 0; 46 | }; 47 | 48 | } // namespace hwcomposer 49 | #endif // COMMON_COMPOSITOR_NATIVEGPURESOURCE_H_ 50 | -------------------------------------------------------------------------------- /common/compositor/renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_RENDERER_H_ 18 | #define COMMON_COMPOSITOR_RENDERER_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | namespace hwcomposer { 26 | 27 | class NativeSurface; 28 | struct RenderState; 29 | struct MediaState; 30 | struct media_import; 31 | 32 | class Renderer { 33 | public: 34 | Renderer() = default; 35 | virtual ~Renderer() { 36 | } 37 | Renderer(const Renderer& rhs) = delete; 38 | Renderer& operator=(const Renderer& rhs) = delete; 39 | 40 | // Needs to be implemented for 3D Renderer's only. 41 | virtual bool Init() { 42 | return false; 43 | } 44 | 45 | virtual bool Draw(const std::vector& /*commands*/, 46 | NativeSurface* /*surface*/) { 47 | return false; 48 | } 49 | 50 | // Needs to be implemented for Media Renderer's only. 51 | virtual bool Init(int /*gpu_fd*/) { 52 | return false; 53 | } 54 | 55 | virtual bool DestroyMediaResources( 56 | std::vector& /*resources*/) { 57 | return true; 58 | } 59 | 60 | virtual bool Draw(const MediaState& /*state*/, NativeSurface* /*surface*/) { 61 | return false; 62 | } 63 | 64 | virtual void InsertFence(int32_t kms_fence) = 0; 65 | 66 | virtual void SetDisableExplicitSync(bool disable_explicit_sync) = 0; 67 | }; 68 | 69 | } // namespace hwcomposer 70 | #endif // COMMON_COMPOSITOR_RENDERER_H_ 71 | -------------------------------------------------------------------------------- /common/compositor/va/vautils.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_COMPOSITOR_VA_VAUTILS_H_ 18 | #define COMMON_COMPOSITOR_VA_VAUTILS_H_ 19 | 20 | namespace hwcomposer { 21 | 22 | int DrmFormatToVAFormat(int format); 23 | int DrmFormatToRTFormat(int format); 24 | 25 | } // namespace hwcomposer 26 | 27 | #endif // COMMON_COMPOSITOR_VA_VAUTILS_H_ 28 | -------------------------------------------------------------------------------- /common/compositor/vk/nativevkresource.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef NATIVE_VK_RESOURCE_H_ 16 | #define NATIVE_VK_RESOURCE_H_ 17 | 18 | #include "nativegpuresource.h" 19 | #include "vkshim.h" 20 | 21 | namespace hwcomposer { 22 | 23 | struct OverlayLayer; 24 | 25 | class NativeVKResource : public NativeGpuResource { 26 | public: 27 | NativeVKResource() = default; 28 | ~NativeVKResource() override; 29 | 30 | bool PrepareResources(const std::vector& buffers) override; 31 | GpuResourceHandle GetResourceHandle(uint32_t layer_index) const override; 32 | void ReleaseGPUResources( 33 | const std::vector& handles) override { 34 | } 35 | 36 | private: 37 | void Reset(); 38 | std::vector layer_textures_; 39 | std::vector src_image_memory_; 40 | }; 41 | 42 | } // namespace hwcomposer 43 | 44 | #endif // NATIVE_VK_RESOURCE_H_ 45 | -------------------------------------------------------------------------------- /common/compositor/vk/vkcomp.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #extension GL_ARB_separate_shader_objects : enable 4 | #extension GL_ARB_shading_language_420pack : enable 5 | 6 | layout(constant_id = 0) const uint kLayerCount = 1; 7 | 8 | struct LayerBlend { 9 | float alpha; 10 | float premult; 11 | }; 12 | 13 | layout (std140, set = 0, binding = 1) uniform FRAG_UBO { 14 | LayerBlend uLayerBlend[kLayerCount]; 15 | }; 16 | 17 | layout (set = 0, binding = 2) uniform sampler2D uLayerTextures[kLayerCount]; 18 | layout (location = 0) in vec2 fTexCoords[kLayerCount]; 19 | layout (location = 0) out vec4 oFragColor; 20 | 21 | void main() { 22 | vec3 color = vec3(0.0, 0.0, 0.0); 23 | float alphaCover = 1.0; 24 | vec4 texSample; 25 | vec3 multRgb; 26 | 27 | for (uint i = 0; i < kLayerCount; i++) { 28 | if (alphaCover > 0.5/255.0) { 29 | texSample = texture(uLayerTextures[i], fTexCoords[i]); 30 | multRgb = texSample.rgb * max(texSample.a, uLayerBlend[i].premult); 31 | color += multRgb * uLayerBlend[i].alpha * alphaCover; 32 | alphaCover *= 1.0 - texSample.a * uLayerBlend[i].alpha; 33 | } 34 | } 35 | oFragColor = vec4(color, 1.0 - alphaCover); 36 | } 37 | -------------------------------------------------------------------------------- /common/compositor/vk/vkcomp.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #extension GL_ARB_seperate_shader_objects : enable 4 | #extension GL_ARB_shading_language_420pack : enable 5 | 6 | layout(constant_id = 0) const uint kLayerCount = 1; 7 | 8 | struct LayerTransform { 9 | vec4 layerCrop; 10 | mat2 texMatrix; 11 | }; 12 | 13 | layout (std140, set = 0, binding = 0) uniform VERT_UBO { 14 | vec4 uViewport; 15 | layerTransform uTransform[kLayerCount]; 16 | }; 17 | 18 | layout (location = 0) in vec2 vPosition; 19 | layout (location = 1) in vec2 vTexCoords; 20 | 21 | layout (location = 0) out vec2 fTexCoords[kLayerCount]; 22 | 23 | out gl_PerVertex 24 | { 25 | vec4 gl_Position; 26 | }; 27 | 28 | void main() 29 | { 30 | for (uint i = 0; i < kLayerCount; i++) { 31 | vec2 tempCoords = vTexCoords * uTransform[i].texMatrix; 32 | fTexCoords[i] = uTransform[i].layerCrop.xy + tempCoords + uTransform[i].layerCrop.zw; 33 | } 34 | vec2 scaledPosition = uViewport.xy + vPosition * uViewport.zw; 35 | gl_Position = vec4(scaledPosition * vec2(2.0) - vec2(1.0), 0.0, 1.0); 36 | } 37 | -------------------------------------------------------------------------------- /common/compositor/vk/vkprogram.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef VK_PROGRAM_H_ 16 | #define VK_PROGRAM_H_ 17 | 18 | #include 19 | #include 20 | #include "vkshim.h" 21 | 22 | namespace hwcomposer { 23 | 24 | struct RenderState; 25 | 26 | struct pipeline_info { 27 | uint32_t layer_index; 28 | VkSpecializationInfo special; 29 | VkPipelineShaderStageCreateInfo stages[2]; 30 | }; 31 | 32 | class VKProgram { 33 | public: 34 | VKProgram(); 35 | VKProgram(const VKProgram& rhs) = delete; 36 | VKProgram& operator=(const VKProgram& rhs) = delete; 37 | 38 | ~VKProgram(); 39 | 40 | bool Init(unsigned layer_index); 41 | void UseProgram(const RenderState& cmd, unsigned int viewport_width, 42 | unsigned int viewport_height); 43 | 44 | VkDescriptorSetLayout getDescLayout() { 45 | return descriptor_set_layout_; 46 | } 47 | VkPipelineLayout getPipeLayout() { 48 | return pipeline_layout_; 49 | } 50 | VkPipeline getPipeline() { 51 | return pipeline_; 52 | } 53 | VkDescriptorBufferInfo getVertUBInfo() { 54 | return vert_buf_info_; 55 | } 56 | VkDescriptorBufferInfo getFragUBInfo() { 57 | return frag_buf_info_; 58 | } 59 | 60 | private: 61 | VkDescriptorSetLayout descriptor_set_layout_; 62 | VkPipelineLayout pipeline_layout_; 63 | VkShaderModule vertex_module_; 64 | VkShaderModule fragment_module_; 65 | VkPipeline pipeline_; 66 | VkDescriptorBufferInfo vert_buf_info_; 67 | VkDescriptorBufferInfo frag_buf_info_; 68 | }; 69 | 70 | } // namespace hwcomposer 71 | 72 | #endif // VK_PROGRAM_H_ 73 | -------------------------------------------------------------------------------- /common/compositor/vk/vkrenderer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef VK_RENDERER_H_ 16 | #define VK_RENDERER_H_ 17 | 18 | #include 19 | 20 | #include "renderer.h" 21 | #include "vkprogram.h" 22 | #include "vkshim.h" 23 | 24 | namespace hwcomposer { 25 | 26 | class VKRenderer : public Renderer { 27 | public: 28 | VKRenderer() = default; 29 | ~VKRenderer(); 30 | 31 | bool Init() override; 32 | bool Draw(const std::vector &commands, 33 | NativeSurface *surface) override; 34 | void InsertFence(int32_t kms_fence) override; 35 | void SetDisableExplicitSync(bool disable_explicit_sync) override; 36 | 37 | private: 38 | VKProgram *GetProgram(unsigned texture_count); 39 | uint32_t GetMemoryTypeIndex(uint32_t mem_type_bits, uint32_t required_props); 40 | VkBuffer UploadBuffer(size_t data_size, const uint8_t *data, 41 | VkBufferUsageFlags usage); 42 | 43 | VkPhysicalDeviceProperties device_props_; 44 | VkPhysicalDeviceMemoryProperties device_mem_props_; 45 | VkDeviceMemory uniform_buffer_mem_; 46 | VkDescriptorPool desc_pool_; 47 | VkCommandPool cmd_pool_; 48 | VkQueue queue_; 49 | VkBuffer vert_buffer_; 50 | 51 | std::vector> programs_; 52 | }; 53 | 54 | } // namespace hwcomposer 55 | 56 | #endif // VK_RENDERER_H_ 57 | -------------------------------------------------------------------------------- /common/compositor/vk/vksurface.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Intel Corporation 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef VK_SURFACE_H_ 16 | #define VK_SURFACE_H_ 17 | 18 | #include "nativesurface.h" 19 | #include "vkshim.h" 20 | 21 | namespace hwcomposer { 22 | 23 | class OverlayBuffer; 24 | 25 | class VKSurface : public NativeSurface { 26 | public: 27 | VKSurface() = default; 28 | ~VKSurface() override; 29 | VKSurface(uint32_t width, uint32_t height); 30 | 31 | bool MakeCurrent() override; 32 | 33 | private: 34 | bool InitializeGPUResources(); 35 | VkDeviceMemory image_memory_; 36 | VkImage image_; 37 | VkImageView image_view_; 38 | VkFramebuffer surface_fb_; 39 | }; 40 | 41 | } // namespace hwcomposer 42 | 43 | #endif // VK_SURFACE_H_ 44 | -------------------------------------------------------------------------------- /common/display/hyperdmadisplay.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_DISPLAY_HYPERDMABUF_H_ 18 | #define COMMON_DISPLAY_HYPERDMABUF_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include "drmbuffer.h" 26 | #include "hwctrace.h" 27 | #define SURFACE_NAME_LENGTH 64 28 | #define HYPER_DMABUF_PATH "/dev/hyper_dmabuf" 29 | 30 | namespace hwcomposer { 31 | 32 | struct vm_header { 33 | int32_t version; 34 | int32_t output; 35 | int32_t counter; 36 | int32_t n_buffers; 37 | int32_t disp_w; 38 | int32_t disp_h; 39 | }; 40 | 41 | struct vm_buffer_info { 42 | int32_t surf_index; 43 | int32_t width, height; 44 | int32_t format; 45 | int32_t pitch[3]; 46 | int32_t offset[3]; 47 | int32_t tile_format; 48 | int32_t rotation; 49 | int32_t status; 50 | int32_t counter; 51 | union { 52 | hyper_dmabuf_id_t hyper_dmabuf_id; 53 | unsigned long ggtt_offset; 54 | }; 55 | char surface_name[SURFACE_NAME_LENGTH]; 56 | uint64_t surface_id; 57 | int32_t bbox[4]; 58 | }; 59 | 60 | } // namespace hwcomposer 61 | #endif // COMMON_DISPLAY_HYPERDMABUF_H_ 62 | -------------------------------------------------------------------------------- /common/display/vblankeventhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_DISPLAY_VBLANK_EVENT_HANDLER_H_ 18 | #define COMMON_DISPLAY_VBLANK_EVENT_HANDLER_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include "hwcthread.h" 29 | 30 | namespace hwcomposer { 31 | 32 | class DisplayQueue; 33 | 34 | class VblankEventHandler : public HWCThread { 35 | public: 36 | VblankEventHandler(DisplayQueue* queue); 37 | ~VblankEventHandler() override; 38 | 39 | void Init(int fd, int pipe); 40 | 41 | bool SetPowerMode(uint32_t power_mode); 42 | 43 | void HandlePageFlipEvent(unsigned int sec, unsigned int usec); 44 | 45 | int RegisterCallback(std::shared_ptr callback, 46 | uint32_t display_id); 47 | 48 | int RegisterCallback(std::shared_ptr callback, 49 | uint32_t display_id); 50 | 51 | int VSyncControl(bool enabled); 52 | 53 | protected: 54 | void HandleRoutine() override; 55 | void HandleWait() override; 56 | 57 | private: 58 | // shared_ptr since we need to use this outside of the thread lock (to 59 | // actually call the hook) and we don't want the memory freed until we're 60 | // done 61 | std::shared_ptr callback_ = NULL; 62 | std::shared_ptr callback_2_4_ = NULL; 63 | SpinLock spin_lock_; 64 | uint32_t display_; 65 | int64_t vperiod_; 66 | bool enabled_ = false; 67 | 68 | int fd_; 69 | int64_t last_timestamp_; 70 | int64_t previous_timestamp_; 71 | drmVBlankSeqType type_; 72 | DisplayQueue* queue_; 73 | }; 74 | 75 | } // namespace hwcomposer 76 | #endif // COMMON_DISPLAY_VBLANK_EVENT_HANDLER_H_ 77 | -------------------------------------------------------------------------------- /common/utils/fdhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_UTILS_FDHANDLER_H_ 18 | #define COMMON_UTILS_FDHANDLER_H_ 19 | 20 | #include 21 | 22 | namespace hwcomposer { 23 | 24 | // Class wrapper around poll() and struct pollfd. 25 | // It keeps the fds added on it so one doesn't have to keep 26 | // recreating/populating the pollfd manually. 27 | class FDHandler { 28 | public: 29 | FDHandler(); 30 | virtual ~FDHandler(); 31 | 32 | // Add fd to the list of fds that we care about. This makes ::Poll watch for 33 | // this fd when called. 34 | bool AddFd(int fd); 35 | 36 | // Remove the fd from the list of fds that we are watching. 37 | bool RemoveFd(int fd); 38 | 39 | // Call poll() on the list of fds that we are watching. Will block if 40 | // timemout > 0. Store the result from the poll request, so it can be queried 41 | // with ::IsReady(). 42 | // - timeout: time in miliseconds to stay blocked before returning if no fd 43 | // is ready. 44 | // - return: number of fds ready. If return is 0, it means we timed out. If 45 | // return is < 0, an error has ocurred. 46 | int Poll(int timeout); 47 | 48 | // Check whether this fd is ready. 49 | // - return: 1 if fd is ready to read 50 | // 0 if fd is not ready 51 | // -1 if there's an error on the fd 52 | // -2 if the fd is closed and can't be polled 53 | int IsReady(int fd) const; 54 | 55 | private: 56 | struct FDWatch { 57 | FDWatch(); 58 | int idx; 59 | short revents; 60 | }; 61 | 62 | std::map fds_; 63 | }; 64 | 65 | } // namespace hwcomposer 66 | 67 | #endif // COMMON_UTILS_FDHANDLER_H_ 68 | -------------------------------------------------------------------------------- /common/utils/hwcevent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #include "hwcevent.h" 18 | 19 | #include 20 | #include 21 | 22 | #include "hwctrace.h" 23 | 24 | #ifndef EFD_SEMAPHORE 25 | #define EFD_SEMAPHORE (1 << 0) 26 | #endif 27 | 28 | namespace hwcomposer { 29 | 30 | HWCEvent::HWCEvent() : fd_(0) { 31 | } 32 | 33 | HWCEvent::~HWCEvent() { 34 | if (fd_ >= 0) 35 | close(fd_); 36 | 37 | fd_ = -1; 38 | } 39 | 40 | bool HWCEvent::Initialize() { 41 | if (fd_ > 0) { 42 | return true; 43 | } 44 | 45 | fd_ = eventfd(0, EFD_SEMAPHORE); 46 | if (fd_ < 0) { 47 | ETRACE("Failed to initialize eventfd: %s", PRINTERROR()); 48 | return false; 49 | } 50 | 51 | return true; 52 | } 53 | 54 | bool HWCEvent::Signal() { 55 | uint64_t inc = 1; 56 | ssize_t ret = write(fd_, &inc, sizeof(inc)); 57 | if (ret < 0) { 58 | ETRACE("couldn't write to eventfd: %zd (%s)", ret, PRINTERROR()); 59 | return false; 60 | } 61 | 62 | return true; 63 | } 64 | 65 | bool HWCEvent::Wait() { 66 | if (fd_ < 0) { 67 | ETRACE("invalid eventfd: %d", fd_); 68 | return false; 69 | } 70 | 71 | uint64_t result; 72 | ssize_t ret = read(fd_, &result, sizeof(result)); 73 | if (ret < 0) { 74 | ETRACE("couldn't read from eventfd: %zd (%s)", ret, PRINTERROR()); 75 | return false; 76 | } 77 | 78 | if (result != 1) { 79 | ETRACE("read from eventfd has wrong value: %" PRIu64 " (should be 1)", result); 80 | return false; 81 | } 82 | 83 | return true; 84 | } 85 | 86 | } // namespace hwcomposer 87 | -------------------------------------------------------------------------------- /common/utils/hwcevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_UTILS_HWCEVENT_H_ 18 | #define COMMON_UTILS_HWCEVENT_H_ 19 | 20 | #include 21 | 22 | namespace hwcomposer { 23 | 24 | // This class wraps eventfd and uses it as a method to signal events. 25 | class HWCEvent { 26 | public: 27 | HWCEvent(); 28 | virtual ~HWCEvent(); 29 | 30 | // Initialize the eventfd. Do not use an instance of this class before 31 | // calling this first. 32 | bool Initialize(); 33 | 34 | // Signals the eventfd, waking up whoever is blocked waiting on it to be 35 | // signaled. If the eventfd counter is already > 0, just increase it by 1. 36 | bool Signal(); 37 | 38 | // Wait on the eventfd to be signaled. If the eventfd counter is already > 0, 39 | // return immediately. 40 | bool Wait(); 41 | 42 | // Return the internal fd, so it can be polled on. 43 | int get_fd() const { 44 | return fd_; 45 | } 46 | 47 | private: 48 | int fd_; 49 | }; 50 | 51 | } // namespace hwcomposer 52 | 53 | #endif // COMMON_UTILS_HWCEVENT_H_ 54 | -------------------------------------------------------------------------------- /common/utils/hwcthread.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_UTILS_HWCTHREAD_H_ 18 | #define COMMON_UTILS_HWCTHREAD_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "fdhandler.h" 25 | #include "hwcevent.h" 26 | #include "spinlock.h" 27 | 28 | namespace hwcomposer { 29 | 30 | class HWCThread { 31 | protected: 32 | HWCThread(int priority, const char *name); 33 | virtual ~HWCThread(); 34 | 35 | bool InitWorker(); 36 | 37 | void Resume(); 38 | void Exit(); 39 | 40 | virtual void HandleRoutine() = 0; 41 | virtual void HandleExit(); 42 | virtual void HandleWait(); 43 | 44 | FDHandler fd_handler_; 45 | bool initialized_; 46 | 47 | private: 48 | void ProcessThread(); 49 | 50 | int priority_; 51 | std::string name_; 52 | HWCEvent event_; 53 | bool exit_ = false; 54 | 55 | std::unique_ptr thread_; 56 | }; 57 | 58 | } // namespace hwcomposer 59 | #endif // COMMON_UTILS_HWCTHREAD_H_ 60 | -------------------------------------------------------------------------------- /common/utils/val/abstractcompositionchecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef COMMON_UTILS_VAL_ABSTRACTCOMPOSITIONCHECKER_H_ 18 | #define COMMON_UTILS_VAL_ABSTRACTCOMPOSITIONCHECKER_H_ 19 | 20 | #include 21 | 22 | namespace hwcomposer { 23 | 24 | // HWC supports version 0 of AbstractCompositionChecker interface 25 | #define ABSTRACTCOMPOSITIONCHECKER_VERSION_SUPPORT_MASK (1 << 0) 26 | 27 | // This interface is for process internal use only hence not subclass of 28 | // IInterface. 29 | class AbstractCompositionChecker { 30 | public: 31 | class ValLayer : public hwc_layer_1_t {}; 32 | 33 | virtual ~AbstractCompositionChecker() { 34 | } 35 | 36 | // Composition check - Initiate. 37 | // Returns a context, or null to indicate that this composition is not 38 | // required by the validation interface. 39 | virtual void* CreateContext(const char* composer) = 0; 40 | 41 | // Add a source layer to the validation context. 42 | virtual void AddSource(void* ctx, const ValLayer& layer, 43 | const char* debug) = 0; 44 | 45 | // Add the target layer to the validation context, perform the validation, 46 | // and close the context. 47 | virtual void CheckComposition(void* ctx, const ValLayer& layer, 48 | const char* debug) = 0; 49 | }; 50 | 51 | } // hwcomposer 52 | 53 | #endif // COMMON_UTILS_VAL_ABSTRACTCOMPOSITIONCHECKER_H_ 54 | -------------------------------------------------------------------------------- /iahwc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | datarootdir=@datarootdir@ 4 | pkgdatadir=@datadir@/@PACKAGE@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: IA Hardware Composer 9 | Description: Hardware composer for Intel Architecture 10 | Version: 0.1.1 11 | Cflags: -I${includedir}/libiahwc 12 | -------------------------------------------------------------------------------- /os/alios/platformdefines.cpp: -------------------------------------------------------------------------------- 1 | #include "platformdefines.h" 2 | 3 | void* GetVADisplay(uint32_t gpu_fd) { 4 | return NULL; 5 | } 6 | -------------------------------------------------------------------------------- /os/alios/yallocbufferhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef OS_ALIOS_YALLOCBUFFERHANDLER_H_ 18 | #define OS_ALIOS_YallocBufferHandler_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | namespace hwcomposer { 26 | 27 | class GpuDevice; 28 | 29 | class YallocBufferHandler : public NativeBufferHandler { 30 | public: 31 | explicit YallocBufferHandler(uint32_t fd); 32 | ~YallocBufferHandler() override; 33 | 34 | bool Init(); 35 | 36 | bool CreateBuffer(uint32_t w, uint32_t h, int format, HWCNativeHandle *handle, 37 | uint32_t layer_type = kLayerNormal, 38 | bool *modifier_used = NULL, int64_t modifier = -1, 39 | bool raw_pixel_buffer = false) const override; 40 | bool ReleaseBuffer(HWCNativeHandle handle) const override; 41 | void DestroyHandle(HWCNativeHandle handle) const override; 42 | void CopyHandle(HWCNativeHandle source, 43 | HWCNativeHandle *target) const override; 44 | bool ImportBuffer(HWCNativeHandle handle) const override; 45 | uint32_t GetTotalPlanes(HWCNativeHandle handle) const override; 46 | void *Map(HWCNativeHandle handle, uint32_t x, uint32_t y, uint32_t width, 47 | uint32_t height, uint32_t *stride, void **map_data, 48 | size_t plane) const override; 49 | int32_t UnMap(HWCNativeHandle handle, void *map_data) const override; 50 | 51 | uint32_t GetFd() const override; 52 | bool GetInterlace(HWCNativeHandle handle) const override { 53 | return false; 54 | } 55 | 56 | private: 57 | uint32_t fd_; 58 | struct yalloc_device_t *device_; 59 | }; 60 | 61 | } // namespace hwcomposer 62 | #endif // OS_ALIOS_YALLOCBUFFERHANDLER_H_ 63 | -------------------------------------------------------------------------------- /os/android/libhwcservice/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | # Obtain Android Version 20 | ANDROID_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION))) 21 | 22 | LOCAL_SRC_FILES += icontrols.cpp \ 23 | idiagnostic.cpp \ 24 | iservice.cpp \ 25 | hwcserviceapi.cpp 26 | 27 | LOCAL_MODULE := libhwcservice 28 | LOCAL_CFLAGS += -fvisibility=default 29 | ifeq ($(strip $(ENABLE_HYPER_DMABUF_SHARING)), true) 30 | LOCAL_CFLAGS += -DENABLE_PANORAMA 31 | endif 32 | LOCAL_SHARED_LIBRARIES := libutils libbinder liblog 33 | LOCAL_MULTILIB := both 34 | LOCAL_EXPORT_C_INCLUDE_DIRS += $(LOCAL_PATH) 35 | LOCAL_PROPRIETARY_MODULE := true 36 | LOCAL_HEADER_LIBRARIES += libcutils_headers 37 | include $(BUILD_SHARED_LIBRARY) 38 | 39 | #static library for the device 40 | include $(CLEAR_VARS) 41 | 42 | # Obtain Android Version 43 | ANDROID_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION))) 44 | 45 | LOCAL_SRC_FILES += icontrols.cpp \ 46 | idiagnostic.cpp \ 47 | iservice.cpp \ 48 | hwcserviceapi.cpp 49 | 50 | LOCAL_MODULE := libhwcservice 51 | LOCAL_CFLAGS += -fvisibility=default 52 | LOCAL_SHARED_LIBRARIES := libbinder liblog libutils 53 | LOCAL_MULTILIB := both 54 | LOCAL_EXPORT_C_INCLUDE_DIRS += $(LOCAL_PATH) 55 | LOCAL_PROPRIETARY_MODULE := true 56 | LOCAL_HEADER_LIBRARIES += libcutils_headers 57 | include $(BUILD_STATIC_LIBRARY) 58 | -------------------------------------------------------------------------------- /os/android/libhwcservice/hwcservicehelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef OS_ANDROID_HWC_HWCSERVICEHELPER_H_ 18 | #define OS_ANDROID_HWC_HWCSERVICEHELPER_H_ 19 | 20 | // Inline c++ helpers to augment HwcServiceApi.h 21 | 22 | #include 23 | 24 | #if __ANDROID__ 25 | #include 26 | 27 | class HwcServiceConnection : public android::RefBase { 28 | public: 29 | HwcServiceConnection() { 30 | mHwcs = HwcService_Connect(); 31 | } 32 | ~HwcServiceConnection() { 33 | HwcService_Disconnect(mHwcs); 34 | } 35 | operator HWCSHANDLE() { 36 | return mHwcs; 37 | } 38 | HWCSHANDLE handle() { 39 | return mHwcs; 40 | } 41 | 42 | private: 43 | // Non-copyable. 44 | HwcServiceConnection(HwcServiceConnection const &); 45 | void operator=(HwcServiceConnection const &); 46 | 47 | HWCSHANDLE mHwcs; 48 | }; 49 | 50 | #endif // __ANDROID__ 51 | 52 | #endif // OS_ANDROID_HWC_HWCSERVICEHELPER_H_ 53 | -------------------------------------------------------------------------------- /os/android/libhwcservice/idiagnostic.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef OS_ANDROID_HWC_IDIAGNOSTIC_H 18 | #define OS_ANDROID_HWC_IDIAGNOSTIC_H 19 | 20 | #include 21 | #include 22 | 23 | namespace hwcomposer { 24 | 25 | using namespace android; 26 | 27 | class IDiagnostic : public IInterface { 28 | public: 29 | DECLARE_META_INTERFACE(Diagnostic); 30 | 31 | // This class is shared with the validation team. Take care when changing it 32 | // that 33 | // the validation tests understand how we have changed this. 34 | enum { 35 | eLogTruncated = 36 | 101, // Status to indicate log entries have been overwritten 37 | }; 38 | 39 | virtual status_t ReadLogParcel(android::Parcel* reply) = 0; 40 | 41 | // Debug API 42 | virtual void EnableDisplay(uint32_t d) = 0; 43 | virtual void DisableDisplay(uint32_t d, bool bBlank) = 0; 44 | virtual void MaskLayer(uint32_t d, uint32_t layer, bool bHide) = 0; 45 | virtual void DumpFrames(uint32_t d, int32_t frames, bool bSync) = 0; 46 | }; 47 | 48 | class BnDiagnostic : public android::BnInterface { 49 | public: 50 | BnDiagnostic() { 51 | } 52 | 53 | virtual ~BnDiagnostic() { 54 | } 55 | 56 | status_t onTransact(uint32_t, const Parcel&, Parcel*, uint32_t) override; 57 | }; 58 | 59 | } // namespace hwcomposer 60 | 61 | #endif // OS_ANDROID_HWC_IDIAGNOSTIC_H 62 | -------------------------------------------------------------------------------- /os/android/libhwcservice/idisplayoverscancontrol.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef OS_ANDROID_IDISPLAY_OVERSCAN_CONTROL_H_ 18 | #define OS_ANDROID_IDISPLAY_OVERSCAN_CONTROL_H_ 19 | 20 | #include 21 | #include "hwcservicehelper.h" 22 | 23 | namespace hwcomposer { 24 | 25 | /** 26 | * Allows control of HDMI overscan 27 | */ 28 | class IDisplayOverscanControl : public android::RefBase { 29 | public: 30 | IDisplayOverscanControl(uint32_t display) : mDisplay(display) { 31 | } 32 | 33 | enum { 34 | MAX_OVERSCAN = HWCS_MAX_OVERSCAN, // The limit of the control parameters 35 | // are +/-MAX_OVERSCAN inclusive. 36 | RANGE = HWCS_OVERSCAN_RANGE, // RANGE describes the % of the display size a 37 | // max control setting will adjust by. 38 | }; 39 | 40 | /// Set overscan in the range +/-MAX_OVERSCAN inclusive. 41 | // -ve : zoom/crop the image (increase display overscan). 42 | // +ve : shrink the image (decrease display overscan). 43 | status_t setOverscan(int32_t xoverscan, int32_t yoverscan) { 44 | return HwcService_Display_SetOverscan(mHwcConn, mDisplay, xoverscan, 45 | yoverscan); 46 | } 47 | 48 | // Get last set overscan. 49 | // Returns INVALID_OPERATION if overscan has not been set and 50 | // xoverscan/yoverscan are untouched. 51 | status_t getOverscan(int32_t *xoverscan, int32_t *yoverscan) { 52 | return HwcService_Display_GetOverscan(mHwcConn, mDisplay, xoverscan, 53 | yoverscan); 54 | } 55 | 56 | private: 57 | HwcServiceConnection mHwcConn; 58 | uint32_t mDisplay; 59 | }; 60 | 61 | } // namespace hwcomposer 62 | 63 | #endif // OS_ANDROID_IDISPLAY_OVERSCAN_CONTROL_H_ 64 | -------------------------------------------------------------------------------- /os/android/libhwcservice/iservice.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef OS_ANDROID_ISERVICE_H_ 18 | #define OS_ANDROID_ISERVICE_H_ 19 | 20 | #include 21 | #include 22 | 23 | #define IA_HWC_SERVICE_NAME "hwc.info" 24 | 25 | namespace hwcomposer { 26 | 27 | class IControls; 28 | class IDiagnostic; 29 | 30 | using namespace android; 31 | 32 | /** Maintenance interface to control HWC activity. 33 | */ 34 | class IService : public IInterface { 35 | public: 36 | DECLARE_META_INTERFACE(Service); 37 | 38 | virtual sp GetDiagnostic() = 0; 39 | virtual sp GetControls() = 0; 40 | 41 | virtual String8 GetHwcVersion() = 0; 42 | virtual void DumpOptions(void) = 0; 43 | virtual status_t SetOption(String8 option, String8 optionValue) = 0; 44 | virtual status_t EnableLogviewToLogcat(bool enable = true) = 0; 45 | }; 46 | 47 | /** 48 | */ 49 | class BnService : public BnInterface { 50 | public: 51 | status_t onTransact(uint32_t, const Parcel&, Parcel*, uint32_t) override; 52 | }; 53 | 54 | } // namespace hwcomposer 55 | 56 | #endif // OS_ANDROID_ISERVICE_H_ 57 | -------------------------------------------------------------------------------- /os/android/libhwcservice/test/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 Intel Corporation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | ANDROID_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION))) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE:= hwcservice_test 21 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../ 22 | LOCAL_SRC_FILES:= hwcservice_test.cpp 23 | LOCAL_SHARED_LIBRARIES := libutils libbinder liblog libhwcservice 24 | LOCAL_PROPRIETARY_MODULE := true 25 | ifeq ($(shell test $(ANDROID_VERSION) -ge 8; echo $$?), 0) 26 | LOCAL_CFLAGS += -DUSE_PROCESS_STATE 27 | endif 28 | ifeq ($(strip $(ENABLE_HYPER_DMABUF_SHARING)), true) 29 | LOCAL_CFLAGS += -DENABLE_PANORAMA 30 | endif 31 | include $(BUILD_EXECUTABLE) 32 | -------------------------------------------------------------------------------- /os/chromeos/IA-Hardware-Composer-9999.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Intel Corporation 2 | # Distributed under the terms of the GNU General Public License v2 3 | # $Header: $ 4 | 5 | EAPI=5 6 | 7 | inherit base autotools multilib flag-o-matic toolchain-funcs cros-workon eutils 8 | 9 | CROS_WORKON_PROJECT="chromiumos/third_party/IA-Hardware-Composer" 10 | KEYWORDS="~x86 ~amd64" 11 | 12 | RESTRICT="mirror" 13 | 14 | DESCRIPTION="test for hardware composer" 15 | HOMEPAGE="" 16 | 17 | LICENSE="apache" 18 | SLOT="0" 19 | 20 | RDEPEND="${DEPEND}" 21 | 22 | src_prepare() { 23 | eautoreconf 24 | } 25 | 26 | src_configure() { 27 | econf 28 | } 29 | 30 | src_compile() { 31 | emake 32 | } 33 | 34 | src_install() { 35 | base_src_install 36 | } 37 | -------------------------------------------------------------------------------- /os/linux/gbmbufferhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef OS_LINUX_GBMBUFFERHANDLER_H_ 18 | #define OS_LINUX_GBMBUFFERHANDLER_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace hwcomposer { 25 | 26 | class GpuDevice; 27 | 28 | class GbmBufferHandler : public NativeBufferHandler { 29 | public: 30 | explicit GbmBufferHandler(uint32_t fd); 31 | ~GbmBufferHandler() override; 32 | 33 | bool Init(); 34 | 35 | bool CreateBuffer(uint32_t w, uint32_t h, int format, HWCNativeHandle *handle, 36 | uint32_t layer_type = kLayerNormal, 37 | bool *modifier_used = NULL, int64_t modifier = -1, 38 | bool raw_pixel_buffer = false) const override; 39 | bool ReleaseBuffer(HWCNativeHandle handle) const override; 40 | void DestroyHandle(HWCNativeHandle handle) const override; 41 | void CopyHandle(HWCNativeHandle source, 42 | HWCNativeHandle *target) const override; 43 | bool ImportBuffer(HWCNativeHandle handle) const override; 44 | uint32_t GetTotalPlanes(HWCNativeHandle handle) const override; 45 | void *Map(HWCNativeHandle handle, uint32_t x, uint32_t y, uint32_t width, 46 | uint32_t height, uint32_t *stride, void **map_data, 47 | size_t plane) const override; 48 | int32_t UnMap(HWCNativeHandle handle, void *map_data) const override; 49 | uint32_t GetFd() const override { 50 | return fd_; 51 | } 52 | bool GetInterlace(HWCNativeHandle handle) const override { 53 | return false; 54 | } 55 | 56 | private: 57 | uint32_t fd_; 58 | struct gbm_device *device_; 59 | uint64_t preferred_cursor_width_; 60 | uint64_t preferred_cursor_height_; 61 | }; 62 | 63 | } // namespace hwcomposer 64 | #endif // OS_LINUX_GBMBUFFERHANDLER_H_ 65 | -------------------------------------------------------------------------------- /public/hwcmeta.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef PUBLIC_HWCMETA_H_ 18 | #define PUBLIC_HWCMETA_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | struct HwcMeta { 26 | HwcMeta() = default; 27 | 28 | HwcMeta &operator=(const HwcMeta &rhs) = delete; 29 | bool is_interlaced_ = false; 30 | uint32_t width_ = 0; 31 | uint32_t height_ = 0; 32 | uint32_t format_ = 0; // Drm format equivalent to native_format. 33 | uint32_t tiling_mode_ = 0; 34 | uint32_t native_format_ = 0; // OS specific format. 35 | uint32_t pitches_[4]; 36 | uint32_t offsets_[4]; 37 | uint32_t gem_handles_[4]; 38 | int prime_fds_[4]; 39 | uint32_t num_planes_ = 0; 40 | uint32_t fb_modifiers_[8]; 41 | uint32_t dataspace_ = 0; 42 | hwcomposer::HWCLayerType usage_ = hwcomposer::kLayerNormal; 43 | }; 44 | 45 | #endif // PUBLIC_HWCMETA_H_ 46 | -------------------------------------------------------------------------------- /public/hwcrect.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | /** \file */ 17 | #ifndef PUBLIC_HWCRECT_H_ 18 | #define PUBLIC_HWCRECT_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace hwcomposer { 25 | 26 | // Some of the structs are adopted from drm_hwcomposer 27 | template 28 | struct Rect { 29 | union { 30 | struct { 31 | TFloat left, top, right, bottom; 32 | }; 33 | TFloat bounds[4]; 34 | }; 35 | typedef TFloat TNum; 36 | Rect() { 37 | reset(); 38 | } 39 | Rect(TFloat left_, TFloat top_, TFloat right_, TFloat bottom_) 40 | : left(left_), top(top_), right(right_), bottom(bottom_) { 41 | } 42 | template 43 | Rect(const Rect &rhs) { 44 | for (int i = 0; i < 4; i++) 45 | bounds[i] = rhs.bounds[i]; 46 | } 47 | template 48 | Rect &operator=(const Rect &rhs) { 49 | for (int i = 0; i < 4; i++) 50 | bounds[i] = rhs.bounds[i]; 51 | return *this; 52 | } 53 | bool operator==(const Rect &rhs) const { 54 | for (int i = 0; i < 4; i++) { 55 | if (bounds[i] != rhs.bounds[i]) 56 | return false; 57 | } 58 | return true; 59 | } 60 | 61 | /** 62 | * Check if bounds are unset 63 | * 64 | * @return True if all bounds are set to 0 65 | */ 66 | bool empty() const { 67 | for (int i = 0; i < 4; i++) { 68 | if (bounds[i] != 0) 69 | return false; 70 | } 71 | return true; 72 | } 73 | 74 | /** 75 | * Set bounds to 0 76 | */ 77 | void reset() { 78 | for (int i = 0; i < 4; i++) { 79 | memset(&bounds, 0, sizeof(bounds)); 80 | } 81 | } 82 | }; 83 | 84 | } // namespace hwcomposer 85 | 86 | #endif // PUBLIC_HWCRECT_H_ 87 | -------------------------------------------------------------------------------- /public/nativebufferhandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef PUBLIC_NATIVEBUFFERHANDLER_H_ 18 | #define PUBLIC_NATIVEBUFFERHANDLER_H_ 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | namespace hwcomposer { 26 | 27 | class NativeBufferHandler { 28 | public: 29 | static NativeBufferHandler *CreateInstance(uint32_t fd); 30 | 31 | virtual ~NativeBufferHandler() { 32 | } 33 | 34 | virtual bool CreateBuffer(uint32_t w, uint32_t h, int format, 35 | HWCNativeHandle *handle = NULL, 36 | uint32_t layer_type = kLayerNormal, 37 | bool *modifier_used = NULL, int64_t modifier = -1, 38 | bool raw_pixel_buffer = false) const = 0; 39 | 40 | virtual bool ReleaseBuffer(HWCNativeHandle handle) const = 0; 41 | 42 | virtual void DestroyHandle(HWCNativeHandle handle) const = 0; 43 | 44 | virtual bool ImportBuffer(HWCNativeHandle handle) const = 0; 45 | 46 | virtual void CopyHandle(HWCNativeHandle source, 47 | HWCNativeHandle *target) const = 0; 48 | 49 | virtual uint32_t GetTotalPlanes(HWCNativeHandle handle) const = 0; 50 | 51 | virtual void *Map(HWCNativeHandle handle, uint32_t x, uint32_t y, 52 | uint32_t width, uint32_t height, uint32_t *stride, 53 | void **map_data, size_t plane) const = 0; 54 | 55 | virtual int32_t UnMap(HWCNativeHandle handle, void *map_data) const = 0; 56 | 57 | virtual uint32_t GetFd() const = 0; 58 | virtual bool GetInterlace(HWCNativeHandle handle) const = 0; 59 | }; 60 | 61 | } // namespace hwcomposer 62 | #endif // PUBLIC_NATIVEBUFFERHANDLER_H_ 63 | -------------------------------------------------------------------------------- /public/spinlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef PUBLIC_SPINLOCK_H_ 18 | #define PUBLIC_SPINLOCK_H_ 19 | 20 | #include 21 | 22 | namespace hwcomposer { 23 | 24 | class SpinLock { 25 | public: 26 | void lock() { 27 | while (atomic_lock_.test_and_set(std::memory_order_acquire)) { 28 | } 29 | } 30 | 31 | void unlock() { 32 | atomic_lock_.clear(std::memory_order_release); 33 | } 34 | 35 | private: 36 | std::atomic_flag atomic_lock_ = ATOMIC_FLAG_INIT; 37 | }; 38 | 39 | class ScopedSpinLock { 40 | public: 41 | explicit ScopedSpinLock(SpinLock& lock) : lock_(lock) { 42 | lock_.lock(); 43 | locked_ = true; 44 | } 45 | 46 | ~ScopedSpinLock() { 47 | if (locked_) { 48 | lock_.unlock(); 49 | locked_ = false; 50 | } 51 | } 52 | 53 | private: 54 | SpinLock& lock_; 55 | bool locked_; 56 | }; 57 | 58 | class ScopedSpinLocks { 59 | public: 60 | ScopedSpinLocks(SpinLock& lock1, SpinLock& lock2) 61 | : lock1_(lock1), lock2_(lock2) { 62 | lock1_.lock(); 63 | lock2_.lock(); 64 | } 65 | 66 | ~ScopedSpinLocks() { 67 | lock1_.unlock(); 68 | lock2_.unlock(); 69 | } 70 | 71 | private: 72 | SpinLock& lock1_; 73 | SpinLock& lock2_; 74 | }; 75 | 76 | } // namespace hwcomposer 77 | #endif // PUBLIC_SPINLOCK_H_ 78 | -------------------------------------------------------------------------------- /tests/apps/panorama_disable.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | /vendor/bin/hwcservice_test -m 0 3 | screen_res=`/vendor/bin/hwcservice_test -g | sed -n "/^[0-9]/p" | sed -n "s/\(^[0-9]*\)[ \t]*\([0-9]*\)[ \t]*.*/\1x\2/p"` 4 | echo "screen_res: $screen_res" 5 | wm size $screen_res 6 | -------------------------------------------------------------------------------- /tests/apps/panorama_enable.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | /vendor/bin/hwcservice_test -w 0 3 | screen_res=`/vendor/bin/hwcservice_test -g | sed -n "/^[0-9]/p" | sed -n "s/\(^[0-9]*\)[ \t]*\([0-9]*\)[ \t]*.*/\1x\2/p"` 4 | echo "screen_res: $screen_res" 5 | wm size $screen_res 6 | -------------------------------------------------------------------------------- /tests/common/cclayerrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef CC_LAYER_RENDERER_H_ 18 | #define CC_LAYER_RENDERER_H_ 19 | 20 | #include "platformdefines.h" 21 | #include "layerrenderer.h" 22 | #include 23 | 24 | class CCLayerRenderer : public LayerRenderer { 25 | public: 26 | CCLayerRenderer(hwcomposer::NativeBufferHandler* buffer_handler); 27 | ~CCLayerRenderer() override; 28 | 29 | bool Init(uint32_t width, uint32_t height, uint32_t format, 30 | uint32_t usage_format = -1, uint32_t usage = 0, 31 | glContext* gl = NULL, const char* resource_path = NULL) override; 32 | void Draw(int64_t* pfence) override; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /tests/common/glcubelayerrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef GL_CUBE_LAYER_RENDERER_H_ 18 | #define GL_CUBE_LAYER_RENDERER_H_ 19 | 20 | #include "gllayerrenderer.h" 21 | 22 | class StreamTextureImpl; 23 | 24 | namespace hwcomposer { 25 | class NativeBufferHandler; 26 | } 27 | 28 | class GLCubeLayerRenderer : public GLLayerRenderer { 29 | public: 30 | GLCubeLayerRenderer(hwcomposer::NativeBufferHandler *buffer_handler, 31 | bool enable_texture); 32 | ~GLCubeLayerRenderer() override; 33 | 34 | bool Init(uint32_t width, uint32_t height, uint32_t format, 35 | uint32_t usage_format = -1, uint32_t usage = 0, 36 | glContext *gl = NULL, const char *resource_path = NULL) override; 37 | void glDrawFrame() override; 38 | void UpdateStreamTexture(unsigned long usec); 39 | 40 | private: 41 | GLuint program_ = 0; 42 | GLint modelviewmatrix_ = 0, modelviewprojectionmatrix_ = 0, normalmatrix_ = 0; 43 | GLuint vbo_ = 0; 44 | GLuint positionsoffset_ = 0, colorsoffset_ = 0, normalsoffset_ = 0, 45 | texcoordoffset_ = 0; 46 | uint32_t frame_count_ = 0; 47 | StreamTextureImpl *stream_texture_ = NULL; 48 | static const size_t s_length = 512; 49 | float last_progress_ = 0.f; 50 | bool even_turn_ = true; 51 | bool enable_texture_ = false; 52 | }; 53 | #endif 54 | -------------------------------------------------------------------------------- /tests/common/gllayerrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef GL_LAYER_RENDERER_H_ 18 | #define GL_LAYER_RENDERER_H_ 19 | 20 | #include "layerrenderer.h" 21 | #include "esUtil.h" 22 | #include 23 | #include 24 | 25 | class GLLayerRenderer : public LayerRenderer { 26 | public: 27 | GLLayerRenderer(hwcomposer::NativeBufferHandler* buffer_handler); 28 | ~GLLayerRenderer() override; 29 | 30 | bool Init(uint32_t width, uint32_t height, uint32_t format, 31 | uint32_t usage_format = -1, uint32_t usage = 0, 32 | glContext* gl = NULL, const char* resource_path = NULL) override; 33 | void Draw(int64_t* pfence) override; 34 | virtual void glDrawFrame() = 0; 35 | 36 | protected: 37 | bool Init_GL(glContext* gl); 38 | GLuint gl_renderbuffer_ = 0; 39 | GLuint gl_framebuffer_ = 0; 40 | EGLImageKHR egl_image_ = EGL_NO_IMAGE_KHR; 41 | glContext* gl_ = NULL; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /tests/common/igt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright: 3 | * code of this file copied/modified from 4 | * https://anongit.freedesktop.org/git/xorg/app/intel-gpu-tools.git 5 | * commit: 0a0eb5d48bab8df3e2fd530fb631e1478c9c9215 6 | */ 7 | 8 | #ifndef IGT_H 9 | #define IGT_H 10 | 11 | #define MAX_CRC_ENTRIES 10 12 | #define MAX_LINE_LEN (10 + 11 * MAX_CRC_ENTRIES + 1) 13 | #define LEGACY_LINE_LEN (6 * 8 + 5 + 1) 14 | #define DRM_MAX_CRC_NR 10 15 | 16 | typedef struct { 17 | uint32_t frame; 18 | bool has_valid_frame; 19 | int n_words; 20 | uint32_t crc[DRM_MAX_CRC_NR]; 21 | } igt_crc_t; 22 | 23 | struct _igt_pipe_crc { 24 | int ctl_fd; 25 | int crc_fd; 26 | int flags; 27 | bool is_legacy; 28 | int pipe; 29 | int source; 30 | }; 31 | 32 | typedef struct _igt_pipe_crc igt_pipe_crc_t; 33 | 34 | typedef struct { 35 | char root[128]; 36 | char dri_path[128]; 37 | } igt_debugfs_t; 38 | 39 | const char *igt_debugfs_mount(void); 40 | static bool __igt_debugfs_init(igt_debugfs_t *debugfs); 41 | static igt_debugfs_t *__igt_debugfs_singleton(void); 42 | FILE *igt_debugfs_fopen(const char *filename, const char *mode); 43 | int igt_debugfs_open(const char *filename, int mode); 44 | const char *kmstest_pipe_name(int pipe); 45 | igt_pipe_crc_t *pipe_crc_new(int pipe); 46 | bool igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc); 47 | bool igt_pipe_crc_collect_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out_crc); 48 | bool igt_assert_crc_equal(const igt_crc_t *a, const igt_crc_t *b); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /tests/common/imagelayerrenderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #include "imagelayerrenderer.h" 18 | 19 | ImageLayerRenderer::ImageLayerRenderer( 20 | hwcomposer::NativeBufferHandler* buffer_handler) 21 | : LayerRenderer(buffer_handler) { 22 | } 23 | 24 | ImageLayerRenderer::~ImageLayerRenderer() { 25 | } 26 | 27 | bool ImageLayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format, 28 | uint32_t usage_format, uint32_t usage, 29 | glContext* gl, const char* resource_path) { 30 | return true; 31 | } 32 | 33 | void ImageLayerRenderer::Draw(int64_t* pfence) { 34 | *pfence = -1; 35 | } 36 | -------------------------------------------------------------------------------- /tests/common/imagelayerrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef IMAGE_LAYER_RENDERER_H_ 18 | #define IMAGE_LAYER_RENDERER_H_ 19 | 20 | #include "platformdefines.h" 21 | #include "layerrenderer.h" 22 | 23 | class ImageLayerRenderer : public LayerRenderer { 24 | public: 25 | ImageLayerRenderer(hwcomposer::NativeBufferHandler* buffer_handler); 26 | ~ImageLayerRenderer(); 27 | 28 | bool Init(uint32_t width, uint32_t height, uint32_t format, 29 | uint32_t usage_format = -1, uint32_t usage = 0, 30 | glContext* gl = NULL, const char* resourePath = NULL) override; 31 | void Draw(int64_t* pfence) override; 32 | 33 | private: 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /tests/common/layerrenderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #include "layerrenderer.h" 18 | 19 | #include 20 | 21 | LayerRenderer::LayerRenderer(hwcomposer::NativeBufferHandler* buffer_handler) { 22 | buffer_handler_ = buffer_handler; 23 | } 24 | 25 | LayerRenderer::~LayerRenderer() { 26 | if (buffer_handler_ && handle_) { 27 | buffer_handler_->ReleaseBuffer(handle_); 28 | buffer_handler_->DestroyHandle(handle_); 29 | } 30 | } 31 | 32 | bool LayerRenderer::Init(uint32_t width, uint32_t height, uint32_t format, 33 | uint32_t usage_format, uint32_t usage, glContext* gl, 34 | const char* resource_path) { 35 | if (!buffer_handler_->CreateBuffer(width, height, format, &handle_, usage)) { 36 | ETRACE("LayerRenderer: CreateBuffer failed"); 37 | return false; 38 | } 39 | 40 | buffer_handler_->CopyHandle(handle_, &handle_); 41 | 42 | if (!buffer_handler_->ImportBuffer(handle_)) { 43 | ETRACE("LayerRenderer: ImportBuffer failed"); 44 | return false; 45 | } 46 | 47 | width_ = handle_->meta_data_.width_; 48 | height_ = handle_->meta_data_.height_; 49 | stride_ = handle_->meta_data_.pitches_[0]; 50 | fd_ = handle_->meta_data_.prime_fds_[0]; 51 | planes_ = buffer_handler_->GetTotalPlanes(handle_); 52 | format_ = format; 53 | 54 | return true; 55 | } 56 | -------------------------------------------------------------------------------- /tests/common/layerrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef LAYER_RENDERER_H_ 18 | #define LAYER_RENDERER_H_ 19 | 20 | #include 21 | #include "esUtil.h" 22 | #include 23 | #include 24 | #include 25 | 26 | typedef struct { 27 | EGLDisplay display; 28 | EGLConfig config; 29 | EGLContext context; 30 | PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC 31 | glEGLImageTargetRenderbufferStorageOES; 32 | PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; 33 | PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR; 34 | PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR; 35 | PFNEGLWAITSYNCKHRPROC eglWaitSyncKHR; 36 | PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR; 37 | PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID; 38 | PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; 39 | PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; 40 | } glContext; 41 | 42 | namespace hwcomposer { 43 | class NativeBufferHandler; 44 | } 45 | 46 | class LayerRenderer { 47 | public: 48 | LayerRenderer(hwcomposer::NativeBufferHandler* buffer_handler); 49 | virtual ~LayerRenderer(); 50 | 51 | virtual bool Init(uint32_t width, uint32_t height, uint32_t format, 52 | uint32_t usage_format = -1, uint32_t usage = 0, 53 | glContext* gl = NULL, const char* resourePath = NULL) = 0; 54 | virtual void Draw(int64_t* pfence) = 0; 55 | HWCNativeHandle GetNativeBoHandle() { 56 | return handle_; 57 | } 58 | 59 | protected: 60 | HWCNativeHandle handle_; 61 | hwcomposer::NativeBufferHandler* buffer_handler_ = NULL; 62 | uint32_t format_ = DRM_FORMAT_XRGB8888; 63 | uint32_t planes_ = 0; 64 | uint32_t width_ = 0; 65 | uint32_t height_ = 0; 66 | uint32_t stride_ = 0; 67 | uint32_t fd_ = 0; 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /tests/common/videolayerrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef VIDEO_LAYER_RENDERER_H_ 18 | #define VIDEO_LAYER_RENDERER_H_ 19 | 20 | #include "platformdefines.h" 21 | #include "layerrenderer.h" 22 | #include 23 | 24 | class VideoLayerRenderer : public LayerRenderer { 25 | public: 26 | VideoLayerRenderer(hwcomposer::NativeBufferHandler* buffer_handler); 27 | ~VideoLayerRenderer() override; 28 | 29 | bool Init(uint32_t width, uint32_t height, uint32_t format, 30 | uint32_t usage_format = -1, uint32_t usage = 0, 31 | glContext* gl = NULL, const char* resource_path = NULL) override; 32 | void Draw(int64_t* pfence) override; 33 | 34 | private: 35 | FILE* resource_fd_ = NULL; 36 | uint32_t source_width_ = 0; 37 | uint32_t source_height_ = 0; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /tests/jsonconfigs/colorcorrection.json: -------------------------------------------------------------------------------- 1 | { 2 | "broadcast_rgb": "Full", 3 | "gamma_b": "0", 4 | "gamma_g": "0", 5 | "gamma_r": "0", 6 | "layers_parameters": [ 7 | { 8 | "format": 25, 9 | "frame": { 10 | "height": 1080, 11 | "width": 1920, 12 | "x": 0, 13 | "y": 0 14 | }, 15 | "resource_path": "", 16 | "source": { 17 | "crop": { 18 | "height": 1080, 19 | "width": 1920, 20 | "x": 0, 21 | "y": 0 22 | }, 23 | "height": 1080, 24 | "width": 1920 25 | }, 26 | "transform": 0, 27 | "type": 4 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /tests/jsonconfigs/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "brightness_b": "200", 3 | "brightness_g": "200", 4 | "brightness_r": "200", 5 | "broadcast_rgb": "Full", 6 | "contrast_b": "50", 7 | "contrast_g": "50", 8 | "contrast_r": "50", 9 | "gamma_b": "0.3", 10 | "gamma_g": "0.3", 11 | "gamma_r": "0.3", 12 | "layers_parameters": [ 13 | { 14 | "format": 3, 15 | "frame": { 16 | "height": 50, 17 | "width": 30, 18 | "x": 1, 19 | "y": 1 20 | }, 21 | "resource_path": "./image.bmp", 22 | "source": { 23 | "crop": { 24 | "height": 50, 25 | "width": 30, 26 | "x": 1, 27 | "y": 1 28 | }, 29 | "height": 10, 30 | "width": 10 31 | }, 32 | "transform": 1, 33 | "type": 2 34 | }, 35 | { 36 | "format": 25, 37 | "frame": { 38 | "height": 1080, 39 | "width": 1920, 40 | "x": 0, 41 | "y": 0 42 | }, 43 | "resource_path": "", 44 | "source": { 45 | "crop": { 46 | "height": 1080, 47 | "width": 1920, 48 | "x": 0, 49 | "y": 0 50 | }, 51 | "height": 1080, 52 | "width": 1920 53 | }, 54 | "transform": 0, 55 | "type": 0 56 | } 57 | ], 58 | "power_mode": "no" 59 | } 60 | -------------------------------------------------------------------------------- /tests/jsonconfigs/kmscube1layer.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 25, 5 | "frame": { 6 | "height": 1080, 7 | "width": 1920, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "", 12 | "source": { 13 | "crop": { 14 | "height": 1080, 15 | "width": 1920, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 1080, 20 | "width": 1920 21 | }, 22 | "transform": 0, 23 | "type": 0 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tests/jsonconfigs/kmscube1layer_canvascolor.json: -------------------------------------------------------------------------------- 1 | { 2 | "canvas_color": "00ff0000", 3 | "bits_per_color": 8, 4 | "layers_parameters": [ 5 | { 6 | "format": 25, 7 | "frame": { 8 | "height": 500, 9 | "width": 500, 10 | "x": 0, 11 | "y": 0 12 | }, 13 | "resource_path": "", 14 | "source": { 15 | "crop": { 16 | "height": 500, 17 | "width": 500, 18 | "x": 0, 19 | "y": 0 20 | }, 21 | "height": 500, 22 | "width": 500 23 | }, 24 | "transform": 0, 25 | "type": 0 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /tests/jsonconfigs/kmscube1layer_rot90.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 25, 5 | "frame": { 6 | "height": 1080, 7 | "width": 1920, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "", 12 | "source": { 13 | "crop": { 14 | "height": 1080, 15 | "width": 1920, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 1080, 20 | "width": 1920 21 | }, 22 | "transform": 4, 23 | "type": 0 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tests/jsonconfigs/kmscube1layer_rot90flipx.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 25, 5 | "frame": { 6 | "height": 1080, 7 | "width": 1920, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "", 12 | "source": { 13 | "crop": { 14 | "height": 1080, 15 | "width": 1920, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 1080, 20 | "width": 1920 21 | }, 22 | "transform": 5, 23 | "type": 0 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tests/jsonconfigs/kmscube1layer_rot90flipy.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 25, 5 | "frame": { 6 | "height": 1080, 7 | "width": 1920, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "", 12 | "source": { 13 | "crop": { 14 | "height": 1080, 15 | "width": 1920, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 1080, 20 | "width": 1920 21 | }, 22 | "transform": 6, 23 | "type": 0 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tests/jsonconfigs/multiplelayers_idle.json: -------------------------------------------------------------------------------- 1 | { 2 | "power_mode":"dozesuspend", 3 | "layers_parameters": [ 4 | { 5 | "format": 25, 6 | "frame": { 7 | "height": 500, 8 | "width": 500, 9 | "x": 0, 10 | "y": 0 11 | }, 12 | "resource_path": "", 13 | "source": { 14 | "crop": { 15 | "height": 1080, 16 | "width": 1920, 17 | "x": 0, 18 | "y": 0 19 | }, 20 | "height": 1080, 21 | "width": 1920 22 | }, 23 | "transform": 0, 24 | "type": 0 25 | }, 26 | { 27 | "format": 25, 28 | "frame": { 29 | "height": 700, 30 | "width": 900, 31 | "x": 300, 32 | "y": 100 33 | }, 34 | "resource_path": "", 35 | "source": { 36 | "crop": { 37 | "height": 1080, 38 | "width": 1920, 39 | "x": 0, 40 | "y": 0 41 | }, 42 | "height": 1080, 43 | "width": 1920 44 | }, 45 | "transform": 0, 46 | "type": 3 47 | }, 48 | { 49 | "format": 25, 50 | "frame": { 51 | "height": 900, 52 | "width": 1920, 53 | "x": 1200, 54 | "y": 400 55 | }, 56 | "resource_path": "", 57 | "source": { 58 | "crop": { 59 | "height": 1080, 60 | "width": 1920, 61 | "x": 0, 62 | "y": 0 63 | }, 64 | "height": 1080, 65 | "width": 1920 66 | }, 67 | "transform": 0, 68 | "type": 3 69 | } 70 | ] 71 | } 72 | -------------------------------------------------------------------------------- /tests/jsonconfigs/multiplelayersnovideo.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 25, 5 | "frame": { 6 | "height": 500, 7 | "width": 500, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "", 12 | "source": { 13 | "crop": { 14 | "height": 1080, 15 | "width": 1920, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 1080, 20 | "width": 1920 21 | }, 22 | "transform": 0, 23 | "type": 0 24 | }, 25 | { 26 | "format": 25, 27 | "frame": { 28 | "height": 700, 29 | "width": 900, 30 | "x": 300, 31 | "y": 100 32 | }, 33 | "resource_path": "", 34 | "source": { 35 | "crop": { 36 | "height": 1080, 37 | "width": 1920, 38 | "x": 0, 39 | "y": 0 40 | }, 41 | "height": 1080, 42 | "width": 1920 43 | }, 44 | "transform": 0, 45 | "type": 3 46 | }, 47 | { 48 | "format": 25, 49 | "frame": { 50 | "height": 900, 51 | "width": 1920, 52 | "x": 1200, 53 | "y": 400 54 | }, 55 | "resource_path": "", 56 | "source": { 57 | "crop": { 58 | "height": 1080, 59 | "width": 1920, 60 | "x": 0, 61 | "y": 0 62 | }, 63 | "height": 1080, 64 | "width": 1920 65 | }, 66 | "transform": 0, 67 | "type": 3 68 | } 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /tests/jsonconfigs/multiplelayersnovideo_powermode.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 25, 5 | "frame": { 6 | "height": 500, 7 | "width": 500, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "", 12 | "source": { 13 | "crop": { 14 | "height": 1080, 15 | "width": 1920, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 1080, 20 | "width": 1920 21 | }, 22 | "transform": 0, 23 | "type": 0 24 | }, 25 | { 26 | "format": 25, 27 | "frame": { 28 | "height": 700, 29 | "width": 900, 30 | "x": 300, 31 | "y": 100 32 | }, 33 | "resource_path": "", 34 | "source": { 35 | "crop": { 36 | "height": 1080, 37 | "width": 1920, 38 | "x": 0, 39 | "y": 0 40 | }, 41 | "height": 1080, 42 | "width": 1920 43 | }, 44 | "transform": 0, 45 | "type": 3 46 | }, 47 | { 48 | "format": 25, 49 | "frame": { 50 | "height": 900, 51 | "width": 1920, 52 | "x": 1200, 53 | "y": 400 54 | }, 55 | "resource_path": "", 56 | "source": { 57 | "crop": { 58 | "height": 1080, 59 | "width": 1920, 60 | "x": 0, 61 | "y": 0 62 | }, 63 | "height": 1080, 64 | "width": 1920 65 | }, 66 | "transform": 0, 67 | "type": 3 68 | } 69 | ], 70 | "power_mode": "on" 71 | } 72 | -------------------------------------------------------------------------------- /tests/jsonconfigs/powermode.json: -------------------------------------------------------------------------------- 1 | { 2 | "power_mode":"doze", 3 | "layers_parameters": [ 4 | { 5 | "format": 25, 6 | "frame": { 7 | "height": 1080, 8 | "width": 1920, 9 | "x": 0, 10 | "y": 0 11 | }, 12 | "resource_path": "", 13 | "source": { 14 | "crop": { 15 | "height": 1080, 16 | "width": 1920, 17 | "x": 0, 18 | "y": 0 19 | }, 20 | "height": 1080, 21 | "width": 1920 22 | }, 23 | "transform": 0, 24 | "type": 0 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /tests/jsonconfigs/video1layer_bgra.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 25, 5 | "frame": { 6 | "height": 360, 7 | "width": 640, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "./resources/test.640x360.bgra", 12 | "source": { 13 | "crop": { 14 | "height": 360, 15 | "width": 640, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 360, 20 | "width": 640 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tests/jsonconfigs/video1layer_nv12.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 47, 5 | "frame": { 6 | "height": 360, 7 | "width": 640, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "./resources/test.640x360.nv12", 12 | "source": { 13 | "crop": { 14 | "height": 360, 15 | "width": 640, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 360, 20 | "width": 640 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tests/third_party/json-c/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig 2 | # http://EditorConfig.org 3 | 4 | # top-most EditorConfig file 5 | root = true 6 | 7 | # LF end-of-line, insert an empty new line and UTF-8 8 | [*] 9 | end_of_line = lf 10 | insert_final_newline = true 11 | charset = utf-8 12 | 13 | # Tab indentation 14 | [makefile,Makefile] 15 | indent_style = tab 16 | -------------------------------------------------------------------------------- /tests/third_party/json-c/.gitignore: -------------------------------------------------------------------------------- 1 | # Temp files 2 | *~ 3 | *.swp 4 | *.bak 5 | *.backup 6 | \#* 7 | .\#* 8 | *\# 9 | *.sav 10 | *.save 11 | *.autosav 12 | *.autosave 13 | 14 | # Tests 15 | /test-driver 16 | /tests/Makefile 17 | /tests/Makefile.in 18 | /tests/test1 19 | /tests/test1Formatted 20 | /tests/test2 21 | /tests/test2Formatted 22 | /tests/test4 23 | /tests/testReplaceExisting 24 | /tests/testSubDir 25 | /tests/test_cast 26 | /tests/test_charcase 27 | /tests/test_compare 28 | /tests/test_double_serializer 29 | /tests/test_float 30 | /tests/test_json_pointer 31 | /tests/test_locale 32 | /tests/test_null 33 | /tests/test_parse 34 | /tests/test_parse_int64 35 | /tests/test_printbuf 36 | /tests/test_set_serializer 37 | /tests/test_set_value 38 | /tests/test_util_file 39 | /tests/test_visit 40 | /tests/*.vg.out 41 | /tests/*.log 42 | /tests/*.trs 43 | 44 | # Generated folders 45 | /Debug 46 | /Release 47 | /*/Debug 48 | /*/Release 49 | 50 | # Generated binaries 51 | *.lo 52 | *.o 53 | /libjson-c.la 54 | /libjson.la 55 | 56 | # Archives 57 | *.zip 58 | *.tar.* 59 | *.tgz 60 | *.gz 61 | *.bz2 62 | *.xz 63 | *.lz 64 | *.lzma 65 | *.7z 66 | *.dll 67 | *.deb 68 | *.rpm 69 | *.apk 70 | *.exe 71 | *.msi 72 | *.dmg 73 | *.ipa 74 | 75 | /INSTALL 76 | .deps/ 77 | .libs/ 78 | /aclocal.m4 79 | /autom4te.cache 80 | /config.guess 81 | /config.h.in 82 | /compile 83 | /config.h 84 | /config.log 85 | /config.status 86 | /config.sub 87 | /configure 88 | /depcomp 89 | /doc 90 | /install-sh 91 | /json.pc 92 | /json-c.pc 93 | /json-c-uninstalled.pc 94 | /libtool 95 | /ltmain.sh 96 | /Makefile 97 | /Makefile.in 98 | /missing 99 | /stamp-h1 100 | /stamp-h2 101 | -------------------------------------------------------------------------------- /tests/third_party/json-c/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | compiler: 4 | - gcc 5 | - clang 6 | 7 | addons: 8 | apt: 9 | packages: 10 | - cppcheck 11 | 12 | os: 13 | - linux 14 | - osx 15 | 16 | before_install: 17 | - echo $LANG 18 | - echo $LC_ALL 19 | 20 | install: 21 | - sh autogen.sh 22 | 23 | before_script: 24 | - ./configure 25 | 26 | script: 27 | - make 28 | 29 | after_success: 30 | - make check 31 | - cppcheck --quiet *.h *.c tests/ 32 | -------------------------------------------------------------------------------- /tests/third_party/json-c/AUTHORS: -------------------------------------------------------------------------------- 1 | Michael Clark 2 | Jehiah Czebotar 3 | Eric Haszlakiewicz 4 | C. Watford (christopher.watford@gmail.com) 5 | -------------------------------------------------------------------------------- /tests/third_party/json-c/Android.configure.mk: -------------------------------------------------------------------------------- 1 | # This file is the top android makefile for all sub-modules. 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | json_c_TOP := $(LOCAL_PATH) 7 | 8 | JSON_C_BUILT_SOURCES := Android.mk 9 | 10 | JSON_C_BUILT_SOURCES := $(patsubst %, $(abspath $(json_c_TOP))/%, $(JSON_C_BUILT_SOURCES)) 11 | 12 | .PHONY: json-c-configure json-c-configure-real 13 | json-c-configure-real: 14 | echo $(JSON_C_BUILT_SOURCES) 15 | cd $(json_c_TOP) ; \ 16 | $(abspath $(json_c_TOP))/autogen.sh && \ 17 | CC="$(CONFIGURE_CC)" \ 18 | CFLAGS="$(CONFIGURE_CFLAGS)" \ 19 | LD=$(TARGET_LD) \ 20 | LDFLAGS="$(CONFIGURE_LDFLAGS)" \ 21 | CPP=$(CONFIGURE_CPP) \ 22 | CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \ 23 | PKG_CONFIG_LIBDIR=$(CONFIGURE_PKG_CONFIG_LIBDIR) \ 24 | PKG_CONFIG_TOP_BUILD_DIR=/ \ 25 | ac_cv_func_malloc_0_nonnull=yes \ 26 | ac_cv_func_realloc_0_nonnull=yes \ 27 | $(abspath $(json_c_TOP))/$(CONFIGURE) --host=$(CONFIGURE_HOST) \ 28 | --prefix=/system \ 29 | && \ 30 | for file in $(JSON_C_BUILT_SOURCES); do \ 31 | rm -f $$file && \ 32 | make -C $$(dirname $$file) $$(basename $$file) ; \ 33 | done 34 | 35 | json-c-configure: json-c-configure-real 36 | 37 | PA_CONFIGURE_TARGETS += json-c-configure 38 | 39 | -include $(json_c_TOP)/Android.mk 40 | -------------------------------------------------------------------------------- /tests/third_party/json-c/Android.mk: -------------------------------------------------------------------------------- 1 | # This file is generated by androgenizer for: 2 | # [ ] NDK 3 | # [x] system 4 | 5 | LOCAL_PATH:=$(call my-dir) 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_MODULE:=libjson-c 9 | 10 | LOCAL_MODULE_TAGS:=eng debug 11 | 12 | LOCAL_SRC_FILES := \ 13 | arraylist.c \ 14 | debug.c \ 15 | json_c_version.c \ 16 | json_object.c \ 17 | json_object_iterator.c \ 18 | json_pointer.c \ 19 | json_tokener.c \ 20 | json_util.c \ 21 | json_visit.c \ 22 | linkhash.c \ 23 | printbuf.c \ 24 | random_seed.c 25 | 26 | LOCAL_C_INCLUDES := \ 27 | -DHAVE_CONFIG_H 28 | 29 | LOCAL_PRELINK_MODULE := false 30 | LOCAL_COPY_HEADERS_TO := json-c 31 | LOCAL_COPY_HEADERS := \ 32 | arraylist.h \ 33 | bits.h \ 34 | debug.h \ 35 | json.h \ 36 | json_c_version.h \ 37 | json_config.h \ 38 | json_inttypes.h \ 39 | json_object.h \ 40 | json_object_iterator.h \ 41 | json_object_private.h \ 42 | json_pointer.h \ 43 | json_tokener.h \ 44 | json_util.h \ 45 | json_visit.h \ 46 | linkhash.h \ 47 | math_compat.h \ 48 | strdup_compat.h \ 49 | vasprintf_compat.h \ 50 | printbuf.h \ 51 | random_seed.h 52 | 53 | LOCAL_ARM_MODE:=arm 54 | 55 | include $(BUILD_SHARED_LIBRARY) 56 | 57 | -------------------------------------------------------------------------------- /tests/third_party/json-c/COPYING: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2009-2012 Eric Haszlakiewicz 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a 5 | copy of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | ---------------------------------------------------------------- 23 | 24 | Copyright (c) 2004, 2005 Metaparadigm Pte Ltd 25 | 26 | Permission is hereby granted, free of charge, to any person obtaining a 27 | copy of this software and associated documentation files (the "Software"), 28 | to deal in the Software without restriction, including without limitation 29 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 30 | and/or sell copies of the Software, and to permit persons to whom the 31 | Software is furnished to do so, subject to the following conditions: 32 | 33 | The above copyright notice and this permission notice shall be included 34 | in all copies or substantial portions of the Software. 35 | 36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 39 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 42 | SOFTWARE. 43 | -------------------------------------------------------------------------------- /tests/third_party/json-c/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tests/third_party/json-c/ChangeLog -------------------------------------------------------------------------------- /tests/third_party/json-c/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = README.md README.html README-WIN32.html 2 | EXTRA_DIST += config.h.win32 json-c.vcproj json-c.vcxproj json-c.vcxproj.filters 3 | EXTRA_DIST += Doxyfile doc 4 | 5 | dist-hook: 6 | test -d "$(distdir)/doc" || mkdir "$(distdir)/doc" 7 | chmod -R u+w "$(distdir)/doc" 8 | cd "$(distdir)" && doxygen 9 | 10 | SUBDIRS = . 11 | 12 | lib_LTLIBRARIES = libjson-c.la 13 | 14 | libjson_cincludedir = $(includedir)/json-c 15 | libjson_cinclude_HEADERS = \ 16 | arraylist.h \ 17 | bits.h \ 18 | debug.h \ 19 | json.h \ 20 | json_c_version.h \ 21 | json_config.h \ 22 | json_inttypes.h \ 23 | json_object.h \ 24 | json_object_iterator.h \ 25 | json_object_private.h \ 26 | json_pointer.h \ 27 | json_tokener.h \ 28 | json_util.h \ 29 | json_visit.h \ 30 | linkhash.h \ 31 | math_compat.h \ 32 | strdup_compat.h \ 33 | vasprintf_compat.h \ 34 | printbuf.h \ 35 | random_seed.h 36 | 37 | libjson_c_la_LDFLAGS = -version-info 3:0:0 -no-undefined @JSON_BSYMBOLIC_LDFLAGS@ -static 38 | 39 | libjson_c_la_SOURCES = \ 40 | arraylist.c \ 41 | debug.c \ 42 | json_c_version.c \ 43 | json_object.c \ 44 | json_object_iterator.c \ 45 | json_pointer.c \ 46 | json_tokener.c \ 47 | json_util.c \ 48 | json_visit.c \ 49 | linkhash.c \ 50 | printbuf.c \ 51 | random_seed.c 52 | 53 | 54 | distclean-local: 55 | -rm -rf $(testsubdir) 56 | -rm -rf config.h.in~ Makefile.in aclocal.m4 autom4te.cache/ config.guess config.sub depcomp install-sh ltmain.sh missing 57 | -rm -f INSTALL test-driver tests/Makefile.in compile 58 | 59 | maintainer-clean-local: 60 | -rm -rf configure 61 | 62 | uninstall-local: 63 | rm -rf "$(DESTDIR)@includedir@/json-c" 64 | rm -f "$(DESTDIR)@includedir@/json" 65 | 66 | ANDROID_CFLAGS = -I$(top_srcdir) -DHAVE_CONFIG_H 67 | 68 | Android.mk: Makefile.am 69 | androgenizer -:PROJECT json-c \ 70 | -:SHARED libjson-c \ 71 | -:TAGS eng debug \ 72 | -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ 73 | -:SOURCES $(libjson_c_la_SOURCES) $(nodist_libjson_c_la_SOURCES) \ 74 | -:CFLAGS $(DEFS) $(ANDROID_CFLAGS) $(libjson_c_la_CFLAGS) \ 75 | -:LDFLAGS $(libjson_c_la_LDFLAGS) $(libjson_c_la_LIBADD) \ 76 | -:HEADER_TARGET json-c \ 77 | -:HEADERS $(libjson_cinclude_HEADERS) \ 78 | -:PASSTHROUGH LOCAL_ARM_MODE:=arm \ 79 | > $@ 80 | -------------------------------------------------------------------------------- /tests/third_party/json-c/NEWS: -------------------------------------------------------------------------------- 1 | See the git repo. 2 | -------------------------------------------------------------------------------- /tests/third_party/json-c/README: -------------------------------------------------------------------------------- 1 | See README.md or README.html 2 | -------------------------------------------------------------------------------- /tests/third_party/json-c/README-WIN32.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JSON-C - A JSON implementation in C - Win32 specific notes 5 | 6 | 7 | 8 |

Windows specific notes for JSON-C

9 |

Win32 Specific Changes:

10 |
    11 |
  • 12 | Use json_config.h.win32 to define Windows specific differences.
  • 13 |
  • 14 | Various functions have been redefined to their Win32 version (i.e. open 15 | on win32 is _open)
  • 16 |
  • 17 | Implemented missing functions from MS's libc (i.e. vasprintf)
  • 18 |
  • 19 | Added code to allow Win64 support without integer resizing issues, this 20 | probably makes it much nicer on 64bit machines everywhere (i.e. using ptrdiff_t 21 | for pointer math)
  • 22 |
23 |

This program is free software; you can redistribute it and/or modify it under 24 | the terms of the MIT License. See COPYING for details.

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /tests/third_party/json-c/README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | JSON-C - A JSON implementation in C 5 | 6 | 7 | 8 |

JSON-C - A JSON implementation in C

9 | 10 |

Overview

11 |

JSON-C implements a reference counting object model that allows you to easily 12 | construct JSON objects in C, output them as JSON formatted strings and parse 13 | JSON formatted strings back into the C representation of JSON objects. 14 | It aims to conform to RFC 7159. 15 |

16 | 17 |

Building

18 |

To setup JSON-C to build on your system please run configure and make.

19 |

If you are on Win32 and are not using the VS project file, be sure 20 | to rename config.h.win32 to config.h before building.

21 | 22 |

Documentation

23 |

Doxygen generated documentation exists here 24 | and Win32 specific notes can be found here.

25 | 26 |

GIT Reposository

27 |

git clone https://github.com/json-c/json-c.git

28 | 29 |

Mailing List

30 | Send email to json-c <at> googlegroups <dot> com

31 | 32 |

License

33 |

This program is free software; you can redistribute it and/or modify it under the terms of the MIT License.

34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/third_party/json-c/README.md: -------------------------------------------------------------------------------- 1 | `json-c` {#mainpage} 2 | ======== 3 | 4 | JSON-C - A JSON implementation in C 5 | ----------------------------------- 6 | 7 | JSON-C implements a reference counting object model that allows you to easily 8 | construct JSON objects in C, output them as JSON formatted strings and parse 9 | JSON formatted strings back into the C representation of JSON objects. 10 | It aims to conform to [RFC 7159](https://tools.ietf.org/html/rfc7159). 11 | 12 | Building on Unix with `git`, `gcc` and `autotools` 13 | -------------------------------------------------- 14 | 15 | Home page for json-c: https://github.com/json-c/json-c/wiki 16 | 17 | Prerequisites: 18 | 19 | - `gcc`, `clang`, or another C compiler 20 | - `libtool>=2.2.6b` 21 | 22 | If you're not using a release tarball, you'll also need: 23 | 24 | - `autoconf>=2.64` (`autoreconf`) 25 | - `automake>=1.10.3` 26 | 27 | Make sure you have a complete `libtool` install, including `libtoolize`. 28 | 29 | `json-c` GitHub repo: https://github.com/json-c/json-c 30 | 31 | ```sh 32 | $ git clone https://github.com/json-c/json-c.git 33 | $ cd json-c 34 | $ sh autogen.sh 35 | ``` 36 | 37 | followed by 38 | 39 | ```sh 40 | $ ./configure 41 | $ make 42 | $ make install 43 | ``` 44 | 45 | To build and run the test programs: 46 | 47 | ```sh 48 | $ make check 49 | ``` 50 | 51 | Linking to `libjson-c` 52 | ---------------------- 53 | 54 | If your system has `pkgconfig`, 55 | then you can just add this to your `makefile`: 56 | 57 | ```make 58 | CFLAGS += $(shell pkg-config --cflags json-c) 59 | LDFLAGS += $(shell pkg-config --libs json-c) 60 | ``` 61 | 62 | Without `pkgconfig`, you would do something like this: 63 | 64 | ```make 65 | JSON_C_DIR=/path/to/json_c/install 66 | CFLAGS += -I$(JSON_C_DIR)/include/json-c 67 | LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c 68 | ``` 69 | -------------------------------------------------------------------------------- /tests/third_party/json-c/STYLE.txt: -------------------------------------------------------------------------------- 1 | In general: 2 | For minor changes to a function, copy the existing formatting. 3 | When changing the style, commit that separately from other changes. 4 | For new code and major changes to a function, switch to the official json-c style. 5 | 6 | Official json-c style: 7 | Aim for readability, not strict conformance to fixed style rules. 8 | These rules are not comprehensive. Look to existing code for guidelines. 9 | Indentation is tab based, with continuations of long lines starting with tabs then spaces for alignment. 10 | Try to line up components of continuation lines with corresponding part of the line above (i.e. "indent -lp" effect), but avoid excessive identation tha causes extra line wraps. 11 | e.g. (T=tab, S=space): 12 | TTTTsome_long_func_call(arg1, arg2, 13 | TTTTSSSSSSSSSSSSSSSSSSSarg3, arg4); 14 | TTTTsome_reallly_really_long_func_name(arg1, 15 | TTTTTarg2, arg3, arg4); 16 | There should be a space between "if"/"while" and the following parenthesis. 17 | "case" lines are indented at the same level as the "switch" statement. 18 | Commas are followed by a single space. 19 | Include spaces around most non-unary, non-postfix operators, "=", "==', "&", "||", etc... 20 | Function calls have no space between the name and the parenthesis. 21 | Curly braces go on their own line. 22 | Curly braces may be omitted. 23 | 24 | Naming: 25 | Words within function and variable names are separated with underscores. Avoid camel case. 26 | Prefer longer, more descriptive names, but not excessively so. No single letter variable names. 27 | 28 | Other: 29 | Variables should be defined for the smallest scope needed. 30 | Functions should be defined static when possible. 31 | When possible, avoid exposing internals in the public API. 32 | -------------------------------------------------------------------------------- /tests/third_party/json-c/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{branch}.{build}' 2 | os: Windows Server 2012 R2 3 | 4 | configuration: 5 | - Debug 6 | - Release 7 | platform: x64 8 | environment: 9 | matrix: 10 | - PlatformToolset: v140 11 | - PlatformToolset: v120 12 | - PlatformToolset: Windows7.1SDK 13 | 14 | build_script: 15 | - > 16 | msbuild "json-c.vcxproj" /m /verbosity:normal 17 | /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" 18 | /p:PlatformToolset=%PlatformToolset% /p:OutDir=lib\ 19 | 20 | after_build: 21 | - md include\json-c 22 | - copy json.h include\json-c\* 23 | - copy debug.h include\json-c\* 24 | - copy linkhash.h include\json-c\* 25 | - copy arraylist.h include\json-c\* 26 | - copy json_util.h include\json-c\* 27 | - copy json_object.h include\json-c\* 28 | - copy json_tokener.h include\json-c\* 29 | - copy json_object_iterator.h include\json-c\* 30 | - copy json_c_version.h include\json-c\* 31 | - copy json_inttypes.h include\json-c\* 32 | - copy json_config.h include\json-c\* 33 | - copy json_object_private.h include\json-c\* 34 | - 7z a json-c.lib.zip lib\json-c.lib include\json-c\*.h 35 | 36 | artifacts: 37 | - path: json-c.lib.zip 38 | name: json-c.lib.zip 39 | -------------------------------------------------------------------------------- /tests/third_party/json-c/arraylist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ 3 | * 4 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 5 | * Michael Clark 6 | * 7 | * This library is free software; you can redistribute it and/or modify 8 | * it under the terms of the MIT license. See COPYING for details. 9 | * 10 | */ 11 | 12 | #ifndef _arraylist_h_ 13 | #define _arraylist_h_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #define ARRAY_LIST_DEFAULT_SIZE 32 20 | #include 21 | #include 22 | 23 | typedef void(array_list_free_fn)(void *data); 24 | 25 | struct array_list { 26 | void **array; 27 | size_t length; 28 | size_t size; 29 | array_list_free_fn *free_fn; 30 | }; 31 | 32 | extern struct array_list* 33 | array_list_new(array_list_free_fn *free_fn); 34 | 35 | extern void 36 | array_list_free(struct array_list *al); 37 | 38 | extern void* 39 | array_list_get_idx(struct array_list *al, size_t i); 40 | 41 | extern int 42 | array_list_put_idx(struct array_list *al, size_t i, void *data); 43 | 44 | extern int 45 | array_list_add(struct array_list *al, void *data); 46 | 47 | extern size_t 48 | array_list_length(struct array_list *al); 49 | 50 | extern void 51 | array_list_sort(struct array_list *arr, int(*compar)(const void *, const void *)); 52 | 53 | extern void* array_list_bsearch(const void **key, 54 | struct array_list *arr, 55 | int (*sort_fn)(const void *, const void *)); 56 | 57 | extern int 58 | array_list_del_idx(struct array_list *arr, size_t idx, size_t count); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /tests/third_party/json-c/autoconf-archive/README.txt: -------------------------------------------------------------------------------- 1 | 2 | Autoconf Archive fetched from: 3 | 4 | http://gnu.mirror.iweb.com/autoconf-archive/autoconf-archive-2015.09.25.tar.xz 5 | 6 | Grabbed the minimum files needed for the AX_APPEND_COMPILE_FLAGS and 7 | AX_COMPILE_CHECK_SIZEOF macros. 8 | -------------------------------------------------------------------------------- /tests/third_party/json-c/autoconf-archive/m4/ax_require_defined.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_require_defined.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_REQUIRE_DEFINED(MACRO) 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have 12 | # been defined and thus are available for use. This avoids random issues 13 | # where a macro isn't expanded. Instead the configure script emits a 14 | # non-fatal: 15 | # 16 | # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found 17 | # 18 | # It's like AC_REQUIRE except it doesn't expand the required macro. 19 | # 20 | # Here's an example: 21 | # 22 | # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) 23 | # 24 | # LICENSE 25 | # 26 | # Copyright (c) 2014 Mike Frysinger 27 | # 28 | # Copying and distribution of this file, with or without modification, are 29 | # permitted in any medium without royalty provided the copyright notice 30 | # and this notice are preserved. This file is offered as-is, without any 31 | # warranty. 32 | 33 | #serial 1 34 | 35 | AC_DEFUN([AX_REQUIRE_DEFINED], [dnl 36 | m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) 37 | ])dnl AX_REQUIRE_DEFINED 38 | -------------------------------------------------------------------------------- /tests/third_party/json-c/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | autoreconf -Iautoconf-archive/m4 -v --install || exit 1 3 | 4 | # If there are any options, assume the user wants to run configure. 5 | # To run configure w/o any options, use ./autogen.sh --configure 6 | if [ $# -gt 0 ] ; then 7 | case "$1" in 8 | --conf*) 9 | shift 1 10 | ;; 11 | esac 12 | exec ./configure "$@" 13 | fi 14 | -------------------------------------------------------------------------------- /tests/third_party/json-c/bits.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @deprecated Use json_util.h instead. 4 | * 5 | * $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $ 6 | * 7 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 8 | * Michael Clark 9 | * 10 | * This library is free software; you can redistribute it and/or modify 11 | * it under the terms of the MIT license. See COPYING for details. 12 | * 13 | */ 14 | 15 | #ifndef _bits_h_ 16 | #define _bits_h_ 17 | 18 | /** 19 | * @deprecated 20 | */ 21 | #define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9) 22 | /** 23 | * @deprecated 24 | */ 25 | #define error_ptr(error) ((void*)error) 26 | /** 27 | * @deprecated 28 | */ 29 | #define error_description(error) (json_tokener_get_error(error)) 30 | /** 31 | * @deprecated 32 | */ 33 | #define is_error(ptr) (ptr == NULL) 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /tests/third_party/json-c/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: debug.c,v 1.5 2006/01/26 02:16:28 mclark Exp $ 3 | * 4 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 5 | * Michael Clark 6 | * 7 | * This library is free software; you can redistribute it and/or modify 8 | * it under the terms of the MIT license. See COPYING for details. 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #if HAVE_SYSLOG_H 18 | # include 19 | #endif /* HAVE_SYSLOG_H */ 20 | 21 | #if HAVE_UNISTD_H 22 | # include 23 | #endif /* HAVE_UNISTD_H */ 24 | 25 | #if HAVE_SYS_PARAM_H 26 | #include 27 | #endif /* HAVE_SYS_PARAM_H */ 28 | 29 | #include "debug.h" 30 | 31 | static int _syslog = 0; 32 | static int _debug = 0; 33 | 34 | void mc_set_debug(int debug) { _debug = debug; } 35 | int mc_get_debug(void) { return _debug; } 36 | 37 | extern void mc_set_syslog(int syslog) 38 | { 39 | _syslog = syslog; 40 | } 41 | 42 | void mc_debug(const char *msg, ...) 43 | { 44 | va_list ap; 45 | if(_debug) { 46 | va_start(ap, msg); 47 | #if HAVE_VSYSLOG 48 | if(_syslog) { 49 | vsyslog(LOG_DEBUG, msg, ap); 50 | } else 51 | #endif 52 | vprintf(msg, ap); 53 | va_end(ap); 54 | } 55 | } 56 | 57 | void mc_error(const char *msg, ...) 58 | { 59 | va_list ap; 60 | va_start(ap, msg); 61 | #if HAVE_VSYSLOG 62 | if(_syslog) { 63 | vsyslog(LOG_ERR, msg, ap); 64 | } else 65 | #endif 66 | vfprintf(stderr, msg, ap); 67 | va_end(ap); 68 | } 69 | 70 | void mc_info(const char *msg, ...) 71 | { 72 | va_list ap; 73 | va_start(ap, msg); 74 | #if HAVE_VSYSLOG 75 | if(_syslog) { 76 | vsyslog(LOG_INFO, msg, ap); 77 | } else 78 | #endif 79 | vfprintf(stderr, msg, ap); 80 | va_end(ap); 81 | } 82 | -------------------------------------------------------------------------------- /tests/third_party/json-c/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $ 3 | * 4 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 5 | * Michael Clark 6 | * Copyright (c) 2009 Hewlett-Packard Development Company, L.P. 7 | * 8 | * This library is free software; you can redistribute it and/or modify 9 | * it under the terms of the MIT license. See COPYING for details. 10 | * 11 | */ 12 | 13 | #ifndef _DEBUG_H_ 14 | #define _DEBUG_H_ 15 | 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | extern void mc_set_debug(int debug); 23 | extern int mc_get_debug(void); 24 | 25 | extern void mc_set_syslog(int syslog); 26 | 27 | extern void mc_debug(const char *msg, ...); 28 | extern void mc_error(const char *msg, ...); 29 | extern void mc_info(const char *msg, ...); 30 | 31 | #ifndef __STRING 32 | #define __STRING(x) #x 33 | #endif 34 | 35 | #ifndef PARSER_BROKEN_FIXED 36 | 37 | #define JASSERT(cond) do {} while(0) 38 | 39 | #else 40 | 41 | #define JASSERT(cond) do { \ 42 | if (!(cond)) { \ 43 | mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", __FILE__, __LINE__); \ 44 | *(int *)0 = 1;\ 45 | abort(); \ 46 | }\ 47 | } while(0) 48 | 49 | #endif 50 | 51 | #define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__) 52 | 53 | #ifdef MC_MAINTAINER_MODE 54 | #define MC_SET_DEBUG(x) mc_set_debug(x) 55 | #define MC_GET_DEBUG() mc_get_debug() 56 | #define MC_SET_SYSLOG(x) mc_set_syslog(x) 57 | #define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__) 58 | #define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__) 59 | #else 60 | #define MC_SET_DEBUG(x) if (0) mc_set_debug(x) 61 | #define MC_GET_DEBUG() (0) 62 | #define MC_SET_SYSLOG(x) if (0) mc_set_syslog(x) 63 | #define MC_DEBUG(x, ...) if (0) mc_debug(x, ##__VA_ARGS__) 64 | #define MC_INFO(x, ...) if (0) mc_info(x, ##__VA_ARGS__) 65 | #endif 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json-c-uninstalled.pc.in: -------------------------------------------------------------------------------- 1 | prefix= 2 | exec_prefix= 3 | libdir=@abs_top_builddir@ 4 | includedir=@abs_top_srcdir@ 5 | 6 | Name: json 7 | Description: JSON implementation in C 8 | Version: @VERSION@ 9 | Requires: 10 | Libs: -L@abs_top_builddir@ -ljson-c 11 | Cflags: -I@abs_top_srcdir@ 12 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json-c.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: json-c 7 | Description: A JSON implementation in C 8 | Version: @VERSION@ 9 | Requires: 10 | Libs.private: @LIBS@ 11 | Libs: -L${libdir} -ljson-c 12 | Cflags: -I${includedir}/json-c 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $ 3 | * 4 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 5 | * Michael Clark 6 | * Copyright (c) 2009 Hewlett-Packard Development Company, L.P. 7 | * 8 | * This library is free software; you can redistribute it and/or modify 9 | * it under the terms of the MIT license. See COPYING for details. 10 | * 11 | */ 12 | 13 | #ifndef _json_h_ 14 | #define _json_h_ 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #include "debug.h" 21 | #include "linkhash.h" 22 | #include "arraylist.h" 23 | #include "json_util.h" 24 | #include "json_object.h" 25 | #include "json_pointer.h" 26 | #include "json_tokener.h" 27 | #include "json_object_iterator.h" 28 | #include "json_c_version.h" 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json_c_version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Eric Haszlakiewicz 3 | * 4 | * This library is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See COPYING for details. 6 | */ 7 | 8 | #include "json_c_version.h" 9 | 10 | const char *json_c_version(void) 11 | { 12 | return JSON_C_VERSION; 13 | } 14 | 15 | int json_c_version_num(void) 16 | { 17 | return JSON_C_VERSION_NUM; 18 | } 19 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json_c_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Eric Haszlakiewicz 3 | * 4 | * This library is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See COPYING for details. 6 | */ 7 | 8 | #ifndef _json_c_version_h_ 9 | #define _json_c_version_h_ 10 | 11 | #define JSON_C_MAJOR_VERSION 0 12 | #define JSON_C_MINOR_VERSION 12 13 | #define JSON_C_MICRO_VERSION 99 14 | #define JSON_C_VERSION_NUM ((JSON_C_MAJOR_VERSION << 16) | \ 15 | (JSON_C_MINOR_VERSION << 8) | \ 16 | JSON_C_MICRO_VERSION) 17 | #define JSON_C_VERSION "0.12.99" 18 | 19 | const char *json_c_version(void); /* Returns JSON_C_VERSION */ 20 | int json_c_version_num(void); /* Returns JSON_C_VERSION_NUM */ 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json_config.h: -------------------------------------------------------------------------------- 1 | /* tests/third_party/json-c/json_config.h. Generated from json_config.h.in by configure. */ 2 | 3 | /* Define to 1 if you have the header file. */ 4 | #define JSON_C_HAVE_INTTYPES_H 1 5 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json_config.h.in: -------------------------------------------------------------------------------- 1 | 2 | /* Define to 1 if you have the header file. */ 3 | #undef JSON_C_HAVE_INTTYPES_H 4 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json_config.h.win32: -------------------------------------------------------------------------------- 1 | 2 | /* Define to 1 if you have the header file. */ 3 | #if defined(_MSC_VER) && _MSC_VER >= 1800 4 | #define JSON_C_HAVE_INTTYPES_H 1 5 | #endif 6 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json_inttypes.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _json_inttypes_h_ 3 | #define _json_inttypes_h_ 4 | 5 | #include "json_config.h" 6 | 7 | #ifdef JSON_C_HAVE_INTTYPES_H 8 | /* inttypes.h includes stdint.h */ 9 | #include 10 | 11 | #else 12 | #include 13 | 14 | #define PRId64 "I64d" 15 | #define SCNd64 "I64d" 16 | 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /tests/third_party/json-c/json_object_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: json_object_private.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ 3 | * 4 | * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. 5 | * Michael Clark 6 | * 7 | * This library is free software; you can redistribute it and/or modify 8 | * it under the terms of the MIT license. See COPYING for details. 9 | * 10 | */ 11 | 12 | #ifndef _json_object_private_h_ 13 | #define _json_object_private_h_ 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #define LEN_DIRECT_STRING_DATA 32 /**< how many bytes are directly stored in json_object for strings? */ 20 | 21 | typedef void (json_object_private_delete_fn)(struct json_object *o); 22 | 23 | struct json_object 24 | { 25 | enum json_type o_type; 26 | json_object_private_delete_fn *_delete; 27 | json_object_to_json_string_fn *_to_json_string; 28 | int _ref_count; 29 | struct printbuf *_pb; 30 | union data { 31 | json_bool c_boolean; 32 | double c_double; 33 | int64_t c_int64; 34 | struct lh_table *c_object; 35 | struct array_list *c_array; 36 | struct { 37 | union { 38 | /* optimize: if we have small strings, we can store them 39 | * directly. This saves considerable CPU cycles AND memory. 40 | */ 41 | char *ptr; 42 | char data[LEN_DIRECT_STRING_DATA]; 43 | } str; 44 | int len; 45 | } c_string; 46 | } o; 47 | json_object_delete_fn *_user_delete; 48 | void *_userdata; 49 | }; 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /tests/third_party/json-c/libjson.c: -------------------------------------------------------------------------------- 1 | 2 | /* dummy source file for compatibility purposes */ 3 | 4 | #if defined(HAVE_CDEFS_H) 5 | #include 6 | #endif 7 | 8 | #ifndef __warn_references 9 | 10 | #if defined(__GNUC__) && defined (HAS_GNU_WARNING_LONG) 11 | 12 | #define __warn_references(sym,msg) \ 13 | __asm__(".section .gnu" #sym ",\n\t.ascii \"" msg "\"\n\t.text"); 14 | 15 | #else 16 | #define __warn_references(sym,msg) /* nothing */ 17 | #endif 18 | 19 | #endif 20 | 21 | #include "json_object.h" 22 | 23 | __warn_references(json_object_get, "Warning: please link against libjson-c instead of libjson"); 24 | 25 | /* __asm__(".section .gnu.warning." __STRING(sym) \ 26 | " ; .ascii \"" msg "\" ; .text") */ 27 | -------------------------------------------------------------------------------- /tests/third_party/json-c/math_compat.h: -------------------------------------------------------------------------------- 1 | #ifndef __math_compat_h 2 | #define __math_compat_h 3 | 4 | /* Define isnan, isinf, infinity and nan on Windows/MSVC */ 5 | 6 | #ifndef HAVE_DECL_ISNAN 7 | # ifdef HAVE_DECL__ISNAN 8 | #include 9 | #define isnan(x) _isnan(x) 10 | # endif 11 | #endif 12 | 13 | #ifndef HAVE_DECL_ISINF 14 | # ifdef HAVE_DECL__FINITE 15 | #include 16 | #define isinf(x) (!_finite(x)) 17 | # endif 18 | #endif 19 | 20 | #ifndef HAVE_DECL_INFINITY 21 | #include 22 | #define INFINITY (DBL_MAX + DBL_MAX) 23 | #define HAVE_DECL_INFINITY 24 | #endif 25 | 26 | #ifndef HAVE_DECL_NAN 27 | #define NAN (INFINITY - INFINITY) 28 | #define HAVE_DECL_NAN 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /tests/third_party/json-c/random_seed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * random_seed.h 3 | * 4 | * Copyright (c) 2013 Metaparadigm Pte. Ltd. 5 | * Michael Clark 6 | * 7 | * This library is free software; you can redistribute it and/or modify 8 | * it under the terms of the MIT license. See COPYING for details. 9 | * 10 | */ 11 | 12 | #ifndef seed_h 13 | #define seed_h 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern int json_c_get_random_seed(); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tests/third_party/json-c/strdup_compat.h: -------------------------------------------------------------------------------- 1 | #ifndef __strdup_compat_h 2 | #define __strdup_compat_h 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests 3 | 4 | LDADD= $(LIBJSON_LA) 5 | 6 | LIBJSON_LA=$(top_builddir)/libjson-c.la 7 | 8 | TESTS= 9 | TESTS+= test_util_file.test 10 | TESTS+= test_float.test 11 | TESTS+= test1.test 12 | TESTS+= test2.test 13 | TESTS+= test4.test 14 | TESTS+= testReplaceExisting.test 15 | TESTS+= test_parse_int64.test 16 | TESTS+= test_null.test 17 | TESTS+= test_cast.test 18 | TESTS+= test_double_serializer.test 19 | TESTS+= test_parse.test 20 | TESTS+= test_locale.test 21 | TESTS+= test_charcase.test 22 | TESTS+= test_printbuf.test 23 | TESTS+= test_set_serializer.test 24 | TESTS+= test_compare.test 25 | TESTS+= test_set_value.test 26 | TESTS+= test_visit.test 27 | TESTS+= test_json_pointer.test 28 | 29 | check_PROGRAMS= 30 | check_PROGRAMS += $(TESTS:.test=) 31 | 32 | EXTRA_DIST= 33 | EXTRA_DIST += $(TESTS) 34 | EXTRA_DIST += $(TESTS:.test=.expected) 35 | EXTRA_DIST += test-defs.sh 36 | EXTRA_DIST += valid.json 37 | 38 | 39 | # Note: handled by test1.test 40 | check_PROGRAMS += test1Formatted 41 | test1Formatted_SOURCES = test1.c parse_flags.c parse_flags.h 42 | test1Formatted_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_FORMATTED 43 | EXTRA_DIST+= test1Formatted_plain.expected 44 | EXTRA_DIST+= test1Formatted_pretty.expected 45 | EXTRA_DIST+= test1Formatted_spaced.expected 46 | 47 | # Note: handled by test2.test 48 | check_PROGRAMS += test2Formatted 49 | test2Formatted_SOURCES = test2.c parse_flags.c parse_flags.h 50 | test2Formatted_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_FORMATTED 51 | EXTRA_DIST+= test2Formatted_plain.expected 52 | EXTRA_DIST+= test2Formatted_pretty.expected 53 | EXTRA_DIST+= test2Formatted_spaced.expected 54 | 55 | test_util_file_SOURCES = test_util_file.c strerror_override.c 56 | 57 | testsubdir=testSubDir 58 | TESTS_ENVIRONMENT = top_builddir=$(top_builddir) 59 | 60 | distclean-local: 61 | -rm -rf $(testsubdir) 62 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/parse_flags.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "json.h" 7 | #include "parse_flags.h" 8 | 9 | #if !defined(HAVE_STRCASECMP) && defined(_MSC_VER) 10 | # define strcasecmp _stricmp 11 | #elif !defined(HAVE_STRCASECMP) 12 | # error You do not have strcasecmp on your system. 13 | #endif /* HAVE_STRNCASECMP */ 14 | 15 | static struct { 16 | const char *arg; 17 | int flag; 18 | } format_args[] = { 19 | { "plain", JSON_C_TO_STRING_PLAIN }, 20 | { "spaced", JSON_C_TO_STRING_SPACED }, 21 | { "pretty", JSON_C_TO_STRING_PRETTY }, 22 | }; 23 | 24 | #ifndef NELEM 25 | #define NELEM(x) (sizeof(x) / sizeof(&x[0])) 26 | #endif 27 | 28 | int parse_flags(int argc, char **argv) 29 | { 30 | int arg_idx; 31 | int sflags = 0; 32 | for (arg_idx = 1; arg_idx < argc ; arg_idx++) 33 | { 34 | int jj; 35 | for (jj = 0; jj < (int)NELEM(format_args); jj++) 36 | { 37 | if (strcasecmp(argv[arg_idx], format_args[jj].arg) == 0) 38 | { 39 | sflags |= format_args[jj].flag; 40 | break; 41 | } 42 | } 43 | if (jj == NELEM(format_args)) 44 | { 45 | printf("Unknown arg: %s\n", argv[arg_idx]); 46 | exit(1); 47 | } 48 | } 49 | return sflags; 50 | } 51 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/parse_flags.h: -------------------------------------------------------------------------------- 1 | #ifndef __parse_flags_h 2 | #define __parse_flags_h 3 | int parse_flags(int argc, char **argv); 4 | #endif 5 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/strerror_override.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * Override strerror() to get consistent output across platforms. 5 | */ 6 | 7 | static struct { 8 | int errno_value; 9 | const char *errno_str; 10 | } errno_list[] = { 11 | #define STRINGIFY(x) #x 12 | #define ENTRY(x) {x, &STRINGIFY(undef_ ## x)[6]} 13 | ENTRY(EPERM), 14 | ENTRY(ENOENT), 15 | ENTRY(ESRCH), 16 | ENTRY(EINTR), 17 | ENTRY(EIO), 18 | ENTRY(ENXIO), 19 | ENTRY(E2BIG), 20 | ENTRY(ENOEXEC), 21 | ENTRY(EBADF), 22 | ENTRY(ECHILD), 23 | ENTRY(EDEADLK), 24 | ENTRY(ENOMEM), 25 | ENTRY(EACCES), 26 | ENTRY(EFAULT), 27 | ENTRY(ENOTBLK), 28 | ENTRY(EBUSY), 29 | ENTRY(EEXIST), 30 | ENTRY(EXDEV), 31 | ENTRY(ENODEV), 32 | ENTRY(ENOTDIR), 33 | ENTRY(EISDIR), 34 | ENTRY(EINVAL), 35 | ENTRY(ENFILE), 36 | ENTRY(EMFILE), 37 | ENTRY(ENOTTY), 38 | ENTRY(ETXTBSY), 39 | ENTRY(EFBIG), 40 | ENTRY(ENOSPC), 41 | ENTRY(ESPIPE), 42 | ENTRY(EROFS), 43 | ENTRY(EMLINK), 44 | ENTRY(EPIPE), 45 | ENTRY(EDOM), 46 | ENTRY(ERANGE), 47 | ENTRY(EAGAIN), 48 | { 0, (char *)0 } 49 | }; 50 | 51 | #define PREFIX "ERRNO=" 52 | static char errno_buf[128] = PREFIX; 53 | char *strerror(int errno_in) 54 | { 55 | int start_idx; 56 | char digbuf[20]; 57 | int ii, jj; 58 | 59 | // Avoid standard functions, so we don't need to include any 60 | // headers, or guess at signatures. 61 | 62 | for (ii = 0; errno_list[ii].errno_str != (char *)0; ii++) 63 | { 64 | const char *errno_str = errno_list[ii].errno_str; 65 | if (errno_list[ii].errno_value != errno_in) 66 | continue; 67 | 68 | for (start_idx = sizeof(PREFIX) - 1, jj = 0; errno_str[jj] != '\0'; jj++, start_idx++) 69 | { 70 | errno_buf[start_idx] = errno_str[jj]; 71 | } 72 | errno_buf[start_idx] = '\0'; 73 | return errno_buf; 74 | } 75 | 76 | // It's not one of the known errno values, return the numeric value. 77 | for (ii = 0; errno_in > 10; errno_in /= 10, ii++) 78 | { 79 | digbuf[ii] = "0123456789"[(errno_in % 10)]; 80 | } 81 | digbuf[ii] = "0123456789"[(errno_in % 10)]; 82 | 83 | // Reverse the digits 84 | for (start_idx = sizeof(PREFIX) - 1 ; ii >= 0; ii--, start_idx++) 85 | { 86 | errno_buf[start_idx] = digbuf[ii]; 87 | } 88 | return errno_buf; 89 | } 90 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test1.expected: -------------------------------------------------------------------------------- 1 | my_string= 2 | my_string.to_string()="\t" 3 | my_string=\ 4 | my_string.to_string()="\\" 5 | my_string=/ 6 | my_string.to_string()="\/" 7 | my_string.to_string(NOSLASHESCAPE)="/" 8 | my_string=/foo/bar/baz 9 | my_string.to_string()="\/foo\/bar\/baz" 10 | my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz" 11 | my_string=foo 12 | my_string.to_string()="foo" 13 | my_int=9 14 | my_int.to_string()=9 15 | my_array= 16 | [0]=1 17 | [1]=2 18 | [2]=3 19 | [3]=null 20 | [4]=5 21 | my_array.to_string()=[ 1, 2, 3, null, 5 ] 22 | my_array= 23 | [0]=1 24 | [1]=2 25 | [2]=3 26 | [3]=4 27 | [4]=5 28 | [5]=null 29 | [6]=7 30 | my_array.to_string()=[ 1, 2, 3, 4, 5, null, 7 ] 31 | after del_idx(0,1)=0, my_array.to_string()=[ 2, 3, 4, 5, null, 7 ] 32 | after del_idx(0,1)=0, my_array.to_string()=[ 3, 4, 5, null, 7 ] 33 | after del_idx(0,1)=0, my_array.to_string()=[ 4, 5, null, 7 ] 34 | after del_idx(0,1)=0, my_array.to_string()=[ 5, null, 7 ] 35 | after del_idx(0,1)=0, my_array.to_string()=[ null, 7 ] 36 | after del_idx(0,1)=0, my_array.to_string()=[ 7 ] 37 | after del_idx(0,1)=0, my_array.to_string()=[ ] 38 | after del_idx(0,1)=-1, my_array.to_string()=[ ] 39 | after del_idx(0,7)=0, my_array.to_string()=[ ] 40 | after del_idx(0,8)=-1, my_array.to_string()=[ 1, 2, 3, 4, 5, null, 7 ] 41 | my_array= 42 | [0]=3 43 | [1]=1 44 | [2]=2 45 | [3]=null 46 | [4]=0 47 | my_array.to_string()=[ 3, 1, 2, null, 0 ] 48 | my_array= 49 | [0]=null 50 | [1]=0 51 | [2]=1 52 | [3]=2 53 | [4]=3 54 | my_array.to_string()=[ null, 0, 1, 2, 3 ] 55 | baz_obj.to_string()="fark" 56 | my_object= 57 | abc: 12 58 | foo: "bar" 59 | bool0: false 60 | bool1: true 61 | my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true } 62 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test1.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test1 12 | _err=$? 13 | 14 | for flag in plain spaced pretty ; do 15 | run_output_test -o test1Formatted_${flag} test1Formatted ${flag} 16 | _err2=$? 17 | if [ $_err -eq 0 ] ; then 18 | _err=$_err2 19 | fi 20 | done 21 | 22 | exit $_err 23 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test1Formatted_plain.expected: -------------------------------------------------------------------------------- 1 | my_string= 2 | my_string.to_string()="\t" 3 | my_string=\ 4 | my_string.to_string()="\\" 5 | my_string=/ 6 | my_string.to_string()="\/" 7 | my_string.to_string(NOSLASHESCAPE)="/" 8 | my_string=/foo/bar/baz 9 | my_string.to_string()="\/foo\/bar\/baz" 10 | my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz" 11 | my_string=foo 12 | my_string.to_string()="foo" 13 | my_int=9 14 | my_int.to_string()=9 15 | my_array= 16 | [0]=1 17 | [1]=2 18 | [2]=3 19 | [3]=null 20 | [4]=5 21 | my_array.to_string()=[1,2,3,null,5] 22 | my_array= 23 | [0]=1 24 | [1]=2 25 | [2]=3 26 | [3]=4 27 | [4]=5 28 | [5]=null 29 | [6]=7 30 | my_array.to_string()=[1,2,3,4,5,null,7] 31 | after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7] 32 | after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7] 33 | after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7] 34 | after del_idx(0,1)=0, my_array.to_string()=[5,null,7] 35 | after del_idx(0,1)=0, my_array.to_string()=[null,7] 36 | after del_idx(0,1)=0, my_array.to_string()=[7] 37 | after del_idx(0,1)=0, my_array.to_string()=[] 38 | after del_idx(0,1)=-1, my_array.to_string()=[] 39 | after del_idx(0,7)=0, my_array.to_string()=[] 40 | after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7] 41 | my_array= 42 | [0]=3 43 | [1]=1 44 | [2]=2 45 | [3]=null 46 | [4]=0 47 | my_array.to_string()=[3,1,2,null,0] 48 | my_array= 49 | [0]=null 50 | [1]=0 51 | [2]=1 52 | [3]=2 53 | [4]=3 54 | my_array.to_string()=[null,0,1,2,3] 55 | baz_obj.to_string()="fark" 56 | my_object= 57 | abc: 12 58 | foo: "bar" 59 | bool0: false 60 | bool1: true 61 | my_object.to_string()={"abc":12,"foo":"bar","bool0":false,"bool1":true} 62 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test1Formatted_pretty.expected: -------------------------------------------------------------------------------- 1 | my_string= 2 | my_string.to_string()="\t" 3 | my_string=\ 4 | my_string.to_string()="\\" 5 | my_string=/ 6 | my_string.to_string()="\/" 7 | my_string.to_string(NOSLASHESCAPE)="/" 8 | my_string=/foo/bar/baz 9 | my_string.to_string()="\/foo\/bar\/baz" 10 | my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz" 11 | my_string=foo 12 | my_string.to_string()="foo" 13 | my_int=9 14 | my_int.to_string()=9 15 | my_array= 16 | [0]=1 17 | [1]=2 18 | [2]=3 19 | [3]=null 20 | [4]=5 21 | my_array.to_string()=[ 22 | 1, 23 | 2, 24 | 3, 25 | null, 26 | 5 27 | ] 28 | my_array= 29 | [0]=1 30 | [1]=2 31 | [2]=3 32 | [3]=4 33 | [4]=5 34 | [5]=null 35 | [6]=7 36 | my_array.to_string()=[1,2,3,4,5,null,7] 37 | after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7] 38 | after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7] 39 | after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7] 40 | after del_idx(0,1)=0, my_array.to_string()=[5,null,7] 41 | after del_idx(0,1)=0, my_array.to_string()=[null,7] 42 | after del_idx(0,1)=0, my_array.to_string()=[7] 43 | after del_idx(0,1)=0, my_array.to_string()=[] 44 | after del_idx(0,1)=-1, my_array.to_string()=[] 45 | after del_idx(0,7)=0, my_array.to_string()=[] 46 | after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7] 47 | my_array= 48 | [0]=3 49 | [1]=1 50 | [2]=2 51 | [3]=null 52 | [4]=0 53 | my_array.to_string()=[ 54 | 3, 55 | 1, 56 | 2, 57 | null, 58 | 0 59 | ] 60 | my_array= 61 | [0]=null 62 | [1]=0 63 | [2]=1 64 | [3]=2 65 | [4]=3 66 | my_array.to_string()=[ 67 | null, 68 | 0, 69 | 1, 70 | 2, 71 | 3 72 | ] 73 | baz_obj.to_string()="fark" 74 | my_object= 75 | abc: 12 76 | foo: "bar" 77 | bool0: false 78 | bool1: true 79 | my_object.to_string()={ 80 | "abc":12, 81 | "foo":"bar", 82 | "bool0":false, 83 | "bool1":true 84 | } 85 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test1Formatted_spaced.expected: -------------------------------------------------------------------------------- 1 | my_string= 2 | my_string.to_string()="\t" 3 | my_string=\ 4 | my_string.to_string()="\\" 5 | my_string=/ 6 | my_string.to_string()="\/" 7 | my_string.to_string(NOSLASHESCAPE)="/" 8 | my_string=/foo/bar/baz 9 | my_string.to_string()="\/foo\/bar\/baz" 10 | my_string.to_string(NOSLASHESCAPE)="/foo/bar/baz" 11 | my_string=foo 12 | my_string.to_string()="foo" 13 | my_int=9 14 | my_int.to_string()=9 15 | my_array= 16 | [0]=1 17 | [1]=2 18 | [2]=3 19 | [3]=null 20 | [4]=5 21 | my_array.to_string()=[ 1, 2, 3, null, 5 ] 22 | my_array= 23 | [0]=1 24 | [1]=2 25 | [2]=3 26 | [3]=4 27 | [4]=5 28 | [5]=null 29 | [6]=7 30 | my_array.to_string()=[1,2,3,4,5,null,7] 31 | after del_idx(0,1)=0, my_array.to_string()=[2,3,4,5,null,7] 32 | after del_idx(0,1)=0, my_array.to_string()=[3,4,5,null,7] 33 | after del_idx(0,1)=0, my_array.to_string()=[4,5,null,7] 34 | after del_idx(0,1)=0, my_array.to_string()=[5,null,7] 35 | after del_idx(0,1)=0, my_array.to_string()=[null,7] 36 | after del_idx(0,1)=0, my_array.to_string()=[7] 37 | after del_idx(0,1)=0, my_array.to_string()=[] 38 | after del_idx(0,1)=-1, my_array.to_string()=[] 39 | after del_idx(0,7)=0, my_array.to_string()=[] 40 | after del_idx(0,8)=-1, my_array.to_string()=[1,2,3,4,5,null,7] 41 | my_array= 42 | [0]=3 43 | [1]=1 44 | [2]=2 45 | [3]=null 46 | [4]=0 47 | my_array.to_string()=[ 3, 1, 2, null, 0 ] 48 | my_array= 49 | [0]=null 50 | [1]=0 51 | [2]=1 52 | [3]=2 53 | [4]=3 54 | my_array.to_string()=[ null, 0, 1, 2, 3 ] 55 | baz_obj.to_string()="fark" 56 | my_object= 57 | abc: 12 58 | foo: "bar" 59 | bool0: false 60 | bool1: true 61 | my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true } 62 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "json.h" 7 | #include "parse_flags.h" 8 | 9 | #ifdef TEST_FORMATTED 10 | #define json_object_to_json_string(obj) json_object_to_json_string_ext(obj,sflags) 11 | #else 12 | /* no special define */ 13 | #endif 14 | 15 | 16 | int main(int argc, char **argv) 17 | { 18 | json_object *new_obj; 19 | #ifdef TEST_FORMATTED 20 | int sflags = 0; 21 | #endif 22 | 23 | MC_SET_DEBUG(1); 24 | 25 | #ifdef TEST_FORMATTED 26 | sflags = parse_flags(argc, argv); 27 | #endif 28 | 29 | new_obj = json_tokener_parse("/* more difficult test case */" 30 | "{ \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", \"GlossList\": [ { \"ID\": \"SGML\", \"SortAs\": \"SGML\", \"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", \"Abbrev\": \"ISO 8879:1986\", \"GlossDef\": \"A meta-markup language, used to create markup languages such as DocBook.\", \"GlossSeeAlso\": [\"GML\", \"XML\", \"markup\"] } ] } } }"); 31 | printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); 32 | json_object_put(new_obj); 33 | 34 | return EXIT_SUCCESS; 35 | } 36 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test2.expected: -------------------------------------------------------------------------------- 1 | new_obj.to_string()={ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": [ "GML", "XML", "markup" ] } ] } } } 2 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test2.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test2 12 | _err=$? 13 | 14 | for flag in plain spaced pretty ; do 15 | run_output_test -o test2Formatted_${flag} test2Formatted ${flag} 16 | _err2=$? 17 | if [ $_err -eq 0 ] ; then 18 | _err=$_err2 19 | fi 20 | done 21 | 22 | exit $_err 23 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test2Formatted_plain.expected: -------------------------------------------------------------------------------- 1 | new_obj.to_string()={"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":[{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML","markup"]}]}}} 2 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test2Formatted_pretty.expected: -------------------------------------------------------------------------------- 1 | new_obj.to_string()={ 2 | "glossary":{ 3 | "title":"example glossary", 4 | "GlossDiv":{ 5 | "title":"S", 6 | "GlossList":[ 7 | { 8 | "ID":"SGML", 9 | "SortAs":"SGML", 10 | "GlossTerm":"Standard Generalized Markup Language", 11 | "Acronym":"SGML", 12 | "Abbrev":"ISO 8879:1986", 13 | "GlossDef":"A meta-markup language, used to create markup languages such as DocBook.", 14 | "GlossSeeAlso":[ 15 | "GML", 16 | "XML", 17 | "markup" 18 | ] 19 | } 20 | ] 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test2Formatted_spaced.expected: -------------------------------------------------------------------------------- 1 | new_obj.to_string()={ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": [ "GML", "XML", "markup" ] } ] } } } 2 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gcc -o utf8 utf8.c -I/home/y/include -L./.libs -ljson 3 | */ 4 | 5 | #include 6 | #include 7 | #include "config.h" 8 | 9 | #include "json_inttypes.h" 10 | #include "json_object.h" 11 | #include "json_tokener.h" 12 | 13 | void print_hex(const char* s) 14 | { 15 | const char *iter = s; 16 | unsigned char ch; 17 | while ((ch = *iter++) != 0) 18 | { 19 | if( ',' != ch) 20 | printf("%x ", ch); 21 | else 22 | printf( ","); 23 | } 24 | putchar('\n'); 25 | } 26 | 27 | int main(void) 28 | { 29 | const char *input = "\"\\ud840\\udd26,\\ud840\\udd27,\\ud800\\udd26,\\ud800\\udd27\""; 30 | const char *expected = "\xF0\xA0\x84\xA6,\xF0\xA0\x84\xA7,\xF0\x90\x84\xA6,\xF0\x90\x84\xA7"; 31 | struct json_object *parse_result = json_tokener_parse(input); 32 | const char *unjson = json_object_get_string(parse_result); 33 | 34 | printf("input: %s\n", input); 35 | 36 | int strings_match = !strcmp( expected, unjson); 37 | int retval = 0; 38 | if (strings_match) 39 | { 40 | printf("JSON parse result is correct: %s\n", unjson); 41 | puts("PASS"); 42 | } else { 43 | printf("JSON parse result doesn't match expected string\n"); 44 | printf("expected string bytes: "); 45 | print_hex(expected); 46 | printf("parsed string bytes: "); 47 | print_hex(unjson); 48 | puts("FAIL"); 49 | retval = 1; 50 | } 51 | json_object_put(parse_result); 52 | return retval; 53 | } 54 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test4.expected: -------------------------------------------------------------------------------- 1 | input: "\ud840\udd26,\ud840\udd27,\ud800\udd26,\ud800\udd27" 2 | JSON parse result is correct: 𠄦,𠄧,𐄦,𐄧 3 | PASS 4 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test4.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test4 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/testReplaceExisting.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "json.h" 7 | 8 | int main(int argc, char **argv) 9 | { 10 | MC_SET_DEBUG(1); 11 | 12 | /* 13 | * Check that replacing an existing object keeps the key valid, 14 | * and that it keeps the order the same. 15 | */ 16 | json_object *my_object = json_object_new_object(); 17 | json_object_object_add(my_object, "foo1", json_object_new_string("bar1")); 18 | json_object_object_add(my_object, "foo2", json_object_new_string("bar2")); 19 | json_object_object_add(my_object, "deleteme", json_object_new_string("bar2")); 20 | json_object_object_add(my_object, "foo3", json_object_new_string("bar3")); 21 | 22 | printf("==== delete-in-loop test starting ====\n"); 23 | 24 | int orig_count = 0; 25 | json_object_object_foreach(my_object, key0, val0) 26 | { 27 | printf("Key at index %d is [%s] %d", orig_count, key0, (val0 == NULL)); 28 | if (strcmp(key0, "deleteme") == 0) 29 | { 30 | json_object_object_del(my_object, key0); 31 | printf(" (deleted)\n"); 32 | } 33 | else 34 | printf(" (kept)\n"); 35 | orig_count++; 36 | } 37 | 38 | printf("==== replace-value first loop starting ====\n"); 39 | 40 | const char *original_key = NULL; 41 | orig_count = 0; 42 | json_object_object_foreach(my_object, key, val) 43 | { 44 | printf("Key at index %d is [%s] %d\n", orig_count, key, (val == NULL)); 45 | orig_count++; 46 | if (strcmp(key, "foo2") != 0) 47 | continue; 48 | printf("replacing value for key [%s]\n", key); 49 | original_key = key; 50 | json_object_object_add(my_object, key, json_object_new_string("zzz")); 51 | } 52 | 53 | printf("==== second loop starting ====\n"); 54 | 55 | int new_count = 0; 56 | int retval = 0; 57 | json_object_object_foreach(my_object, key2, val2) 58 | { 59 | printf("Key at index %d is [%s] %d\n", new_count, key2, (val2 == NULL)); 60 | new_count++; 61 | if (strcmp(key2, "foo2") != 0) 62 | continue; 63 | printf("pointer for key [%s] does %smatch\n", key2, 64 | (key2 == original_key) ? "" : "NOT "); 65 | if (key2 != original_key) 66 | retval = 1; 67 | } 68 | if (new_count != orig_count) 69 | { 70 | printf("mismatch between original count (%d) and new count (%d)\n", 71 | orig_count, new_count); 72 | retval = 1; 73 | } 74 | 75 | json_object_put( my_object ); 76 | 77 | return retval; 78 | } 79 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/testReplaceExisting.expected: -------------------------------------------------------------------------------- 1 | ==== delete-in-loop test starting ==== 2 | Key at index 0 is [foo1] 0 (kept) 3 | Key at index 1 is [foo2] 0 (kept) 4 | Key at index 2 is [deleteme] 0 (deleted) 5 | Key at index 3 is [foo3] 0 (kept) 6 | ==== replace-value first loop starting ==== 7 | Key at index 0 is [foo1] 0 8 | Key at index 1 is [foo2] 0 9 | replacing value for key [foo2] 10 | Key at index 2 is [foo3] 0 11 | ==== second loop starting ==== 12 | Key at index 0 is [foo1] 0 13 | Key at index 1 is [foo2] 0 14 | pointer for key [foo2] does match 15 | Key at index 2 is [foo3] 0 16 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/testReplaceExisting.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test testReplaceExisting 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_cast.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_cast 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_charcase.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "json.h" 8 | #include "json_tokener.h" 9 | 10 | static void test_case_parse(void); 11 | 12 | int main(int argc, char **argv) 13 | { 14 | MC_SET_DEBUG(1); 15 | 16 | test_case_parse(); 17 | } 18 | 19 | /* make sure only lowercase forms are parsed in strict mode */ 20 | static void test_case_parse() 21 | { 22 | struct json_tokener *tok; 23 | json_object *new_obj; 24 | 25 | tok = json_tokener_new(); 26 | json_tokener_set_flags(tok, JSON_TOKENER_STRICT); 27 | 28 | new_obj = json_tokener_parse_ex(tok, "True", 4); 29 | assert (new_obj == NULL); 30 | 31 | new_obj = json_tokener_parse_ex(tok, "False", 5); 32 | assert (new_obj == NULL); 33 | 34 | new_obj = json_tokener_parse_ex(tok, "Null", 4); 35 | assert (new_obj == NULL); 36 | 37 | printf("OK\n"); 38 | 39 | json_tokener_free(tok); 40 | } 41 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_charcase.expected: -------------------------------------------------------------------------------- 1 | OK 2 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_charcase.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_charcase 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_compare.expected: -------------------------------------------------------------------------------- 1 | JSON integer comparision is correct 2 | JSON same object comparision is correct 3 | JSON same integer comparision is correct 4 | Comparing equal strings is correct 5 | Comparing different strings is correct 6 | Comparing equal doubles is correct 7 | Comparing different doubles is correct 8 | Comparing equal arrays is correct 9 | Comparing arrays of different len is correct 10 | Comparing different arrays is correct 11 | Comparing different arrays (one empty) is correct 12 | Comparing JSON object with different key order is correct 13 | Comparing different objects is correct 14 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_compare.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_compare 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_double_serializer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tests if the format string for double serialization is handled correctly 3 | */ 4 | 5 | #include 6 | #include "config.h" 7 | 8 | #include "json_object.h" 9 | #include "json_object_private.h" 10 | 11 | int main() 12 | { 13 | struct json_object *obj = json_object_new_double(0.5); 14 | 15 | printf("Test default serializer:\n"); 16 | printf("obj.to_string(standard)=%s\n", json_object_to_json_string(obj)); 17 | 18 | printf("Test default serializer with custom userdata:\n"); 19 | obj->_userdata = "test"; 20 | printf("obj.to_string(userdata)=%s\n", json_object_to_json_string(obj)); 21 | 22 | printf("Test explicit serializer with custom userdata:\n"); 23 | json_object_set_serializer(obj, json_object_double_to_json_string, "test", NULL); 24 | printf("obj.to_string(custom)=%s\n", json_object_to_json_string(obj)); 25 | 26 | printf("Test reset serializer:\n"); 27 | json_object_set_serializer(obj, NULL, NULL, NULL); 28 | printf("obj.to_string(reset)=%s\n", json_object_to_json_string(obj)); 29 | 30 | json_object_put(obj); 31 | } 32 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_double_serializer.expected: -------------------------------------------------------------------------------- 1 | Test default serializer: 2 | obj.to_string(standard)=0.5 3 | Test default serializer with custom userdata: 4 | obj.to_string(userdata)=0.5 5 | Test explicit serializer with custom userdata: 6 | obj.to_string(custom)=test 7 | Test reset serializer: 8 | obj.to_string(reset)=0.5 9 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_double_serializer.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_double_serializer 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_float.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2016 by Rainer Gerhards 2 | * Released under ASL 2.0 */ 3 | #include "config.h" 4 | #include 5 | #include "../json_object.h" 6 | #include "../json_tokener.h" 7 | int main(void) 8 | { 9 | json_object *json; 10 | 11 | json = json_object_new_double(1.0); 12 | printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); 13 | json_object_put(json); 14 | json = json_object_new_double(1.23); 15 | printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); 16 | json_object_put(json); 17 | json = json_object_new_double(123456789.0); 18 | printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); 19 | json_object_put(json); 20 | json = json_object_new_double(123456789.123); 21 | printf("json = %s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); 22 | json_object_put(json); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_float.expected: -------------------------------------------------------------------------------- 1 | json = 1.0 2 | json = 1.23 3 | json = 123456789.0 4 | json = 123456789.123 5 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_float.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_float 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_json_pointer.expected: -------------------------------------------------------------------------------- 1 | PASSED - GET - LOADED TEST JSON 2 | { "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 } 3 | PASSED - GET - ENTIRE OBJECT WORKED 4 | PASSED - GET - /foo == ['bar', 'baz'] 5 | PASSED - GET - /foo/0 == 'bar' 6 | PASSED - GET - / == 0 7 | PASSED - GET - /a~1b == 1 8 | PASSED - GET - /c%d == 2 9 | PASSED - GET - /e^f == 3 10 | PASSED - GET - /g|h == 4 11 | PASSED - GET - /i\j == 5 12 | PASSED - GET - /k"l == 6 13 | PASSED - GET - / == 7 14 | PASSED - GET - /m~0n == 8 15 | { "arr": [ { "obj": [ { }, { }, { "obj1": 0, "obj2": "1" } ] } ], "obj": { "obj": { "obj": [ { "obj1": 0, "obj2": "1" } ] } } } 16 | PASSED - GET - RECURSION TEST 17 | PASSED - GET - LOADED TEST JSON 18 | { "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 } 19 | PASSED - GET - MISSING / 20 | PASSED - GET - NULL INPUTS 21 | PASSED - GET - INVALID INDEXES 22 | PASSED - SET - LOADED TEST JSON 23 | { "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 } 24 | PASSED - SET - 'cod' in /foo/1 25 | PASSED - SET - non-existing /fud/gaw 26 | PASSED - SET - /fud == {} 27 | PASSED - SET - /fug/gaw == [1,2,3] 28 | PASSED - SET - /fug/gaw == [0,2,3] 29 | PASSED - SET - /fug/gaw == [0,2,3,4] 30 | PASSED - SET - / == 9 31 | PASSED - SET - Final JSON is: { "foo": [ "bar", "cod" ], "": 9, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8, "fud": { "gaw": [ 0, 2, 3, 4 ] } } 32 | 10 33 | PASSED - SET - LOADED TEST JSON 34 | { "foo": [ "bar", "baz" ], "": 0, "a\/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 } 35 | PASSED - SET - failed 'cod' with path 'foo/bar' 36 | PASSED - SET - failed to set index to non-array 37 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_json_pointer.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_json_pointer 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_locale.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "config.h" 8 | #include "json.h" 9 | #include "json_tokener.h" 10 | 11 | #ifdef HAVE_LOCALE_H 12 | #include 13 | #endif /* HAVE_LOCALE_H */ 14 | #ifdef HAVE_XLOCALE_H 15 | #include 16 | #endif 17 | 18 | int main(int argc, char **argv) 19 | { 20 | json_object *new_obj; 21 | #ifdef HAVE_SETLOCALE 22 | setlocale(LC_NUMERIC, "de_DE"); 23 | #else 24 | printf("No locale\n"); 25 | #endif 26 | 27 | char buf1[10], buf2[10]; 28 | // Should result in "0,1", if the locale is installed. 29 | // Regardless of what it generates, we check that it's 30 | // consistent below. 31 | (void)snprintf(buf1, sizeof(buf1), "%f", 0.1); 32 | 33 | MC_SET_DEBUG(1); 34 | 35 | new_obj = json_tokener_parse("[1.2,3.4,123456.78,5.0,2.3e10]"); 36 | 37 | (void)snprintf(buf2, sizeof(buf2), "%f", 0.1); 38 | if (strcmp(buf1, buf2) != 0) 39 | printf("ERROR: Original locale not restored \"%s\" != \"%s\"", 40 | buf1, buf2); 41 | 42 | #ifdef HAVE_SETLOCALE 43 | setlocale(LC_NUMERIC, "C"); 44 | #endif 45 | 46 | // Explicitly print each value, to avoid having the "special" 47 | // serialization done for parsed doubles simply re-emit the original 48 | // string that was parsed. (see json_object_new_double_s()) 49 | printf("new_obj.to_string()=["); 50 | unsigned int ii; 51 | for (ii = 0 ; ii < json_object_array_length(new_obj); ii++) 52 | { 53 | json_object *val = json_object_array_get_idx(new_obj, ii); 54 | printf("%s%.2lf", (ii > 0) ? "," : "", json_object_get_double(val)); 55 | } 56 | printf("]\n"); 57 | 58 | printf("new_obj.to_string()=%s\n", json_object_to_json_string_ext(new_obj,JSON_C_TO_STRING_NOZERO)); 59 | json_object_put(new_obj); 60 | } 61 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_locale.expected: -------------------------------------------------------------------------------- 1 | new_obj.to_string()=[1.20,3.40,123456.78,5.00,23000000000.00] 2 | new_obj.to_string()=[1.2,3.4,123456.78,5.0,2.3e10] 3 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_locale.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_locale 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Tests if binary strings are supported. 3 | */ 4 | 5 | #include 6 | #include 7 | #include "config.h" 8 | 9 | #include "json_inttypes.h" 10 | #include "json_object.h" 11 | #include "json_tokener.h" 12 | 13 | int main(void) 14 | { 15 | /* this test has a space after the null character. check that it's still included */ 16 | const char *input = " \0 "; 17 | const char *expected = "\" \\u0000 \""; 18 | struct json_object *string = json_object_new_string_len(input, 3); 19 | const char *json = json_object_to_json_string(string); 20 | 21 | int strings_match = !strcmp( expected, json); 22 | int retval = 0; 23 | if (strings_match) 24 | { 25 | printf("JSON write result is correct: %s\n", json); 26 | puts("PASS"); 27 | } else { 28 | puts("JSON write result doesn't match expected string"); 29 | printf("expected string: "); 30 | puts(expected); 31 | printf("parsed string: "); 32 | puts(json); 33 | puts("FAIL"); 34 | retval=1; 35 | } 36 | json_object_put(string); 37 | 38 | struct json_object *parsed_str = json_tokener_parse(expected); 39 | if (parsed_str) 40 | { 41 | int parsed_len = json_object_get_string_len(parsed_str); 42 | const char *parsed_cstr = json_object_get_string(parsed_str); 43 | int ii; 44 | printf("Re-parsed object string len=%d, chars=[", parsed_len); 45 | for (ii = 0; ii < parsed_len ; ii++) 46 | { 47 | printf("%s%d", (ii ? ", " : ""), (int)parsed_cstr[ii]); 48 | } 49 | puts("]"); 50 | json_object_put(parsed_str); 51 | } 52 | else 53 | { 54 | puts("ERROR: failed to parse"); 55 | } 56 | return retval; 57 | } 58 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_null.expected: -------------------------------------------------------------------------------- 1 | JSON write result is correct: " \u0000 " 2 | PASS 3 | Re-parsed object string len=3, chars=[32, 0, 32] 4 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_null.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_null 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_parse.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_parse 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_parse_int64.expected: -------------------------------------------------------------------------------- 1 | buf=x parseit=1, value=-666 2 | buf=0 parseit=0, value=0 3 | buf=-0 parseit=0, value=0 4 | buf=00000000 parseit=0, value=0 5 | buf=-00000000 parseit=0, value=0 6 | buf=1 parseit=0, value=1 7 | buf=2147483647 parseit=0, value=2147483647 8 | buf=-1 parseit=0, value=-1 9 | buf= -1 parseit=0, value=-1 10 | buf=00001234 parseit=0, value=1234 11 | buf=0001234x parseit=0, value=1234 12 | buf=-00001234 parseit=0, value=-1234 13 | buf=-00001234x parseit=0, value=-1234 14 | buf=21474836470 parseit=0, value=21474836470 15 | buf=31474836470 parseit=0, value=31474836470 16 | buf=-2147483647 parseit=0, value=-2147483647 17 | buf=-2147483648 parseit=0, value=-2147483648 18 | buf=-2147483649 parseit=0, value=-2147483649 19 | buf=-21474836480 parseit=0, value=-21474836480 20 | buf=9223372036854775806 parseit=0, value=9223372036854775806 21 | buf=9223372036854775807 parseit=0, value=9223372036854775807 22 | buf=9223372036854775808 parseit=0, value=9223372036854775807 23 | buf=-9223372036854775808 parseit=0, value=-9223372036854775808 24 | buf=-9223372036854775809 parseit=0, value=-9223372036854775808 25 | buf=18446744073709551614 parseit=0, value=9223372036854775807 26 | buf=18446744073709551615 parseit=0, value=9223372036854775807 27 | buf=18446744073709551616 parseit=0, value=9223372036854775807 28 | buf=-18446744073709551616 parseit=0, value=-9223372036854775808 29 | buf=123 parseit=0, value=123 30 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_parse_int64.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_parse_int64 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_printbuf.expected: -------------------------------------------------------------------------------- 1 | test_basic_printbuf_memset: starting test 2 | Buffer contents:blue:1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 3 | test_basic_printbuf_memset: end test 4 | ======================================== 5 | test_printbuf_memset_length: starting test 6 | Buffer length: 0 7 | Buffer length: 12 8 | Buffer length: 18 9 | Buffer length: 76 10 | Buffer length: 76 11 | Buffer length: 77 12 | test_printbuf_memset_length: end test 13 | ======================================== 14 | test_printbuf_memappend: starting test 15 | Buffer length: 0 16 | Appended 32 bytes for resize: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] 17 | Partial append: 3, [blu] 18 | With embedded \0 character: 4, [ab] 19 | Append to just before resize: 31, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] 20 | Append to just after resize: 32, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] 21 | test_printbuf_memappend: end test 22 | ======================================== 23 | test_sprintbuf: starting test 24 | Buffer length: 0 25 | sprintbuf to just after resize(31+1): 32, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX], strlen(buf)=32 26 | 5, [plain] 27 | 6, [plain1] 28 | 16, [plain12147483647] 29 | 27, [plain12147483647-2147483648] 30 | 29, [plain12147483647-2147483648%s] 31 | test_sprintbuf: end test 32 | ======================================== 33 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_printbuf.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_printbuf 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_set_serializer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "json.h" 6 | #include "printbuf.h" 7 | 8 | struct myinfo { 9 | int value; 10 | }; 11 | 12 | static int freeit_was_called = 0; 13 | static void freeit(json_object *jso, void *userdata) 14 | { 15 | struct myinfo *info = userdata; 16 | printf("freeit, value=%d\n", info->value); 17 | // Don't actually free anything here, the userdata is stack allocated. 18 | freeit_was_called = 1; 19 | } 20 | static int custom_serializer(struct json_object *o, 21 | struct printbuf *pb, 22 | int level, 23 | int flags) 24 | { 25 | sprintbuf(pb, "Custom Output"); 26 | return 0; 27 | } 28 | 29 | int main(int argc, char **argv) 30 | { 31 | json_object *my_object; 32 | 33 | MC_SET_DEBUG(1); 34 | 35 | printf("Test setting, then resetting a custom serializer:\n"); 36 | my_object = json_object_new_object(); 37 | json_object_object_add(my_object, "abc", json_object_new_int(12)); 38 | json_object_object_add(my_object, "foo", json_object_new_string("bar")); 39 | 40 | printf("my_object.to_string(standard)=%s\n", json_object_to_json_string(my_object)); 41 | 42 | struct myinfo userdata = { .value = 123 }; 43 | json_object_set_serializer(my_object, custom_serializer, &userdata, freeit); 44 | 45 | printf("my_object.to_string(custom serializer)=%s\n", json_object_to_json_string(my_object)); 46 | 47 | printf("Next line of output should be from the custom freeit function:\n"); 48 | freeit_was_called = 0; 49 | json_object_set_serializer(my_object, NULL, NULL, NULL); 50 | assert(freeit_was_called); 51 | 52 | printf("my_object.to_string(standard)=%s\n", json_object_to_json_string(my_object)); 53 | 54 | json_object_put(my_object); 55 | 56 | // ============================================ 57 | 58 | my_object = json_object_new_object(); 59 | printf("Check that the custom serializer isn't free'd until the last json_object_put:\n"); 60 | json_object_set_serializer(my_object, custom_serializer, &userdata, freeit); 61 | json_object_get(my_object); 62 | json_object_put(my_object); 63 | printf("my_object.to_string(custom serializer)=%s\n", json_object_to_json_string(my_object)); 64 | printf("Next line of output should be from the custom freeit function:\n"); 65 | 66 | freeit_was_called = 0; 67 | json_object_put(my_object); 68 | assert(freeit_was_called); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_set_serializer.expected: -------------------------------------------------------------------------------- 1 | Test setting, then resetting a custom serializer: 2 | my_object.to_string(standard)={ "abc": 12, "foo": "bar" } 3 | my_object.to_string(custom serializer)=Custom Output 4 | Next line of output should be from the custom freeit function: 5 | freeit, value=123 6 | my_object.to_string(standard)={ "abc": 12, "foo": "bar" } 7 | Check that the custom serializer isn't free'd until the last json_object_put: 8 | my_object.to_string(custom serializer)=Custom Output 9 | Next line of output should be from the custom freeit function: 10 | freeit, value=123 11 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_set_serializer.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_set_serializer 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_set_value.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "json.h" 6 | 7 | int main(int argc, char **argv) 8 | { 9 | json_object *tmp=json_object_new_int(123); 10 | assert (json_object_get_int(tmp)==123); 11 | json_object_set_int(tmp,321); 12 | assert (json_object_get_int(tmp)==321); 13 | printf("INT PASSED\n"); 14 | json_object_set_int64(tmp,(int64_t)321321321); 15 | assert (json_object_get_int64(tmp)==321321321); 16 | json_object_put(tmp); 17 | printf("INT64 PASSED\n"); 18 | tmp=json_object_new_boolean(TRUE); 19 | assert (json_object_get_boolean(tmp)==TRUE); 20 | json_object_set_boolean(tmp,FALSE); 21 | assert (json_object_get_boolean(tmp)==FALSE); 22 | json_object_set_boolean(tmp,TRUE); 23 | assert (json_object_get_boolean(tmp)==TRUE); 24 | json_object_put(tmp); 25 | printf("BOOL PASSED\n"); 26 | tmp=json_object_new_double(12.34); 27 | assert (json_object_get_double(tmp)==12.34); 28 | json_object_set_double(tmp,34.56); 29 | assert (json_object_get_double(tmp)==34.56); 30 | json_object_set_double(tmp,6435.34); 31 | assert (json_object_get_double(tmp)==6435.34); 32 | json_object_put(tmp); 33 | printf("DOUBLE PASSED\n"); 34 | #define SHORT "SHORT" 35 | #define MID "A MID STRING" 36 | // 12345678901234567890123456789012.... 37 | #define HUGE "A string longer than 32 chars as to check non local buf codepath" 38 | tmp=json_object_new_string(SHORT); 39 | assert (strcmp(json_object_get_string(tmp),SHORT)==0); 40 | json_object_set_string(tmp,MID); 41 | assert (strcmp(json_object_get_string(tmp),MID)==0); 42 | json_object_set_string(tmp,HUGE); 43 | assert (strcmp(json_object_get_string(tmp),HUGE)==0); 44 | json_object_set_string(tmp,SHORT); 45 | assert (strcmp(json_object_get_string(tmp),SHORT)==0); 46 | json_object_put(tmp); 47 | printf("STRING PASSED\n"); 48 | 49 | 50 | printf("PASSED\n"); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_set_value.expected: -------------------------------------------------------------------------------- 1 | INT PASSED 2 | INT64 PASSED 3 | BOOL PASSED 4 | DOUBLE PASSED 5 | STRING PASSED 6 | PASSED 7 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_set_value.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_set_value 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_util_file.expected: -------------------------------------------------------------------------------- 1 | OK: json_object_from_fd(./valid.json)={ "foo": 123 } 2 | OK: json_object_from_file(./not_present.json) correctly returned NULL: json_object_from_file: error opening file ./not_present.json: ERRNO=ENOENT 3 | 4 | OK: json_object_from_fd(closed_fd), expecting NULL, EBADF, got:0x0, json_object_from_fd: error reading fd 10: ERRNO=EBADF 5 | 6 | OK: json_object_to_file(json.out, jso)=0 7 | file[json.out], size=336, contents={"foo":1234,"foo1":"abcdefghijklmnopqrstuvwxyz","foo2":"abcdefghijklmnopqrstuvwxyz","foo3":"abcdefghijklmnopqrstuvwxyz","foo4":"abcdefghijklmnopqrstuvwxyz","foo5":"abcdefghijklmnopqrstuvwxyz","foo6":"abcdefghijklmnopqrstuvwxyz","foo7":"abcdefghijklmnopqrstuvwxyz","foo8":"abcdefghijklmnopqrstuvwxyz","foo9":"abcdefghijklmnopqrstuvwxyz"} 8 | 9 | OK: json_object_to_file_ext(json2.out, jso, JSON_C_TO_STRING_PRETTY)=0 10 | file[json2.out], size=367, contents={ 11 | "foo":1234, 12 | "foo1":"abcdefghijklmnopqrstuvwxyz", 13 | "foo2":"abcdefghijklmnopqrstuvwxyz", 14 | "foo3":"abcdefghijklmnopqrstuvwxyz", 15 | "foo4":"abcdefghijklmnopqrstuvwxyz", 16 | "foo5":"abcdefghijklmnopqrstuvwxyz", 17 | "foo6":"abcdefghijklmnopqrstuvwxyz", 18 | "foo7":"abcdefghijklmnopqrstuvwxyz", 19 | "foo8":"abcdefghijklmnopqrstuvwxyz", 20 | "foo9":"abcdefghijklmnopqrstuvwxyz" 21 | } 22 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_util_file.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | cp -f "$srcdir/valid.json" . 12 | run_output_test test_util_file "$srcdir" 13 | _err=$? 14 | 15 | exit $_err 16 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/test_visit.test: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Common definitions 4 | if test -z "$srcdir"; then 5 | srcdir="${0%/*}" 6 | test "$srcdir" = "$0" && srcdir=. 7 | test -z "$srcdir" && srcdir=. 8 | fi 9 | . "$srcdir/test-defs.sh" 10 | 11 | run_output_test test_visit 12 | exit $? 13 | -------------------------------------------------------------------------------- /tests/third_party/json-c/tests/valid.json: -------------------------------------------------------------------------------- 1 | {"foo":123} 2 | -------------------------------------------------------------------------------- /tests/third_party/json-c/vasprintf_compat.h: -------------------------------------------------------------------------------- 1 | #ifndef __vasprintf_compat_h 2 | #define __vasprintf_compat_h 3 | 4 | #include 5 | 6 | #endif /* __vasprintf_compat_h */ 7 | -------------------------------------------------------------------------------- /tools/colorformatter/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Intel Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | bin_PROGRAMS = colorformatter 17 | 18 | AM_CPP_INCLUDES = -I$(top_srcdir) 19 | AM_CPPFLAGS = -std=c++11 -fPIC -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE 20 | AM_CPPFLAGS += $(AM_CPP_INCLUDES) $(CWARNFLAGS) $(DRM_CFLAGS) $(DEBUG_CFLAGS) -Wformat -Wformat-security 21 | 22 | colorformatter_CFLAGS = \ 23 | -O0 -g -lm \ 24 | $(AM_CPPFLAGS) 25 | 26 | colorformatter_SOURCES = \ 27 | colorformatter.cpp 28 | -------------------------------------------------------------------------------- /tools/colorformatter/README.md: -------------------------------------------------------------------------------- 1 | ## Build Color Formatter 2 | ``` 3 | cd path/to/colorformatter/ 4 | 5 | ./autogen.sh 6 | 7 | make 8 | ``` 9 | 10 | ## Generate Test Image 11 | The script will use ffmpeg to convert image media file to the original raw data which can be used by colorformatter 12 | to convert the final test image files. 13 | 14 | ``` 15 | sudo apt-get install ffmpeg 16 | 17 | sh resources/commands.sh 18 | ``` 19 | -------------------------------------------------------------------------------- /tools/colorformatter/autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Copyright (c) 2016 Intel Corporation 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | srcdir=`dirname $0` 18 | test -z "$srcdir" && srcdir=. 19 | 20 | ORIGDIR=`pwd` 21 | cd $srcdir 22 | 23 | mkdir -p m4 24 | 25 | if ! type gtkdocize > /dev/null 2>&1; then 26 | echo "EXTRA_DIST =" > gtk-doc.make 27 | echo "CLEANFILES =" >> gtk-doc.make 28 | else 29 | gtkdocize || exit $? 30 | fi 31 | 32 | autoreconf -v --install || exit 1 33 | cd $ORIGDIR || exit $? 34 | 35 | if test -z "$NOCONFIGURE"; then 36 | $srcdir/configure "$@" 37 | fi 38 | -------------------------------------------------------------------------------- /tools/colorformatter/configure.ac: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Intel Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | AC_PREREQ([2.64]) 17 | AC_INIT([colorformatter], 18 | [0.01], 19 | [https://github.com/intel/IA-Hardware-Composer/tools/colorformatter], 20 | [colorformatter]) 21 | 22 | AC_CONFIG_SRCDIR([Makefile.am]) 23 | AC_CONFIG_HEADERS([config.h]) 24 | AC_CONFIG_MACRO_DIR([m4]) 25 | AC_USE_SYSTEM_EXTENSIONS 26 | AC_SYS_LARGEFILE 27 | AC_GNU_SOURCE 28 | AC_CANONICAL_HOST 29 | AC_CANONICAL_TARGET 30 | 31 | AM_INIT_AUTOMAKE([1.12 foreign subdir-objects dist-bzip2]) 32 | AM_PATH_PYTHON([3],, [:]) 33 | 34 | AC_PROG_CC 35 | AC_PROG_CXX 36 | 37 | AC_SUBST(ASSEMBLER_WARN_CFLAGS) 38 | 39 | AC_CONFIG_FILES([ 40 | Makefile 41 | ]) 42 | AC_OUTPUT 43 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.nv12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.nv12 -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.nv21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.nv21 -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.y16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.y16 -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.y8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.y8 -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.ycbcr_422_888: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.ycbcr_422_888 -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.ycbcr_422_sp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.ycbcr_422_sp -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.ycbcr_444_888: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.ycbcr_444_888 -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.yuv420p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.yuv420p -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.yuv420p16le: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.yuv420p16le -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.yuv422p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.yuv422p -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.yuv444p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.yuv444p -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.yuyv422: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.yuyv422 -------------------------------------------------------------------------------- /tools/colorformatter/resources/resource.yv12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/resource.yv12 -------------------------------------------------------------------------------- /tools/colorformatter/resources/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/tools/colorformatter/resources/test.jpg -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_nv12.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 47, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.nv12", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_nv12_y_tiled_intel.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 77, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.nv12", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_y16.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 63, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.y16", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_y8.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 62, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.y8", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_ycbcr_422_888.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 67, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.ycbcr_422_888", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_ycbcr_422_i.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 65, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.yuyv422", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_ycbcr_422_sp.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 66, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.ycbcr_422_sp", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_ycbcr_444_888.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 64, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.ycbcr_444_888", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_ycrcb_420_sp.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 69, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.nv21", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tools/colorformatter/resources/video1layer_yv12.json: -------------------------------------------------------------------------------- 1 | { 2 | "layers_parameters": [ 3 | { 4 | "format": 61, 5 | "frame": { 6 | "height": 400, 7 | "width": 600, 8 | "x": 0, 9 | "y": 0 10 | }, 11 | "resource_path": "resource.yv12", 12 | "source": { 13 | "crop": { 14 | "height": 400, 15 | "width": 600, 16 | "x": 0, 17 | "y": 0 18 | }, 19 | "height": 400, 20 | "width": 600 21 | }, 22 | "transform": 0, 23 | "type": 1 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /travisci/check_patch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from subprocess import Popen, PIPE, STDOUT 4 | 5 | # Run clang to check if code changes cause a diff output and return 1 if so. 6 | cmd = "git show origin/master..@ | clang-format-diff-3.9 -p 1 -style=file" 7 | diff = Popen(cmd, stdout=PIPE, shell=True).communicate()[0] 8 | if diff: 9 | print("Code formatting is not according to style guidelines. Read:\n" 10 | "https://github.com/intel/IA-Hardware-Composer/wiki/Contributions#conformance-and-documentation-requirements") 11 | exit(1) 12 | 13 | # Run cppcheck, on fail return msg and exit code 1. 14 | cmd = 'cppcheck --quiet --force --error-exitcode=1 .' 15 | out = Popen(cmd, stderr=STDOUT, stdout=PIPE, shell=True) 16 | msg = out.communicate()[0] 17 | if out.returncode: 18 | print(msg) 19 | exit(1) 20 | 21 | exit(0) 22 | -------------------------------------------------------------------------------- /travisci/realpath: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/IA-Hardware-Composer/b10b0218a6224c4a777f604e3eba808f63145109/travisci/realpath -------------------------------------------------------------------------------- /travisci/travisci.md: -------------------------------------------------------------------------------- 1 | ## Debug Travis CI with Docker 2 | 3 | Host PC: Ubuntu 16.04 LTS with "su root" 4 | 5 | Reference: https://docs.travis-ci.com/user/common-build-problems/#Running-a-Container-Based-Docker-Image-Locally 6 | 7 | * Install Docker: apt-get install docker 8 | * Download Travis CI Docker image(refer to https://hub.docker.com/u/travisci/): docker pull travisci/ci-garnet:packer-1490989530 9 | * Start Docket service: service docker start 10 | * List existing images: docker images 11 | * Don't use this vritual net interface as we only need use --net=host: ifconfig docker0 down 12 | * Run Travis CI image in Docker: docker run --name travis-debug-001 --rm -v /mnt:/mnt/ --net=host -dit travisci/ci-garnet:packer-1490989530 /sbin/init 13 | * Switch to shell: docker exec -it travis-debug-001 bash -l 14 | * Setup network, e.g. proxy....to install dependance packages 15 | * Save changed image to new name: docker commit travis-debug-001 travis-debug-002 16 | 17 | ## Commits of headers & libs 18 | * linux: https://github.com/android-ia/device-androidia-kernel.git "master" branch 9d2ec87a7f431fd699dc4b52c02fd421d961329d 19 | * libdrm: https://github.com/android-ia/external-libdrm.git "master" branch 82a4b6756572a9d708f174708615bddb2f472275 20 | * mesa: https://github.com/android-ia/external-mesa.git "master" branch 98b57dd99d603072da4e3dddf062de71303d4f84 21 | * mingbm: https://github.com/01org/minigbm.git "master" barnch deb93aca440ab75828c847cb3cec97a1315a69e2 22 | -------------------------------------------------------------------------------- /wsi/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Intel Corporation 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | include Makefile.sources 17 | 18 | ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4 19 | 20 | AM_MAKEFLAGS = -s 21 | 22 | SUBDIRS = . 23 | 24 | MAINTAINERCLEANFILES = ChangeLog INSTALL 25 | 26 | AM_CPP_INCLUDES = -Idrm -I../os/ -I../os/linux/ -I../public/ -I../common/display/ -I../common/core/ -I../common/utils/ -I../common/compositor/ -I../common/compositor/va 27 | AM_CPPFLAGS = -std=c++11 -fPIC -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fPIE -DENABLE_DOUBLE_BUFFERING 28 | AM_CPPFLAGS += $(AM_CPP_INCLUDES) $(CWARNFLAGS) $(DRM_CFLAGS) $(DEBUG_CFLAGS) -Wformat -Wformat-security 29 | 30 | if DISABLE_HOTPLUG_SUPPORT 31 | AM_CPPFLAGS += -DDISABLE_HOTPLUG_NOTIFICATION 32 | endif 33 | 34 | libhwcomposer_wsi_la_LIBADD = \ 35 | $(DRM_LIBS) \ 36 | $(GBM_LIBS) \ 37 | $(EGL_LIBS) \ 38 | -lm 39 | 40 | noinst_LTLIBRARIES = libhwcomposer_wsi.la 41 | libhwcomposer_wsi_la_SOURCES = $(wsi_SOURCES) 42 | libhwcomposer_wsi_ladir = $(libdir) 43 | libhwcomposer_wsi_la_LDFLAGS = -version-number 0:0:1 -no-undefined 44 | 45 | if ENABLE_VULKAN 46 | AM_CPP_INCLUDES += -I../common/compositor/vk 47 | AM_CPPFLAGS += -I../common/compositor/vk -DUSE_VK -DDISABLE_EXPLICIT_SYNC 48 | libhwcomposer_wsi_la_LIBADD += -lvulkan 49 | else 50 | AM_CPP_INCLUDES += -I../common/compositor/gl 51 | AM_CPPFLAGS += -DUSE_GL 52 | libhwcomposer_wsi_la_LIBADD += $(GLES2_LIBS) 53 | endif 54 | 55 | .PHONY: ChangeLog INSTALL 56 | 57 | INSTALL: 58 | $(INSTALL_CMD) 59 | 60 | ChangeLog: 61 | $(CHANGELOG_CMD) 62 | 63 | dist-hook: ChangeLog INSTALL 64 | -------------------------------------------------------------------------------- /wsi/Makefile.sources: -------------------------------------------------------------------------------- 1 | wsi_SOURCES = \ 2 | physicaldisplay.cpp \ 3 | drm/drmdisplay.cpp \ 4 | drm/drmbuffer.cpp \ 5 | drm/drmplane.cpp \ 6 | drm/drmdisplaymanager.cpp \ 7 | drm/drmscopedtypes.cpp \ 8 | $(NULL) 9 | -------------------------------------------------------------------------------- /wsi/displayplanehandler.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef WSI_DISPLAYPLANEHANDLER_H_ 18 | #define WSI_DISPLAYPLANEHANDLER_H_ 19 | 20 | #include "displayplanestate.h" 21 | namespace hwcomposer { 22 | 23 | struct OverlayLayer; 24 | 25 | struct OverlayPlane { 26 | public: 27 | OverlayPlane(DisplayPlane* plane, const OverlayLayer* layer) 28 | : plane(plane), layer(layer) { 29 | } 30 | DisplayPlane* plane; 31 | const OverlayLayer* layer; 32 | }; 33 | 34 | class DisplayPlaneHandler { 35 | public: 36 | virtual ~DisplayPlaneHandler() { 37 | } 38 | 39 | virtual bool PopulatePlanes( 40 | std::vector>& overlay_planes) = 0; 41 | 42 | virtual bool TestCommit(const DisplayPlaneStateList& composition) const = 0; 43 | }; 44 | 45 | } // namespace hwcomposer 46 | #endif // WSI_DISPLAYPLANEHANDLER_H_ 47 | -------------------------------------------------------------------------------- /wsi/drm/drmscopedtypes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2016 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #include "drmscopedtypes.h" 18 | 19 | #include 20 | #include 21 | 22 | namespace hwcomposer { 23 | void DrmResourcesDeleter::operator()(drmModeRes* resources) const { 24 | drmModeFreeResources(resources); 25 | } 26 | 27 | void DrmConnectorDeleter::operator()(drmModeConnector* connector) const { 28 | drmModeFreeConnector(connector); 29 | } 30 | 31 | void DrmCrtcDeleter::operator()(drmModeCrtc* crtc) const { 32 | drmModeFreeCrtc(crtc); 33 | } 34 | 35 | void DrmEncoderDeleter::operator()(drmModeEncoder* encoder) const { 36 | drmModeFreeEncoder(encoder); 37 | } 38 | 39 | void DrmObjectPropertiesDeleter::operator()( 40 | drmModeObjectProperties* properties) const { 41 | drmModeFreeObjectProperties(properties); 42 | } 43 | 44 | void DrmPlaneDeleter::operator()(drmModePlane* plane) const { 45 | drmModeFreePlane(plane); 46 | } 47 | 48 | void DrmPlaneResDeleter::operator()(drmModePlaneRes* plane) const { 49 | drmModeFreePlaneResources(plane); 50 | } 51 | 52 | void DrmPropertyDeleter::operator()(drmModePropertyRes* property) const { 53 | drmModeFreeProperty(property); 54 | } 55 | 56 | void DrmAtomicReqDeleter::operator()(drmModeAtomicReq* property) const { 57 | drmModeAtomicFree(property); 58 | } 59 | 60 | } // namespace hwcomposer 61 | -------------------------------------------------------------------------------- /wsi/wsi_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (c) 2017 Intel Corporation 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | */ 16 | 17 | #ifndef WSI_UTILS_H__ 18 | #define WSI_UTILS_H__ 19 | 20 | #ifndef DISABLE_HOTPLUG_NOTIFICATION 21 | #define SPIN_LOCK(X) X.lock(); 22 | #else 23 | #define SPIN_LOCK(X) ((void)0) 24 | #endif 25 | 26 | #ifndef DISABLE_HOTPLUG_NOTIFICATION 27 | #define SPIN_UNLOCK(X) X.unlock(); 28 | #else 29 | #define SPIN_UNLOCK(X) ((void)0) 30 | #endif 31 | 32 | #endif // WSI_UTILS_H__ 33 | --------------------------------------------------------------------------------