├── .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
31 |
32 |
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 |
--------------------------------------------------------------------------------