From e26c1ec581be598521517829adba8c8dd23a768f Mon Sep 17 00:00:00 2001 From: hanyu <13366022056@163.com> Date: Thu, 4 Jun 2020 19:28:37 +0800 Subject: [PATCH] TYPE3 Change-Id: I6fa8bf173dc6a7c5c9197784eb6c2d903f0bb5af --- src/type3_AndroidCloud/anbox-master/AUTHORS | 6 + src/type3_AndroidCloud/anbox-master/Android.mk | 111 + src/type3_AndroidCloud/anbox-master/CMakeLists.txt | 162 + src/type3_AndroidCloud/anbox-master/COPYING.GPL | 676 ++ src/type3_AndroidCloud/anbox-master/Dockerfile | 39 + src/type3_AndroidCloud/anbox-master/README.md | 171 + .../anbox-master/android/CMakeLists.txt | 47 + .../anbox-master/android/anboxd.rc | 5 + .../anbox-master/android/appmgr/Android.mk | 19 + .../android/appmgr/AndroidManifest.xml | 35 + .../android/appmgr/res/layout/app_view.xml | 17 + .../appmgr/res/layout/list_item_icon_text.xml | 38 + .../android/appmgr/res/values/dimens.xml | 5 + .../android/appmgr/res/values/strings.xml | 3 + .../src/org/anbox/appmgr/AppListAdapter.java | 89 + .../src/org/anbox/appmgr/AppListFragment.java | 74 + .../appmgr/src/org/anbox/appmgr/AppModel.java | 101 + .../src/org/anbox/appmgr/AppViewActivity.java | 41 + .../src/org/anbox/appmgr/AppsGridFragment.java | 90 + .../appmgr/src/org/anbox/appmgr/AppsLoader.java | 184 + .../appmgr/src/org/anbox/appmgr/GridFragment.java | 399 + .../src/org/anbox/appmgr/LauncherActivity.java | 47 + .../src/org/anbox/appmgr/LauncherService.java | 66 + .../src/org/anbox/appmgr/MainApplication.java | 23 + .../src/org/anbox/appmgr/PackageEventReceiver.java | 54 + .../org/anbox/appmgr/PackageIntentReceiver.java | 62 + .../src/org/anbox/appmgr/PlatformService.java | 168 + .../android/audio/MODULE_LICENSE_APACHE2 | 0 .../anbox-master/android/audio/NOTICE | 190 + .../anbox-master/android/audio/audio_hw.cpp | 676 ++ .../anbox-master/android/camera/Android.mk | 152 + .../android/camera/CallbackNotifier.cpp | 300 + .../anbox-master/android/camera/CallbackNotifier.h | 238 + .../anbox-master/android/camera/Converters.cpp | 173 + .../anbox-master/android/camera/Converters.h | 314 + .../android/camera/EmulatedBaseCamera.cpp | 89 + .../android/camera/EmulatedBaseCamera.h | 117 + .../anbox-master/android/camera/EmulatedCamera.cpp | 1041 +++ .../anbox-master/android/camera/EmulatedCamera.h | 401 + .../android/camera/EmulatedCamera2.cpp | 410 + .../anbox-master/android/camera/EmulatedCamera2.h | 274 + .../android/camera/EmulatedCamera3.cpp | 271 + .../anbox-master/android/camera/EmulatedCamera3.h | 203 + .../android/camera/EmulatedCameraCommon.h | 60 + .../android/camera/EmulatedCameraDevice.cpp | 413 + .../android/camera/EmulatedCameraDevice.h | 546 ++ .../android/camera/EmulatedCameraFactory.cpp | 542 ++ .../android/camera/EmulatedCameraFactory.h | 207 + .../android/camera/EmulatedCameraHal.cpp | 48 + .../android/camera/EmulatedCameraHotplugThread.cpp | 372 + .../android/camera/EmulatedCameraHotplugThread.h | 77 + .../android/camera/EmulatedFakeCamera.cpp | 90 + .../android/camera/EmulatedFakeCamera.h | 74 + .../android/camera/EmulatedFakeCamera2.cpp | 2717 +++++++ .../android/camera/EmulatedFakeCamera2.h | 429 + .../android/camera/EmulatedFakeCamera3.cpp | 2519 ++++++ .../android/camera/EmulatedFakeCamera3.h | 289 + .../android/camera/EmulatedFakeCameraDevice.cpp | 437 + .../android/camera/EmulatedFakeCameraDevice.h | 197 + .../android/camera/EmulatedQemuCamera.cpp | 119 + .../android/camera/EmulatedQemuCamera.h | 73 + .../android/camera/EmulatedQemuCamera2.cpp | 55 + .../android/camera/EmulatedQemuCamera2.h | 66 + .../android/camera/EmulatedQemuCameraDevice.cpp | 265 + .../android/camera/EmulatedQemuCameraDevice.h | 121 + .../anbox-master/android/camera/JpegCompressor.cpp | 95 + .../anbox-master/android/camera/JpegCompressor.h | 95 + .../anbox-master/android/camera/JpegStub.cpp | 69 + .../anbox-master/android/camera/JpegStub.h | 35 + .../anbox-master/android/camera/PreviewWindow.cpp | 216 + .../anbox-master/android/camera/PreviewWindow.h | 165 + .../anbox-master/android/camera/QemuClient.cpp | 559 ++ .../anbox-master/android/camera/QemuClient.h | 437 + .../android/camera/fake-pipeline2/Base.h | 65 + .../camera/fake-pipeline2/JpegCompressor.cpp | 286 + .../android/camera/fake-pipeline2/JpegCompressor.h | 120 + .../android/camera/fake-pipeline2/Scene.cpp | 478 ++ .../android/camera/fake-pipeline2/Scene.h | 191 + .../android/camera/fake-pipeline2/Sensor.cpp | 610 ++ .../android/camera/fake-pipeline2/Sensor.h | 245 + .../anbox-master/android/data/etc/apns-conf.xml | 265 + .../anbox-master/android/fingerprint/Android.mk | 33 + .../anbox-master/android/fingerprint/fingerprint.c | 857 ++ .../anbox-master/android/fstab.goldfish | 1 + .../anbox-master/android/gps/Android.mk | 47 + .../anbox-master/android/gps/gps_qemu.c | 953 +++ .../anbox-master/android/hwcomposer/hwcomposer.cpp | 333 + .../anbox-master/android/init.goldfish.rc | 100 + .../anbox-master/android/init.goldfish.sh | 68 + .../anbox-master/android/lights/Android.mk | 25 + .../anbox-master/android/lights/lights_qemu.c | 213 + .../anbox-master/android/media/media_codecs.xml | 85 + .../android/media/media_codecs_google_audio.xml | 97 + .../media/media_codecs_google_telephony.xml | 25 + .../android/media/media_codecs_google_tv.xml | 29 + .../android/media/media_codecs_google_video.xml | 122 + .../anbox-master/android/media/media_profiles.xml | 368 + .../anbox-master/android/opengl/Android.mk | 65 + .../anbox-master/android/opengl/README | 19 + .../anbox-master/android/opengl/common.mk | 237 + .../opengl/host/include/libOpenglRender/IOStream.h | 102 + .../opengl/shared/OpenglCodecCommon/Android.mk | 23 + .../OpenglCodecCommon/ChecksumCalculator.cpp | 154 + .../shared/OpenglCodecCommon/ChecksumCalculator.h | 181 + .../opengl/shared/OpenglCodecCommon/ErrorLog.h | 37 + .../opengl/shared/OpenglCodecCommon/FixedBuffer.h | 53 + .../shared/OpenglCodecCommon/GLClientState.cpp | 422 + .../shared/OpenglCodecCommon/GLClientState.h | 462 ++ .../shared/OpenglCodecCommon/GLSharedGroup.cpp | 497 ++ .../shared/OpenglCodecCommon/GLSharedGroup.h | 144 + .../opengl/shared/OpenglCodecCommon/Makefile | 13 + .../opengl/shared/OpenglCodecCommon/SmartPtr.h | 167 + .../shared/OpenglCodecCommon/SocketStream.cpp | 168 + .../opengl/shared/OpenglCodecCommon/SocketStream.h | 50 + .../opengl/shared/OpenglCodecCommon/TcpStream.cpp | 91 + .../opengl/shared/OpenglCodecCommon/TcpStream.h | 32 + .../opengl/shared/OpenglCodecCommon/codec_defs.h | 23 + .../opengl/shared/OpenglCodecCommon/glUtils.cpp | 475 ++ .../opengl/shared/OpenglCodecCommon/glUtils.h | 95 + .../shared/OpenglCodecCommon/gl_base_types.h | 63 + .../android/opengl/system/GLESv1/Android.mk | 12 + .../android/opengl/system/GLESv1/gl.cpp | 165 + .../android/opengl/system/GLESv1_enc/Android.mk | 19 + .../android/opengl/system/GLESv1_enc/GLEncoder.cpp | 1029 +++ .../android/opengl/system/GLESv1_enc/GLEncoder.h | 154 + .../opengl/system/GLESv1_enc/GLEncoderUtils.cpp | 28 + .../opengl/system/GLESv1_enc/GLEncoderUtils.h | 23 + .../opengl/system/GLESv1_enc/gl_client_context.cpp | 306 + .../opengl/system/GLESv1_enc/gl_client_context.h | 313 + .../opengl/system/GLESv1_enc/gl_client_proc.h | 305 + .../android/opengl/system/GLESv1_enc/gl_enc.cpp | 8463 ++++++++++++++++++++ .../android/opengl/system/GLESv1_enc/gl_enc.h | 23 + .../android/opengl/system/GLESv1_enc/gl_entry.cpp | 2066 +++++ .../android/opengl/system/GLESv1_enc/gl_ftable.h | 288 + .../android/opengl/system/GLESv1_enc/gl_opcodes.h | 300 + .../android/opengl/system/GLESv1_enc/gl_types.h | 20 + .../android/opengl/system/GLESv2/Android.mk | 12 + .../android/opengl/system/GLESv2/gl2.cpp | 177 + .../android/opengl/system/GLESv2_enc/Android.mk | 20 + .../opengl/system/GLESv2_enc/GL2Encoder.cpp | 1488 ++++ .../android/opengl/system/GLESv2_enc/GL2Encoder.h | 251 + .../opengl/system/GLESv2_enc/GL2EncoderUtils.cpp | 43 + .../opengl/system/GLESv2_enc/GL2EncoderUtils.h | 27 + .../system/GLESv2_enc/gl2_client_context.cpp | 223 + .../opengl/system/GLESv2_enc/gl2_client_context.h | 230 + .../opengl/system/GLESv2_enc/gl2_client_proc.h | 222 + .../android/opengl/system/GLESv2_enc/gl2_enc.cpp | 5191 ++++++++++++ .../android/opengl/system/GLESv2_enc/gl2_enc.h | 24 + .../android/opengl/system/GLESv2_enc/gl2_entry.cpp | 1483 ++++ .../android/opengl/system/GLESv2_enc/gl2_ftable.h | 216 + .../android/opengl/system/GLESv2_enc/gl2_opcodes.h | 217 + .../android/opengl/system/GLESv2_enc/gl2_types.h | 21 + .../opengl/system/OpenglSystemCommon/Android.mk | 13 + .../system/OpenglSystemCommon/EGLClientIface.h | 41 + .../opengl/system/OpenglSystemCommon/EGLImage.h | 36 + .../system/OpenglSystemCommon/HostConnection.cpp | 186 + .../system/OpenglSystemCommon/HostConnection.h | 61 + .../system/OpenglSystemCommon/QemuPipeStream.cpp | 209 + .../system/OpenglSystemCommon/QemuPipeStream.h | 51 + .../system/OpenglSystemCommon/ThreadInfo.cpp | 40 + .../opengl/system/OpenglSystemCommon/ThreadInfo.h | 59 + .../opengl/system/OpenglSystemCommon/gralloc_cb.h | 114 + .../android/opengl/system/egl/Android.mk | 41 + .../android/opengl/system/egl/ClientAPIExts.cpp | 157 + .../android/opengl/system/egl/ClientAPIExts.h | 29 + .../android/opengl/system/egl/ClientAPIExts.in | 201 + .../anbox-master/android/opengl/system/egl/egl.cfg | 1 + .../anbox-master/android/opengl/system/egl/egl.cpp | 1379 ++++ .../android/opengl/system/egl/eglContext.h | 52 + .../android/opengl/system/egl/eglDisplay.cpp | 485 ++ .../android/opengl/system/egl/eglDisplay.h | 89 + .../android/opengl/system/egl/egl_ftable.h | 64 + .../android/opengl/system/gralloc/Android.mk | 20 + .../android/opengl/system/gralloc/gralloc.cpp | 1059 +++ .../opengl/system/renderControl_enc/Android.mk | 12 + .../android/opengl/system/renderControl_enc/README | 142 + .../system/renderControl_enc/renderControl.attrib | 45 + .../system/renderControl_enc/renderControl.in | 35 + .../system/renderControl_enc/renderControl.types | 11 + .../renderControl_enc/renderControl_client_base.h | 41 + .../renderControl_client_context.cpp | 52 + .../renderControl_client_context.h | 59 + .../renderControl_enc/renderControl_client_proc.h | 51 + .../system/renderControl_enc/renderControl_enc.cpp | 1392 ++++ .../system/renderControl_enc/renderControl_enc.h | 24 + .../renderControl_enc/renderControl_entry.cpp | 276 + .../renderControl_enc/renderControl_ftable.h | 52 + .../renderControl_enc/renderControl_opcodes.h | 46 + .../system/renderControl_enc/renderControl_types.h | 28 + .../opengl/tests/gles_android_wrapper/Android.mk | 74 + .../tests/gles_android_wrapper/ApiInitializer.h | 42 + .../opengl/tests/gles_android_wrapper/CleanSpec.mk | 50 + .../gles_android_wrapper/ServerConnection.cpp | 125 + .../tests/gles_android_wrapper/ServerConnection.h | 55 + .../tests/gles_android_wrapper/ThreadInfo.cpp | 39 + .../opengl/tests/gles_android_wrapper/ThreadInfo.h | 49 + .../opengl/tests/gles_android_wrapper/egl.cfg | 1 + .../opengl/tests/gles_android_wrapper/egl.cpp | 663 ++ .../tests/gles_android_wrapper/egl_dispatch.cpp | 71 + .../tests/gles_android_wrapper/egl_dispatch.h | 115 + .../opengl/tests/gles_android_wrapper/egl_ftable.h | 66 + .../opengl/tests/gles_android_wrapper/egl_proc.h | 68 + .../opengl/tests/gles_android_wrapper/gles.cpp | 1410 ++++ .../tests/gles_android_wrapper/gles_dispatch.cpp | 298 + .../tests/gles_android_wrapper/gles_dispatch.h | 570 ++ .../tests/gles_android_wrapper/gles_emul.cfg | 7 + .../tests/gles_android_wrapper/gles_ftable.h | 292 + .../opengl/tests/gles_android_wrapper/gles_proc.h | 296 + .../tests/gles_android_wrapper/glesv1_emul_ifc.cpp | 39 + .../tests/gles_android_wrapper/glesv2_emul_ifc.cpp | 40 + .../opengl/tests/ut_rendercontrol_enc/Android.mk | 8 + .../ut_rendercontrol_enc/ut_rendercontrol.attrib | 4 + .../tests/ut_rendercontrol_enc/ut_rendercontrol.in | 11 + .../ut_rendercontrol_enc/ut_rendercontrol.types | 2 + .../ut_rendercontrol_enc/ut_rendercontrol_types.h | 17 + .../anbox-master/android/power/Android.mk | 28 + .../anbox-master/android/power/power_qemu.c | 64 + .../anbox-master/android/qemu-props/Android.mk | 28 + .../anbox-master/android/qemu-props/qemu-props.c | 116 + .../anbox-master/android/qemud/Android.mk | 20 + .../anbox-master/android/qemud/qemud.c | 1683 ++++ .../anbox-master/android/sensors/Android.mk | 40 + .../anbox-master/android/sensors/sensors_qemu.c | 751 ++ .../android/service/activity_manager_interface.cpp | 54 + .../android/service/activity_manager_interface.h | 58 + .../android/service/android_api_skeleton.cpp | 176 + .../android/service/android_api_skeleton.h | 80 + .../anbox-master/android/service/daemon.cpp | 61 + .../anbox-master/android/service/daemon.h | 31 + .../android/service/host_connector.cpp | 79 + .../anbox-master/android/service/host_connector.h | 58 + .../android/service/local_socket_connection.cpp | 84 + .../android/service/local_socket_connection.h | 42 + .../anbox-master/android/service/main.cpp | 23 + .../android/service/message_processor.cpp | 52 + .../android/service/message_processor.h | 40 + .../android/service/platform_api_stub.cpp | 165 + .../android/service/platform_api_stub.h | 113 + .../android/service/platform_server_proxy.cpp | 0 .../android/service/platform_server_proxy.h | 0 .../android/service/platform_service.cpp | 162 + .../android/service/platform_service.h | 47 + .../android/service/platform_service_interface.cpp | 81 + .../android/service/platform_service_interface.h | 68 + .../anbox-master/android/ueventd.goldfish.rc | 6 + .../anbox-master/android/vibrator/Android.mk | 29 + .../anbox-master/android/vibrator/vibrator_qemu.c | 93 + .../anbox-master/cmake/FindEGL.cmake | 25 + .../anbox-master/cmake/FindGLESv2.cmake | 25 + .../anbox-master/cmake/FindGMock.cmake | 102 + .../anbox-master/cmake/LinuxCrossCompile.cmake | 46 + .../anbox-master/cmake_uninstall.cmake.in | 21 + .../anbox-master/cross-compile-chroot.sh | 177 + .../anbox-master/data/apparmor.json | 5 + .../anbox-master/data/apparmor/anbox-container.aa | 246 + .../data/desktop/android-settings.desktop | 7 + .../anbox-master/data/desktop/appmgr.desktop | 8 + .../anbox-master/data/glvnd/10_nvidia.json | 6 + .../anbox-master/data/glvnd/50_mesa.json | 6 + .../anbox-master/data/manifest.json | 15 + .../anbox-master/data/seccomp/anbox.sc | 7 + .../anbox-master/data/ui/loading-screen.png | Bin 0 -> 13724 bytes .../anbox-master/data/xsession.conf | 11 + .../anbox-master/docs/architecture.png | Bin 0 -> 29330 bytes .../anbox-master/docs/build-android.md | 117 + .../anbox-master/docs/generate-emugl-source.md | 16 + .../anbox-master/docs/install.md | 130 + .../anbox-master/docs/runtime-setup.md | 35 + .../anbox-master/external/CMakeLists.txt | 5 + .../external/android-emugl/CMakeLists.txt | 28 + .../anbox-master/external/android-emugl/DESIGN | 615 ++ .../anbox-master/external/android-emugl/README | 96 + .../external/android-emugl/README.anbox | 3 + .../anbox-master/external/android-emugl/common.mk | 241 + .../external/android-emugl/googletest.mk | 37 + .../external/android-emugl/host/CMakeLists.txt | 2 + .../android-emugl/host/include/ETC1/etc1.h | 106 + .../external/android-emugl/host/include/GLES/gl.h | 774 ++ .../android-emugl/host/include/GLES/glext.h | 1073 +++ .../android-emugl/host/include/GLES/glplatform.h | 30 + .../host/include/OpenGLESDispatch/EGLDispatch.h | 54 + .../host/include/OpenGLESDispatch/GLESv1Dispatch.h | 42 + .../host/include/OpenGLESDispatch/GLESv2Dispatch.h | 42 + .../host/include/OpenGLESDispatch/gldefs.h | 45 + .../host/include/OpenGLESDispatch/gles_functions.h | 50 + .../host/include/libOpenglRender/IOStream.h | 85 + .../android-emugl/host/libs/CMakeLists.txt | 40 + .../host/libs/GLESv1_dec/CMakeLists.txt | 26 + .../host/libs/GLESv1_dec/GLESv1Decoder.cpp | 229 + .../host/libs/GLESv1_dec/GLESv1Decoder.h | 68 + .../android-emugl/host/libs/GLESv1_dec/gles1.addon | 15 + .../host/libs/GLESv1_dec/gles1.attrib | 694 ++ .../android-emugl/host/libs/GLESv1_dec/gles1.in | 298 + .../android-emugl/host/libs/GLESv1_dec/gles1.types | 34 + .../host/libs/GLESv1_dec/gles1_types.h | 21 + .../host/libs/GLESv2_dec/CMakeLists.txt | 26 + .../host/libs/GLESv2_dec/GLESv2Decoder.cpp | 129 + .../host/libs/GLESv2_dec/GLESv2Decoder.h | 48 + .../host/libs/GLESv2_dec/gles2.attrib | 595 ++ .../android-emugl/host/libs/GLESv2_dec/gles2.in | 214 + .../android-emugl/host/libs/GLESv2_dec/gles2.types | 38 + .../host/libs/GLESv2_dec/gles2_types.h | 21 + .../host/libs/libOpenGLESDispatch/CMakeLists.txt | 10 + .../host/libs/libOpenGLESDispatch/EGLDispatch.cpp | 58 + .../libs/libOpenGLESDispatch/GLESv1Dispatch.cpp | 104 + .../libs/libOpenGLESDispatch/GLESv2Dispatch.cpp | 100 + .../libOpenGLESDispatch/gles1_extensions.entries | 21 + .../libs/libOpenGLESDispatch/gles1_only.entries | 65 + .../libOpenGLESDispatch/gles2_extensions.entries | 6 + .../libs/libOpenGLESDispatch/gles2_only.entries | 81 + .../libs/libOpenGLESDispatch/gles3_only.entries | 18 + .../libs/libOpenGLESDispatch/gles_common.entries | 68 + .../libOpenGLESDispatch/gles_extensions.entries | 24 + .../libs/libOpenGLESDispatch/render_egl.entries | 26 + .../render_egl_extensions.entries | 11 + .../host/libs/renderControl_dec/CMakeLists.txt | 22 + .../libs/renderControl_dec/renderControl.attrib | 47 + .../host/libs/renderControl_dec/renderControl.in | 37 + .../libs/renderControl_dec/renderControl.types | 13 + .../libs/renderControl_dec/renderControl_types.h | 28 + .../android-emugl/host/tools/CMakeLists.txt | 1 + .../android-emugl/host/tools/emugen/ApiGen.cpp | 1392 ++++ .../android-emugl/host/tools/emugen/ApiGen.h | 97 + .../android-emugl/host/tools/emugen/CMakeLists.txt | 13 + .../android-emugl/host/tools/emugen/EntryPoint.cpp | 349 + .../android-emugl/host/tools/emugen/EntryPoint.h | 70 + .../android-emugl/host/tools/emugen/Parser.cpp | 191 + .../android-emugl/host/tools/emugen/Parser.h | 68 + .../host/tools/emugen/Parser_unittest.cpp | 120 + .../android-emugl/host/tools/emugen/README | 332 + .../host/tools/emugen/TypeFactory.cpp | 157 + .../android-emugl/host/tools/emugen/TypeFactory.h | 37 + .../external/android-emugl/host/tools/emugen/Var.h | 110 + .../android-emugl/host/tools/emugen/VarType.h | 62 + .../android-emugl/host/tools/emugen/errors.h | 24 + .../android-emugl/host/tools/emugen/getopt.c | 76 + .../android-emugl/host/tools/emugen/getopt.h | 18 + .../android-emugl/host/tools/emugen/main.cpp | 164 + .../android-emugl/host/tools/emugen/strUtils.cpp | 49 + .../android-emugl/host/tools/emugen/strUtils.h | 33 + .../host/tools/emugen/tests/run-tests.sh | 129 + .../tests/t.001/expected/decoder/foo_dec.cpp | 128 + .../emugen/tests/t.001/expected/decoder/foo_dec.h | 18 + .../tests/t.001/expected/decoder/foo_opcodes.h | 14 + .../t.001/expected/decoder/foo_server_context.cpp | 20 + .../t.001/expected/decoder/foo_server_context.h | 22 + .../tests/t.001/expected/decoder/foo_server_proc.h | 21 + .../t.001/expected/encoder/foo_client_context.cpp | 20 + .../t.001/expected/encoder/foo_client_context.h | 27 + .../tests/t.001/expected/encoder/foo_client_proc.h | 21 + .../tests/t.001/expected/encoder/foo_enc.cpp | 153 + .../emugen/tests/t.001/expected/encoder/foo_enc.h | 23 + .../tests/t.001/expected/encoder/foo_entry.cpp | 53 + .../tests/t.001/expected/encoder/foo_ftable.h | 20 + .../tests/t.001/expected/encoder/foo_opcodes.h | 14 + .../t.001/expected/wrapper/foo_wrapper_context.cpp | 20 + .../t.001/expected/wrapper/foo_wrapper_context.h | 25 + .../t.001/expected/wrapper/foo_wrapper_entry.cpp | 52 + .../t.001/expected/wrapper/foo_wrapper_proc.h | 21 + .../host/tools/emugen/tests/t.001/input/foo.attrib | 15 + .../host/tools/emugen/tests/t.001/input/foo.in | 5 + .../host/tools/emugen/tests/t.001/input/foo.types | 10 + .../external/android-emugl/scripts/gen-headers.sh | 114 + .../external/android-emugl/shared/CMakeLists.txt | 2 + .../shared/OpenglCodecCommon/CMakeLists.txt | 15 + .../OpenglCodecCommon/ChecksumCalculator.cpp | 154 + .../shared/OpenglCodecCommon/ChecksumCalculator.h | 181 + .../ChecksumCalculatorThreadInfo.cpp | 103 + .../ChecksumCalculatorThreadInfo.h | 56 + .../shared/OpenglCodecCommon/ErrorLog.h | 28 + .../OpenglCodecCommon/GLDecoderContextData.h | 82 + .../shared/OpenglCodecCommon/Makefile | 13 + .../shared/OpenglCodecCommon/ProtocolUtils.h | 193 + .../shared/OpenglCodecCommon/glUtils.cpp | 416 + .../shared/OpenglCodecCommon/glUtils.h | 41 + .../shared/OpenglCodecCommon/gl_base_types.h | 62 + .../android-emugl/shared/emugl/CMakeLists.txt | 1 + .../shared/emugl/common/CMakeLists.txt | 33 + .../shared/emugl/common/condition_variable.h | 91 + .../emugl/common/condition_variable_unittest.cpp | 27 + .../emugl/common/condition_variable_win32.cpp | 114 + .../shared/emugl/common/crash_reporter.cpp | 33 + .../shared/emugl/common/crash_reporter.h | 22 + .../shared/emugl/common/id_to_object_map.cpp | 236 + .../shared/emugl/common/id_to_object_map.h | 176 + .../emugl/common/id_to_object_map_unittest.cpp | 116 + .../shared/emugl/common/lazy_instance.cpp | 101 + .../shared/emugl/common/lazy_instance.h | 156 + .../shared/emugl/common/lazy_instance_unittest.cpp | 146 + .../android-emugl/shared/emugl/common/logging.cpp | 38 + .../android-emugl/shared/emugl/common/logging.h | 58 + .../shared/emugl/common/message_channel.cpp | 64 + .../shared/emugl/common/message_channel.h | 98 + .../emugl/common/message_channel_unittest.cpp | 101 + .../android-emugl/shared/emugl/common/mutex.h | 95 + .../shared/emugl/common/mutex_unittest.cpp | 108 + .../shared/emugl/common/pod_vector.cpp | 150 + .../android-emugl/shared/emugl/common/pod_vector.h | 265 + .../shared/emugl/common/pod_vector_unittest.cpp | 127 + .../shared/emugl/common/scoped_pointer_vector.h | 27 + .../shared/emugl/common/shared_library.cpp | 169 + .../shared/emugl/common/shared_library.h | 100 + .../emugl/common/shared_library_unittest.cpp | 177 + .../shared/emugl/common/smart_ptr.cpp | 113 + .../android-emugl/shared/emugl/common/smart_ptr.h | 150 + .../shared/emugl/common/smart_ptr_unittest.cpp | 140 + .../android-emugl/shared/emugl/common/sockets.cpp | 247 + .../android-emugl/shared/emugl/common/sockets.h | 57 + .../emugl/common/testing/test_shared_library.cpp | 22 + .../shared/emugl/common/testing/test_thread.h | 78 + .../android-emugl/shared/emugl/common/thread.h | 103 + .../shared/emugl/common/thread_pthread.cpp | 136 + .../shared/emugl/common/thread_store.cpp | 242 + .../shared/emugl/common/thread_store.h | 110 + .../shared/emugl/common/thread_store_unittest.cpp | 146 + .../shared/emugl/common/thread_unittest.cpp | 164 + .../shared/emugl/common/thread_win32.cpp | 121 + .../shared/emugl/common/unique_integer_map.h | 225 + .../emugl/common/unique_integer_map_unittest.cpp | 103 + .../anbox-master/external/backward-cpp/.gitignore | 2 + .../anbox-master/external/backward-cpp/.travis.yml | 25 + .../external/backward-cpp/BackwardConfig.cmake | 202 + .../external/backward-cpp/CMakeLists.txt | 130 + .../anbox-master/external/backward-cpp/LICENSE.txt | 21 + .../anbox-master/external/backward-cpp/README.md | 411 + .../external/backward-cpp/backward.cpp | 32 + .../external/backward-cpp/backward.hpp | 3796 +++++++++ .../anbox-master/external/backward-cpp/builds.sh | 77 + .../external/backward-cpp/conanfile.py | 45 + .../external/backward-cpp/doc/nice.png | Bin 0 -> 40904 bytes .../external/backward-cpp/doc/pretty.png | Bin 0 -> 105498 bytes .../external/backward-cpp/doc/rude.png | Bin 0 -> 6183 bytes .../external/backward-cpp/test/_test_main.cpp | 146 + .../external/backward-cpp/test/rectrace.cpp | 99 + .../external/backward-cpp/test/select_signals.cpp | 51 + .../external/backward-cpp/test/stacktrace.cpp | 65 + .../external/backward-cpp/test/suicide.cpp | 99 + .../external/backward-cpp/test/test.cpp | 75 + .../external/backward-cpp/test/test.hpp | 170 + .../backward-cpp/test_package/CMakeLists.txt | 8 + .../backward-cpp/test_package/conanfile.py | 14 + .../external/backward-cpp/test_package/main.cpp | 60 + .../external/cpu_features/.clang-format | 4 + .../anbox-master/external/cpu_features/.gitignore | 1 + .../anbox-master/external/cpu_features/.travis.yml | 91 + .../external/cpu_features/CMakeLists.txt | 174 + .../external/cpu_features/CONTRIBUTING.md | 23 + .../anbox-master/external/cpu_features/LICENSE | 202 + .../anbox-master/external/cpu_features/README.md | 165 + .../anbox-master/external/cpu_features/WORKSPACE | 7 + .../external/cpu_features/appveyor.yml | 24 + .../cpu_features/cmake/CpuFeaturesConfig.cmake.in | 3 + .../external/cpu_features/cmake/README.md | 28 + .../cmake/googletest.CMakeLists.txt.in | 15 + .../cpu_features/cmake/mips32-linux-gcc.cmake | 34 + .../cpu_features/include/cpu_features_macros.h | 125 + .../cpu_features/include/cpuinfo_aarch64.h | 65 + .../external/cpu_features/include/cpuinfo_arm.h | 80 + .../external/cpu_features/include/cpuinfo_mips.h | 53 + .../external/cpu_features/include/cpuinfo_ppc.h | 141 + .../external/cpu_features/include/cpuinfo_x86.h | 154 + .../cpu_features/include/internal/bit_utils.h | 39 + .../cpu_features/include/internal/cpuid_x86.h | 37 + .../cpu_features/include/internal/filesystem.h | 38 + .../cpu_features/include/internal/hwcaps.h | 131 + .../include/internal/linux_features_aggregator.h | 60 + .../include/internal/stack_line_reader.h | 49 + .../cpu_features/include/internal/string_view.h | 108 + .../cpu_features/scripts/run_integration.sh | 173 + .../cpu_features/scripts/test_integration.sh | 80 + .../cpu_features/src/cpuid_x86_clang_gcc.c | 36 + .../external/cpu_features/src/cpuid_x86_msvc.c | 34 + .../external/cpu_features/src/cpuinfo_aarch64.c | 141 + .../external/cpu_features/src/cpuinfo_arm.c | 259 + .../external/cpu_features/src/cpuinfo_mips.c | 98 + .../external/cpu_features/src/cpuinfo_ppc.c | 358 + .../external/cpu_features/src/cpuinfo_x86.c | 447 ++ .../external/cpu_features/src/filesystem.c | 57 + .../external/cpu_features/src/hwcaps.c | 187 + .../cpu_features/src/linux_features_aggregator.c | 51 + .../external/cpu_features/src/stack_line_reader.c | 131 + .../external/cpu_features/src/string_view.c | 182 + .../cpu_features/src/utils/list_cpu_features.c | 237 + .../external/cpu_features/test/CMakeLists.txt | 79 + .../external/cpu_features/test/bit_utils_test.cc | 53 + .../cpu_features/test/cpuinfo_aarch64_test.cc | 74 + .../external/cpu_features/test/cpuinfo_arm_test.cc | 182 + .../cpu_features/test/cpuinfo_mips_test.cc | 125 + .../external/cpu_features/test/cpuinfo_ppc_test.cc | 119 + .../external/cpu_features/test/cpuinfo_x86_test.cc | 172 + .../cpu_features/test/filesystem_for_testing.cc | 103 + .../cpu_features/test/filesystem_for_testing.h | 61 + .../cpu_features/test/hwcaps_for_testing.cc | 45 + .../cpu_features/test/hwcaps_for_testing.h | 27 + .../test/linux_features_aggregator_test.cc | 95 + .../cpu_features/test/stack_line_reader_test.cc | 132 + .../external/cpu_features/test/string_view_test.cc | 144 + .../anbox-master/external/nsexec/uidmapshift.c | 160 + .../external/process-cpp-minimal/CMakeLists.txt | 39 + .../external/process-cpp-minimal/COPYING | 165 + .../external/process-cpp-minimal/README.md | 86 + .../process-cpp-minimal/include/core/connection.h | 190 + .../include/core/posix/child_process.h | 177 + .../process-cpp-minimal/include/core/posix/exec.h | 68 + .../process-cpp-minimal/include/core/posix/exit.h | 42 + .../process-cpp-minimal/include/core/posix/fork.h | 54 + .../core/posix/linux/proc/process/oom_adj.h | 106 + .../core/posix/linux/proc/process/oom_score.h | 67 + .../core/posix/linux/proc/process/oom_score_adj.h | 131 + .../include/core/posix/linux/proc/process/stat.h | 120 + .../include/core/posix/linux/proc/process/state.h | 51 + .../include/core/posix/process.h | 93 + .../include/core/posix/process_group.h | 65 + .../include/core/posix/signal.h | 117 + .../include/core/posix/signalable.h | 64 + .../include/core/posix/standard_stream.h | 46 + .../include/core/posix/this_process.h | 128 + .../include/core/posix/visibility.h | 30 + .../process-cpp-minimal/include/core/posix/wait.h | 104 + .../process-cpp-minimal/include/core/signal.h | 297 + .../include/core/testing/cross_process_sync.h | 99 + .../include/core/testing/fork_and_run.h | 115 + .../process-cpp-minimal/src/CMakeLists.txt | 49 + .../src/core/posix/CMakeLists.txt | 24 + .../src/core/posix/backtrace.cpp | 153 + .../process-cpp-minimal/src/core/posix/backtrace.h | 122 + .../src/core/posix/child_process.cpp | 422 + .../process-cpp-minimal/src/core/posix/exec.cpp | 75 + .../process-cpp-minimal/src/core/posix/fork.cpp | 184 + .../src/core/posix/linux/CMakeLists.txt | 28 + .../src/core/posix/linux/proc/process/oom_adj.cpp | 81 + .../core/posix/linux/proc/process/oom_score.cpp | 49 + .../posix/linux/proc/process/oom_score_adj.cpp | 76 + .../src/core/posix/linux/proc/process/stat.cpp | 106 + .../src/core/posix/linux/proc/process/state.cpp | 40 + .../process-cpp-minimal/src/core/posix/process.cpp | 86 + .../src/core/posix/process_group.cpp | 47 + .../process-cpp-minimal/src/core/posix/signal.cpp | 221 + .../src/core/posix/signalable.cpp | 52 + .../src/core/posix/standard_stream.cpp | 35 + .../src/core/posix/this_process.cpp | 177 + .../process-cpp-minimal/src/core/posix/wait.cpp | 33 + .../src/core/testing/cross_process_sync.cpp | 99 + .../src/core/testing/fork_and_run.cpp | 78 + .../external/process-cpp-minimal/symbols.map | 16 + .../anbox-master/external/xdg/CMakeLists.txt | 24 + .../anbox-master/external/xdg/LICENSE | 166 + .../anbox-master/external/xdg/xdg.cpp | 202 + .../anbox-master/external/xdg/xdg.h | 118 + .../anbox-master/external/xdg/xdg_test.cpp | 130 + .../anbox-master/products/AndroidProducts.mk | 4 + .../anbox-master/products/anbox.mk | 100 + .../anbox-master/products/anbox.xml | 34 + .../anbox-master/products/anbox_arm64.mk | 24 + .../anbox-master/products/anbox_armv7a_neon.mk | 27 + .../anbox-master/products/anbox_x86_64.mk | 25 + .../anbox-master/products/arm64/BoardConfig.mk | 53 + .../anbox-master/products/arm64/device.mk | 25 + .../products/armv7-a-neon/BoardConfig.mk | 47 + .../anbox-master/products/armv7-a-neon/device.mk | 1 + .../SettingsProvider/res/values/defaults.xml | 24 + .../base/packages/SystemUI/res/values/config.xml | 22 + .../anbox-master/products/vendorsetup.sh | 6 + .../anbox-master/products/x86_64/BoardConfig.mk | 36 + .../anbox-master/products/x86_64/device.mk | 1 + .../anbox-master/scripts/anbox-bridge.sh | 182 + .../anbox-master/scripts/anbox-init.sh | 40 + .../anbox-master/scripts/anbox-shell.sh | 36 + .../anbox-master/scripts/android-sync.sh | 17 + .../anbox-master/scripts/app-android-settings.sh | 6 + .../anbox-master/scripts/app-appmgr.sh | 8 + .../anbox-master/scripts/build-debs.sh | 34 + .../anbox-master/scripts/build-with-docker.sh | 3 + .../anbox-master/scripts/clean-build.sh | 22 + .../anbox-master/scripts/clean-format.sh | 3 + .../anbox-master/scripts/collect-bug-info.sh | 57 + .../anbox-master/scripts/container-manager.sh | 124 + .../anbox-master/scripts/create-package.sh | 36 + .../anbox-master/scripts/gen-emugl-entries.py | 482 ++ .../anbox-master/scripts/gen-emugl-headers.sh | 110 + .../anbox-master/scripts/load-kmods.sh | 5 + .../anbox-master/scripts/mount-android.sh | 37 + .../anbox-master/scripts/setup-partial-chroot.sh | 181 + .../anbox-master/scripts/snap-wrapper.sh | 60 + .../anbox-master/scripts/start-container.sh | 3 + .../anbox-master/scripts/update-emugl-sources.sh | 136 + .../anbox-master/snap/.snapcraft/state | 4 + .../anbox-master/snap/gui/icon.png | Bin 0 -> 60960 bytes .../anbox-master/snap/hooks/configure | 7 + .../anbox-master/snap/hooks/install | 4 + .../anbox-master/snap/snapcraft.yaml | 308 + .../anbox-master/src/CMakeLists.txt | 389 + .../anbox-master/src/anbox/android/intent.cpp | 53 + .../anbox-master/src/anbox/android/intent.h | 42 + .../src/anbox/android/ip_config_builder.cpp | 114 + .../src/anbox/android/ip_config_builder.h | 66 + .../src/anbox/application/database.cpp | 60 + .../anbox-master/src/anbox/application/database.h | 59 + .../src/anbox/application/launcher_storage.cpp | 125 + .../src/anbox/application/launcher_storage.h | 51 + .../anbox-master/src/anbox/application/manager.h | 71 + .../anbox-master/src/anbox/audio/client_info.h | 36 + .../anbox-master/src/anbox/audio/server.cpp | 109 + .../anbox-master/src/anbox/audio/server.h | 56 + .../anbox-master/src/anbox/audio/sink.h | 35 + .../anbox-master/src/anbox/audio/source.h | 36 + .../src/anbox/bridge/android_api_stub.cpp | 227 + .../src/anbox/bridge/android_api_stub.h | 84 + .../src/anbox/bridge/platform_api_skeleton.cpp | 148 + .../src/anbox/bridge/platform_api_skeleton.h | 90 + .../anbox/bridge/platform_message_processor.cpp | 61 + .../src/anbox/bridge/platform_message_processor.h | 43 + .../anbox-master/src/anbox/build/config.h.in | 37 + .../anbox-master/src/anbox/cli.cpp | 249 + .../anbox-master/src/anbox/cli.h | 386 + .../anbox-master/src/anbox/cmds/check_features.cpp | 140 + .../anbox-master/src/anbox/cmds/check_features.h | 39 + .../src/anbox/cmds/container_manager.cpp | 276 + .../src/anbox/cmds/container_manager.h | 56 + .../anbox-master/src/anbox/cmds/install.cpp | 51 + .../anbox-master/src/anbox/cmds/install.h | 39 + .../anbox-master/src/anbox/cmds/launch.cpp | 225 + .../anbox-master/src/anbox/cmds/launch.h | 47 + .../src/anbox/cmds/session_manager.cpp | 313 + .../anbox-master/src/anbox/cmds/session_manager.h | 59 + .../anbox-master/src/anbox/cmds/system_info.cpp | 264 + .../anbox-master/src/anbox/cmds/system_info.h | 36 + .../anbox-master/src/anbox/cmds/version.cpp | 32 + .../anbox-master/src/anbox/cmds/version.h | 38 + .../anbox-master/src/anbox/cmds/wait_ready.cpp | 56 + .../anbox-master/src/anbox/cmds/wait_ready.h | 39 + .../src/anbox/common/binary_writer.cpp | 106 + .../anbox-master/src/anbox/common/binary_writer.h | 57 + .../src/anbox/common/binder_device.cpp | 49 + .../anbox-master/src/anbox/common/binder_device.h | 43 + .../src/anbox/common/binder_device_allocator.cpp | 84 + .../src/anbox/common/binder_device_allocator.h | 34 + .../anbox-master/src/anbox/common/binderfs.h | 44 + .../anbox-master/src/anbox/common/dispatcher.cpp | 40 + .../anbox-master/src/anbox/common/dispatcher.h | 44 + .../anbox-master/src/anbox/common/fd.cpp | 47 + .../anbox-master/src/anbox/common/fd.h | 50 + .../anbox-master/src/anbox/common/fd_sets.h | 31 + .../anbox-master/src/anbox/common/loop_device.cpp | 65 + .../anbox-master/src/anbox/common/loop_device.h | 46 + .../src/anbox/common/loop_device_allocator.cpp | 55 + .../src/anbox/common/loop_device_allocator.h | 33 + .../src/anbox/common/message_channel.cpp | 64 + .../src/anbox/common/message_channel.h | 99 + .../anbox-master/src/anbox/common/mount_entry.cpp | 78 + .../anbox-master/src/anbox/common/mount_entry.h | 48 + .../anbox-master/src/anbox/common/scope_ptr.h | 99 + .../anbox-master/src/anbox/common/small_vector.h | 376 + .../anbox-master/src/anbox/common/type_traits.h | 124 + .../src/anbox/common/variable_length_array.h | 58 + .../anbox-master/src/anbox/common/wait_handle.cpp | 79 + .../anbox-master/src/anbox/common/wait_handle.h | 53 + .../anbox-master/src/anbox/container/client.cpp | 83 + .../anbox-master/src/anbox/container/client.h | 63 + .../src/anbox/container/configuration.h | 40 + .../anbox-master/src/anbox/container/container.cpp | 24 + .../anbox-master/src/anbox/container/container.h | 49 + .../src/anbox/container/lxc_container.cpp | 506 ++ .../src/anbox/container/lxc_container.h | 68 + .../container/management_api_message_processor.cpp | 45 + .../container/management_api_message_processor.h | 43 + .../anbox/container/management_api_skeleton.cpp | 100 + .../src/anbox/container/management_api_skeleton.h | 66 + .../src/anbox/container/management_api_stub.cpp | 106 + .../src/anbox/container/management_api_stub.h | 64 + .../anbox-master/src/anbox/container/service.cpp | 106 + .../anbox-master/src/anbox/container/service.h | 63 + .../anbox-master/src/anbox/daemon.cpp | 65 + .../anbox-master/src/anbox/daemon.h | 39 + .../anbox-master/src/anbox/dbus/bus.cpp | 84 + .../anbox-master/src/anbox/dbus/bus.h | 59 + .../anbox-master/src/anbox/dbus/codecs.h | 47 + .../anbox-master/src/anbox/dbus/interface.h | 45 + .../anbox-master/src/anbox/dbus/sd_bus_helpers.c | 77 + .../anbox-master/src/anbox/dbus/sd_bus_helpers.h | 54 + .../anbox-master/src/anbox/dbus/sd_bus_helpers.hpp | 30 + .../anbox/dbus/skeleton/application_manager.cpp | 189 + .../src/anbox/dbus/skeleton/application_manager.h | 55 + .../src/anbox/dbus/skeleton/service.cpp | 49 + .../anbox-master/src/anbox/dbus/skeleton/service.h | 51 + .../src/anbox/dbus/stub/application_manager.cpp | 136 + .../src/anbox/dbus/stub/application_manager.h | 53 + .../anbox-master/src/anbox/defer_action.h | 41 + .../anbox-master/src/anbox/do_not_copy_or_move.h | 36 + .../src/anbox/graphics/buffer_queue.cpp | 104 + .../anbox-master/src/anbox/graphics/buffer_queue.h | 58 + .../src/anbox/graphics/buffered_io_stream.cpp | 137 + .../src/anbox/graphics/buffered_io_stream.h | 65 + .../anbox-master/src/anbox/graphics/density.cpp | 30 + .../anbox-master/src/anbox/graphics/density.h | 44 + .../src/anbox/graphics/emugl/ColorBuffer.cpp | 342 + .../src/anbox/graphics/emugl/ColorBuffer.h | 139 + .../src/anbox/graphics/emugl/DispatchTables.h | 22 + .../src/anbox/graphics/emugl/DisplayManager.cpp | 38 + .../src/anbox/graphics/emugl/DisplayManager.h | 46 + .../src/anbox/graphics/emugl/ReadBuffer.cpp | 69 + .../src/anbox/graphics/emugl/ReadBuffer.h | 38 + .../src/anbox/graphics/emugl/RenderApi.cpp | 88 + .../src/anbox/graphics/emugl/RenderApi.h | 47 + .../src/anbox/graphics/emugl/RenderContext.cpp | 41 + .../src/anbox/graphics/emugl/RenderContext.h | 67 + .../src/anbox/graphics/emugl/RenderControl.cpp | 475 ++ .../src/anbox/graphics/emugl/RenderControl.h | 38 + .../src/anbox/graphics/emugl/RenderThread.cpp | 102 + .../src/anbox/graphics/emugl/RenderThread.h | 64 + .../src/anbox/graphics/emugl/RenderThreadInfo.cpp | 40 + .../src/anbox/graphics/emugl/RenderThreadInfo.h | 64 + .../src/anbox/graphics/emugl/Renderable.cpp | 55 + .../src/anbox/graphics/emugl/Renderable.h | 69 + .../src/anbox/graphics/emugl/Renderer.cpp | 964 +++ .../src/anbox/graphics/emugl/Renderer.h | 313 + .../src/anbox/graphics/emugl/RendererConfig.cpp | 238 + .../src/anbox/graphics/emugl/RendererConfig.h | 162 + .../src/anbox/graphics/emugl/TextureDraw.cpp | 229 + .../src/anbox/graphics/emugl/TextureDraw.h | 55 + .../src/anbox/graphics/emugl/TextureResize.cpp | 355 + .../src/anbox/graphics/emugl/TextureResize.h | 52 + .../src/anbox/graphics/emugl/TimeUtils.cpp | 31 + .../src/anbox/graphics/emugl/TimeUtils.h | 23 + .../src/anbox/graphics/emugl/WindowSurface.cpp | 171 + .../src/anbox/graphics/emugl/WindowSurface.h | 97 + .../src/anbox/graphics/gl_extensions.h | 56 + .../src/anbox/graphics/gl_renderer_server.cpp | 112 + .../src/anbox/graphics/gl_renderer_server.h | 64 + .../src/anbox/graphics/layer_composer.cpp | 39 + .../src/anbox/graphics/layer_composer.h | 55 + .../graphics/multi_window_composer_strategy.cpp | 86 + .../graphics/multi_window_composer_strategy.h | 40 + .../anbox/graphics/opengles_message_processor.cpp | 65 + .../anbox/graphics/opengles_message_processor.h | 56 + .../anbox-master/src/anbox/graphics/primitives.h | 47 + .../src/anbox/graphics/program_family.cpp | 96 + .../src/anbox/graphics/program_family.h | 65 + .../anbox-master/src/anbox/graphics/rect.cpp | 87 + .../anbox-master/src/anbox/graphics/rect.h | 82 + .../anbox-master/src/anbox/graphics/renderer.h | 38 + .../graphics/single_window_composer_strategy.cpp | 50 + .../graphics/single_window_composer_strategy.h | 40 + .../anbox-master/src/anbox/input/device.cpp | 172 + .../anbox-master/src/anbox/input/device.h | 103 + .../anbox-master/src/anbox/input/manager.cpp | 57 + .../anbox-master/src/anbox/input/manager.h | 45 + .../anbox-master/src/anbox/logger.cpp | 210 + .../anbox-master/src/anbox/logger.h | 150 + .../src/anbox/network/base_socket_messenger.cpp | 157 + .../src/anbox/network/base_socket_messenger.h | 65 + .../src/anbox/network/connection_context.cpp | 28 + .../src/anbox/network/connection_context.h | 46 + .../src/anbox/network/connection_creator.cpp | 16 + .../src/anbox/network/connection_creator.h | 37 + .../anbox-master/src/anbox/network/connections.h | 68 + .../anbox-master/src/anbox/network/connector.h | 29 + .../anbox-master/src/anbox/network/credentials.cpp | 31 + .../anbox-master/src/anbox/network/credentials.h | 43 + .../anbox/network/delegate_connection_creator.h | 54 + .../anbox/network/delegate_message_processor.cpp | 35 + .../src/anbox/network/delegate_message_processor.h | 41 + .../src/anbox/network/fd_socket_transmission.cpp | 181 + .../src/anbox/network/fd_socket_transmission.h | 47 + .../src/anbox/network/local_socket_messenger.cpp | 48 + .../src/anbox/network/local_socket_messenger.h | 44 + .../src/anbox/network/message_processor.h | 34 + .../src/anbox/network/message_receiver.h | 52 + .../src/anbox/network/message_sender.h | 41 + .../anbox/network/published_socket_connector.cpp | 58 + .../src/anbox/network/published_socket_connector.h | 56 + .../src/anbox/network/socket_connection.cpp | 75 + .../src/anbox/network/socket_connection.h | 65 + .../src/anbox/network/socket_helper.cpp | 76 + .../anbox-master/src/anbox/network/socket_helper.h | 31 + .../src/anbox/network/socket_messenger.cpp | 0 .../src/anbox/network/socket_messenger.h | 40 + .../src/anbox/network/stream_socket_transport.cpp | 68 + .../src/anbox/network/stream_socket_transport.h | 65 + .../src/anbox/network/tcp_socket_connector.cpp | 65 + .../src/anbox/network/tcp_socket_connector.h | 57 + .../src/anbox/network/tcp_socket_messenger.cpp | 40 + .../src/anbox/network/tcp_socket_messenger.h | 44 + .../anbox-master/src/anbox/not_reachable.cpp | 35 + .../anbox-master/src/anbox/not_reachable.h | 42 + .../anbox-master/src/anbox/optional.h | 31 + .../src/anbox/platform/base_platform.cpp | 39 + .../src/anbox/platform/base_platform.h | 76 + .../src/anbox/platform/null/platform.cpp | 75 + .../src/anbox/platform/null/platform.h | 43 + .../src/anbox/platform/sdl/audio_sink.cpp | 119 + .../src/anbox/platform/sdl/audio_sink.h | 55 + .../src/anbox/platform/sdl/keycode_converter.cpp | 295 + .../src/anbox/platform/sdl/keycode_converter.h | 41 + .../anbox/platform/sdl/mir_display_connection.cpp | 123 + .../anbox/platform/sdl/mir_display_connection.h | 52 + .../src/anbox/platform/sdl/platform.cpp | 513 ++ .../anbox-master/src/anbox/platform/sdl/platform.h | 117 + .../src/anbox/platform/sdl/sdl_wrapper.h | 29 + .../anbox-master/src/anbox/platform/sdl/window.cpp | 225 + .../anbox-master/src/anbox/platform/sdl/window.h | 81 + .../src/anbox/protobuf/anbox_bridge.proto | 104 + .../src/anbox/protobuf/anbox_container.proto | 25 + .../src/anbox/protobuf/anbox_rpc.proto | 26 + .../src/anbox/protobuf/google_protobuf_guard.cpp | 38 + .../src/anbox/qemu/adb_message_processor.cpp | 210 + .../src/anbox/qemu/adb_message_processor.h | 77 + .../anbox-master/src/anbox/qemu/at_parser.cpp | 76 + .../anbox-master/src/anbox/qemu/at_parser.h | 49 + .../qemu/boot_properties_message_processor.cpp | 50 + .../anbox/qemu/boot_properties_message_processor.h | 40 + .../anbox/qemu/bootanimation_message_processor.cpp | 48 + .../anbox/qemu/bootanimation_message_processor.h | 43 + .../src/anbox/qemu/camera_message_processor.cpp | 64 + .../src/anbox/qemu/camera_message_processor.h | 46 + .../anbox/qemu/fingerprint_message_processor.cpp | 41 + .../src/anbox/qemu/fingerprint_message_processor.h | 40 + .../src/anbox/qemu/gsm_message_processor.cpp | 112 + .../src/anbox/qemu/gsm_message_processor.h | 60 + .../src/anbox/qemu/hwcontrol_message_processor.cpp | 44 + .../src/anbox/qemu/hwcontrol_message_processor.h | 37 + .../src/anbox/qemu/null_message_processor.cpp | 35 + .../src/anbox/qemu/null_message_processor.h | 35 + .../src/anbox/qemu/pipe_connection_creator.cpp | 167 + .../src/anbox/qemu/pipe_connection_creator.h | 76 + .../src/anbox/qemu/qemud_message_processor.cpp | 90 + .../src/anbox/qemu/qemud_message_processor.h | 50 + .../src/anbox/qemu/sensors_message_processor.cpp | 43 + .../src/anbox/qemu/sensors_message_processor.h | 40 + .../src/anbox/qemu/telephony_manager.cpp | 40 + .../src/anbox/qemu/telephony_manager.h | 40 + .../anbox-master/src/anbox/rpc/channel.cpp | 104 + .../anbox-master/src/anbox/rpc/channel.h | 72 + .../src/anbox/rpc/connection_creator.cpp | 64 + .../src/anbox/rpc/connection_creator.h | 61 + .../anbox-master/src/anbox/rpc/constants.h | 33 + .../src/anbox/rpc/make_protobuf_object.h | 40 + .../src/anbox/rpc/message_processor.cpp | 121 + .../anbox-master/src/anbox/rpc/message_processor.h | 72 + .../src/anbox/rpc/pending_call_cache.cpp | 76 + .../src/anbox/rpc/pending_call_cache.h | 74 + .../src/anbox/rpc/template_message_processor.h | 75 + .../anbox-master/src/anbox/runtime.cpp | 96 + .../anbox-master/src/anbox/runtime.h | 78 + .../src/anbox/system_configuration.cpp | 132 + .../anbox-master/src/anbox/system_configuration.h | 57 + .../anbox-master/src/anbox/testing/gtest_utils.h | 62 + .../anbox-master/src/anbox/ui/splash_screen.cpp | 103 + .../anbox-master/src/anbox/ui/splash_screen.h | 42 + .../anbox-master/src/anbox/utils.cpp | 209 + .../anbox-master/src/anbox/utils.h | 84 + .../src/anbox/utils/environment_file.cpp | 43 + .../src/anbox/utils/environment_file.h | 40 + .../anbox-master/src/anbox/wm/display.cpp | 25 + .../anbox-master/src/anbox/wm/display.h | 38 + .../anbox-master/src/anbox/wm/manager.cpp | 24 + .../anbox-master/src/anbox/wm/manager.h | 49 + .../src/anbox/wm/multi_window_manager.cpp | 128 + .../src/anbox/wm/multi_window_manager.h | 64 + .../src/anbox/wm/single_window_manager.cpp | 79 + .../src/anbox/wm/single_window_manager.h | 63 + .../anbox-master/src/anbox/wm/stack.cpp | 51 + .../anbox-master/src/anbox/wm/stack.h | 45 + .../anbox-master/src/anbox/wm/task.cpp | 24 + .../anbox-master/src/anbox/wm/task.h | 37 + .../anbox-master/src/anbox/wm/window.cpp | 62 + .../anbox-master/src/anbox/wm/window.h | 72 + .../anbox-master/src/anbox/wm/window_state.cpp | 43 + .../anbox-master/src/anbox/wm/window_state.h | 59 + src/type3_AndroidCloud/anbox-master/src/main.cpp | 24 + .../anbox-master/tests/CMakeLists.txt | 33 + .../anbox-master/tests/anbox/CMakeLists.txt | 5 + .../tests/anbox/android/CMakeLists.txt | 1 + .../tests/anbox/android/intent_tests.cpp | 31 + .../tests/anbox/application/CMakeLists.txt | 1 + .../anbox/application/restricted_manager_tests.cpp | 56 + .../anbox-master/tests/anbox/common/CMakeLists.txt | 5 + .../tests/anbox/common/binary_writer_tests.cpp | 130 + .../tests/anbox/common/message_channel_tests.cpp | 94 + .../tests/anbox/common/scope_ptr_tests.cpp | 65 + .../tests/anbox/common/small_vector_tests.cpp | 219 + .../tests/anbox/common/type_traits_tests.cpp | 84 + .../tests/anbox/graphics/CMakeLists.txt | 4 + .../tests/anbox/graphics/buffer_queue_tests.cpp | 298 + .../anbox/graphics/buffered_io_stream_tests.cpp | 145 + .../tests/anbox/graphics/layer_composer_tests.cpp | 235 + .../tests/anbox/graphics/render_control_tests.cpp | 29 + .../tests/anbox/support/CMakeLists.txt | 1 + .../tests/anbox/support/at_parser_tests.cpp | 47 + 889 files changed, 129571 insertions(+) create mode 100644 src/type3_AndroidCloud/anbox-master/AUTHORS create mode 100644 src/type3_AndroidCloud/anbox-master/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/COPYING.GPL create mode 100644 src/type3_AndroidCloud/anbox-master/Dockerfile create mode 100644 src/type3_AndroidCloud/anbox-master/README.md create mode 100644 src/type3_AndroidCloud/anbox-master/android/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/android/anboxd.rc create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/AndroidManifest.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/app_view.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/list_item_icon_text.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/dimens.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/strings.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListAdapter.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListFragment.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppModel.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppViewActivity.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsGridFragment.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsLoader.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/GridFragment.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherActivity.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherService.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/MainApplication.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageEventReceiver.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageIntentReceiver.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PlatformService.java create mode 100644 src/type3_AndroidCloud/anbox-master/android/audio/MODULE_LICENSE_APACHE2 create mode 100644 src/type3_AndroidCloud/anbox-master/android/audio/NOTICE create mode 100644 src/type3_AndroidCloud/anbox-master/android/audio/audio_hw.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/Converters.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/Converters.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraCommon.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHal.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Base.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/data/etc/apns-conf.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/fingerprint/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/fingerprint/fingerprint.c create mode 100644 src/type3_AndroidCloud/anbox-master/android/fstab.goldfish create mode 100644 src/type3_AndroidCloud/anbox-master/android/gps/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/gps/gps_qemu.c create mode 100644 src/type3_AndroidCloud/anbox-master/android/hwcomposer/hwcomposer.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/init.goldfish.rc create mode 100644 src/type3_AndroidCloud/anbox-master/android/init.goldfish.sh create mode 100644 src/type3_AndroidCloud/anbox-master/android/lights/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/lights/lights_qemu.c create mode 100644 src/type3_AndroidCloud/anbox-master/android/media/media_codecs.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_audio.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_telephony.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_tv.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_video.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/media/media_profiles.xml create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/README create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/common.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/host/include/libOpenglRender/IOStream.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ErrorLog.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/FixedBuffer.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Makefile create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SmartPtr.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/codec_defs.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/gl_base_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/gl.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_entry.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_ftable.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_opcodes.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/gl2.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_entry.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_ftable.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_opcodes.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLClientIface.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLImage.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/gralloc_cb.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/ClientAPIExts.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/ClientAPIExts.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/ClientAPIExts.in create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/egl.cfg create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/egl.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglContext.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/egl_ftable.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/gralloc.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/README create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.attrib create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.in create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.types create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_base.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_entry.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_ftable.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_opcodes.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ApiInitializer.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/CleanSpec.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cfg create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_ftable.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_emul.cfg create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_ftable.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.in create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types create mode 100644 src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/power/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/power/power_qemu.c create mode 100644 src/type3_AndroidCloud/anbox-master/android/qemu-props/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/qemu-props/qemu-props.c create mode 100644 src/type3_AndroidCloud/anbox-master/android/qemud/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/qemud/qemud.c create mode 100644 src/type3_AndroidCloud/anbox-master/android/sensors/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/sensors/sensors_qemu.c create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/activity_manager_interface.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/activity_manager_interface.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/android_api_skeleton.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/android_api_skeleton.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/daemon.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/daemon.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/host_connector.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/host_connector.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/local_socket_connection.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/local_socket_connection.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/main.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_api_stub.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_api_stub.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_server_proxy.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_server_proxy.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_service.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_service.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_service_interface.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/android/service/platform_service_interface.h create mode 100644 src/type3_AndroidCloud/anbox-master/android/ueventd.goldfish.rc create mode 100644 src/type3_AndroidCloud/anbox-master/android/vibrator/Android.mk create mode 100644 src/type3_AndroidCloud/anbox-master/android/vibrator/vibrator_qemu.c create mode 100644 src/type3_AndroidCloud/anbox-master/cmake/FindEGL.cmake create mode 100644 src/type3_AndroidCloud/anbox-master/cmake/FindGLESv2.cmake create mode 100644 src/type3_AndroidCloud/anbox-master/cmake/FindGMock.cmake create mode 100644 src/type3_AndroidCloud/anbox-master/cmake/LinuxCrossCompile.cmake create mode 100644 src/type3_AndroidCloud/anbox-master/cmake_uninstall.cmake.in create mode 100644 src/type3_AndroidCloud/anbox-master/cross-compile-chroot.sh create mode 100644 src/type3_AndroidCloud/anbox-master/data/apparmor.json create mode 100644 src/type3_AndroidCloud/anbox-master/data/apparmor/anbox-container.aa create mode 100644 src/type3_AndroidCloud/anbox-master/data/desktop/android-settings.desktop create mode 100644 src/type3_AndroidCloud/anbox-master/data/desktop/appmgr.desktop create mode 100644 src/type3_AndroidCloud/anbox-master/data/glvnd/10_nvidia.json create mode 100644 src/type3_AndroidCloud/anbox-master/data/glvnd/50_mesa.json create mode 100644 src/type3_AndroidCloud/anbox-master/data/manifest.json create mode 100644 src/type3_AndroidCloud/anbox-master/data/seccomp/anbox.sc create mode 100644 src/type3_AndroidCloud/anbox-master/data/ui/loading-screen.png create mode 100644 src/type3_AndroidCloud/anbox-master/data/xsession.conf create mode 100644 src/type3_AndroidCloud/anbox-master/docs/architecture.png create mode 100644 src/type3_AndroidCloud/anbox-master/docs/build-android.md create mode 100644 src/type3_AndroidCloud/anbox-master/docs/generate-emugl-source.md create mode 100644 src/type3_AndroidCloud/anbox-master/docs/install.md create mode 100644 src/type3_AndroidCloud/anbox-master/docs/runtime-setup.md create mode 100644 src/type3_AndroidCloud/anbox-master/external/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/DESIGN create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/README create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/README.anbox create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/common.mk create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/googletest.mk create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/ETC1/etc1.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/gl.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glext.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glplatform.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gldefs.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gles_functions.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/libOpenglRender/IOStream.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.addon create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.attrib create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.in create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.types create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.attrib create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.in create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.types create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/EGLDispatch.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv1Dispatch.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv2Dispatch.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_extensions.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_only.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_extensions.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_only.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles3_only.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_common.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_extensions.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl_extensions.entries create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.attrib create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.in create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.types create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/README create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Var.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/VarType.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/errors.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/main.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/run-tests.sh create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.attrib create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.in create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.types create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/scripts/gen-headers.sh create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ErrorLog.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/GLDecoderContextData.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/Makefile create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ProtocolUtils.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/gl_base_types.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_win32.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/scoped_pointer_vector.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_shared_library.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_thread.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_pthread.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_win32.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map_unittest.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/.gitignore create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/.travis.yml create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/BackwardConfig.cmake create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/LICENSE.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/README.md create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.hpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/builds.sh create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/conanfile.py create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/doc/nice.png create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/doc/pretty.png create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/doc/rude.png create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/_test_main.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/rectrace.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/select_signals.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/stacktrace.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/suicide.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.hpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/conanfile.py create mode 100644 src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/main.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/.clang-format create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/.gitignore create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/.travis.yml create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/CONTRIBUTING.md create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/LICENSE create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/README.md create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/WORKSPACE create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/appveyor.yml create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/CpuFeaturesConfig.cmake.in create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/README.md create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/googletest.CMakeLists.txt.in create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/mips32-linux-gcc.cmake create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpu_features_macros.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_aarch64.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_arm.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_mips.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_ppc.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_x86.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/bit_utils.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/cpuid_x86.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/filesystem.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/hwcaps.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/linux_features_aggregator.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/stack_line_reader.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/string_view.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/run_integration.sh create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/test_integration.sh create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_clang_gcc.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_msvc.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_aarch64.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_arm.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_mips.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_ppc.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_x86.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/filesystem.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/hwcaps.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/linux_features_aggregator.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/stack_line_reader.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/string_view.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/src/utils/list_cpu_features.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/bit_utils_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_aarch64_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_arm_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_mips_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_ppc_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_x86_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/linux_features_aggregator_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/stack_line_reader_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/cpu_features/test/string_view_test.cc create mode 100644 src/type3_AndroidCloud/anbox-master/external/nsexec/uidmapshift.c create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/COPYING create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/README.md create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/connection.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/child_process.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exec.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exit.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/fork.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_adj.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score_adj.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/stat.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/state.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process_group.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signal.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signalable.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/standard_stream.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/this_process.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/visibility.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/wait.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/signal.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/cross_process_sync.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/fork_and_run.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/child_process.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/exec.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/fork.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_adj.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score_adj.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/stat.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/state.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process_group.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signal.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signalable.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/standard_stream.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/this_process.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/wait.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/cross_process_sync.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/fork_and_run.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/symbols.map create mode 100644 src/type3_AndroidCloud/anbox-master/external/xdg/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/external/xdg/LICENSE create mode 100644 src/type3_AndroidCloud/anbox-master/external/xdg/xdg.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/external/xdg/xdg.h create mode 100644 src/type3_AndroidCloud/anbox-master/external/xdg/xdg_test.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/products/AndroidProducts.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/anbox.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/anbox.xml create mode 100644 src/type3_AndroidCloud/anbox-master/products/anbox_arm64.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/anbox_armv7a_neon.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/anbox_x86_64.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/arm64/BoardConfig.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/arm64/device.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/BoardConfig.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/device.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml create mode 100644 src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SystemUI/res/values/config.xml create mode 100644 src/type3_AndroidCloud/anbox-master/products/vendorsetup.sh create mode 100644 src/type3_AndroidCloud/anbox-master/products/x86_64/BoardConfig.mk create mode 100644 src/type3_AndroidCloud/anbox-master/products/x86_64/device.mk create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/anbox-bridge.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/anbox-init.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/anbox-shell.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/android-sync.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/app-android-settings.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/app-appmgr.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/build-debs.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/build-with-docker.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/clean-build.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/clean-format.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/collect-bug-info.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/container-manager.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/create-package.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-entries.py create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-headers.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/load-kmods.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/mount-android.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/setup-partial-chroot.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/snap-wrapper.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/start-container.sh create mode 100644 src/type3_AndroidCloud/anbox-master/scripts/update-emugl-sources.sh create mode 100644 src/type3_AndroidCloud/anbox-master/snap/.snapcraft/state create mode 100644 src/type3_AndroidCloud/anbox-master/snap/gui/icon.png create mode 100644 src/type3_AndroidCloud/anbox-master/snap/hooks/configure create mode 100644 src/type3_AndroidCloud/anbox-master/snap/hooks/install create mode 100644 src/type3_AndroidCloud/anbox-master/snap/snapcraft.yaml create mode 100644 src/type3_AndroidCloud/anbox-master/src/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/application/database.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/application/database.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/application/manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/audio/client_info.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/audio/sink.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/audio/source.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/build/config.h.in create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cli.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cli.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/binderfs.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/fd_sets.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/scope_ptr.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/small_vector.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/type_traits.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/variable_length_array.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/wait_handle.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/common/wait_handle.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/client.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/client.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/configuration.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/container.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/container.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/lxc_container.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/lxc_container.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/management_api_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/management_api_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/management_api_skeleton.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/management_api_skeleton.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/management_api_stub.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/management_api_stub.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/service.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/container/service.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/daemon.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/daemon.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/bus.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/bus.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/codecs.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/interface.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/sd_bus_helpers.c create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/sd_bus_helpers.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/sd_bus_helpers.hpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/skeleton/application_manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/skeleton/application_manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/skeleton/service.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/skeleton/service.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/stub/application_manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/dbus/stub/application_manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/defer_action.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/do_not_copy_or_move.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/buffer_queue.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/buffer_queue.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/buffered_io_stream.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/buffered_io_stream.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/density.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/density.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/ColorBuffer.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/ColorBuffer.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/DispatchTables.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/DisplayManager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/DisplayManager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/ReadBuffer.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/ReadBuffer.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderApi.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderApi.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderContext.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderContext.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderControl.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderControl.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderThread.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderThread.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderThreadInfo.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RenderThreadInfo.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/Renderable.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/Renderable.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/Renderer.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/Renderer.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RendererConfig.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/RendererConfig.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/TextureDraw.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/TextureDraw.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/TextureResize.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/TextureResize.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/TimeUtils.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/TimeUtils.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/WindowSurface.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/emugl/WindowSurface.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/gl_extensions.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/gl_renderer_server.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/gl_renderer_server.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/layer_composer.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/layer_composer.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/multi_window_composer_strategy.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/multi_window_composer_strategy.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/opengles_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/opengles_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/primitives.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/program_family.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/program_family.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/rect.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/rect.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/renderer.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/single_window_composer_strategy.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/graphics/single_window_composer_strategy.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/input/device.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/input/device.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/input/manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/input/manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/logger.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/logger.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/base_socket_messenger.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/base_socket_messenger.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/connection_context.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/connection_context.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/connection_creator.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/connection_creator.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/connections.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/connector.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/credentials.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/credentials.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/delegate_connection_creator.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/delegate_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/delegate_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/fd_socket_transmission.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/fd_socket_transmission.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/local_socket_messenger.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/local_socket_messenger.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/message_receiver.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/message_sender.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/published_socket_connector.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/published_socket_connector.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/socket_connection.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/socket_connection.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/socket_helper.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/socket_helper.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/socket_messenger.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/socket_messenger.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/stream_socket_transport.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/stream_socket_transport.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/tcp_socket_connector.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/tcp_socket_connector.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/tcp_socket_messenger.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/network/tcp_socket_messenger.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/not_reachable.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/not_reachable.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/optional.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/base_platform.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/base_platform.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/null/platform.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/null/platform.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/audio_sink.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/audio_sink.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/keycode_converter.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/keycode_converter.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/mir_display_connection.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/mir_display_connection.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/platform.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/platform.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/sdl_wrapper.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/window.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/platform/sdl/window.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/protobuf/anbox_bridge.proto create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/protobuf/anbox_container.proto create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/protobuf/anbox_rpc.proto create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/protobuf/google_protobuf_guard.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/adb_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/adb_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/at_parser.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/at_parser.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/boot_properties_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/boot_properties_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/bootanimation_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/bootanimation_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/camera_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/camera_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/fingerprint_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/fingerprint_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/gsm_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/gsm_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/hwcontrol_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/hwcontrol_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/null_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/null_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/pipe_connection_creator.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/pipe_connection_creator.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/qemud_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/qemud_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/sensors_message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/sensors_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/telephony_manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/qemu/telephony_manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/channel.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/channel.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/connection_creator.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/connection_creator.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/constants.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/make_protobuf_object.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/message_processor.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/pending_call_cache.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/pending_call_cache.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/rpc/template_message_processor.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/runtime.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/runtime.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/system_configuration.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/system_configuration.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/testing/gtest_utils.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/ui/splash_screen.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/ui/splash_screen.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/utils.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/utils.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/utils/environment_file.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/utils/environment_file.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/display.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/display.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/multi_window_manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/multi_window_manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/single_window_manager.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/single_window_manager.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/stack.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/stack.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/task.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/task.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/window.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/window.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/window_state.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/src/anbox/wm/window_state.h create mode 100644 src/type3_AndroidCloud/anbox-master/src/main.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/android/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/android/intent_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/application/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/application/restricted_manager_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/common/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/common/binary_writer_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/common/message_channel_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/common/scope_ptr_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/common/small_vector_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/common/type_traits_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/graphics/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/graphics/buffer_queue_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/graphics/buffered_io_stream_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/graphics/layer_composer_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/graphics/render_control_tests.cpp create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/support/CMakeLists.txt create mode 100644 src/type3_AndroidCloud/anbox-master/tests/anbox/support/at_parser_tests.cpp diff --git a/src/type3_AndroidCloud/anbox-master/AUTHORS b/src/type3_AndroidCloud/anbox-master/AUTHORS new file mode 100644 index 0000000..01f6448 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/AUTHORS @@ -0,0 +1,6 @@ +People contributed to Anbox in an alphabetical sorted list: + +Marius Gripsgard +Ricardo Mendoza +Simon Fels +Thomas Voß diff --git a/src/type3_AndroidCloud/anbox-master/Android.mk b/src/type3_AndroidCloud/anbox-master/Android.mk new file mode 100644 index 0000000..780f449 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/Android.mk @@ -0,0 +1,111 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := libprocess-cpp-minimal +LOCAL_SRC_FILES := \ + external/process-cpp-minimal/src/core/posix/process.cpp \ + external/process-cpp-minimal/src/core/posix/process_group.cpp \ + external/process-cpp-minimal/src/core/posix/signal.cpp \ + external/process-cpp-minimal/src/core/posix/signalable.cpp \ + external/process-cpp-minimal/src/core/posix/standard_stream.cpp \ + external/process-cpp-minimal/src/core/posix/wait.cpp \ + external/process-cpp-minimal/src/core/posix/fork.cpp \ + external/process-cpp-minimal/src/core/posix/exec.cpp \ + external/process-cpp-minimal/src/core/posix/child_process.cpp +LOCAL_CFLAGS := \ + -DANDROID \ + -fexceptions +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/external/process-cpp-minimal/include +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE_CLASS := EXECUTABLES +LOCAL_MODULE := anboxd +LOCAL_INIT_RC := android/anboxd.rc +LOCAL_SRC_FILES := \ + android/service/main.cpp \ + android/service/daemon.cpp \ + android/service/host_connector.cpp \ + android/service/local_socket_connection.cpp \ + android/service/message_processor.cpp \ + android/service/activity_manager_interface.cpp \ + android/service/android_api_skeleton.cpp \ + android/service/platform_service_interface.cpp \ + android/service/platform_service.cpp \ + android/service/platform_api_stub.cpp \ + src/anbox/common/fd.cpp \ + src/anbox/common/wait_handle.cpp \ + src/anbox/rpc/message_processor.cpp \ + src/anbox/rpc/pending_call_cache.cpp \ + src/anbox/rpc/channel.cpp \ + src/anbox/protobuf/anbox_rpc.proto \ + src/anbox/protobuf/anbox_bridge.proto +proto_header_dir := $(call local-generated-sources-dir)/proto/$(LOCAL_PATH)/src/anbox/protobuf +LOCAL_C_INCLUDES += \ + $(proto_header_dir) \ + $(LOCAL_PATH)/external/process-cpp-minimal/include \ + $(LOCAL_PATH)/src \ + $(LOCAL_PATH)/android/service +LOCAL_EXPORT_C_INCLUDE_DIRS += $(proto_header_dir) +LOCAL_STATIC_LIBRARIES := \ + libprocess-cpp-minimal +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libprotobuf-cpp-lite \ + libsysutils \ + libbinder \ + libcutils \ + libutils +LOCAL_CFLAGS := \ + -fexceptions \ + -std=c++1y +include $(BUILD_EXECUTABLE) + +include $(CLEAR_VARS) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SHARED_LIBRARIES := \ + liblog \ + lib_renderControl_enc \ + libOpenglSystemCommon +LOCAL_SRC_FILES := \ + android/hwcomposer/hwcomposer.cpp +LOCAL_MODULE := hwcomposer.anbox +LOCAL_CFLAGS:= -DLOG_TAG=\"hwcomposer\" +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/android/opengl/host/include/libOpenglRender \ + $(LOCAL_PATH)/android/opengl/shared/OpenglCodecCommon \ + $(LOCAL_PATH)/android/opengl/system/renderControl_enc \ + $(LOCAL_PATH)/android/opengl/system/OpenglSystemCommon +LOCAL_MODULE_TAGS := optional +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := audio.primary.goldfish +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_MODULE_TAGS := optional +LOCAL_SHARED_LIBRARIES := libcutils liblog +LOCAL_SRC_FILES := \ + android/audio/audio_hw.cpp +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/src +LOCAL_SHARED_LIBRARIES += libdl +LOCAL_CFLAGS := -Wno-unused-parameter + +include $(BUILD_SHARED_LIBRARY) + +# Include the Android.mk files below will override LOCAL_PATH so we +# have to take a copy of it here. +TMP_PATH := $(LOCAL_PATH) + +include $(TMP_PATH)/android/appmgr/Android.mk +include $(TMP_PATH)/android/fingerprint/Android.mk +include $(TMP_PATH)/android/power/Android.mk +include $(TMP_PATH)/android/qemu-props/Android.mk +include $(TMP_PATH)/android/qemud/Android.mk +include $(TMP_PATH)/android/sensors/Android.mk +include $(TMP_PATH)/android/opengl/Android.mk +include $(TMP_PATH)/android/gps/Android.mk +include $(TMP_PATH)/android/lights/Android.mk +include $(TMP_PATH)/android/camera/Android.mk +include $(TMP_PATH)/android/vibrator/Android.mk diff --git a/src/type3_AndroidCloud/anbox-master/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/CMakeLists.txt new file mode 100644 index 0000000..d87f689 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/CMakeLists.txt @@ -0,0 +1,162 @@ +project(anbox C CXX) +cmake_minimum_required(VERSION 2.8.2) + +include(CTest) +include(GNUInstallDirs) + +if (NOT CMAKE_BUILD_TYPE) + message(STATUS "No build type selected, default to RelWithDebInfo") + set(CMAKE_BUILD_TYPE "RelWithDebInfo") +endif() + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-variadic-macros -Wextra -fPIC") + +# By default, all symbols are visible in the library. We strip out things we don't +# want at link time, by running a version script (see unity-scopes.map and the +# setting of LINK_FLAGS below). +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default") + +set(C_AND_CXX_WARNINGS "-pedantic -Wall -Wextra") + +# Some additional warnings not included by the general flags set above. +set(EXTRA_C_WARNINGS "-Wcast-align -Wcast-qual -Wformat -Wredundant-decls -Wswitch-default") +set(EXTRA_CXX_WARNINGS "-Wnon-virtual-dtor -Wold-style-cast") + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_AND_CXX_WARNINGS}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_WARNINGS}") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 ${C_AND_CXX_WARNINGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_WARNINGS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_WARNINGS}") + +# -fno-permissive causes warnings with clang, so we only enable it for gcc +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-permissive") +endif() + +string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) + +if ("${cmake_build_type_lower}" STREQUAL "release" OR "${cmake_build_type_lower}" STREQUAL "relwithdebinfo") + option(Werror "Treat warnings as errors" ON) +else() + option(Werror "Treat warnings as errors" OFF) +endif() + +if (${Werror}) + message(STATUS "Treat warnings as errors") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + if ("${cmake_build_type_lower}" STREQUAL "release" OR "${cmake_build_type_lower}" STREQUAL "relwithdebinfo") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations") + endif() +endif() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +find_package(Boost COMPONENTS filesystem log serialization system thread program_options) +find_package(PkgConfig) +find_package(Threads) +find_package(EGL REQUIRED) +find_package(GLESv2 REQUIRED) +find_package(Protobuf REQUIRED) + +pkg_check_modules(SDL2 sdl2 REQUIRED) +pkg_check_modules(SDL2_IMAGE SDL2_image REQUIRED) +pkg_check_modules(DBUS dbus-1 REQUIRED) +pkg_check_modules(LXC lxc REQUIRED) +pkg_check_modules(PROPERTIES_CPP properties-cpp REQUIRED) +pkg_check_modules(LIBSYSTEMD libsystemd REQUIRED) +pkg_check_modules(LIBCAP libcap REQUIRED) + +message(STATUS "LXC version: ${LXC_VERSION}") +if (${LXC_VERSION} VERSION_LESS 3.0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_LXC2_SUPPORT") + message(STATUS "Building with LXC 2.x compatibility support") +endif() + +option(ENABLE_X11 "Enable X11 support" ON) +if (ENABLE_X11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DX11_SUPPORT") +endif() + +option(ENABLE_WAYLAND "Enable wayland support" ON) +if (ENABLE_WAYLAND) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWAYLAND_SUPPORT") +endif() + +option(ENABLE_MIR "Enable mir support" OFF) +if (ENABLE_MIR) + pkg_check_modules(MIRCLIENT mirclient REQUIRED) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMIR_SUPPORT") +endif() + +if (NOT BINDERFS_PATH) + set(BINDERFS_PATH "/dev/binderfs") +endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEGL_NO_X11") + +if((Protobuf_VERSION VERSION_GREATER "3.7") OR (Protobuf_VERSION VERSION_EQUAL "3.7")) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_PROTOBUF_CALLBACK_HEADER") +endif() + +##################################################################### +# Enable code coverage calculation with gcov/gcovr/lcov +# Usage: +# * Switch build type to coverage (use ccmake or cmake-gui) +# * Invoke make, make test, make coverage +# * Find html report in subdir coveragereport +# * Find xml report feasible for jenkins in coverage.xml +##################################################################### +IF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs" ) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs" ) + SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) +ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) + +find_package(GMock) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC") + + +if (NOT ANBOX_VERSION) + exec_program("git" ${CMAKE_SOURCE_DIR} ARGS "rev-parse --short HEAD" OUTPUT_VARIABLE GIT_COMMIT_HASH) + set(ANBOX_VERSION "local-${GIT_COMMIT_HASH}") +endif() +if (ANBOX_VERSION_SUFFIX) + set(ANBOX_VERSION "${ANBOX_VERSION}-${ANBOX_VERSION_SUFFIX}") +endif() +set(ANBOX_RESOURCE_DIR "${CMAKE_INSTALL_DATADIR}/anbox") +set(ANBOX_RESOURCE_DIR_FULL "${CMAKE_INSTALL_FULL_DATADIR}/anbox") +set(ANBOX_STATEDIR_FULL "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/anbox") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/config.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/config.h) + +add_subdirectory(external) +add_subdirectory(src) +add_subdirectory(tests) +add_subdirectory(android) + +if (NOT "${HOST_CMAKE_C_COMPILER}" STREQUAL "") + message(STATUS "Host C compiler: ${HOST_CMAKE_C_COMPILER}") + message(STATUS "Host C compiler: ${HOST_CMAKE_CXX_COMPILER}") +endif() + +option(SNAP_CONFINEMENT "Enable snap confinement support" OFF) +if (SNAP_CONFINEMENT) + message(STATUS "Building with support for snap confinement") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_SNAP_CONFINEMENT") +endif() + +install(FILES data/ui/loading-screen.png DESTINATION ${ANBOX_RESOURCE_DIR}/ui) + +# uninstall target +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) +add_custom_target(uninstall "${CMAKE_COMMAND}" + -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") diff --git a/src/type3_AndroidCloud/anbox-master/COPYING.GPL b/src/type3_AndroidCloud/anbox-master/COPYING.GPL new file mode 100644 index 0000000..4432540 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/COPYING.GPL @@ -0,0 +1,676 @@ + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + diff --git a/src/type3_AndroidCloud/anbox-master/Dockerfile b/src/type3_AndroidCloud/anbox-master/Dockerfile new file mode 100644 index 0000000..efa35b2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/Dockerfile @@ -0,0 +1,39 @@ +FROM ubuntu:18.04 + +# hadolint ignore=DL3008 +RUN apt-get update && \ + apt-get install -qq -y --no-install-recommends \ + build-essential \ + cmake \ + cmake-data \ + cmake-extras \ + debhelper \ + dbus \ + git \ + google-mock \ + libboost-dev \ + libboost-filesystem-dev \ + libboost-log-dev \ + libboost-iostreams-dev \ + libboost-program-options-dev \ + libboost-system-dev \ + libboost-test-dev \ + libboost-thread-dev \ + libcap-dev \ + libegl1-mesa-dev \ + libgles2-mesa-dev \ + libglm-dev \ + libgtest-dev \ + liblxc1 \ + libproperties-cpp-dev \ + libprotobuf-dev \ + libsdl2-dev \ + libsdl2-image-dev \ + libsystemd-dev \ + lxc-dev \ + pkg-config \ + protobuf-compiler && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /anbox diff --git a/src/type3_AndroidCloud/anbox-master/README.md b/src/type3_AndroidCloud/anbox-master/README.md new file mode 100644 index 0000000..f5dd94c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/README.md @@ -0,0 +1,171 @@ +[![Snap Status](https://build.snapcraft.io/badge/anbox/anbox.svg)](https://build.snapcraft.io/user/anbox/anbox) +[![Build Status](https://travis-ci.org/anbox/anbox.svg?branch=master)](https://travis-ci.org/anbox/anbox) + +# Anbox + +Anbox is a container-based approach to boot a full Android system on a +regular GNU/Linux system like Ubuntu. In other words: Anbox will let +you run Android on your Linux system without the slowness of +virtualization. + +## Overview + +Anbox uses Linux namespaces (user, pid, uts, net, mount, ipc) to run a +full Android system in a container and provide Android applications on +any GNU/Linux-based platform. + +The Android inside the container has no direct access to any hardware. +All hardware access is going through the anbox daemon on the host. We're +reusing what Android implemented within the QEMU-based emulator for OpenGL +ES accelerated rendering. The Android system inside the container uses +different pipes to communicate with the host system and sends all hardware +access commands through these. + +For more details have a look at the following documentation pages: + + * [Android Hardware OpenGL ES emulation design overview](https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/android-emugl/DESIGN) + * [Android QEMU fast pipes](https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/docs/ANDROID-QEMU-PIPE.TXT) + * [The Android "qemud" multiplexing daemon](https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/docs/ANDROID-QEMUD.TXT) + * [Android qemud services](https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/docs/ANDROID-QEMUD-SERVICES.TXT) + +Anbox is currently suited for the desktop use case but can be used on +mobile operating systems like Ubuntu Touch, Sailfish OS or Lune OS too. +However as the mapping of Android applications is currently desktop specific +this needs additional work to supported stacked window user interfaces too. + +The Android runtime environment ships with a minimal customized Android system +image based on the [Android Open Source Project](https://source.android.com/). +The used image is currently based on Android 7.1.1 + +## Installation + +See our [installation instructions](docs/install.md) for details. + +## Supported Linux Distributions + +At the moment we officially support the following Linux distributions: + + * Ubuntu 16.04 (xenial) + * Ubuntu 18.04 (bionic) + +However all other distributions supporting snap packages should work as +well as long as they provide the mandatory kernel modules (see kernel/). + +## Install and Run Android Applications + +TBD + +## Build from source + +### Requirements + +To build the Anbox runtime itself there is nothing special to know. We're using +cmake as build system. A few build dependencies need to be present on your host +system: + + * libdbus + * google-mock + * google-test + * libboost + * libboost-filesystem + * libboost-log + * libboost-iostreams + * libboost-program-options + * libboost-system + * libboost-test + * libboost-thread + * libcap + * libsystemd + * mesa (libegl1, libgles2) + * libglm + * libsdl2 + * libprotobuf + * protobuf-compiler + * python2 + * lxc (>= 3.0) + +On an Ubuntu system you can install all build dependencies with the following +command: + +``` +$ sudo apt install build-essential cmake cmake-data debhelper dbus google-mock \ + libboost-dev libboost-filesystem-dev libboost-log-dev libboost-iostreams-dev \ + libboost-program-options-dev libboost-system-dev libboost-test-dev \ + libboost-thread-dev libcap-dev libsystemd-dev libegl1-mesa-dev \ + libgles2-mesa-dev libglm-dev libgtest-dev liblxc1 \ + libproperties-cpp-dev libprotobuf-dev libsdl2-dev libsdl2-image-dev lxc-dev \ + pkg-config protobuf-compiler python-minimal +``` +We recommend Ubuntu 18.04 (bionic) with **GCC 7.x** as your build environment. + + +### Build + +Afterwards you can build Anbox with + +``` +$ git clone https://github.com/anbox/anbox.git +$ cd anbox +$ mkdir build +$ cd build +$ cmake .. +$ make +``` + +A simple + +``` +$ sudo make install +``` + +will install the necessary bits into your system. + +If you want to build the anbox snap instead you can do this with the following +steps: + +``` +$ mkdir android-images +$ cp /path/to/android.img android-images/android.img +$ snapcraft +``` + +The result will be a .snap file you can install on a system supporting snaps + +``` +$ snap install --dangerous --devmode anbox_1_amd64.snap +``` + +## Run Anbox + +Running Anbox from a local build requires a few more things you need to know +about. Please have a look at the ["Runtime Setup"](docs/runtime-setup.md) +documentation. + +## Documentation + +You will find additional documentation for Anbox in the *docs* subdirectory +of the project source. + +Interesting things to have a look at + + * [Runtime Setup](docs/runtime-setup.md) + * [Build Android image](docs/build-android.md) + * [Generate Android emugl source](docs/generate-emugl-source.md) + +## Reporting bugs + +If you have found an issue with Anbox, please [file a bug](https://github.com/anbox/anbox/issues/new). + +## Get in Touch + +If you want to get in contact with the developers please feel free to join the +*#anbox* IRC channel on [Freenode](https://freenode.net/). + +## Copyright and Licensing + +Anbox reuses code from other projects like the Android QEMU emulator. These +projects are available in the external/ subdirectory with the licensing terms +included. + +The Anbox source itself, if not stated differently in the relevant source files, +is licensed under the terms of the GPLv3 license. diff --git a/src/type3_AndroidCloud/anbox-master/android/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/android/CMakeLists.txt new file mode 100644 index 0000000..58b3614 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/CMakeLists.txt @@ -0,0 +1,47 @@ +include_directories( + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_BINARY_DIR}/src) + +set(ANBOXD_SOURCES + ${CMAKE_SOURCE_DIR}/src/anbox/rpc/message_processor.cpp + ${CMAKE_SOURCE_DIR}/src/anbox/rpc/pending_call_cache.cpp + ${CMAKE_SOURCE_DIR}/src/anbox/common/fd.cpp + service/activity_manager_interface.cpp + service/platform_service.cpp + service/platform_service_interface.cpp + service/platform_api_stub.cpp + service/android_api_skeleton.cpp + service/message_processor.cpp + service/local_socket_connection.cpp + service/host_connector.cpp + service/daemon.cpp + service/main.cpp) + +add_executable(anboxd ${ANBOXD_SOURCES}) +target_link_libraries(anboxd + pthread + process-cpp + anbox-protobuf) + +set(HWCOMPOSER_SOURCES + hwcomposer/hwcomposer.cpp) + +add_library(hwcomposer.anbox SHARED ${HWCOMPOSER_SOURCES}) + +set(AUDIO_SOURCES + audio/audio_hw.cpp) +add_library(audio.goldfish SHARED ${AUDIO_SOURCES}) + +# As we're adding Android specific bits in this project we can't +# build this safely within default build anymore. We keep this +# for easy integration into used IDEs. +set_target_properties(anboxd + PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + +set_target_properties(hwcomposer.anbox + PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + +set_target_properties(audio.goldfish + PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) + diff --git a/src/type3_AndroidCloud/anbox-master/android/anboxd.rc b/src/type3_AndroidCloud/anbox-master/android/anboxd.rc new file mode 100644 index 0000000..69bef1c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/anboxd.rc @@ -0,0 +1,5 @@ +service anboxd /system/bin/anboxd + class core + +service anbox-log-dumper /system/bin/logcat -f /data/system.log -r 2048 -n 4 + class core diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/Android.mk b/src/type3_AndroidCloud/anbox-master/android/appmgr/Android.mk new file mode 100644 index 0000000..e122453 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/Android.mk @@ -0,0 +1,19 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE_TAGS := optional +LOCAL_STATIC_JAVA_LIBRARIES := \ + android-common \ + android-support-v13 +LOCAL_SRC_FILES := $(call all-java-files-under, src) +# LOCAL_SDK_VERSION := current +LOCAL_PACKAGE_NAME := AnboxAppMgr +LOCAL_CERTIFICATE := shared +LOCAL_PRIVILEGED_MODULE := true +LOCAL_OVERRIDES_PACKAGES := \ + Home \ + Launcher2 \ + Launcher3 \ + LatinIME \ + QuickSearchBox +include $(BUILD_PACKAGE) diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/AndroidManifest.xml b/src/type3_AndroidCloud/anbox-master/android/appmgr/AndroidManifest.xml new file mode 100644 index 0000000..6b9277b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/AndroidManifest.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/app_view.xml b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/app_view.xml new file mode 100644 index 0000000..1b76962 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/app_view.xml @@ -0,0 +1,17 @@ + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/list_item_icon_text.xml b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/list_item_icon_text.xml new file mode 100644 index 0000000..9ea839c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/layout/list_item_icon_text.xml @@ -0,0 +1,38 @@ + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/dimens.xml b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/dimens.xml new file mode 100644 index 0000000..47c8224 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/strings.xml b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/strings.xml new file mode 100644 index 0000000..8926490 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/res/values/strings.xml @@ -0,0 +1,3 @@ + + Anbox Application Manager + diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListAdapter.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListAdapter.java new file mode 100644 index 0000000..6146d9a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListAdapter.java @@ -0,0 +1,89 @@ +/* + * The MIT License (MIT) + * + * Copyright 2016 Arnab Chakraborty. http://arnab.ch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.anbox.appmgr; + +import android.annotation.TargetApi; +import android.content.Context; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Created by Arnab Chakraborty + */ +public class AppListAdapter extends ArrayAdapter { + private final LayoutInflater mInflater; + + public AppListAdapter (Context context) { + super(context, android.R.layout.simple_list_item_2); + + mInflater = LayoutInflater.from(context); + } + + public void setData(ArrayList data) { + clear(); + if (data != null) { + addAll(data); + } + } + + @Override + @TargetApi(Build.VERSION_CODES.HONEYCOMB) + public void addAll(Collection items) { + //If the platform supports it, use addAll, otherwise add in loop + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + super.addAll(items); + }else{ + for(AppModel item: items){ + super.add(item); + } + } + } + + /** + * Populate new items in the list. + */ + @Override public View getView(int position, View convertView, ViewGroup parent) { + View view; + + if (convertView == null) { + view = mInflater.inflate(R.layout.list_item_icon_text, parent, false); + } else { + view = convertView; + } + + AppModel item = getItem(position); + ((ImageView)view.findViewById(R.id.icon)).setImageDrawable(item.getIcon()); + ((TextView)view.findViewById(R.id.text)).setText(item.getLabel()); + + return view; + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListFragment.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListFragment.java new file mode 100644 index 0000000..8bd2b17 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppListFragment.java @@ -0,0 +1,74 @@ +/* + * The MIT License (MIT) + * + * Copyright 2016 Arnab Chakraborty. http://arnab.ch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.anbox.appmgr; + +import android.os.Bundle; +import android.support.v4.app.ListFragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.Loader; +import java.util.ArrayList; + +/** + * Created by Arnab Chakraborty + */ +public class AppListFragment extends ListFragment implements LoaderManager.LoaderCallbacks> { + AppListAdapter mAdapter; + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + setEmptyText("No Applications"); + + mAdapter = new AppListAdapter(getActivity()); + setListAdapter(mAdapter); + + // till the data is loaded display a spinner + setListShown(false); + + // create the loader to load the apps list in background + getLoaderManager().initLoader(0, null, this); + } + + @Override + public Loader> onCreateLoader(int id, Bundle bundle) { + return new AppsLoader(getActivity()); + } + + @Override + public void onLoadFinished(Loader> loader, ArrayList apps) { + mAdapter.setData(apps); + + if (isResumed()) { + setListShown(true); + } else { + setListShownNoAnimation(true); + } + } + + @Override + public void onLoaderReset(Loader> loader) { + mAdapter.setData(null); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppModel.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppModel.java new file mode 100644 index 0000000..cc4896b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppModel.java @@ -0,0 +1,101 @@ +/* + * The MIT License (MIT) + * + * Copyright 2016 Arnab Chakraborty. http://arnab.ch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.anbox.appmgr; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.graphics.drawable.Drawable; + +import java.io.File; + +/** + * @credit http://developer.android.com/reference/android/content/AsyncTaskLoader.html + */ +public class AppModel { + + private final Context mContext; + private final ApplicationInfo mInfo; + + private String mAppLabel; + private Drawable mIcon; + + private boolean mMounted; + private final File mApkFile; + + public AppModel(Context context, ApplicationInfo info) { + mContext = context; + mInfo = info; + + mApkFile = new File(info.sourceDir); + } + + public ApplicationInfo getAppInfo() { + return mInfo; + } + + public String getApplicationPackageName() { + return getAppInfo().packageName; + } + + public String getLabel() { + return mAppLabel; + } + + public Drawable getIcon() { + if (mIcon == null) { + if (mApkFile.exists()) { + mIcon = mInfo.loadIcon(mContext.getPackageManager()); + return mIcon; + } else { + mMounted = false; + } + } else if (!mMounted) { + // If the app wasn't mounted but is now mounted, reload + // its icon. + if (mApkFile.exists()) { + mMounted = true; + mIcon = mInfo.loadIcon(mContext.getPackageManager()); + return mIcon; + } + } else { + return mIcon; + } + + return mContext.getResources().getDrawable(android.R.drawable.sym_def_app_icon); + } + + + void loadLabel(Context context) { + if (mAppLabel == null || !mMounted) { + if (!mApkFile.exists()) { + mMounted = false; + mAppLabel = mInfo.packageName; + } else { + mMounted = true; + CharSequence label = mInfo.loadLabel(context.getPackageManager()); + mAppLabel = label != null ? label.toString() : mInfo.packageName; + } + } + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppViewActivity.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppViewActivity.java new file mode 100644 index 0000000..7b92f68 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppViewActivity.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +package org.anbox.appmgr; + +import android.os.Bundle; +import android.util.Log; +import android.support.v4.app.FragmentActivity; + +public final class AppViewActivity extends FragmentActivity { + private static final String TAG = "AnboxAppView"; + + @Override + public void onCreate(Bundle info) { + super.onCreate(info); + + setContentView(R.layout.app_view); + + Log.i(TAG, "Created application view activity"); + } + + @Override + public void onDestroy() { + Log.i(TAG, "Destroying application view activity"); + super.onDestroy(); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsGridFragment.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsGridFragment.java new file mode 100644 index 0000000..6b45672 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsGridFragment.java @@ -0,0 +1,90 @@ +/* + * The MIT License (MIT) + * + * Copyright 2016 Arnab Chakraborty. http://arnab.ch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.anbox.appmgr; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.Loader; +import android.view.View; +import android.widget.GridView; + +import java.util.ArrayList; + +/** + * Created by Arnab Chakraborty + */ +public class AppsGridFragment extends GridFragment implements LoaderManager.LoaderCallbacks> { + + AppListAdapter mAdapter; + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + setEmptyText("No Applications"); + + mAdapter = new AppListAdapter(getActivity()); + setGridAdapter(mAdapter); + + // till the data is loaded display a spinner + setGridShown(false); + + // create the loader to load the apps list in background + getLoaderManager().initLoader(0, null, this); + } + + @Override + public Loader> onCreateLoader(int id, Bundle bundle) { + return new AppsLoader(getActivity()); + } + + @Override + public void onLoadFinished(Loader> loader, ArrayList apps) { + mAdapter.setData(apps); + + if (isResumed()) { + setGridShown(true); + } else { + setGridShownNoAnimation(true); + } + } + + @Override + public void onLoaderReset(Loader> loader) { + mAdapter.setData(null); + } + + @Override + public void onGridItemClick(GridView g, View v, int position, long id) { + AppModel app = (AppModel) getGridAdapter().getItem(position); + if (app != null) { + Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage(app.getApplicationPackageName()); + + if (intent != null) { + startActivity(intent); + } + } + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsLoader.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsLoader.java new file mode 100644 index 0000000..5f1dee6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/AppsLoader.java @@ -0,0 +1,184 @@ +/* + * The MIT License (MIT) + * + * Copyright 2016 Arnab Chakraborty. http://arnab.ch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.anbox.appmgr; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.support.v4.content.AsyncTaskLoader; + +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Comparator; + +/** + * @credit http://developer.android.com/reference/android/content/AsyncTaskLoader.html + */ +public class AppsLoader extends AsyncTaskLoader> { + ArrayList mInstalledApps; + + final PackageManager mPm; + PackageIntentReceiver mPackageObserver; + + public AppsLoader(Context context) { + super(context); + + mPm = context.getPackageManager(); + } + + @Override + public ArrayList loadInBackground() { + // retrieve the list of installed applications + List apps = mPm.getInstalledApplications(0); + + if (apps == null) { + apps = new ArrayList(); + } + + final Context context = getContext(); + + // create corresponding apps and load their labels + ArrayList items = new ArrayList(apps.size()); + for (int i = 0; i < apps.size(); i++) { + String pkg = apps.get(i).packageName; + + // only apps which are launchable + if (context.getPackageManager().getLaunchIntentForPackage(pkg) != null) { + AppModel app = new AppModel(context, apps.get(i)); + app.loadLabel(context); + items.add(app); + } + } + + // sort the list + Collections.sort(items, ALPHA_COMPARATOR); + + return items; + } + + @Override + public void deliverResult(ArrayList apps) { + if (isReset()) { + // An async query came in while the loader is stopped. We + // don't need the result. + if (apps != null) { + onReleaseResources(apps); + } + } + + ArrayList oldApps = apps; + mInstalledApps = apps; + + if (isStarted()) { + // If the Loader is currently started, we can immediately + // deliver its results. + super.deliverResult(apps); + } + + // At this point we can release the resources associated with + // 'oldApps' if needed; now that the new result is delivered we + // know that it is no longer in use. + if (oldApps != null) { + onReleaseResources(oldApps); + } + } + + @Override + protected void onStartLoading() { + if (mInstalledApps != null) { + // If we currently have a result available, deliver it + // immediately. + deliverResult(mInstalledApps); + } + + // watch for changes in app install and uninstall operation + if (mPackageObserver == null) { + mPackageObserver = new PackageIntentReceiver(this); + } + + if (takeContentChanged() || mInstalledApps == null ) { + // If the data has changed since the last time it was loaded + // or is not currently available, start a load. + forceLoad(); + } + } + + @Override + protected void onStopLoading() { + // Attempt to cancel the current load task if possible. + cancelLoad(); + } + + @Override + public void onCanceled(ArrayList apps) { + super.onCanceled(apps); + + // At this point we can release the resources associated with 'apps' + // if needed. + onReleaseResources(apps); + } + + @Override + protected void onReset() { + // Ensure the loader is stopped + onStopLoading(); + + // At this point we can release the resources associated with 'apps' + // if needed. + if (mInstalledApps != null) { + onReleaseResources(mInstalledApps); + mInstalledApps = null; + } + + // Stop monitoring for changes. + if (mPackageObserver != null) { + getContext().unregisterReceiver(mPackageObserver); + mPackageObserver = null; + } + } + + /** + * Helper method to do the cleanup work if needed, for example if we're + * using Cursor, then we should be closing it here + * + * @param apps + */ + protected void onReleaseResources(ArrayList apps) { + // do nothing + } + + + /** + * Perform alphabetical comparison of application entry objects. + */ + public static final Comparator ALPHA_COMPARATOR = new Comparator() { + private final Collator sCollator = Collator.getInstance(); + @Override + public int compare(AppModel object1, AppModel object2) { + return sCollator.compare(object1.getLabel(), object2.getLabel()); + } + }; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/GridFragment.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/GridFragment.java new file mode 100644 index 0000000..779aa46 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/GridFragment.java @@ -0,0 +1,399 @@ +package org.anbox.appmgr; + +/* + * Created by Thomas Barrasso on 9/11/12. + * Copyright (c) 2012 Loupe Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import android.content.Context; +import android.content.res.Resources; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.support.v4.app.Fragment; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.AnimationUtils; +import android.widget.AdapterView; +import android.widget.FrameLayout; +import android.widget.GridView; +import android.widget.LinearLayout; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.ProgressBar; +import android.widget.TextView; + +/** + * Based on {@link android.app.ListFragment} but adapted for {@link GridView}. + */ +public class GridFragment extends Fragment { + + static final int INTERNAL_EMPTY_ID = 0x00ff0001; + static final int INTERNAL_PROGRESS_CONTAINER_ID = 0x00ff0002; + static final int INTERNAL_LIST_CONTAINER_ID = 0x00ff0003; + + final private Handler mHandler = new Handler(); + + final private Runnable mRequestFocus = new Runnable() { + public void run() { + mGrid.focusableViewAvailable(mGrid); + } + }; + + final private AdapterView.OnItemClickListener mOnClickListener + = new AdapterView.OnItemClickListener() { + public void onItemClick(AdapterView parent, View v, int position, long id) { + onGridItemClick((GridView) parent, v, position, id); + } + }; + + ListAdapter mAdapter; + GridView mGrid; + View mEmptyView; + TextView mStandardEmptyView; + View mProgressContainer; + View mGridContainer; + CharSequence mEmptyText; + boolean mGridShown; + + public GridFragment() { } + + /** + * Provide default implementation to return a simple grid view. Subclasses + * can override to replace with their own layout. If doing so, the + * returned view hierarchy must have a GridView whose id + * is {@link android.R.id#list android.R.id.list} and can optionally + * have a sibling view id {@link android.R.id#empty android.R.id.empty} + * that is to be shown when the grid is empty. + * + *

If you are overriding this method with your own custom content, + * consider including the standard layout {@link android.R.layout#list_content} + * in your layout file, so that you continue to retain all of the standard + * behavior of ListFragment. In particular, this is currently the only + * way to have the built-in indeterminant progress state be shown. + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + final Context context = getActivity(); + + FrameLayout root = new FrameLayout(context); + + // ------------------------------------------------------------------ + + LinearLayout pframe = new LinearLayout(context); + pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); + pframe.setOrientation(LinearLayout.VERTICAL); + pframe.setVisibility(View.GONE); + pframe.setGravity(Gravity.CENTER); + + ProgressBar progress = new ProgressBar(context, null, + android.R.attr.progressBarStyleLarge); + pframe.addView(progress, new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + + root.addView(pframe, new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + + // ------------------------------------------------------------------ + + FrameLayout lframe = new FrameLayout(context); + lframe.setId(INTERNAL_LIST_CONTAINER_ID); + + TextView tv = new TextView(getActivity()); + tv.setId(INTERNAL_EMPTY_ID); + tv.setGravity(Gravity.CENTER); + lframe.addView(tv, new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + + GridView lv = new GridView(getActivity()); + lv.setId(android.R.id.list); + lv.setDrawSelectorOnTop(false); + lv.setColumnWidth(convertDpToPixels(60, getActivity())); + lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); + lv.setNumColumns(GridView.AUTO_FIT); + lv.setHorizontalSpacing(convertDpToPixels(20, getActivity())); + lv.setVerticalSpacing(convertDpToPixels(20, getActivity())); + lv.setSmoothScrollbarEnabled(true); + + // disable overscroll + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { + lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER); + } + + lframe.addView(lv, new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + + root.addView(lframe, new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + + // ------------------------------------------------------------------ + + root.setLayoutParams(new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + + return root; + } + + /** + * Attach to grid view once the view hierarchy has been created. + */ + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + ensureGrid(); + } + + /** + * Detach from {@link GridView} + */ + @Override + public void onDestroyView() { + mHandler.removeCallbacks(mRequestFocus); + mGrid = null; + mGridShown = false; + mEmptyView = mProgressContainer = mGridContainer = null; + mStandardEmptyView = null; + super.onDestroyView(); + } + + public static int convertDpToPixels(float dp, Context context){ + Resources resources = context.getResources(); + return (int) TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_DIP, + dp, + resources.getDisplayMetrics() + ); + } + + /** + * This method will be called when an item in the grid is selected. + * Subclasses should override. Subclasses can call + * getGridView().getItemAtPosition(position) if they need to access the + * data associated with the selected item. + * + * @param g The {@link GridView} where the click happened + * @param v The view that was clicked within the {@link GridView} + * @param position The position of the view in the grid + * @param id The row id of the item that was clicked + */ + public void onGridItemClick(GridView g, View v, int position, long id) { + + } + + /** + * Provide the cursor for the {@link GridView}. + */ + public void setGridAdapter(ListAdapter adapter) { + final boolean hadAdapter = (mAdapter != null); + mAdapter = adapter; + if (mGrid != null) { + mGrid.setAdapter(adapter); + if (!mGridShown && !hadAdapter) { + // The grid was hidden, and previously didn't have an + // adapter. It is now time to show it. + setGridShown(true, (getView().getWindowToken() != null)); + } + } + } + + /** + * Set the currently selected grid item to the specified + * position with the adapter's data + * + * @param position + */ + public void setSelection(int position) { + ensureGrid(); + mGrid.setSelection(position); + } + + /** + * Get the position of the currently selected grid item. + */ + public int getSelectedItemPosition() { + ensureGrid(); + return mGrid.getSelectedItemPosition(); + } + + /** + * Get the cursor row ID of the currently selected grid item. + */ + public long getSelectedItemId() { + ensureGrid(); + return mGrid.getSelectedItemId(); + } + + /** + * Get the activity's {@link GridView} widget. + */ + public GridView getGridView() { + ensureGrid(); + return mGrid; + } + + /** + * The default content for a ListFragment has a TextView that can + * be shown when the grid is empty. If you would like to have it + * shown, call this method to supply the text it should use. + */ + public void setEmptyText(CharSequence text) { + ensureGrid(); + if (mStandardEmptyView == null) { + throw new IllegalStateException("Can't be used with a custom content view"); + } + mStandardEmptyView.setText(text); + if (mEmptyText == null) { + mGrid.setEmptyView(mStandardEmptyView); + } + mEmptyText = text; + } + + /** + * Control whether the grid is being displayed. You can make it not + * displayed if you are waiting for the initial data to show in it. During + * this time an indeterminant progress indicator will be shown instead. + * + *

Applications do not normally need to use this themselves. The default + * behavior of ListFragment is to start with the grid not being shown, only + * showing it once an adapter is given with {@link #setGridAdapter(ListAdapter)}. + * If the grid at that point had not been shown, when it does get shown + * it will be do without the user ever seeing the hidden state. + * + * @param shown If true, the grid view is shown; if false, the progress + * indicator. The initial value is true. + */ + public void setGridShown(boolean shown) { + setGridShown(shown, true); + } + + /** + * Like {@link #setGridShown(boolean)}, but no animation is used when + * transitioning from the previous state. + */ + public void setGridShownNoAnimation(boolean shown) { + setGridShown(shown, false); + } + + /** + * Control whether the grid is being displayed. You can make it not + * displayed if you are waiting for the initial data to show in it. During + * this time an indeterminant progress indicator will be shown instead. + * + * @param shown If true, the grid view is shown; if false, the progress + * indicator. The initial value is true. + * @param animate If true, an animation will be used to transition to the + * new state. + */ + private void setGridShown(boolean shown, boolean animate) { + ensureGrid(); + if (mProgressContainer == null) { + throw new IllegalStateException("Can't be used with a custom content view"); + } + if (mGridShown == shown) { + return; + } + mGridShown = shown; + if (shown) { + if (animate) { + mProgressContainer.startAnimation(AnimationUtils.loadAnimation( + getActivity(), android.R.anim.fade_out)); + mGridContainer.startAnimation(AnimationUtils.loadAnimation( + getActivity(), android.R.anim.fade_in)); + } else { + mProgressContainer.clearAnimation(); + mGridContainer.clearAnimation(); + } + mProgressContainer.setVisibility(View.GONE); + mGridContainer.setVisibility(View.VISIBLE); + } else { + if (animate) { + mProgressContainer.startAnimation(AnimationUtils.loadAnimation( + getActivity(), android.R.anim.fade_in)); + mGridContainer.startAnimation(AnimationUtils.loadAnimation( + getActivity(), android.R.anim.fade_out)); + } else { + mProgressContainer.clearAnimation(); + mGridContainer.clearAnimation(); + } + mProgressContainer.setVisibility(View.VISIBLE); + mGridContainer.setVisibility(View.GONE); + } + } + + /** + * Get the ListAdapter associated with this activity's {@link GridView}. + */ + public ListAdapter getGridAdapter() { + return mAdapter; + } + + private void ensureGrid() { + if (mGrid != null) { + return; + } + View root = getView(); + if (root == null) { + throw new IllegalStateException("Content view not yet created"); + } + if (root instanceof GridView) { + mGrid = (GridView) root; + } else { + mStandardEmptyView = (TextView)root.findViewById(INTERNAL_EMPTY_ID); + if (mStandardEmptyView == null) { + mEmptyView = root.findViewById(android.R.id.empty); + } else { + mStandardEmptyView.setVisibility(View.GONE); + } + mProgressContainer = root.findViewById(INTERNAL_PROGRESS_CONTAINER_ID); + mGridContainer = root.findViewById(INTERNAL_LIST_CONTAINER_ID); + View rawGridView = root.findViewById(android.R.id.list); + if (!(rawGridView instanceof GridView)) { + if (rawGridView == null) { + throw new RuntimeException( + "Your content must have a GridView whose id attribute is " + + "'android.R.id.list'"); + } + throw new RuntimeException( + "Content has view with id attribute 'android.R.id.list' " + + "that is not a GridView class"); + } + mGrid = (GridView) rawGridView; + if (mEmptyView != null) { + mGrid.setEmptyView(mEmptyView); + } else if (mEmptyText != null) { + mStandardEmptyView.setText(mEmptyText); + mGrid.setEmptyView(mStandardEmptyView); + } + } + mGridShown = true; + mGrid.setOnItemClickListener(mOnClickListener); + if (mAdapter != null) { + ListAdapter adapter = mAdapter; + mAdapter = null; + setGridAdapter(adapter); + } else { + // We are starting without an adapter, so assume we won't + // have our data right away and start with the progress indicator. + if (mProgressContainer != null) { + setGridShown(false, false); + } + } + mHandler.post(mRequestFocus); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherActivity.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherActivity.java new file mode 100644 index 0000000..d89b03e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherActivity.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +package org.anbox.appmgr; + +import android.app.Activity; +import android.os.Bundle; +import android.util.Log; +import android.content.Intent; + +public final class LauncherActivity extends Activity { + private static final String TAG = "AnboxAppMgr"; + + @Override + public void onCreate(Bundle info) { + super.onCreate(info); + + Intent intent = new Intent(this, LauncherService.class); + startService(intent); + + Log.i(TAG, "Created launcher activity"); + } + + @Override + public void onDestroy() { + Log.i(TAG, "Destroyed launcher activity"); + + Intent intent = new Intent(this, LauncherService.class); + stopService(intent); + + super.onDestroy(); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherService.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherService.java new file mode 100644 index 0000000..09a94ec --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/LauncherService.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +package org.anbox.appmgr; + +import android.app.Service; +import android.util.Log; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.IBinder; + +public final class LauncherService extends Service { + public static final String TAG = "AnboxAppMgr"; + + private PlatformService mPlatformService; + private PackageEventReceiver mPkgEventReceiver; + + public LauncherService() { + super(); + Log.i(TAG, "Service created"); + } + + @Override + public void onCreate() { + mPlatformService = new PlatformService(getBaseContext()); + + // Send the current list of applications over to the host so + // it can rebuild its list of available applications. + mPlatformService.sendApplicationListUpdate(); + + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_PACKAGE_ADDED); + filter.addAction(Intent.ACTION_PACKAGE_CHANGED); + filter.addAction(Intent.ACTION_PACKAGE_REMOVED); + filter.addDataScheme("package"); + + mPkgEventReceiver = new PackageEventReceiver(); + registerReceiver(mPkgEventReceiver, filter); + + Log.i(TAG, "Service started"); + } + + @Override + public void onDestroy() { + Log.i(TAG, "Service stopped"); + } + + @Override + public IBinder onBind(Intent intent) { + return null; + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/MainApplication.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/MainApplication.java new file mode 100644 index 0000000..db74d49 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/MainApplication.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +package org.anbox.appmgr; + +import android.app.Application; + +public final class MainApplication extends Application { +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageEventReceiver.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageEventReceiver.java new file mode 100644 index 0000000..1f299ba --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageEventReceiver.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +package org.anbox.appmgr; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.util.Log; + +public class PackageEventReceiver extends BroadcastReceiver { + private static final String TAG = "AnboxAppMgr"; + + private PlatformService mPlatformService; + + private String getPackageName(Intent intent) { + Uri uri = intent.getData(); + String package_name = (uri != null ? uri.getSchemeSpecificPart() : null); + return package_name; + } + + @Override + public void onReceive(Context context, Intent intent) { + if (mPlatformService == null) + mPlatformService = new PlatformService(context); + + if (intent.getAction() == Intent.ACTION_PACKAGE_ADDED || + intent.getAction() == Intent.ACTION_PACKAGE_CHANGED) { + // Send updated list of applications to the host so that it + // can update the list of applications available for the user. + mPlatformService.sendApplicationListUpdate(); + } else if (intent.getAction() == Intent.ACTION_PACKAGE_REMOVED) { + // Only send notification when package got removed and not replaced + if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { + mPlatformService.notifyPackageRemoved(getPackageName(intent)); + } + } + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageIntentReceiver.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageIntentReceiver.java new file mode 100644 index 0000000..7d19ce7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PackageIntentReceiver.java @@ -0,0 +1,62 @@ +/* + * The MIT License (MIT) + * + * Copyright 2016 Arnab Chakraborty. http://arnab.ch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this + * software and associated documentation files (the "Software"), to deal in the Software + * without restriction, including without limitation the rights to use, copy, modify, + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies + * or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package org.anbox.appmgr; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; + +/** + * Helper class to look for interesting changes to the installed apps + * so that the loader can be updated. + * + * @Credit http://developer.android.com/reference/android/content/AsyncTaskLoader.html + */ +public class PackageIntentReceiver extends BroadcastReceiver { + + final AppsLoader mLoader; + + public PackageIntentReceiver(AppsLoader loader) { + mLoader = loader; + + IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); + filter.addAction(Intent.ACTION_PACKAGE_REMOVED); + filter.addAction(Intent.ACTION_PACKAGE_CHANGED); + filter.addDataScheme("package"); + mLoader.getContext().registerReceiver(this, filter); + + // Register for events related to sdcard installation. + IntentFilter sdFilter = new IntentFilter(); + sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE); + sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE); + mLoader.getContext().registerReceiver(this, sdFilter); + } + + @Override public void onReceive(Context context, Intent intent) { + // Tell the loader about the change. + mLoader.onContentChanged(); + } + +} diff --git a/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PlatformService.java b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PlatformService.java new file mode 100644 index 0000000..68581aa --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/appmgr/src/org/anbox/appmgr/PlatformService.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +package org.anbox.appmgr; + +import android.os.ServiceManager; +import android.os.IBinder; +import android.os.Parcel; +import android.os.RemoteException; +import android.util.Log; +import android.content.Intent; +import android.content.Context; +import android.content.pm.PackageManager; +import android.content.pm.ApplicationInfo; +import android.net.Uri; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.graphics.Canvas; + +import java.util.List; +import java.io.ByteArrayOutputStream; + +public final class PlatformService { + private static final String TAG = "AnboxAppMgr"; + private static final String SERVICE_NAME = "org.anbox.PlatformService"; + private static final String DESCRIPTOR = "org.anbox.IPlatformService"; + + private static final int TRANSACTION_updateApplicationList = (IBinder.FIRST_CALL_TRANSACTION + 2); + + private IBinder mService = null; + private PackageManager mPm = null; + + private void connectService() { + if (mService != null) + return; + mService = ServiceManager.getService(SERVICE_NAME); + } + + public PlatformService(Context context) { + if (context != null) { + mPm = context.getPackageManager(); + } else { + Log.w(TAG, "No context available"); + } + + Log.i(TAG, "Connected to platform service"); + } + + public void notifyPackageRemoved(String packageName) { + connectService(); + + if (mService == null) + return; + + Log.i(TAG, "Sending package removed notification to host service"); + + Parcel data = Parcel.obtain(); + data.writeInterfaceToken(DESCRIPTOR); + // No added or updated applications to report + data.writeInt(0); + // .. but a single removed application + data.writeInt(1); + data.writeString(packageName); + + Parcel reply = Parcel.obtain(); + try { + mService.transact(TRANSACTION_updateApplicationList, data, reply, 0); + } + catch (RemoteException ex) { + Log.w(TAG, "Failed to send updatePackageList request to remote binder service: " + ex.getMessage()); + } + } + + public void sendApplicationListUpdate() { + connectService(); + + if (mPm == null || mService == null) + return; + + Parcel data = Parcel.obtain(); + data.writeInterfaceToken(DESCRIPTOR); + + List apps = mPm.getInstalledApplications(0); + data.writeInt(apps.size()); + for (int n = 0; n < apps.size(); n++) { + ApplicationInfo appInfo = apps.get(n); + + Intent launchIntent = mPm.getLaunchIntentForPackage(appInfo.packageName); + if (launchIntent == null) + continue; + + Drawable icon = null; + try { + icon = mPm.getApplicationIcon(appInfo.packageName); + } + catch (PackageManager.NameNotFoundException ex) { + continue; + } + + if (icon == null) + continue; + + String name = appInfo.name; + CharSequence label = appInfo.loadLabel(mPm); + if (label != null) + name = label.toString(); + + data.writeString(name); + data.writeString(appInfo.packageName); + + data.writeString(launchIntent.getAction()); + if (launchIntent.getData() != null) + data.writeString(launchIntent.getData().toString()); + else + data.writeString(""); + data.writeString(launchIntent.getType()); + data.writeString(launchIntent.getComponent().getPackageName()); + data.writeString(launchIntent.getComponent().getClassName()); + data.writeInt(launchIntent.getCategories().size()); + for (String category : launchIntent.getCategories()) + data.writeString(category); + + Bitmap iconBitmap = drawableToBitmap(icon); + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + iconBitmap.compress(Bitmap.CompressFormat.PNG, 90, outStream); + data.writeByteArray(outStream.toByteArray()); + } + + // We don't have any removed applications to include in the update + data.writeInt(0); + + Parcel reply = Parcel.obtain(); + try { + mService.transact(TRANSACTION_updateApplicationList, data, reply, 0); + } + catch (RemoteException ex) { + Log.w(TAG, "Failed to send updatePackageList request to remote binder service: " + ex.getMessage()); + } + } + + private Bitmap drawableToBitmap(Drawable drawable) { + if (drawable instanceof BitmapDrawable) + return ((BitmapDrawable)drawable).getBitmap(); + + Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + + return bitmap; + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/audio/MODULE_LICENSE_APACHE2 b/src/type3_AndroidCloud/anbox-master/android/audio/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 diff --git a/src/type3_AndroidCloud/anbox-master/android/audio/NOTICE b/src/type3_AndroidCloud/anbox-master/android/audio/NOTICE new file mode 100644 index 0000000..3237da6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/audio/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2008-2009, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/src/type3_AndroidCloud/anbox-master/android/audio/audio_hw.cpp b/src/type3_AndroidCloud/anbox-master/android/audio/audio_hw.cpp new file mode 100644 index 0000000..f44e738 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/audio/audio_hw.cpp @@ -0,0 +1,676 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "audio_hw_generic" +#define LOG_NDEBUG 0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "anbox/audio/client_info.h" + +#define AUDIO_DEVICE_NAME "/dev/anbox_audio" +#define OUT_SAMPLING_RATE 44100 +#define OUT_BUFFER_SIZE 4096 +#define OUT_LATENCY_MS 20 +#define IN_SAMPLING_RATE 8000 +#define IN_BUFFER_SIZE 320 + +struct generic_audio_device { + struct audio_hw_device device; + pthread_mutex_t lock; + struct audio_stream_out *output; + struct audio_stream_in *input; + bool mic_mute; +}; + +struct generic_stream_out { + struct audio_stream_out stream; + struct generic_audio_device *dev; + audio_devices_t device; + int fd; +}; + +struct generic_stream_in { + struct audio_stream_in stream; + struct generic_audio_device *dev; + audio_devices_t device; + int fd; +}; + +static uint32_t out_get_sample_rate(const struct audio_stream *stream) { + return OUT_SAMPLING_RATE; +} + +static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate) { + return -ENOSYS; +} + +static size_t out_get_buffer_size(const struct audio_stream *stream) { + return OUT_BUFFER_SIZE; +} + +static audio_channel_mask_t out_get_channels(const struct audio_stream *stream) { + return AUDIO_CHANNEL_OUT_STEREO; +} + +static audio_format_t out_get_format(const struct audio_stream *stream) { + return AUDIO_FORMAT_PCM_16_BIT; +} + +static int out_set_format(struct audio_stream *stream, audio_format_t format) { + return -ENOSYS; +} + +static int out_standby(struct audio_stream *stream) { + return 0; +} + +static int out_dump(const struct audio_stream *stream, int fd) { + struct generic_stream_out *out = (struct generic_stream_out *)stream; + + dprintf(fd, + "\tout_dump:\n" + "\t\tsample rate: %u\n" + "\t\tbuffer size: %u\n" + "\t\tchannel mask: %08x\n" + "\t\tformat: %d\n" + "\t\tdevice: %08x\n" + "\t\taudio dev: %p\n\n", + out_get_sample_rate(stream), + out_get_buffer_size(stream), + out_get_channels(stream), + out_get_format(stream), + out->device, + out->dev); + + return 0; +} + +static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) { + struct generic_stream_out *out = (struct generic_stream_out *)stream; + struct str_parms *parms; + char value[32]; + int ret; + long val; + char *end; + + parms = str_parms_create_str(kvpairs); + + ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, + value, sizeof(value)); + if (ret >= 0) { + errno = 0; + val = strtol(value, &end, 10); + if (errno == 0 && (end != NULL) && (*end == '\0') && ((int)val == val)) { + out->device = (int)val; + } else { + ret = -EINVAL; + } + } + + str_parms_destroy(parms); + return ret; +} + +static char *out_get_parameters(const struct audio_stream *stream, const char *keys) { + struct generic_stream_out *out = (struct generic_stream_out *)stream; + struct str_parms *query = str_parms_create_str(keys); + char *str; + char value[256]; + struct str_parms *reply = str_parms_create(); + int ret; + + ret = str_parms_get_str(query, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value)); + if (ret >= 0) { + str_parms_add_int(reply, AUDIO_PARAMETER_STREAM_ROUTING, out->device); + str = strdup(str_parms_to_str(reply)); + } else { + str = strdup(keys); + } + + str_parms_destroy(query); + str_parms_destroy(reply); + return str; +} + +static uint32_t out_get_latency(const struct audio_stream_out *stream) { + return OUT_LATENCY_MS; +} + +static int out_set_volume(struct audio_stream_out *stream, float left, + float right) { + return -ENOSYS; +} + +static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, + size_t bytes) { + struct generic_stream_out *out = (struct generic_stream_out *)stream; + struct generic_audio_device *adev = out->dev; + + pthread_mutex_lock(&adev->lock); + if (out->fd >= 0) + bytes = write(out->fd, buffer, bytes); + pthread_mutex_unlock(&adev->lock); + return bytes; +} + +static int out_get_render_position(const struct audio_stream_out *stream, + uint32_t *dsp_frames) { + return -ENOSYS; +} + +static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { + return 0; +} + +static int out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { + return 0; +} + +static int out_get_next_write_timestamp(const struct audio_stream_out *stream, + int64_t *timestamp) { + return -ENOSYS; +} + +static uint32_t in_get_sample_rate(const struct audio_stream *stream) { + return IN_SAMPLING_RATE; +} + +static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate) { + return -ENOSYS; +} + +static size_t in_get_buffer_size(const struct audio_stream *stream) { + return IN_BUFFER_SIZE; +} + +static audio_channel_mask_t in_get_channels(const struct audio_stream *stream) { + return AUDIO_CHANNEL_IN_MONO; +} + +static audio_format_t in_get_format(const struct audio_stream *stream) { + return AUDIO_FORMAT_PCM_16_BIT; +} + +static int in_set_format(struct audio_stream *stream, audio_format_t format) { + return -ENOSYS; +} + +static int in_standby(struct audio_stream *stream) { + return 0; +} + +static int in_dump(const struct audio_stream *stream, int fd) { + struct generic_stream_in *in = (struct generic_stream_in *)stream; + + dprintf(fd, + "\tin_dump:\n" + "\t\tsample rate: %u\n" + "\t\tbuffer size: %u\n" + "\t\tchannel mask: %08x\n" + "\t\tformat: %d\n" + "\t\tdevice: %08x\n" + "\t\taudio dev: %p\n\n", + in_get_sample_rate(stream), + in_get_buffer_size(stream), + in_get_channels(stream), + in_get_format(stream), + in->device, + in->dev); + + return 0; +} + +static int in_set_parameters(struct audio_stream *stream, const char *kvpairs) { + struct generic_stream_in *in = (struct generic_stream_in *)stream; + struct str_parms *parms; + char value[32]; + int ret; + long val; + char *end; + + parms = str_parms_create_str(kvpairs); + + ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, + value, sizeof(value)); + if (ret >= 0) { + errno = 0; + val = strtol(value, &end, 10); + if ((errno == 0) && (end != NULL) && (*end == '\0') && ((int)val == val)) { + in->device = (int)val; + } else { + ret = -EINVAL; + } + } + + str_parms_destroy(parms); + return ret; +} + +static char *in_get_parameters(const struct audio_stream *stream, + const char *keys) { + struct generic_stream_in *in = (struct generic_stream_in *)stream; + struct str_parms *query = str_parms_create_str(keys); + char *str; + char value[256]; + struct str_parms *reply = str_parms_create(); + int ret; + + ret = str_parms_get_str(query, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value)); + if (ret >= 0) { + str_parms_add_int(reply, AUDIO_PARAMETER_STREAM_ROUTING, in->device); + str = strdup(str_parms_to_str(reply)); + } else { + str = strdup(keys); + } + + str_parms_destroy(query); + str_parms_destroy(reply); + return str; +} + +static int in_set_gain(struct audio_stream_in *stream, float gain) { + return 0; +} + +static ssize_t in_read(struct audio_stream_in *stream, void *buffer, + size_t bytes) { + struct generic_stream_in *in = (struct generic_stream_in *)stream; + struct generic_audio_device *adev = in->dev; + + pthread_mutex_lock(&adev->lock); + if (in->fd >= 0) + bytes = read(in->fd, buffer, bytes); + if (adev->mic_mute && (bytes > 0)) { + memset(buffer, 0, bytes); + } + pthread_mutex_unlock(&adev->lock); + + return bytes; +} + +static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream) { + return 0; +} + +static int in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { + return 0; +} + +static int in_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { + return 0; +} + +static int connect_audio_server(const anbox::audio::ClientInfo::Type &type) { + int fd = socket(AF_LOCAL, SOCK_STREAM, 0); + if (fd < 0) + return -errno; + + struct sockaddr_un addr; + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, AUDIO_DEVICE_NAME, sizeof(addr.sun_path)); + + if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + close(fd); + return -errno; + } + + // We will send out client type information to the server and the + // server will either deny the request by closing the connection + // or by sending us the approved client details back. + anbox::audio::ClientInfo client_info{type}; + if (::write(fd, &client_info, sizeof(client_info)) < 0) { + close(fd); + return -EIO; + } + + auto bytes_read = ::read(fd, &client_info, sizeof(client_info)); + if (bytes_read < 0) { + close(fd); + return -EIO; + } + + // FIXME once we have real client details we need to check if we + // got everything we need or if anything is missing. + + ALOGE("Successfully connected Anbox audio server"); + + return fd; +} + +static int adev_open_output_stream(struct audio_hw_device *dev, + audio_io_handle_t handle, + audio_devices_t devices, + audio_output_flags_t flags, + struct audio_config *config, + struct audio_stream_out **stream_out, + const char *address __unused) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + struct generic_stream_out *out; + int ret = 0, fd = 0; + + pthread_mutex_lock(&adev->lock); + if (adev->output != NULL) { + ret = -ENOSYS; + goto error; + } + + fd = connect_audio_server(anbox::audio::ClientInfo::Type::Playback); + if (fd < 0) { + ret = fd; + ALOGE("Failed to connect with Anbox audio servers (err %d)", ret); + goto error; + } + + if ((config->format != AUDIO_FORMAT_PCM_16_BIT) || + (config->channel_mask != AUDIO_CHANNEL_OUT_STEREO) || + (config->sample_rate != OUT_SAMPLING_RATE)) { + ALOGE("Error opening output stream format %d, channel_mask %04x, sample_rate %u", + config->format, config->channel_mask, config->sample_rate); + config->format = AUDIO_FORMAT_PCM_16_BIT; + config->channel_mask = AUDIO_CHANNEL_OUT_STEREO; + config->sample_rate = OUT_SAMPLING_RATE; + ret = -EINVAL; + goto error; + } + + out = (struct generic_stream_out *)calloc(1, sizeof(struct generic_stream_out)); + out->fd = fd; + + out->stream.common.get_sample_rate = out_get_sample_rate; + out->stream.common.set_sample_rate = out_set_sample_rate; + out->stream.common.get_buffer_size = out_get_buffer_size; + out->stream.common.get_channels = out_get_channels; + out->stream.common.get_format = out_get_format; + out->stream.common.set_format = out_set_format; + out->stream.common.standby = out_standby; + out->stream.common.dump = out_dump; + out->stream.common.set_parameters = out_set_parameters; + out->stream.common.get_parameters = out_get_parameters; + out->stream.common.add_audio_effect = out_add_audio_effect; + out->stream.common.remove_audio_effect = out_remove_audio_effect; + out->stream.get_latency = out_get_latency; + out->stream.set_volume = out_set_volume; + out->stream.write = out_write; + out->stream.get_render_position = out_get_render_position; + out->stream.get_next_write_timestamp = out_get_next_write_timestamp; + + out->dev = adev; + out->device = devices; + adev->output = (struct audio_stream_out *)out; + *stream_out = &out->stream; + +error: + pthread_mutex_unlock(&adev->lock); + + return ret; +} + +static void adev_close_output_stream(struct audio_hw_device *dev, + struct audio_stream_out *stream) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + + pthread_mutex_lock(&adev->lock); + if (stream == adev->output) { + free(stream); + adev->output = NULL; + } + pthread_mutex_unlock(&adev->lock); +} + +static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) { + return 0; +} + +static char *adev_get_parameters(const struct audio_hw_device *dev, + const char *keys) { + return strdup(""); +} + +static int adev_init_check(const struct audio_hw_device *dev) { + return 0; +} + +static int adev_set_voice_volume(struct audio_hw_device *dev, float volume) { + return 0; +} + +static int adev_set_master_volume(struct audio_hw_device *dev, float volume) { + return -ENOSYS; +} + +static int adev_get_master_volume(struct audio_hw_device *dev, float *volume) { + return -ENOSYS; +} + +static int adev_set_master_mute(struct audio_hw_device *dev, bool muted) { + return -ENOSYS; +} + +static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted) { + return -ENOSYS; +} + +static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode) { + return 0; +} + +static int adev_set_mic_mute(struct audio_hw_device *dev, bool state) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + + pthread_mutex_lock(&adev->lock); + adev->mic_mute = state; + pthread_mutex_unlock(&adev->lock); + return 0; +} + +static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + + pthread_mutex_lock(&adev->lock); + *state = adev->mic_mute; + pthread_mutex_unlock(&adev->lock); + + return 0; +} + +static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev, + const struct audio_config *config) { + return IN_BUFFER_SIZE; +} + +static int adev_open_input_stream(struct audio_hw_device *dev, + audio_io_handle_t handle, + audio_devices_t devices, + struct audio_config *config, + struct audio_stream_in **stream_in, + audio_input_flags_t flags __unused, + const char *address __unused, + audio_source_t source __unused) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + struct generic_stream_in *in; + int ret = 0, fd = 0; + + pthread_mutex_lock(&adev->lock); + if (adev->input != NULL) { + ret = -ENOSYS; + goto error; + } + + if ((config->format != AUDIO_FORMAT_PCM_16_BIT) || + (config->channel_mask != AUDIO_CHANNEL_IN_MONO) || + (config->sample_rate != IN_SAMPLING_RATE)) { + ALOGE("Error opening input stream format %d, channel_mask %04x, sample_rate %u", + config->format, config->channel_mask, config->sample_rate); + config->format = AUDIO_FORMAT_PCM_16_BIT; + config->channel_mask = AUDIO_CHANNEL_IN_MONO; + config->sample_rate = IN_SAMPLING_RATE; + ret = -EINVAL; + goto error; + } + + fd = connect_audio_server(anbox::audio::ClientInfo::Type::Recording); + if (fd < 0) { + ret = fd; + ALOGE("Failed to connect with Anbox audio servers (err %d)", ret); + goto error; + } + + in = (struct generic_stream_in *)calloc(1, sizeof(struct generic_stream_in)); + in->fd = fd; + + in->stream.common.get_sample_rate = in_get_sample_rate; + in->stream.common.set_sample_rate = in_set_sample_rate; + in->stream.common.get_buffer_size = in_get_buffer_size; + in->stream.common.get_channels = in_get_channels; + in->stream.common.get_format = in_get_format; + in->stream.common.set_format = in_set_format; + in->stream.common.standby = in_standby; + in->stream.common.dump = in_dump; + in->stream.common.set_parameters = in_set_parameters; + in->stream.common.get_parameters = in_get_parameters; + in->stream.common.add_audio_effect = in_add_audio_effect; + in->stream.common.remove_audio_effect = in_remove_audio_effect; + in->stream.set_gain = in_set_gain; + in->stream.read = in_read; + in->stream.get_input_frames_lost = in_get_input_frames_lost; + + in->dev = adev; + in->device = devices; + adev->input = (struct audio_stream_in *)in; + *stream_in = &in->stream; + +error: + pthread_mutex_unlock(&adev->lock); + + return ret; +} + +static void adev_close_input_stream(struct audio_hw_device *dev, + struct audio_stream_in *stream) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + + pthread_mutex_lock(&adev->lock); + if (stream == adev->input) { + free(stream); + adev->input = NULL; + } + pthread_mutex_unlock(&adev->lock); +} + +static int adev_dump(const audio_hw_device_t *dev, int fd) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + + const size_t SIZE = 256; + char buffer[SIZE]; + + dprintf(fd, + "\nadev_dump:\n" + "\tmic_mute: %s\n" + "\toutput: %p\n" + "\tinput: %p\n\n", + adev->mic_mute ? "true" : "false", + adev->output, + adev->input); + + if (adev->output != NULL) + out_dump((const struct audio_stream *)adev->output, fd); + if (adev->input != NULL) + in_dump((const struct audio_stream *)adev->input, fd); + + return 0; +} + +static int adev_close(hw_device_t *dev) { + struct generic_audio_device *adev = (struct generic_audio_device *)dev; + + adev_close_output_stream((struct audio_hw_device *)dev, adev->output); + adev_close_input_stream((struct audio_hw_device *)dev, adev->input); + + free(dev); + return 0; +} + +static int adev_open(const hw_module_t *module, const char *name, + hw_device_t **device) { + struct generic_audio_device *adev; + + if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) + return -EINVAL; + + adev = (struct generic_audio_device*) calloc(1, sizeof(struct generic_audio_device)); + + adev->device.common.tag = HARDWARE_DEVICE_TAG; + adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0; + adev->device.common.module = (struct hw_module_t *)module; + adev->device.common.close = adev_close; + + adev->device.init_check = adev_init_check; + adev->device.set_voice_volume = adev_set_voice_volume; + adev->device.set_master_volume = adev_set_master_volume; + adev->device.get_master_volume = adev_get_master_volume; + adev->device.set_master_mute = adev_set_master_mute; + adev->device.get_master_mute = adev_get_master_mute; + adev->device.set_mode = adev_set_mode; + adev->device.set_mic_mute = adev_set_mic_mute; + adev->device.get_mic_mute = adev_get_mic_mute; + adev->device.set_parameters = adev_set_parameters; + adev->device.get_parameters = adev_get_parameters; + adev->device.get_input_buffer_size = adev_get_input_buffer_size; + adev->device.open_output_stream = adev_open_output_stream; + adev->device.close_output_stream = adev_close_output_stream; + adev->device.open_input_stream = adev_open_input_stream; + adev->device.close_input_stream = adev_close_input_stream; + adev->device.dump = adev_dump; + + *device = &adev->device.common; + + return 0; +} + +static struct hw_module_methods_t hal_module_methods = { + .open = adev_open, +}; + +struct audio_module HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = AUDIO_MODULE_API_VERSION_0_1, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = AUDIO_HARDWARE_MODULE_ID, + .name = "Anbox audio HW HAL", + .author = "The Android Open Source Project", + .methods = &hal_module_methods, + }, +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/Android.mk b/src/type3_AndroidCloud/anbox-master/android/camera/Android.mk new file mode 100644 index 0000000..26d4936 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/Android.mk @@ -0,0 +1,152 @@ +# Copyright (C) 2011 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +# Emulator camera module######################################################## + +emulator_camera_module_relative_path := hw +emulator_camera_cflags := -fno-short-enums -DQEMU_HARDWARE +emulator_camera_cflags += -Wno-unused-parameter -Wno-missing-field-initializers +emulator_camera_clang_flags := -Wno-c++11-narrowing +emulator_camera_shared_libraries := \ + libbinder \ + liblog \ + libutils \ + libcutils \ + libcamera_client \ + libui \ + libdl \ + libjpeg \ + libcamera_metadata + +emulator_camera_c_includes := external/jpeg \ + frameworks/native/include/media/hardware \ + $(LOCAL_PATH)/../opengl/system/OpenglSystemCommon \ + $(call include-path-for, camera) + +emulator_camera_src := \ + EmulatedCameraHal.cpp \ + EmulatedCameraFactory.cpp \ + EmulatedCameraHotplugThread.cpp \ + EmulatedBaseCamera.cpp \ + EmulatedCamera.cpp \ + EmulatedCameraDevice.cpp \ + EmulatedQemuCamera.cpp \ + EmulatedQemuCameraDevice.cpp \ + EmulatedFakeCamera.cpp \ + EmulatedFakeCameraDevice.cpp \ + Converters.cpp \ + PreviewWindow.cpp \ + CallbackNotifier.cpp \ + QemuClient.cpp \ + JpegCompressor.cpp \ + EmulatedCamera2.cpp \ + EmulatedFakeCamera2.cpp \ + EmulatedQemuCamera2.cpp \ + fake-pipeline2/Scene.cpp \ + fake-pipeline2/Sensor.cpp \ + fake-pipeline2/JpegCompressor.cpp \ + EmulatedCamera3.cpp \ + EmulatedFakeCamera3.cpp + +# Emulated camera - goldfish / vbox_x86 build################################### + +LOCAL_MODULE_RELATIVE_PATH := ${emulator_camera_module_relative_path} +LOCAL_CFLAGS := ${emulator_camera_cflags} +LOCAL_CLANG_CFLAGS += ${emulator_camera_clang_flags} + +LOCAL_SHARED_LIBRARIES := ${emulator_camera_shared_libraries} +LOCAL_C_INCLUDES += ${emulator_camera_c_includes} +LOCAL_SRC_FILES := ${emulator_camera_src} + +ifeq ($(TARGET_PRODUCT),vbox_x86) +LOCAL_MODULE := camera.vbox_x86 +else +LOCAL_MODULE := camera.goldfish +endif + +include $(BUILD_SHARED_LIBRARY) + +# Emulator camera - ranchu build################################################ + +include ${CLEAR_VARS} + +LOCAL_MODULE_RELATIVE_PATH := ${emulator_camera_module_relative_path} +LOCAL_CFLAGS := ${emulator_camera_cflags} +LOCAL_CLANG_CFLAGS += ${emulator_camera_clang_flags} + +LOCAL_SHARED_LIBRARIES := ${emulator_camera_shared_libraries} +LOCAL_C_INCLUDES += ${emulator_camera_c_includes} +LOCAL_SRC_FILES := ${emulator_camera_src} + +LOCAL_MODULE := camera.ranchu + +include $(BUILD_SHARED_LIBRARY) + +# JPEG stub##################################################################### + +ifneq ($(TARGET_BUILD_PDK),true) + +include $(CLEAR_VARS) + +jpeg_module_relative_path := hw +jpeg_cflags := -fno-short-enums -DQEMU_HARDWARE +jpeg_cflags += -Wno-unused-parameter +jpeg_clang_flags += -Wno-c++11-narrowing +jpeg_shared_libraries := \ + libcutils \ + liblog \ + libskia \ + libandroid_runtime +jpeg_c_includes := external/libjpeg-turbo \ + external/skia/include/core/ \ + frameworks/base/core/jni/android/graphics \ + frameworks/native/include +jpeg_src := JpegStub.cpp + +# JPEG stub - goldfish build#################################################### + +LOCAL_MODULE_RELATIVE_PATH := ${jpeg_module_relative_path} +LOCAL_CFLAGS += ${jpeg_cflags} +LOCAL_CLANG_CFLAGS += ${jpeg_clangflags} + +LOCAL_SHARED_LIBRARIES := ${jpeg_shared_libraries} +LOCAL_C_INCLUDES += ${jpeg_c_includes} +LOCAL_SRC_FILES := ${jpeg_src} + +LOCAL_MODULE := camera.goldfish.jpeg + +include $(BUILD_SHARED_LIBRARY) + +# JPEG stub - ranchu build###################################################### + +include ${CLEAR_VARS} + +LOCAL_MODULE := camera.ranchu.jpeg + +LOCAL_MODULE_RELATIVE_PATH := ${jpeg_module_relative_path} +LOCAL_CFLAGS += ${jpeg_cflags} +LOCAL_CLANG_CFLAGS += ${jpeg_clangflags} + +LOCAL_SHARED_LIBRARIES := ${jpeg_shared_libraries} +LOCAL_C_INCLUDES += ${jpeg_c_includes} +LOCAL_SRC_FILES := ${jpeg_src} + +include $(BUILD_SHARED_LIBRARY) + +endif # !PDK diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.cpp new file mode 100644 index 0000000..0dbd50d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.cpp @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class CallbackNotifier that manages callbacks set + * via set_callbacks, enable_msg_type, and disable_msg_type camera HAL API. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_CallbackNotifier" +#include +#include +#include "EmulatedCameraDevice.h" +#include "CallbackNotifier.h" +#include "JpegCompressor.h" + +namespace android { + +/* String representation of camera messages. */ +static const char* lCameraMessages[] = +{ + "CAMERA_MSG_ERROR", + "CAMERA_MSG_SHUTTER", + "CAMERA_MSG_FOCUS", + "CAMERA_MSG_ZOOM", + "CAMERA_MSG_PREVIEW_FRAME", + "CAMERA_MSG_VIDEO_FRAME", + "CAMERA_MSG_POSTVIEW_FRAME", + "CAMERA_MSG_RAW_IMAGE", + "CAMERA_MSG_COMPRESSED_IMAGE", + "CAMERA_MSG_RAW_IMAGE_NOTIFY", + "CAMERA_MSG_PREVIEW_METADATA" +}; +static const int lCameraMessagesNum = sizeof(lCameraMessages) / sizeof(char*); + +/* Builds an array of strings for the given set of messages. + * Param: + * msg - Messages to get strings for, + * strings - Array where to save strings + * max - Maximum number of entries in the array. + * Return: + * Number of strings saved into the 'strings' array. + */ +static int GetMessageStrings(uint32_t msg, const char** strings, int max) +{ + int index = 0; + int out = 0; + while (msg != 0 && out < max && index < lCameraMessagesNum) { + while ((msg & 0x1) == 0 && index < lCameraMessagesNum) { + msg >>= 1; + index++; + } + if ((msg & 0x1) != 0 && index < lCameraMessagesNum) { + strings[out] = lCameraMessages[index]; + out++; + msg >>= 1; + index++; + } + } + + return out; +} + +/* Logs messages, enabled by the mask. */ +static void PrintMessages(uint32_t msg) +{ + const char* strs[lCameraMessagesNum]; + const int translated = GetMessageStrings(msg, strs, lCameraMessagesNum); + for (int n = 0; n < translated; n++) { + ALOGV(" %s", strs[n]); + } +} + +CallbackNotifier::CallbackNotifier() + : mNotifyCB(NULL), + mDataCB(NULL), + mDataCBTimestamp(NULL), + mGetMemoryCB(NULL), + mCBOpaque(NULL), + mLastFrameTimestamp(0), + mFrameRefreshFreq(0), + mMessageEnabler(0), + mJpegQuality(90), + mVideoRecEnabled(false), + mTakingPicture(false) +{ +} + +CallbackNotifier::~CallbackNotifier() +{ +} + +/**************************************************************************** + * Camera API + ***************************************************************************/ + +void CallbackNotifier::setCallbacks(camera_notify_callback notify_cb, + camera_data_callback data_cb, + camera_data_timestamp_callback data_cb_timestamp, + camera_request_memory get_memory, + void* user) +{ + ALOGV("%s: %p, %p, %p, %p (%p)", + __FUNCTION__, notify_cb, data_cb, data_cb_timestamp, get_memory, user); + + Mutex::Autolock locker(&mObjectLock); + mNotifyCB = notify_cb; + mDataCB = data_cb; + mDataCBTimestamp = data_cb_timestamp; + mGetMemoryCB = get_memory; + mCBOpaque = user; +} + +void CallbackNotifier::enableMessage(uint msg_type) +{ + ALOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type); + PrintMessages(msg_type); + + Mutex::Autolock locker(&mObjectLock); + mMessageEnabler |= msg_type; + ALOGV("**** Currently enabled messages:"); + PrintMessages(mMessageEnabler); +} + +void CallbackNotifier::disableMessage(uint msg_type) +{ + ALOGV("%s: msg_type = 0x%x", __FUNCTION__, msg_type); + PrintMessages(msg_type); + + Mutex::Autolock locker(&mObjectLock); + mMessageEnabler &= ~msg_type; + ALOGV("**** Currently enabled messages:"); + PrintMessages(mMessageEnabler); +} + +status_t CallbackNotifier::enableVideoRecording(int fps) +{ + ALOGV("%s: FPS = %d", __FUNCTION__, fps); + + Mutex::Autolock locker(&mObjectLock); + mVideoRecEnabled = true; + mLastFrameTimestamp = 0; + mFrameRefreshFreq = 1000000000LL / fps; + + return NO_ERROR; +} + +void CallbackNotifier::disableVideoRecording() +{ + ALOGV("%s:", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + mVideoRecEnabled = false; + mLastFrameTimestamp = 0; + mFrameRefreshFreq = 0; +} + +void CallbackNotifier::releaseRecordingFrame(const void* opaque) +{ + List::iterator it = mCameraMemoryTs.begin(); + for( ; it != mCameraMemoryTs.end(); ++it ) { + if ( (*it)->data == opaque ) { + (*it)->release( *it ); + mCameraMemoryTs.erase(it); + break; + } + } +} + +status_t CallbackNotifier::storeMetaDataInBuffers(bool enable) +{ + // Return error if metadata is request, otherwise silently agree. + return enable ? INVALID_OPERATION : NO_ERROR; +} + +/**************************************************************************** + * Public API + ***************************************************************************/ + +void CallbackNotifier::cleanupCBNotifier() +{ + Mutex::Autolock locker(&mObjectLock); + mMessageEnabler = 0; + mNotifyCB = NULL; + mDataCB = NULL; + mDataCBTimestamp = NULL; + mGetMemoryCB = NULL; + mCBOpaque = NULL; + mLastFrameTimestamp = 0; + mFrameRefreshFreq = 0; + mJpegQuality = 90; + mVideoRecEnabled = false; + mTakingPicture = false; +} + +void CallbackNotifier::onNextFrameAvailable(const void* frame, + nsecs_t timestamp, + EmulatedCameraDevice* camera_dev) +{ + if (isMessageEnabled(CAMERA_MSG_VIDEO_FRAME) && isVideoRecordingEnabled() && + isNewVideoFrameTime(timestamp)) { + camera_memory_t* cam_buff = + mGetMemoryCB(-1, camera_dev->getFrameBufferSize(), 1, NULL); + if (NULL != cam_buff && NULL != cam_buff->data) { + memcpy(cam_buff->data, frame, camera_dev->getFrameBufferSize()); + mDataCBTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME, + cam_buff, 0, mCBOpaque); + + mCameraMemoryTs.push_back( cam_buff ); + } else { + ALOGE("%s: Memory failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__); + } + } + + if (isMessageEnabled(CAMERA_MSG_PREVIEW_FRAME)) { + camera_memory_t* cam_buff = + mGetMemoryCB(-1, camera_dev->getFrameBufferSize(), 1, NULL); + if (NULL != cam_buff && NULL != cam_buff->data) { + memcpy(cam_buff->data, frame, camera_dev->getFrameBufferSize()); + mDataCB(CAMERA_MSG_PREVIEW_FRAME, cam_buff, 0, NULL, mCBOpaque); + cam_buff->release(cam_buff); + } else { + ALOGE("%s: Memory failure in CAMERA_MSG_PREVIEW_FRAME", __FUNCTION__); + } + } + + if (mTakingPicture) { + /* This happens just once. */ + mTakingPicture = false; + /* The sequence of callbacks during picture taking is: + * - CAMERA_MSG_SHUTTER + * - CAMERA_MSG_RAW_IMAGE_NOTIFY + * - CAMERA_MSG_COMPRESSED_IMAGE + */ + if (isMessageEnabled(CAMERA_MSG_SHUTTER)) { + mNotifyCB(CAMERA_MSG_SHUTTER, 0, 0, mCBOpaque); + } + if (isMessageEnabled(CAMERA_MSG_RAW_IMAGE_NOTIFY)) { + mNotifyCB(CAMERA_MSG_RAW_IMAGE_NOTIFY, 0, 0, mCBOpaque); + } + if (isMessageEnabled(CAMERA_MSG_COMPRESSED_IMAGE)) { + /* Compress the frame to JPEG. Note that when taking pictures, we + * have requested camera device to provide us with NV21 frames. */ + NV21JpegCompressor compressor; + status_t res = + compressor.compressRawImage(frame, camera_dev->getFrameWidth(), + camera_dev->getFrameHeight(), + mJpegQuality); + if (res == NO_ERROR) { + camera_memory_t* jpeg_buff = + mGetMemoryCB(-1, compressor.getCompressedSize(), 1, NULL); + if (NULL != jpeg_buff && NULL != jpeg_buff->data) { + compressor.getCompressedImage(jpeg_buff->data); + mDataCB(CAMERA_MSG_COMPRESSED_IMAGE, jpeg_buff, 0, NULL, mCBOpaque); + jpeg_buff->release(jpeg_buff); + } else { + ALOGE("%s: Memory failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__); + } + } else { + ALOGE("%s: Compression failure in CAMERA_MSG_VIDEO_FRAME", __FUNCTION__); + } + } + } +} + +void CallbackNotifier::onCameraDeviceError(int err) +{ + if (isMessageEnabled(CAMERA_MSG_ERROR) && mNotifyCB != NULL) { + mNotifyCB(CAMERA_MSG_ERROR, err, 0, mCBOpaque); + } +} + +/**************************************************************************** + * Private API + ***************************************************************************/ + +bool CallbackNotifier::isNewVideoFrameTime(nsecs_t timestamp) +{ + Mutex::Autolock locker(&mObjectLock); + if ((timestamp - mLastFrameTimestamp) >= mFrameRefreshFreq) { + mLastFrameTimestamp = timestamp; + return true; + } + return false; +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.h b/src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.h new file mode 100644 index 0000000..24784b5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/CallbackNotifier.h @@ -0,0 +1,238 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_CALLBACK_NOTIFIER_H +#define HW_EMULATOR_CAMERA_CALLBACK_NOTIFIER_H + +/* + * Contains declaration of a class CallbackNotifier that manages callbacks set + * via set_callbacks, enable_msg_type, and disable_msg_type camera HAL API. + */ + +#include + +namespace android { + +class EmulatedCameraDevice; + +/* Manages callbacks set via set_callbacks, enable_msg_type, and disable_msg_type + * camera HAL API. + * + * Objects of this class are contained in EmulatedCamera objects, and handle + * relevant camera API callbacks. + * Locking considerations. Apparently, it's not allowed to call callbacks + * registered in this class, while holding a lock: recursion is quite possible, + * which will cause a deadlock. + */ +class CallbackNotifier { +public: + /* Constructs CallbackNotifier instance. */ + CallbackNotifier(); + + /* Destructs CallbackNotifier instance. */ + ~CallbackNotifier(); + + /**************************************************************************** + * Camera API + ***************************************************************************/ + +public: + /* Actual handler for camera_device_ops_t::set_callbacks callback. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::set_callbacks callback. + */ + void setCallbacks(camera_notify_callback notify_cb, + camera_data_callback data_cb, + camera_data_timestamp_callback data_cb_timestamp, + camera_request_memory get_memory, + void* user); + + /* Actual handler for camera_device_ops_t::enable_msg_type callback. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::enable_msg_type callback. + */ + void enableMessage(uint msg_type); + + /* Actual handler for camera_device_ops_t::disable_msg_type callback. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::disable_msg_type callback. + */ + void disableMessage(uint msg_type); + + /* Actual handler for camera_device_ops_t::store_meta_data_in_buffers + * callback. This method is called by the containing emulated camera object + * when it is handing the camera_device_ops_t::store_meta_data_in_buffers + * callback. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + status_t storeMetaDataInBuffers(bool enable); + + /* Enables video recording. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::start_recording callback. + * Param: + * fps - Video frame frequency. This parameter determins when a frame + * received via onNextFrameAvailable call will be pushed through the + * callback. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + status_t enableVideoRecording(int fps); + + /* Disables video recording. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::stop_recording callback. + */ + void disableVideoRecording(); + + /* Releases video frame, sent to the framework. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::release_recording_frame callback. + */ + void releaseRecordingFrame(const void* opaque); + + /* Actual handler for camera_device_ops_t::msg_type_enabled callback. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::msg_type_enabled callback. + * Note: this method doesn't grab a lock while checking message status, since + * upon exit the status would be undefined anyway. So, grab a lock before + * calling this method if you care about persisting a defined message status. + * Return: + * 0 if message is disabled, or non-zero value, if message is enabled. + */ + inline int isMessageEnabled(uint msg_type) + { + return mMessageEnabler & msg_type; + } + + /* Checks id video recording is enabled. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::recording_enabled callback. + * Note: this method doesn't grab a lock while checking video recordin status, + * since upon exit the status would be undefined anyway. So, grab a lock + * before calling this method if you care about persisting of a defined video + * recording status. + * Return: + * true if video recording is enabled, or false if it is disabled. + */ + inline bool isVideoRecordingEnabled() + { + return mVideoRecEnabled; + } + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + /* Resets the callback notifier. */ + void cleanupCBNotifier(); + + /* Next frame is available in the camera device. + * This is a notification callback that is invoked by the camera device when + * a new frame is available. + * Note that most likely this method is called in context of a worker thread + * that camera device has created for frame capturing. + * Param: + * frame - Captured frame, or NULL if camera device didn't pull the frame + * yet. If NULL is passed in this parameter use GetCurrentFrame method + * of the camera device class to obtain the next frame. Also note that + * the size of the frame that is passed here (as well as the frame + * returned from the GetCurrentFrame method) is defined by the current + * frame settings (width + height + pixel format) for the camera device. + * timestamp - Frame's timestamp. + * camera_dev - Camera device instance that delivered the frame. + */ + void onNextFrameAvailable(const void* frame, + nsecs_t timestamp, + EmulatedCameraDevice* camera_dev); + + /* Entry point for notifications that occur in camera device. + * Param: + * err - CAMERA_ERROR_XXX error code. + */ + void onCameraDeviceError(int err); + + /* Sets, or resets taking picture state. + * This state control whether or not to notify the framework about compressed + * image, shutter, and other picture related events. + */ + void setTakingPicture(bool taking) + { + mTakingPicture = taking; + } + + /* Sets JPEG quality used to compress frame during picture taking. */ + void setJpegQuality(int jpeg_quality) + { + mJpegQuality = jpeg_quality; + } + + /**************************************************************************** + * Private API + ***************************************************************************/ + +protected: + /* Checks if it's time to push new video frame. + * Note that this method must be called while object is locked. + * Param: + * timestamp - Timestamp for the new frame. */ + bool isNewVideoFrameTime(nsecs_t timestamp); + + /**************************************************************************** + * Data members + ***************************************************************************/ + +protected: + /* Locks this instance for data change. */ + Mutex mObjectLock; + + /* + * Callbacks, registered in set_callbacks. + */ + + camera_notify_callback mNotifyCB; + camera_data_callback mDataCB; + camera_data_timestamp_callback mDataCBTimestamp; + camera_request_memory mGetMemoryCB; + void* mCBOpaque; + + /* video frame queue for the CameraHeapMemory destruction */ + List mCameraMemoryTs; + + /* Timestamp when last frame has been delivered to the framework. */ + nsecs_t mLastFrameTimestamp; + + /* Video frequency in nanosec. */ + nsecs_t mFrameRefreshFreq; + + /* Message enabler. */ + uint32_t mMessageEnabler; + + /* JPEG quality used to compress frame during picture taking. */ + int mJpegQuality; + + /* Video recording status. */ + bool mVideoRecEnabled; + + /* Picture taking status. */ + bool mTakingPicture; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_CALLBACK_NOTIFIER_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/Converters.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/Converters.cpp new file mode 100644 index 0000000..f63f67f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/Converters.cpp @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implemenation of framebuffer conversion routines. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_Converter" +#include +#include "Converters.h" + +namespace android { + +static void _YUV420SToRGB565(const uint8_t* Y, + const uint8_t* U, + const uint8_t* V, + int dUV, + uint16_t* rgb, + int width, + int height) +{ + const uint8_t* U_pos = U; + const uint8_t* V_pos = V; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x += 2, U += dUV, V += dUV) { + const uint8_t nU = *U; + const uint8_t nV = *V; + *rgb = YUVToRGB565(*Y, nU, nV); + Y++; rgb++; + *rgb = YUVToRGB565(*Y, nU, nV); + Y++; rgb++; + } + if (y & 0x1) { + U_pos = U; + V_pos = V; + } else { + U = U_pos; + V = V_pos; + } + } +} + +static void _YUV420SToRGB32(const uint8_t* Y, + const uint8_t* U, + const uint8_t* V, + int dUV, + uint32_t* rgb, + int width, + int height) +{ + const uint8_t* U_pos = U; + const uint8_t* V_pos = V; + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x += 2, U += dUV, V += dUV) { + const uint8_t nU = *U; + const uint8_t nV = *V; + *rgb = YUVToRGB32(*Y, nU, nV); + Y++; rgb++; + *rgb = YUVToRGB32(*Y, nU, nV); + Y++; rgb++; + } + if (y & 0x1) { + U_pos = U; + V_pos = V; + } else { + U = U_pos; + V = V_pos; + } + } +} + +void YV12ToRGB565(const void* yv12, void* rgb, int width, int height) +{ + const int pix_total = width * height; + const uint8_t* Y = reinterpret_cast(yv12); + const uint8_t* U = Y + pix_total; + const uint8_t* V = U + pix_total / 4; + _YUV420SToRGB565(Y, U, V, 1, reinterpret_cast(rgb), width, height); +} + +void YV12ToRGB32(const void* yv12, void* rgb, int width, int height) +{ + const int pix_total = width * height; + const uint8_t* Y = reinterpret_cast(yv12); + const uint8_t* V = Y + pix_total; + const uint8_t* U = V + pix_total / 4; + _YUV420SToRGB32(Y, U, V, 1, reinterpret_cast(rgb), width, height); +} + +void YU12ToRGB32(const void* yu12, void* rgb, int width, int height) +{ + const int pix_total = width * height; + const uint8_t* Y = reinterpret_cast(yu12); + const uint8_t* U = Y + pix_total; + const uint8_t* V = U + pix_total / 4; + _YUV420SToRGB32(Y, U, V, 1, reinterpret_cast(rgb), width, height); +} + +/* Common converter for YUV 4:2:0 interleaved to RGB565. + * y, u, and v point to Y,U, and V panes, where U and V values are interleaved. + */ +static void _NVXXToRGB565(const uint8_t* Y, + const uint8_t* U, + const uint8_t* V, + uint16_t* rgb, + int width, + int height) +{ + _YUV420SToRGB565(Y, U, V, 2, rgb, width, height); +} + +/* Common converter for YUV 4:2:0 interleaved to RGB32. + * y, u, and v point to Y,U, and V panes, where U and V values are interleaved. + */ +static void _NVXXToRGB32(const uint8_t* Y, + const uint8_t* U, + const uint8_t* V, + uint32_t* rgb, + int width, + int height) +{ + _YUV420SToRGB32(Y, U, V, 2, rgb, width, height); +} + +void NV12ToRGB565(const void* nv12, void* rgb, int width, int height) +{ + const int pix_total = width * height; + const uint8_t* y = reinterpret_cast(nv12); + _NVXXToRGB565(y, y + pix_total, y + pix_total + 1, + reinterpret_cast(rgb), width, height); +} + +void NV12ToRGB32(const void* nv12, void* rgb, int width, int height) +{ + const int pix_total = width * height; + const uint8_t* y = reinterpret_cast(nv12); + _NVXXToRGB32(y, y + pix_total, y + pix_total + 1, + reinterpret_cast(rgb), width, height); +} + +void NV21ToRGB565(const void* nv21, void* rgb, int width, int height) +{ + const int pix_total = width * height; + const uint8_t* y = reinterpret_cast(nv21); + _NVXXToRGB565(y, y + pix_total + 1, y + pix_total, + reinterpret_cast(rgb), width, height); +} + +void NV21ToRGB32(const void* nv21, void* rgb, int width, int height) +{ + const int pix_total = width * height; + const uint8_t* y = reinterpret_cast(nv21); + _NVXXToRGB32(y, y + pix_total + 1, y + pix_total, + reinterpret_cast(rgb), width, height); +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/Converters.h b/src/type3_AndroidCloud/anbox-master/android/camera/Converters.h new file mode 100644 index 0000000..13e2a85 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/Converters.h @@ -0,0 +1,314 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_CONVERTERS_H +#define HW_EMULATOR_CAMERA_CONVERTERS_H + +#include + +#ifndef __BYTE_ORDER +#error "could not determine byte order" +#endif + +/* + * Contains declaration of framebuffer conversion routines. + * + * NOTE: RGB and big/little endian considerations. Wherewer in this code RGB + * pixels are represented as WORD, or DWORD, the color order inside the + * WORD / DWORD matches the one that would occur if that WORD / DWORD would have + * been read from the typecasted framebuffer: + * + * const uint32_t rgb = *reinterpret_cast(framebuffer); + * + * So, if this code runs on the little endian CPU, red color in 'rgb' would be + * masked as 0x000000ff, and blue color would be masked as 0x00ff0000, while if + * the code runs on a big endian CPU, the red color in 'rgb' would be masked as + * 0xff000000, and blue color would be masked as 0x0000ff00, + */ + +namespace android { + +/* + * RGB565 color masks + */ + +#if __BYTE_ORDER == __LITTLE_ENDIAN +static const uint16_t kRed5 = 0x001f; +static const uint16_t kGreen6 = 0x07e0; +static const uint16_t kBlue5 = 0xf800; +#else // __BYTE_ORDER +static const uint16_t kRed5 = 0xf800; +static const uint16_t kGreen6 = 0x07e0; +static const uint16_t kBlue5 = 0x001f; +#endif // __BYTE_ORDER +static const uint32_t kBlack16 = 0x0000; +static const uint32_t kWhite16 = kRed5 | kGreen6 | kBlue5; + +/* + * RGB32 color masks + */ + +#if __BYTE_ORDER == __LITTLE_ENDIAN +static const uint32_t kRed8 = 0x000000ff; +static const uint32_t kGreen8 = 0x0000ff00; +static const uint32_t kBlue8 = 0x00ff0000; +#else // __BYTE_ORDER +static const uint32_t kRed8 = 0x00ff0000; +static const uint32_t kGreen8 = 0x0000ff00; +static const uint32_t kBlue8 = 0x000000ff; +#endif // __BYTE_ORDER +static const uint32_t kBlack32 = 0x00000000; +static const uint32_t kWhite32 = kRed8 | kGreen8 | kBlue8; + +/* + * Extracting, and saving color bytes from / to WORD / DWORD RGB. + */ + +#if __BYTE_ORDER == __LITTLE_ENDIAN +/* Extract red, green, and blue bytes from RGB565 word. */ +#define R16(rgb) static_cast(rgb & kRed5) +#define G16(rgb) static_cast((rgb & kGreen6) >> 5) +#define B16(rgb) static_cast((rgb & kBlue5) >> 11) +/* Make 8 bits red, green, and blue, extracted from RGB565 word. */ +#define R16_32(rgb) static_cast(((rgb & kRed5) << 3) | ((rgb & kRed5) >> 2)) +#define G16_32(rgb) static_cast(((rgb & kGreen6) >> 3) | ((rgb & kGreen6) >> 9)) +#define B16_32(rgb) static_cast(((rgb & kBlue5) >> 8) | ((rgb & kBlue5) >> 14)) +/* Extract red, green, and blue bytes from RGB32 dword. */ +#define R32(rgb) static_cast(rgb & kRed8) +#define G32(rgb) static_cast(((rgb & kGreen8) >> 8) & 0xff) +#define B32(rgb) static_cast(((rgb & kBlue8) >> 16) & 0xff) +/* Build RGB565 word from red, green, and blue bytes. */ +#define RGB565(r, g, b) static_cast((((static_cast(b) << 6) | g) << 5) | r) +/* Build RGB32 dword from red, green, and blue bytes. */ +#define RGB32(r, g, b) static_cast((((static_cast(b) << 8) | g) << 8) | r) +#else // __BYTE_ORDER +/* Extract red, green, and blue bytes from RGB565 word. */ +#define R16(rgb) static_cast((rgb & kRed5) >> 11) +#define G16(rgb) static_cast((rgb & kGreen6) >> 5) +#define B16(rgb) static_cast(rgb & kBlue5) +/* Make 8 bits red, green, and blue, extracted from RGB565 word. */ +#define R16_32(rgb) static_cast(((rgb & kRed5) >> 8) | ((rgb & kRed5) >> 14)) +#define G16_32(rgb) static_cast(((rgb & kGreen6) >> 3) | ((rgb & kGreen6) >> 9)) +#define B16_32(rgb) static_cast(((rgb & kBlue5) << 3) | ((rgb & kBlue5) >> 2)) +/* Extract red, green, and blue bytes from RGB32 dword. */ +#define R32(rgb) static_cast((rgb & kRed8) >> 16) +#define G32(rgb) static_cast((rgb & kGreen8) >> 8) +#define B32(rgb) static_cast(rgb & kBlue8) +/* Build RGB565 word from red, green, and blue bytes. */ +#define RGB565(r, g, b) static_cast((((static_cast(r) << 6) | g) << 5) | b) +/* Build RGB32 dword from red, green, and blue bytes. */ +#define RGB32(r, g, b) static_cast((((static_cast(r) << 8) | g) << 8) | b) +#endif // __BYTE_ORDER + +/* An union that simplifies breaking 32 bit RGB into separate R, G, and B colors. + */ +typedef union RGB32_t { + uint32_t color; + struct { +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint8_t r; uint8_t g; uint8_t b; uint8_t a; +#else // __BYTE_ORDER + uint8_t a; uint8_t b; uint8_t g; uint8_t r; +#endif // __BYTE_ORDER + }; +} RGB32_t; + + +/* Clips a value to the unsigned 0-255 range, treating negative values as zero. + */ +static __inline__ int +clamp(int x) +{ + if (x > 255) return 255; + if (x < 0) return 0; + return x; +} + +/******************************************************************************** + * Basics of RGB -> YUV conversion + *******************************************************************************/ + +/* + * RGB -> YUV conversion macros + */ +#define RGB2Y(r, g, b) (uint8_t)(((66 * (r) + 129 * (g) + 25 * (b) + 128) >> 8) + 16) +#define RGB2U(r, g, b) (uint8_t)(((-38 * (r) - 74 * (g) + 112 * (b) + 128) >> 8) + 128) +#define RGB2V(r, g, b) (uint8_t)(((112 * (r) - 94 * (g) - 18 * (b) + 128) >> 8) + 128) + +/* Converts R8 G8 B8 color to YUV. */ +static __inline__ void +R8G8B8ToYUV(uint8_t r, uint8_t g, uint8_t b, uint8_t* y, uint8_t* u, uint8_t* v) +{ + *y = RGB2Y((int)r, (int)g, (int)b); + *u = RGB2U((int)r, (int)g, (int)b); + *v = RGB2V((int)r, (int)g, (int)b); +} + +/* Converts RGB565 color to YUV. */ +static __inline__ void +RGB565ToYUV(uint16_t rgb, uint8_t* y, uint8_t* u, uint8_t* v) +{ + R8G8B8ToYUV(R16_32(rgb), G16_32(rgb), B16_32(rgb), y, u, v); +} + +/* Converts RGB32 color to YUV. */ +static __inline__ void +RGB32ToYUV(uint32_t rgb, uint8_t* y, uint8_t* u, uint8_t* v) +{ + RGB32_t rgb_c; + rgb_c.color = rgb; + R8G8B8ToYUV(rgb_c.r, rgb_c.g, rgb_c.b, y, u, v); +} + +/******************************************************************************** + * Basics of YUV -> RGB conversion. + * Note that due to the fact that guest uses RGB only on preview window, and the + * RGB format that is used is RGB565, we can limit YUV -> RGB conversions to + * RGB565 only. + *******************************************************************************/ + +/* + * YUV -> RGB conversion macros + */ + +/* "Optimized" macros that take specialy prepared Y, U, and V values: + * C = Y - 16 + * D = U - 128 + * E = V - 128 + */ +#define YUV2RO(C, D, E) clamp((298 * (C) + 409 * (E) + 128) >> 8) +#define YUV2GO(C, D, E) clamp((298 * (C) - 100 * (D) - 208 * (E) + 128) >> 8) +#define YUV2BO(C, D, E) clamp((298 * (C) + 516 * (D) + 128) >> 8) + +/* + * Main macros that take the original Y, U, and V values + */ +#define YUV2R(y, u, v) clamp((298 * ((y)-16) + 409 * ((v)-128) + 128) >> 8) +#define YUV2G(y, u, v) clamp((298 * ((y)-16) - 100 * ((u)-128) - 208 * ((v)-128) + 128) >> 8) +#define YUV2B(y, u, v) clamp((298 * ((y)-16) + 516 * ((u)-128) + 128) >> 8) + + +/* Converts YUV color to RGB565. */ +static __inline__ uint16_t +YUVToRGB565(int y, int u, int v) +{ + /* Calculate C, D, and E values for the optimized macro. */ + y -= 16; u -= 128; v -= 128; + const uint16_t r = (YUV2RO(y,u,v) >> 3) & 0x1f; + const uint16_t g = (YUV2GO(y,u,v) >> 2) & 0x3f; + const uint16_t b = (YUV2BO(y,u,v) >> 3) & 0x1f; + return RGB565(r, g, b); +} + +/* Converts YUV color to RGB32. */ +static __inline__ uint32_t +YUVToRGB32(int y, int u, int v) +{ + /* Calculate C, D, and E values for the optimized macro. */ + y -= 16; u -= 128; v -= 128; + RGB32_t rgb; + rgb.r = YUV2RO(y,u,v) & 0xff; + rgb.g = YUV2GO(y,u,v) & 0xff; + rgb.b = YUV2BO(y,u,v) & 0xff; + return rgb.color; +} + +/* YUV pixel descriptor. */ +struct YUVPixel { + uint8_t Y; + uint8_t U; + uint8_t V; + + inline YUVPixel() + : Y(0), U(0), V(0) + { + } + + inline explicit YUVPixel(uint16_t rgb565) + { + RGB565ToYUV(rgb565, &Y, &U, &V); + } + + inline explicit YUVPixel(uint32_t rgb32) + { + RGB32ToYUV(rgb32, &Y, &U, &V); + } + + inline void get(uint8_t* pY, uint8_t* pU, uint8_t* pV) const + { + *pY = Y; *pU = U; *pV = V; + } +}; + +/* Converts an YV12 framebuffer to RGB565 framebuffer. + * Param: + * yv12 - YV12 framebuffer. + * rgb - RGB565 framebuffer. + * width, height - Dimensions for both framebuffers. + */ +void YV12ToRGB565(const void* yv12, void* rgb, int width, int height); + +/* Converts an YV12 framebuffer to RGB32 framebuffer. + * Param: + * yv12 - YV12 framebuffer. + * rgb - RGB32 framebuffer. + * width, height - Dimensions for both framebuffers. + */ +void YV12ToRGB32(const void* yv12, void* rgb, int width, int height); + +/* Converts an YU12 framebuffer to RGB32 framebuffer. + * Param: + * yu12 - YU12 framebuffer. + * rgb - RGB32 framebuffer. + * width, height - Dimensions for both framebuffers. + */ +void YU12ToRGB32(const void* yu12, void* rgb, int width, int height); + +/* Converts an NV12 framebuffer to RGB565 framebuffer. + * Param: + * nv12 - NV12 framebuffer. + * rgb - RGB565 framebuffer. + * width, height - Dimensions for both framebuffers. + */ +void NV12ToRGB565(const void* nv12, void* rgb, int width, int height); + +/* Converts an NV12 framebuffer to RGB32 framebuffer. + * Param: + * nv12 - NV12 framebuffer. + * rgb - RGB32 framebuffer. + * width, height - Dimensions for both framebuffers. + */ +void NV12ToRGB32(const void* nv12, void* rgb, int width, int height); + +/* Converts an NV21 framebuffer to RGB565 framebuffer. + * Param: + * nv21 - NV21 framebuffer. + * rgb - RGB565 framebuffer. + * width, height - Dimensions for both framebuffers. + */ +void NV21ToRGB565(const void* nv21, void* rgb, int width, int height); + +/* Converts an NV21 framebuffer to RGB32 framebuffer. + * Param: + * nv21 - NV21 framebuffer. + * rgb - RGB32 framebuffer. + * width, height - Dimensions for both framebuffers. + */ +void NV21ToRGB32(const void* nv21, void* rgb, int width, int height); + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_CONVERTERS_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.cpp new file mode 100644 index 0000000..5fe7d73 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.cpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedBaseCamera that encapsulates + * functionality common to all emulated camera device versions ("fake", + * "webcam", "video file", "cam2.0" etc.). Instances of this class (for each + * emulated camera) are created during the construction of the + * EmulatedCameraFactory instance. This class serves as an entry point for all + * camera API calls that are common across all versions of the + * camera_device_t/camera_module_t structures. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_BaseCamera" +#include + +#include "EmulatedBaseCamera.h" + +namespace android { + +EmulatedBaseCamera::EmulatedBaseCamera(int cameraId, + uint32_t cameraVersion, + struct hw_device_t* device, + struct hw_module_t* module) + : mCameraInfo(NULL), + mCameraID(cameraId), + mCameraDeviceVersion(cameraVersion) +{ + /* + * Initialize camera_device descriptor for this object. + */ + + /* Common header */ + device->tag = HARDWARE_DEVICE_TAG; + device->version = cameraVersion; + device->module = module; + device->close = NULL; // Must be filled in by child implementation +} + +EmulatedBaseCamera::~EmulatedBaseCamera() +{ +} + +status_t EmulatedBaseCamera::getCameraInfo(struct camera_info* info) +{ + ALOGV("%s", __FUNCTION__); + + info->device_version = mCameraDeviceVersion; + if (mCameraDeviceVersion >= HARDWARE_DEVICE_API_VERSION(2, 0)) { + info->static_camera_characteristics = mCameraInfo; + } else { + info->static_camera_characteristics = (camera_metadata_t*)0xcafef00d; + } + + return NO_ERROR; +} + +status_t EmulatedBaseCamera::plugCamera() { + ALOGE("%s: not supported", __FUNCTION__); + return INVALID_OPERATION; +} + +status_t EmulatedBaseCamera::unplugCamera() { + ALOGE("%s: not supported", __FUNCTION__); + return INVALID_OPERATION; +} + +camera_device_status_t EmulatedBaseCamera::getHotplugStatus() { + return CAMERA_DEVICE_STATUS_PRESENT; +} + + + + +} /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.h new file mode 100644 index 0000000..3b8a6a0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedBaseCamera.h @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H +#define HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H + +#include +#include + +namespace android { + +/* + * Contains declaration of a class EmulatedBaseCamera that encapsulates + * functionality common to all emulated camera device versions ("fake", + * "webcam", "video file", etc.). Instances of this class (for each emulated + * camera) are created during the construction of the EmulatedCameraFactory + * instance. This class serves as an entry point for all camera API calls that + * are common across all versions of the camera_device_t/camera_module_t + * structures. + */ + +class EmulatedBaseCamera { + public: + EmulatedBaseCamera(int cameraId, + uint32_t cameraVersion, + struct hw_device_t* device, + struct hw_module_t* module); + + virtual ~EmulatedBaseCamera(); + + /**************************************************************************** + * Public API + ***************************************************************************/ + + public: + /* Initializes EmulatedCamera instance. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + virtual status_t Initialize() = 0; + + /**************************************************************************** + * Camera API implementation + ***************************************************************************/ + + public: + /* Creates connection to the emulated camera device. + * This method is called in response to hw_module_methods_t::open callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negative EXXX statuses. + */ + virtual status_t connectCamera(hw_device_t** device) = 0; + + + /* Plug the connection for the emulated camera. Until it's plugged in + * calls to connectCamera should fail with -ENODEV. + */ + virtual status_t plugCamera(); + + /* Unplug the connection from underneath the emulated camera. + * This is similar to closing the camera, except that + * all function calls into the camera device will return + * -EPIPE errors until the camera is reopened. + */ + virtual status_t unplugCamera(); + + virtual camera_device_status_t getHotplugStatus(); + + /* Closes connection to the emulated camera. + * This method is called in response to camera_device::close callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negative EXXX statuses. + */ + virtual status_t closeCamera() = 0; + + /* Gets camera information. + * This method is called in response to camera_module_t::get_camera_info + * callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negative EXXX statuses. + */ + virtual status_t getCameraInfo(struct camera_info* info) = 0; + + /**************************************************************************** + * Data members + ***************************************************************************/ + + protected: + /* Fixed camera information for camera2 devices. Must be valid to access if + * mCameraDeviceVersion is >= HARDWARE_DEVICE_API_VERSION(2,0) */ + camera_metadata_t *mCameraInfo; + + /* Zero-based ID assigned to this camera. */ + int mCameraID; + + private: + + /* Version of the camera device HAL implemented by this camera */ + int mCameraDeviceVersion; +}; + +} /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_BASE_CAMERA_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.cpp new file mode 100644 index 0000000..096c5b2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.cpp @@ -0,0 +1,1041 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedCamera that encapsulates + * functionality common to all emulated cameras ("fake", "webcam", "video file", + * etc.). Instances of this class (for each emulated camera) are created during + * the construction of the EmulatedCameraFactory instance. This class serves as + * an entry point for all camera API calls that defined by camera_device_ops_t + * API. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_Camera" +#include +#include +#include "EmulatedCamera.h" +//#include "EmulatedFakeCameraDevice.h" +#include "Converters.h" + +/* Defines whether we should trace parameter changes. */ +#define DEBUG_PARAM 1 + +namespace android { + +#if DEBUG_PARAM +/* Calculates and logs parameter changes. + * Param: + * current - Current set of camera parameters. + * new_par - String representation of new parameters. + */ +static void PrintParamDiff(const CameraParameters& current, const char* new_par); +#else +#define PrintParamDiff(current, new_par) (void(0)) +#endif /* DEBUG_PARAM */ + +/* A helper routine that adds a value to the camera parameter. + * Param: + * param - Camera parameter to add a value to. + * val - Value to add. + * Return: + * A new string containing parameter with the added value on success, or NULL on + * a failure. If non-NULL string is returned, the caller is responsible for + * freeing it with 'free'. + */ +static char* AddValue(const char* param, const char* val); + +EmulatedCamera::EmulatedCamera(int cameraId, + struct hw_module_t* module) + : EmulatedBaseCamera(cameraId, + HARDWARE_DEVICE_API_VERSION(1, 0), + &common, + module), + mPreviewWindow(), + mCallbackNotifier() +{ + /* camera_device v1 fields. */ + common.close = EmulatedCamera::close; + ops = &mDeviceOps; + priv = this; +} + +EmulatedCamera::~EmulatedCamera() +{ +} + +/**************************************************************************** + * Public API + ***************************************************************************/ + +status_t EmulatedCamera::Initialize() +{ + /* Preview formats supported by this HAL. */ + char preview_formats[1024]; + snprintf(preview_formats, sizeof(preview_formats), "%s,%s,%s", + CameraParameters::PIXEL_FORMAT_YUV420SP, + CameraParameters::PIXEL_FORMAT_YUV420P, + CameraParameters::PIXEL_FORMAT_RGBA8888); + + /* + * Fake required parameters. + */ + + mParameters.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES, "320x240,0x0"); + + mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, "512"); + mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, "384"); + mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "90"); + mParameters.set(CameraParameters::KEY_FOCAL_LENGTH, "4.31"); + mParameters.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, "54.8"); + mParameters.set(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, "42.5"); + mParameters.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, "90"); + + /* Preview format settings used here are related to panoramic view only. It's + * not related to the preview window that works only with RGB frames, which + * is explicitly stated when set_buffers_geometry is called on the preview + * window object. */ + mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS, + preview_formats); + mParameters.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP); + + /* We don't relay on the actual frame rates supported by the camera device, + * since we will emulate them through timeouts in the emulated camera device + * worker thread. */ + mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES, + "30,24,20,15,10,5"); + mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE, "(5,30)"); + mParameters.set(CameraParameters::KEY_PREVIEW_FPS_RANGE, "5,30"); + mParameters.setPreviewFrameRate(24); + + /* Only PIXEL_FORMAT_YUV420P is accepted by video framework in emulator! */ + mParameters.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT, + CameraParameters::PIXEL_FORMAT_YUV420P); + mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS, + CameraParameters::PIXEL_FORMAT_JPEG); + mParameters.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG); + + /* Set exposure compensation. */ + mParameters.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "6"); + mParameters.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-6"); + mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5"); + mParameters.set(CameraParameters::KEY_EXPOSURE_COMPENSATION, "0"); + + /* Sets the white balance modes and the device-dependent scale factors. */ + char supported_white_balance[1024]; + snprintf(supported_white_balance, sizeof(supported_white_balance), + "%s,%s,%s,%s", + CameraParameters::WHITE_BALANCE_AUTO, + CameraParameters::WHITE_BALANCE_INCANDESCENT, + CameraParameters::WHITE_BALANCE_DAYLIGHT, + CameraParameters::WHITE_BALANCE_TWILIGHT); + mParameters.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE, + supported_white_balance); + mParameters.set(CameraParameters::KEY_WHITE_BALANCE, + CameraParameters::WHITE_BALANCE_AUTO); + getCameraDevice()->initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_AUTO, 1.0f, 1.0f); + getCameraDevice()->initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_INCANDESCENT, 1.38f, 0.60f); + getCameraDevice()->initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_DAYLIGHT, 1.09f, 0.92f); + getCameraDevice()->initializeWhiteBalanceModes( + CameraParameters::WHITE_BALANCE_TWILIGHT, 0.92f, 1.22f); + getCameraDevice()->setWhiteBalanceMode(CameraParameters::WHITE_BALANCE_AUTO); + + /* Not supported features + */ + mParameters.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES, + CameraParameters::FOCUS_MODE_FIXED); + mParameters.set(CameraParameters::KEY_FOCUS_MODE, + CameraParameters::FOCUS_MODE_FIXED); + + return NO_ERROR; +} + +void EmulatedCamera::onNextFrameAvailable(const void* frame, + nsecs_t timestamp, + EmulatedCameraDevice* camera_dev) +{ + /* Notify the preview window first. */ + mPreviewWindow.onNextFrameAvailable(frame, timestamp, camera_dev); + + /* Notify callback notifier next. */ + mCallbackNotifier.onNextFrameAvailable(frame, timestamp, camera_dev); +} + +void EmulatedCamera::onCameraDeviceError(int err) +{ + /* Errors are reported through the callback notifier */ + mCallbackNotifier.onCameraDeviceError(err); +} + +/**************************************************************************** + * Camera API implementation. + ***************************************************************************/ + +status_t EmulatedCamera::connectCamera(hw_device_t** device) +{ + ALOGV("%s", __FUNCTION__); + + status_t res = EINVAL; + EmulatedCameraDevice* const camera_dev = getCameraDevice(); + ALOGE_IF(camera_dev == NULL, "%s: No camera device instance.", __FUNCTION__); + + if (camera_dev != NULL) { + /* Connect to the camera device. */ + res = getCameraDevice()->connectDevice(); + if (res == NO_ERROR) { + *device = &common; + } + } + + return -res; +} + +status_t EmulatedCamera::closeCamera() +{ + ALOGV("%s", __FUNCTION__); + + return cleanupCamera(); +} + +status_t EmulatedCamera::getCameraInfo(struct camera_info* info) +{ + ALOGV("%s", __FUNCTION__); + + const char* valstr = NULL; + + valstr = mParameters.get(EmulatedCamera::FACING_KEY); + if (valstr != NULL) { + if (strcmp(valstr, EmulatedCamera::FACING_FRONT) == 0) { + info->facing = CAMERA_FACING_FRONT; + } + else if (strcmp(valstr, EmulatedCamera::FACING_BACK) == 0) { + info->facing = CAMERA_FACING_BACK; + } + } else { + info->facing = CAMERA_FACING_BACK; + } + + valstr = mParameters.get(EmulatedCamera::ORIENTATION_KEY); + if (valstr != NULL) { + info->orientation = atoi(valstr); + } else { + info->orientation = 0; + } + + return EmulatedBaseCamera::getCameraInfo(info); +} + +status_t EmulatedCamera::setPreviewWindow(struct preview_stream_ops* window) +{ + /* Callback should return a negative errno. */ + return -mPreviewWindow.setPreviewWindow(window, + mParameters.getPreviewFrameRate()); +} + +void EmulatedCamera::setCallbacks(camera_notify_callback notify_cb, + camera_data_callback data_cb, + camera_data_timestamp_callback data_cb_timestamp, + camera_request_memory get_memory, + void* user) +{ + mCallbackNotifier.setCallbacks(notify_cb, data_cb, data_cb_timestamp, + get_memory, user); +} + +void EmulatedCamera::enableMsgType(int32_t msg_type) +{ + mCallbackNotifier.enableMessage(msg_type); +} + +void EmulatedCamera::disableMsgType(int32_t msg_type) +{ + mCallbackNotifier.disableMessage(msg_type); +} + +int EmulatedCamera::isMsgTypeEnabled(int32_t msg_type) +{ + return mCallbackNotifier.isMessageEnabled(msg_type); +} + +status_t EmulatedCamera::startPreview() +{ + /* Callback should return a negative errno. */ + return -doStartPreview(); +} + +void EmulatedCamera::stopPreview() +{ + doStopPreview(); +} + +int EmulatedCamera::isPreviewEnabled() +{ + return mPreviewWindow.isPreviewEnabled(); +} + +status_t EmulatedCamera::storeMetaDataInBuffers(int enable) +{ + /* Callback should return a negative errno. */ + return -mCallbackNotifier.storeMetaDataInBuffers(enable); +} + +status_t EmulatedCamera::startRecording() +{ + /* Callback should return a negative errno. */ + return -mCallbackNotifier.enableVideoRecording(mParameters.getPreviewFrameRate()); +} + +void EmulatedCamera::stopRecording() +{ + mCallbackNotifier.disableVideoRecording(); +} + +int EmulatedCamera::isRecordingEnabled() +{ + return mCallbackNotifier.isVideoRecordingEnabled(); +} + +void EmulatedCamera::releaseRecordingFrame(const void* opaque) +{ + mCallbackNotifier.releaseRecordingFrame(opaque); +} + +status_t EmulatedCamera::setAutoFocus() +{ + ALOGV("%s", __FUNCTION__); + + /* TODO: Future enhancements. */ + return NO_ERROR; +} + +status_t EmulatedCamera::cancelAutoFocus() +{ + ALOGV("%s", __FUNCTION__); + + /* TODO: Future enhancements. */ + return NO_ERROR; +} + +status_t EmulatedCamera::takePicture() +{ + ALOGV("%s", __FUNCTION__); + + status_t res; + int width, height; + uint32_t org_fmt; + + /* Collect frame info for the picture. */ + mParameters.getPictureSize(&width, &height); + const char* pix_fmt = mParameters.getPictureFormat(); + if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { + org_fmt = V4L2_PIX_FMT_YUV420; + } else if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_RGBA8888) == 0) { + org_fmt = V4L2_PIX_FMT_RGB32; + } else if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { + org_fmt = V4L2_PIX_FMT_NV21; + } else if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_JPEG) == 0) { + /* We only have JPEG converted for NV21 format. */ + org_fmt = V4L2_PIX_FMT_NV21; + } else { + ALOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt); + return EINVAL; + } + /* Get JPEG quality. */ + int jpeg_quality = mParameters.getInt(CameraParameters::KEY_JPEG_QUALITY); + if (jpeg_quality <= 0) { + jpeg_quality = 90; /* Fall back to default. */ + } + + /* + * Make sure preview is not running, and device is stopped before taking + * picture. + */ + + const bool preview_on = mPreviewWindow.isPreviewEnabled(); + if (preview_on) { + doStopPreview(); + } + + /* Camera device should have been stopped when the shutter message has been + * enabled. */ + EmulatedCameraDevice* const camera_dev = getCameraDevice(); + if (camera_dev->isStarted()) { + ALOGW("%s: Camera device is started", __FUNCTION__); + camera_dev->stopDeliveringFrames(); + camera_dev->stopDevice(); + } + + /* + * Take the picture now. + */ + + /* Start camera device for the picture frame. */ + ALOGD("Starting camera for picture: %.4s(%s)[%dx%d]", + reinterpret_cast(&org_fmt), pix_fmt, width, height); + res = camera_dev->startDevice(width, height, org_fmt); + if (res != NO_ERROR) { + if (preview_on) { + doStartPreview(); + } + return res; + } + + /* Deliver one frame only. */ + mCallbackNotifier.setJpegQuality(jpeg_quality); + mCallbackNotifier.setTakingPicture(true); + res = camera_dev->startDeliveringFrames(true); + if (res != NO_ERROR) { + mCallbackNotifier.setTakingPicture(false); + if (preview_on) { + doStartPreview(); + } + } + return res; +} + +status_t EmulatedCamera::cancelPicture() +{ + ALOGV("%s", __FUNCTION__); + + return NO_ERROR; +} + +status_t EmulatedCamera::setParameters(const char* parms) +{ + ALOGV("%s", __FUNCTION__); + PrintParamDiff(mParameters, parms); + + CameraParameters new_param; + String8 str8_param(parms); + new_param.unflatten(str8_param); + + /* + * Check for new exposure compensation parameter. + */ + int new_exposure_compensation = new_param.getInt( + CameraParameters::KEY_EXPOSURE_COMPENSATION); + const int min_exposure_compensation = new_param.getInt( + CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION); + const int max_exposure_compensation = new_param.getInt( + CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION); + + // Checks if the exposure compensation change is supported. + if ((min_exposure_compensation != 0) || (max_exposure_compensation != 0)) { + if (new_exposure_compensation > max_exposure_compensation) { + new_exposure_compensation = max_exposure_compensation; + } + if (new_exposure_compensation < min_exposure_compensation) { + new_exposure_compensation = min_exposure_compensation; + } + + const int current_exposure_compensation = mParameters.getInt( + CameraParameters::KEY_EXPOSURE_COMPENSATION); + if (current_exposure_compensation != new_exposure_compensation) { + const float exposure_value = new_exposure_compensation * + new_param.getFloat( + CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP); + + getCameraDevice()->setExposureCompensation( + exposure_value); + } + } + + const char* new_white_balance = new_param.get( + CameraParameters::KEY_WHITE_BALANCE); + const char* supported_white_balance = new_param.get( + CameraParameters::KEY_SUPPORTED_WHITE_BALANCE); + + if ((supported_white_balance != NULL) && (new_white_balance != NULL) && + (strstr(supported_white_balance, new_white_balance) != NULL)) { + + const char* current_white_balance = mParameters.get( + CameraParameters::KEY_WHITE_BALANCE); + if ((current_white_balance == NULL) || + (strcmp(current_white_balance, new_white_balance) != 0)) { + ALOGV("Setting white balance to %s", new_white_balance); + getCameraDevice()->setWhiteBalanceMode(new_white_balance); + } + } + + mParameters = new_param; + + return NO_ERROR; +} + +/* A dumb variable indicating "no params" / error on the exit from + * EmulatedCamera::getParameters(). */ +static char lNoParam = '\0'; +char* EmulatedCamera::getParameters() +{ + String8 params(mParameters.flatten()); + char* ret_str = + reinterpret_cast(malloc(sizeof(char) * (params.length()+1))); + memset(ret_str, 0, params.length()+1); + if (ret_str != NULL) { + strncpy(ret_str, params.string(), params.length()+1); + return ret_str; + } else { + ALOGE("%s: Unable to allocate string for %s", __FUNCTION__, params.string()); + /* Apparently, we can't return NULL fron this routine. */ + return &lNoParam; + } +} + +void EmulatedCamera::putParameters(char* params) +{ + /* This method simply frees parameters allocated in getParameters(). */ + if (params != NULL && params != &lNoParam) { + free(params); + } +} + +status_t EmulatedCamera::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) +{ + ALOGV("%s: cmd = %d, arg1 = %d, arg2 = %d", __FUNCTION__, cmd, arg1, arg2); + + /* TODO: Future enhancements. */ + return 0; +} + +void EmulatedCamera::releaseCamera() +{ + ALOGV("%s", __FUNCTION__); + + cleanupCamera(); +} + +status_t EmulatedCamera::dumpCamera(int fd) +{ + ALOGV("%s", __FUNCTION__); + + /* TODO: Future enhancements. */ + return -EINVAL; +} + +/**************************************************************************** + * Preview management. + ***************************************************************************/ + +status_t EmulatedCamera::doStartPreview() +{ + ALOGV("%s", __FUNCTION__); + + EmulatedCameraDevice* camera_dev = getCameraDevice(); + if (camera_dev->isStarted()) { + camera_dev->stopDeliveringFrames(); + camera_dev->stopDevice(); + } + + status_t res = mPreviewWindow.startPreview(); + if (res != NO_ERROR) { + return res; + } + + /* Make sure camera device is connected. */ + if (!camera_dev->isConnected()) { + res = camera_dev->connectDevice(); + if (res != NO_ERROR) { + mPreviewWindow.stopPreview(); + return res; + } + } + + int width, height; + /* Lets see what should we use for frame width, and height. */ + if (mParameters.get(CameraParameters::KEY_VIDEO_SIZE) != NULL) { + mParameters.getVideoSize(&width, &height); + } else { + mParameters.getPreviewSize(&width, &height); + } + /* Lets see what should we use for the frame pixel format. Note that there + * are two parameters that define pixel formats for frames sent to the + * application via notification callbacks: + * - KEY_VIDEO_FRAME_FORMAT, that is used when recording video, and + * - KEY_PREVIEW_FORMAT, that is used for preview frame notification. + * We choose one or the other, depending on "recording-hint" property set by + * the framework that indicating intention: video, or preview. */ + const char* pix_fmt = NULL; + const char* is_video = mParameters.get(EmulatedCamera::RECORDING_HINT_KEY); + if (is_video == NULL) { + is_video = CameraParameters::FALSE; + } + if (strcmp(is_video, CameraParameters::TRUE) == 0) { + /* Video recording is requested. Lets see if video frame format is set. */ + pix_fmt = mParameters.get(CameraParameters::KEY_VIDEO_FRAME_FORMAT); + } + /* If this was not video recording, or video frame format is not set, lets + * use preview pixel format for the main framebuffer. */ + if (pix_fmt == NULL) { + pix_fmt = mParameters.getPreviewFormat(); + } + if (pix_fmt == NULL) { + ALOGE("%s: Unable to obtain video format", __FUNCTION__); + mPreviewWindow.stopPreview(); + return EINVAL; + } + + /* Convert framework's pixel format to the FOURCC one. */ + uint32_t org_fmt; + if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_YUV420P) == 0) { + org_fmt = V4L2_PIX_FMT_YUV420; + } else if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_RGBA8888) == 0) { + org_fmt = V4L2_PIX_FMT_RGB32; + } else if (strcmp(pix_fmt, CameraParameters::PIXEL_FORMAT_YUV420SP) == 0) { + org_fmt = V4L2_PIX_FMT_NV21; + } else { + ALOGE("%s: Unsupported pixel format %s", __FUNCTION__, pix_fmt); + mPreviewWindow.stopPreview(); + return EINVAL; + } + ALOGD("Starting camera: %dx%d -> %.4s(%s)", + width, height, reinterpret_cast(&org_fmt), pix_fmt); + res = camera_dev->startDevice(width, height, org_fmt); + if (res != NO_ERROR) { + mPreviewWindow.stopPreview(); + return res; + } + + res = camera_dev->startDeliveringFrames(false); + if (res != NO_ERROR) { + camera_dev->stopDevice(); + mPreviewWindow.stopPreview(); + } + + return res; +} + +status_t EmulatedCamera::doStopPreview() +{ + ALOGV("%s", __FUNCTION__); + + status_t res = NO_ERROR; + if (mPreviewWindow.isPreviewEnabled()) { + /* Stop the camera. */ + if (getCameraDevice()->isStarted()) { + getCameraDevice()->stopDeliveringFrames(); + res = getCameraDevice()->stopDevice(); + } + + if (res == NO_ERROR) { + /* Disable preview as well. */ + mPreviewWindow.stopPreview(); + } + } + + return NO_ERROR; +} + +/**************************************************************************** + * Private API. + ***************************************************************************/ + +status_t EmulatedCamera::cleanupCamera() +{ + status_t res = NO_ERROR; + + /* If preview is running - stop it. */ + res = doStopPreview(); + if (res != NO_ERROR) { + return -res; + } + + /* Stop and disconnect the camera device. */ + EmulatedCameraDevice* const camera_dev = getCameraDevice(); + if (camera_dev != NULL) { + if (camera_dev->isStarted()) { + camera_dev->stopDeliveringFrames(); + res = camera_dev->stopDevice(); + if (res != NO_ERROR) { + return -res; + } + } + if (camera_dev->isConnected()) { + res = camera_dev->disconnectDevice(); + if (res != NO_ERROR) { + return -res; + } + } + } + + mCallbackNotifier.cleanupCBNotifier(); + + return NO_ERROR; +} + +/**************************************************************************** + * Camera API callbacks as defined by camera_device_ops structure. + * + * Callbacks here simply dispatch the calls to an appropriate method inside + * EmulatedCamera instance, defined by the 'dev' parameter. + ***************************************************************************/ + +int EmulatedCamera::set_preview_window(struct camera_device* dev, + struct preview_stream_ops* window) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->setPreviewWindow(window); +} + +void EmulatedCamera::set_callbacks( + struct camera_device* dev, + camera_notify_callback notify_cb, + camera_data_callback data_cb, + camera_data_timestamp_callback data_cb_timestamp, + camera_request_memory get_memory, + void* user) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->setCallbacks(notify_cb, data_cb, data_cb_timestamp, get_memory, user); +} + +void EmulatedCamera::enable_msg_type(struct camera_device* dev, int32_t msg_type) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->enableMsgType(msg_type); +} + +void EmulatedCamera::disable_msg_type(struct camera_device* dev, int32_t msg_type) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->disableMsgType(msg_type); +} + +int EmulatedCamera::msg_type_enabled(struct camera_device* dev, int32_t msg_type) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->isMsgTypeEnabled(msg_type); +} + +int EmulatedCamera::start_preview(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->startPreview(); +} + +void EmulatedCamera::stop_preview(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->stopPreview(); +} + +int EmulatedCamera::preview_enabled(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->isPreviewEnabled(); +} + +int EmulatedCamera::store_meta_data_in_buffers(struct camera_device* dev, + int enable) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->storeMetaDataInBuffers(enable); +} + +int EmulatedCamera::start_recording(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->startRecording(); +} + +void EmulatedCamera::stop_recording(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->stopRecording(); +} + +int EmulatedCamera::recording_enabled(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->isRecordingEnabled(); +} + +void EmulatedCamera::release_recording_frame(struct camera_device* dev, + const void* opaque) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->releaseRecordingFrame(opaque); +} + +int EmulatedCamera::auto_focus(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->setAutoFocus(); +} + +int EmulatedCamera::cancel_auto_focus(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->cancelAutoFocus(); +} + +int EmulatedCamera::take_picture(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->takePicture(); +} + +int EmulatedCamera::cancel_picture(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->cancelPicture(); +} + +int EmulatedCamera::set_parameters(struct camera_device* dev, const char* parms) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->setParameters(parms); +} + +char* EmulatedCamera::get_parameters(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return NULL; + } + return ec->getParameters(); +} + +void EmulatedCamera::put_parameters(struct camera_device* dev, char* params) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->putParameters(params); +} + +int EmulatedCamera::send_command(struct camera_device* dev, + int32_t cmd, + int32_t arg1, + int32_t arg2) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->sendCommand(cmd, arg1, arg2); +} + +void EmulatedCamera::release(struct camera_device* dev) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return; + } + ec->releaseCamera(); +} + +int EmulatedCamera::dump(struct camera_device* dev, int fd) +{ + EmulatedCamera* ec = reinterpret_cast(dev->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->dumpCamera(fd); +} + +int EmulatedCamera::close(struct hw_device_t* device) +{ + EmulatedCamera* ec = + reinterpret_cast(reinterpret_cast(device)->priv); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera device", __FUNCTION__); + return -EINVAL; + } + return ec->closeCamera(); +} + +/**************************************************************************** + * Static initializer for the camera callback API + ****************************************************************************/ + +camera_device_ops_t EmulatedCamera::mDeviceOps = { + EmulatedCamera::set_preview_window, + EmulatedCamera::set_callbacks, + EmulatedCamera::enable_msg_type, + EmulatedCamera::disable_msg_type, + EmulatedCamera::msg_type_enabled, + EmulatedCamera::start_preview, + EmulatedCamera::stop_preview, + EmulatedCamera::preview_enabled, + EmulatedCamera::store_meta_data_in_buffers, + EmulatedCamera::start_recording, + EmulatedCamera::stop_recording, + EmulatedCamera::recording_enabled, + EmulatedCamera::release_recording_frame, + EmulatedCamera::auto_focus, + EmulatedCamera::cancel_auto_focus, + EmulatedCamera::take_picture, + EmulatedCamera::cancel_picture, + EmulatedCamera::set_parameters, + EmulatedCamera::get_parameters, + EmulatedCamera::put_parameters, + EmulatedCamera::send_command, + EmulatedCamera::release, + EmulatedCamera::dump +}; + +/**************************************************************************** + * Common keys + ***************************************************************************/ + +const char EmulatedCamera::FACING_KEY[] = "prop-facing"; +const char EmulatedCamera::ORIENTATION_KEY[] = "prop-orientation"; +const char EmulatedCamera::RECORDING_HINT_KEY[] = "recording-hint"; + +/**************************************************************************** + * Common string values + ***************************************************************************/ + +const char EmulatedCamera::FACING_BACK[] = "back"; +const char EmulatedCamera::FACING_FRONT[] = "front"; + +/**************************************************************************** + * Helper routines + ***************************************************************************/ + +static char* AddValue(const char* param, const char* val) +{ + const size_t len1 = strlen(param); + const size_t len2 = strlen(val); + char* ret = reinterpret_cast(malloc(len1 + len2 + 2)); + ALOGE_IF(ret == NULL, "%s: Memory failure", __FUNCTION__); + if (ret != NULL) { + memcpy(ret, param, len1); + ret[len1] = ','; + memcpy(ret + len1 + 1, val, len2); + ret[len1 + len2 + 1] = '\0'; + } + return ret; +} + +/**************************************************************************** + * Parameter debugging helpers + ***************************************************************************/ + +#if DEBUG_PARAM +static void PrintParamDiff(const CameraParameters& current, + const char* new_par) +{ + char tmp[2048]; + const char* wrk = new_par; + + /* Divided with ';' */ + const char* next = strchr(wrk, ';'); + while (next != NULL) { + snprintf(tmp, sizeof(tmp), "%.*s", (int)(intptr_t)(next-wrk), wrk); + /* in the form key=value */ + char* val = strchr(tmp, '='); + if (val != NULL) { + *val = '\0'; val++; + const char* in_current = current.get(tmp); + if (in_current != NULL) { + if (strcmp(in_current, val)) { + ALOGD("=== Value changed: %s: %s -> %s", tmp, in_current, val); + } + } else { + ALOGD("+++ New parameter: %s=%s", tmp, val); + } + } else { + ALOGW("No value separator in %s", tmp); + } + wrk = next + 1; + next = strchr(wrk, ';'); + } +} +#endif /* DEBUG_PARAM */ + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.h new file mode 100644 index 0000000..9825d5d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera.h @@ -0,0 +1,401 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_H +#define HW_EMULATOR_CAMERA_EMULATED_CAMERA_H + +/* + * Contains declaration of a class EmulatedCamera that encapsulates + * functionality common to all version 1.0 emulated camera devices ("fake", + * "webcam", "video file", etc.). Instances of this class (for each emulated + * camera) are created during the construction of the EmulatedCameraFactory + * instance. This class serves as an entry point for all camera API calls that + * defined by camera_device_ops_t API. + */ + +#include +#include "EmulatedBaseCamera.h" +#include "EmulatedCameraDevice.h" +#include "PreviewWindow.h" +#include "CallbackNotifier.h" + +namespace android { + +/* Encapsulates functionality common to all version 1.0 emulated camera devices + * ("fake", "webcam", "file stream", etc.). + * + * Note that EmulatedCameraFactory instantiates object of this class just once, + * when EmulatedCameraFactory instance gets constructed. Connection to / + * disconnection from the actual camera device is handled by calls to + * connectDevice(), and closeCamera() methods of this class that are ivoked in + * response to hw_module_methods_t::open, and camera_device::close callbacks. + */ +class EmulatedCamera : public camera_device, public EmulatedBaseCamera { +public: + /* Constructs EmulatedCamera instance. + * Param: + * cameraId - Zero based camera identifier, which is an index of the camera + * instance in camera factory's array. + * module - Emulated camera HAL module descriptor. + */ + EmulatedCamera(int cameraId, + struct hw_module_t* module); + + /* Destructs EmulatedCamera instance. */ + virtual ~EmulatedCamera(); + + /**************************************************************************** + * Abstract API + ***************************************************************************/ + +public: + /* Gets emulated camera device used by this instance of the emulated camera. + */ + virtual EmulatedCameraDevice* getCameraDevice() = 0; + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + /** Override of base class method */ + virtual status_t Initialize(); + + /* Next frame is available in the camera device. + * This is a notification callback that is invoked by the camera device when + * a new frame is available. + * Note that most likely this method is called in context of a worker thread + * that camera device has created for frame capturing. + * Param: + * frame - Captured frame, or NULL if camera device didn't pull the frame + * yet. If NULL is passed in this parameter use GetCurrentFrame method + * of the camera device class to obtain the next frame. Also note that + * the size of the frame that is passed here (as well as the frame + * returned from the GetCurrentFrame method) is defined by the current + * frame settings (width + height + pixel format) for the camera device. + * timestamp - Frame's timestamp. + * camera_dev - Camera device instance that delivered the frame. + */ + virtual void onNextFrameAvailable(const void* frame, + nsecs_t timestamp, + EmulatedCameraDevice* camera_dev); + + /* Entry point for notifications that occur in camera device. + * Param: + * err - CAMERA_ERROR_XXX error code. + */ + virtual void onCameraDeviceError(int err); + + /**************************************************************************** + * Camera API implementation + ***************************************************************************/ + +public: + /** Override of base class method */ + virtual status_t connectCamera(hw_device_t** device); + + /** Override of base class method */ + virtual status_t closeCamera(); + + /** Override of base class method */ + virtual status_t getCameraInfo(struct camera_info* info); + + /**************************************************************************** + * Camera API implementation. + * These methods are called from the camera API callback routines. + ***************************************************************************/ + +protected: + /* Actual handler for camera_device_ops_t::set_preview_window callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t setPreviewWindow(struct preview_stream_ops *window); + + /* Actual handler for camera_device_ops_t::set_callbacks callback. + * NOTE: When this method is called the object is locked. + */ + virtual void setCallbacks(camera_notify_callback notify_cb, + camera_data_callback data_cb, + camera_data_timestamp_callback data_cb_timestamp, + camera_request_memory get_memory, + void* user); + + /* Actual handler for camera_device_ops_t::enable_msg_type callback. + * NOTE: When this method is called the object is locked. + */ + virtual void enableMsgType(int32_t msg_type); + + /* Actual handler for camera_device_ops_t::disable_msg_type callback. + * NOTE: When this method is called the object is locked. + */ + virtual void disableMsgType(int32_t msg_type); + + /* Actual handler for camera_device_ops_t::msg_type_enabled callback. + * NOTE: When this method is called the object is locked. + * Return: + * 0 if message(s) is (are) disabled, != 0 if enabled. + */ + virtual int isMsgTypeEnabled(int32_t msg_type); + + /* Actual handler for camera_device_ops_t::start_preview callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t startPreview(); + + /* Actual handler for camera_device_ops_t::stop_preview callback. + * NOTE: When this method is called the object is locked. + */ + virtual void stopPreview(); + + /* Actual handler for camera_device_ops_t::preview_enabled callback. + * NOTE: When this method is called the object is locked. + * Return: + * 0 if preview is disabled, != 0 if enabled. + */ + virtual int isPreviewEnabled(); + + /* Actual handler for camera_device_ops_t::store_meta_data_in_buffers callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t storeMetaDataInBuffers(int enable); + + /* Actual handler for camera_device_ops_t::start_recording callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t startRecording(); + + /* Actual handler for camera_device_ops_t::stop_recording callback. + * NOTE: When this method is called the object is locked. + */ + virtual void stopRecording(); + + /* Actual handler for camera_device_ops_t::recording_enabled callback. + * NOTE: When this method is called the object is locked. + * Return: + * 0 if recording is disabled, != 0 if enabled. + */ + virtual int isRecordingEnabled(); + + /* Actual handler for camera_device_ops_t::release_recording_frame callback. + * NOTE: When this method is called the object is locked. + */ + virtual void releaseRecordingFrame(const void* opaque); + + /* Actual handler for camera_device_ops_t::auto_focus callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t setAutoFocus(); + + /* Actual handler for camera_device_ops_t::cancel_auto_focus callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t cancelAutoFocus(); + + /* Actual handler for camera_device_ops_t::take_picture callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t takePicture(); + + /* Actual handler for camera_device_ops_t::cancel_picture callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t cancelPicture(); + + /* Actual handler for camera_device_ops_t::set_parameters callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t setParameters(const char* parms); + + /* Actual handler for camera_device_ops_t::get_parameters callback. + * NOTE: When this method is called the object is locked. + * Return: + * Flattened parameters string. The caller will free the buffer allocated + * for the string by calling camera_device_ops_t::put_parameters callback. + */ + virtual char* getParameters(); + + /* Actual handler for camera_device_ops_t::put_parameters callback. + * Called to free the string returned from camera_device_ops_t::get_parameters + * callback. There is nothing more to it: the name of the callback is just + * misleading. + * NOTE: When this method is called the object is locked. + */ + virtual void putParameters(char* params); + + /* Actual handler for camera_device_ops_t::send_command callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2); + + /* Actual handler for camera_device_ops_t::release callback. + * NOTE: When this method is called the object is locked. + */ + virtual void releaseCamera(); + + /* Actual handler for camera_device_ops_t::dump callback. + * NOTE: When this method is called the object is locked. + * Note that failures in this method are reported as negave EXXX statuses. + */ + virtual status_t dumpCamera(int fd); + + /**************************************************************************** + * Preview management. + ***************************************************************************/ + +protected: + /* Starts preview. + * Note that when this method is called mPreviewWindow may be NULL, + * indicating that framework has an intention to start displaying video + * frames, but didn't create the preview window yet. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + virtual status_t doStartPreview(); + + /* Stops preview. + * This method reverts DoStartPreview. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + virtual status_t doStopPreview(); + + /**************************************************************************** + * Private API. + ***************************************************************************/ + +protected: + /* Cleans up camera when released. */ + virtual status_t cleanupCamera(); + + /**************************************************************************** + * Camera API callbacks as defined by camera_device_ops structure. + * See hardware/libhardware/include/hardware/camera.h for information on + * each of these callbacks. Implemented in this class, these callbacks simply + * dispatch the call into an instance of EmulatedCamera class defined by the + * 'camera_device' parameter. + ***************************************************************************/ + +private: + static int set_preview_window(struct camera_device* dev, + struct preview_stream_ops* window); + + static void set_callbacks(struct camera_device* dev, + camera_notify_callback notify_cb, + camera_data_callback data_cb, + camera_data_timestamp_callback data_cb_timestamp, + camera_request_memory get_memory, + void* user); + + static void enable_msg_type(struct camera_device* dev, int32_t msg_type); + + static void disable_msg_type(struct camera_device* dev, int32_t msg_type); + + static int msg_type_enabled(struct camera_device* dev, int32_t msg_type); + + static int start_preview(struct camera_device* dev); + + static void stop_preview(struct camera_device* dev); + + static int preview_enabled(struct camera_device* dev); + + static int store_meta_data_in_buffers(struct camera_device* dev, int enable); + + static int start_recording(struct camera_device* dev); + + static void stop_recording(struct camera_device* dev); + + static int recording_enabled(struct camera_device* dev); + + static void release_recording_frame(struct camera_device* dev, + const void* opaque); + + static int auto_focus(struct camera_device* dev); + + static int cancel_auto_focus(struct camera_device* dev); + + static int take_picture(struct camera_device* dev); + + static int cancel_picture(struct camera_device* dev); + + static int set_parameters(struct camera_device* dev, const char* parms); + + static char* get_parameters(struct camera_device* dev); + + static void put_parameters(struct camera_device* dev, char* params); + + static int send_command(struct camera_device* dev, + int32_t cmd, + int32_t arg1, + int32_t arg2); + + static void release(struct camera_device* dev); + + static int dump(struct camera_device* dev, int fd); + + static int close(struct hw_device_t* device); + + /**************************************************************************** + * Data members + ***************************************************************************/ + +protected: + /* Locks this instance for parameters, state, etc. change. */ + Mutex mObjectLock; + + /* Camera parameters. */ + CameraParameters mParameters; + + /* Preview window. */ + PreviewWindow mPreviewWindow; + + /* Callback notifier. */ + CallbackNotifier mCallbackNotifier; + +private: + /* Registered callbacks implementing camera API. */ + static camera_device_ops_t mDeviceOps; + + /**************************************************************************** + * Common keys + ***************************************************************************/ + +public: + static const char FACING_KEY[]; + static const char ORIENTATION_KEY[]; + static const char RECORDING_HINT_KEY[]; + + /**************************************************************************** + * Common string values + ***************************************************************************/ + + /* Possible values for FACING_KEY */ + static const char FACING_BACK[]; + static const char FACING_FRONT[]; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_CAMERA_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.cpp new file mode 100644 index 0000000..ea7424b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.cpp @@ -0,0 +1,410 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedCamera that encapsulates + * functionality common to all version 2.0 emulated camera devices. Instances + * of this class (for each emulated camera) are created during the construction + * of the EmulatedCameraFactory instance. This class serves as an entry point + * for all camera API calls that defined by camera2_device_ops_t API. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera2_Camera" +#include + +#include "EmulatedCamera2.h" +#include "system/camera_metadata.h" + +namespace android { + +/* Constructs EmulatedCamera2 instance. + * Param: + * cameraId - Zero based camera identifier, which is an index of the camera + * instance in camera factory's array. + * module - Emulated camera HAL module descriptor. + */ +EmulatedCamera2::EmulatedCamera2(int cameraId, + struct hw_module_t* module): + EmulatedBaseCamera(cameraId, + CAMERA_DEVICE_API_VERSION_2_0, + &common, + module) +{ + common.close = EmulatedCamera2::close; + ops = &sDeviceOps; + priv = this; + + mNotifyCb = NULL; + + mRequestQueueSrc = NULL; + mFrameQueueDst = NULL; + + mVendorTagOps.get_camera_vendor_section_name = + EmulatedCamera2::get_camera_vendor_section_name; + mVendorTagOps.get_camera_vendor_tag_name = + EmulatedCamera2::get_camera_vendor_tag_name; + mVendorTagOps.get_camera_vendor_tag_type = + EmulatedCamera2::get_camera_vendor_tag_type; + mVendorTagOps.parent = this; + + mStatusPresent = true; +} + +/* Destructs EmulatedCamera2 instance. */ +EmulatedCamera2::~EmulatedCamera2() { +} + +/**************************************************************************** + * Abstract API + ***************************************************************************/ + +/**************************************************************************** + * Public API + ***************************************************************************/ + +status_t EmulatedCamera2::Initialize() { + return NO_ERROR; +} + +/**************************************************************************** + * Camera API implementation + ***************************************************************************/ + +status_t EmulatedCamera2::connectCamera(hw_device_t** device) { + *device = &common; + return NO_ERROR; +} + +status_t EmulatedCamera2::closeCamera() { + return NO_ERROR; +} + +status_t EmulatedCamera2::getCameraInfo(struct camera_info* info) { + return EmulatedBaseCamera::getCameraInfo(info); +} + +/**************************************************************************** + * Camera Device API implementation. + * These methods are called from the camera API callback routines. + ***************************************************************************/ + +/** Request input queue */ + +int EmulatedCamera2::requestQueueNotify() { + return INVALID_OPERATION; +} + +/** Count of requests in flight */ +int EmulatedCamera2::getInProgressCount() { + return INVALID_OPERATION; +} + +/** Cancel all captures in flight */ +int EmulatedCamera2::flushCapturesInProgress() { + return INVALID_OPERATION; +} + +/** Construct a default request for a given use case */ +int EmulatedCamera2::constructDefaultRequest( + int request_template, + camera_metadata_t **request) { + return INVALID_OPERATION; +} + +/** Output stream creation and management */ + +int EmulatedCamera2::allocateStream( + uint32_t width, + uint32_t height, + int format, + const camera2_stream_ops_t *stream_ops, + uint32_t *stream_id, + uint32_t *format_actual, + uint32_t *usage, + uint32_t *max_buffers) { + return INVALID_OPERATION; +} + +int EmulatedCamera2::registerStreamBuffers( + uint32_t stream_id, + int num_buffers, + buffer_handle_t *buffers) { + return INVALID_OPERATION; +} + + +int EmulatedCamera2::releaseStream(uint32_t stream_id) { + return INVALID_OPERATION; +} + +/** Reprocessing input stream management */ + +int EmulatedCamera2::allocateReprocessStream( + uint32_t width, + uint32_t height, + uint32_t format, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id, + uint32_t *consumer_usage, + uint32_t *max_buffers) { + return INVALID_OPERATION; +} + +int EmulatedCamera2::allocateReprocessStreamFromStream( + uint32_t output_stream_id, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id) { + return INVALID_OPERATION; +} + +int EmulatedCamera2::releaseReprocessStream(uint32_t stream_id) { + return INVALID_OPERATION; +} + +/** 3A triggering */ + +int EmulatedCamera2::triggerAction(uint32_t trigger_id, + int ext1, int ext2) { + return INVALID_OPERATION; +} + +/** Custom tag query methods */ + +const char* EmulatedCamera2::getVendorSectionName(uint32_t tag) { + return NULL; +} + +const char* EmulatedCamera2::getVendorTagName(uint32_t tag) { + return NULL; +} + +int EmulatedCamera2::getVendorTagType(uint32_t tag) { + return -1; +} + +/** Debug methods */ + +int EmulatedCamera2::dump(int fd) { + return INVALID_OPERATION; +} + +/**************************************************************************** + * Private API. + ***************************************************************************/ + +/**************************************************************************** + * Camera API callbacks as defined by camera2_device_ops structure. See + * hardware/libhardware/include/hardware/camera2.h for information on each + * of these callbacks. Implemented in this class, these callbacks simply + * dispatch the call into an instance of EmulatedCamera2 class defined by the + * 'camera_device2' parameter, or set a member value in the same. + ***************************************************************************/ + +EmulatedCamera2* getInstance(const camera2_device_t *d) { + const EmulatedCamera2* cec = static_cast(d); + return const_cast(cec); +} + +int EmulatedCamera2::set_request_queue_src_ops(const camera2_device_t *d, + const camera2_request_queue_src_ops *queue_src_ops) { + EmulatedCamera2* ec = getInstance(d); + ec->mRequestQueueSrc = queue_src_ops; + return NO_ERROR; +} + +int EmulatedCamera2::notify_request_queue_not_empty(const camera2_device_t *d) { + EmulatedCamera2* ec = getInstance(d); + return ec->requestQueueNotify(); +} + +int EmulatedCamera2::set_frame_queue_dst_ops(const camera2_device_t *d, + const camera2_frame_queue_dst_ops *queue_dst_ops) { + EmulatedCamera2* ec = getInstance(d); + ec->mFrameQueueDst = queue_dst_ops; + return NO_ERROR; +} + +int EmulatedCamera2::get_in_progress_count(const camera2_device_t *d) { + EmulatedCamera2* ec = getInstance(d); + return ec->getInProgressCount(); +} + +int EmulatedCamera2::flush_captures_in_progress(const camera2_device_t *d) { + EmulatedCamera2* ec = getInstance(d); + return ec->flushCapturesInProgress(); +} + +int EmulatedCamera2::construct_default_request(const camera2_device_t *d, + int request_template, + camera_metadata_t **request) { + EmulatedCamera2* ec = getInstance(d); + return ec->constructDefaultRequest(request_template, request); +} + +int EmulatedCamera2::allocate_stream(const camera2_device_t *d, + uint32_t width, + uint32_t height, + int format, + const camera2_stream_ops_t *stream_ops, + uint32_t *stream_id, + uint32_t *format_actual, + uint32_t *usage, + uint32_t *max_buffers) { + EmulatedCamera2* ec = getInstance(d); + return ec->allocateStream(width, height, format, stream_ops, + stream_id, format_actual, usage, max_buffers); +} + +int EmulatedCamera2::register_stream_buffers(const camera2_device_t *d, + uint32_t stream_id, + int num_buffers, + buffer_handle_t *buffers) { + EmulatedCamera2* ec = getInstance(d); + return ec->registerStreamBuffers(stream_id, + num_buffers, + buffers); +} +int EmulatedCamera2::release_stream(const camera2_device_t *d, + uint32_t stream_id) { + EmulatedCamera2* ec = getInstance(d); + return ec->releaseStream(stream_id); +} + +int EmulatedCamera2::allocate_reprocess_stream(const camera2_device_t *d, + uint32_t width, + uint32_t height, + uint32_t format, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id, + uint32_t *consumer_usage, + uint32_t *max_buffers) { + EmulatedCamera2* ec = getInstance(d); + return ec->allocateReprocessStream(width, height, format, + reprocess_stream_ops, stream_id, consumer_usage, max_buffers); +} + +int EmulatedCamera2::allocate_reprocess_stream_from_stream( + const camera2_device_t *d, + uint32_t output_stream_id, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id) { + EmulatedCamera2* ec = getInstance(d); + return ec->allocateReprocessStreamFromStream(output_stream_id, + reprocess_stream_ops, stream_id); +} + + +int EmulatedCamera2::release_reprocess_stream(const camera2_device_t *d, + uint32_t stream_id) { + EmulatedCamera2* ec = getInstance(d); + return ec->releaseReprocessStream(stream_id); +} + +int EmulatedCamera2::trigger_action(const camera2_device_t *d, + uint32_t trigger_id, + int ext1, + int ext2) { + EmulatedCamera2* ec = getInstance(d); + return ec->triggerAction(trigger_id, ext1, ext2); +} + +int EmulatedCamera2::set_notify_callback(const camera2_device_t *d, + camera2_notify_callback notify_cb, void* user) { + EmulatedCamera2* ec = getInstance(d); + Mutex::Autolock l(ec->mMutex); + ec->mNotifyCb = notify_cb; + ec->mNotifyUserPtr = user; + return NO_ERROR; +} + +int EmulatedCamera2::get_metadata_vendor_tag_ops(const camera2_device_t *d, + vendor_tag_query_ops_t **ops) { + EmulatedCamera2* ec = getInstance(d); + *ops = static_cast( + &ec->mVendorTagOps); + return NO_ERROR; +} + +const char* EmulatedCamera2::get_camera_vendor_section_name( + const vendor_tag_query_ops_t *v, + uint32_t tag) { + EmulatedCamera2* ec = static_cast(v)->parent; + return ec->getVendorSectionName(tag); +} + +const char* EmulatedCamera2::get_camera_vendor_tag_name( + const vendor_tag_query_ops_t *v, + uint32_t tag) { + EmulatedCamera2* ec = static_cast(v)->parent; + return ec->getVendorTagName(tag); +} + +int EmulatedCamera2::get_camera_vendor_tag_type( + const vendor_tag_query_ops_t *v, + uint32_t tag) { + EmulatedCamera2* ec = static_cast(v)->parent; + return ec->getVendorTagType(tag); +} + +int EmulatedCamera2::dump(const camera2_device_t *d, int fd) { + EmulatedCamera2* ec = getInstance(d); + return ec->dump(fd); +} + +int EmulatedCamera2::close(struct hw_device_t* device) { + EmulatedCamera2* ec = + static_cast( + reinterpret_cast(device) ); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera2 device", __FUNCTION__); + return -EINVAL; + } + return ec->closeCamera(); +} + +void EmulatedCamera2::sendNotification(int32_t msgType, + int32_t ext1, int32_t ext2, int32_t ext3) { + camera2_notify_callback notifyCb; + { + Mutex::Autolock l(mMutex); + notifyCb = mNotifyCb; + } + if (notifyCb != NULL) { + notifyCb(msgType, ext1, ext2, ext3, mNotifyUserPtr); + } +} + +camera2_device_ops_t EmulatedCamera2::sDeviceOps = { + EmulatedCamera2::set_request_queue_src_ops, + EmulatedCamera2::notify_request_queue_not_empty, + EmulatedCamera2::set_frame_queue_dst_ops, + EmulatedCamera2::get_in_progress_count, + EmulatedCamera2::flush_captures_in_progress, + EmulatedCamera2::construct_default_request, + EmulatedCamera2::allocate_stream, + EmulatedCamera2::register_stream_buffers, + EmulatedCamera2::release_stream, + EmulatedCamera2::allocate_reprocess_stream, + EmulatedCamera2::allocate_reprocess_stream_from_stream, + EmulatedCamera2::release_reprocess_stream, + EmulatedCamera2::trigger_action, + EmulatedCamera2::set_notify_callback, + EmulatedCamera2::get_metadata_vendor_tag_ops, + EmulatedCamera2::dump +}; + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.h new file mode 100644 index 0000000..9f5f67b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera2.h @@ -0,0 +1,274 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA2_H +#define HW_EMULATOR_CAMERA_EMULATED_CAMERA2_H + +/* + * Contains declaration of a class EmulatedCamera that encapsulates + * functionality common to all version 2.0 emulated camera devices. Instances + * of this class (for each emulated camera) are created during the construction + * of the EmulatedCameraFactory instance. This class serves as an entry point + * for all camera API calls that defined by camera2_device_ops_t API. + */ + +#include "hardware/camera2.h" +#include "system/camera_metadata.h" +#include "EmulatedBaseCamera.h" +#include +#include + +namespace android { + +/* Encapsulates functionality common to all version 2.0 emulated camera devices + * + * Note that EmulatedCameraFactory instantiates object of this class just once, + * when EmulatedCameraFactory instance gets constructed. Connection to / + * disconnection from the actual camera device is handled by calls to + * connectDevice(), and closeCamera() methods of this class that are invoked in + * response to hw_module_methods_t::open, and camera_device::close callbacks. + */ +class EmulatedCamera2 : public camera2_device, public EmulatedBaseCamera { +public: + /* Constructs EmulatedCamera2 instance. + * Param: + * cameraId - Zero based camera identifier, which is an index of the camera + * instance in camera factory's array. + * module - Emulated camera HAL module descriptor. + */ + EmulatedCamera2(int cameraId, + struct hw_module_t* module); + + /* Destructs EmulatedCamera2 instance. */ + virtual ~EmulatedCamera2(); + + /**************************************************************************** + * Abstract API + ***************************************************************************/ + +public: + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + virtual status_t Initialize(); + + /**************************************************************************** + * Camera module API and generic hardware device API implementation + ***************************************************************************/ + +public: + virtual status_t connectCamera(hw_device_t** device); + + virtual status_t closeCamera(); + + virtual status_t getCameraInfo(struct camera_info* info) = 0; + + /**************************************************************************** + * Camera API implementation. + * These methods are called from the camera API callback routines. + ***************************************************************************/ + +protected: + /** Request input queue notification */ + virtual int requestQueueNotify(); + + /** Count of requests in flight */ + virtual int getInProgressCount(); + + /** Cancel all captures in flight */ + virtual int flushCapturesInProgress(); + + virtual int constructDefaultRequest( + int request_template, + camera_metadata_t **request); + + /** Output stream creation and management */ + virtual int allocateStream( + uint32_t width, + uint32_t height, + int format, + const camera2_stream_ops_t *stream_ops, + uint32_t *stream_id, + uint32_t *format_actual, + uint32_t *usage, + uint32_t *max_buffers); + + virtual int registerStreamBuffers( + uint32_t stream_id, + int num_buffers, + buffer_handle_t *buffers); + + virtual int releaseStream(uint32_t stream_id); + + /** Input stream creation and management */ + virtual int allocateReprocessStream( + uint32_t width, + uint32_t height, + uint32_t format, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id, + uint32_t *consumer_usage, + uint32_t *max_buffers); + + virtual int allocateReprocessStreamFromStream( + uint32_t output_stream_id, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id); + + virtual int releaseReprocessStream(uint32_t stream_id); + + /** 3A action triggering */ + virtual int triggerAction(uint32_t trigger_id, + int32_t ext1, int32_t ext2); + + /** Custom tag definitions */ + virtual const char* getVendorSectionName(uint32_t tag); + virtual const char* getVendorTagName(uint32_t tag); + virtual int getVendorTagType(uint32_t tag); + + /** Debug methods */ + + virtual int dump(int fd); + + /**************************************************************************** + * Camera API callbacks as defined by camera2_device_ops structure. See + * hardware/libhardware/include/hardware/camera2.h for information on each + * of these callbacks. Implemented in this class, these callbacks simply + * dispatch the call into an instance of EmulatedCamera2 class defined in + * the 'camera_device2' parameter. + ***************************************************************************/ + +private: + /** Input request queue */ + static int set_request_queue_src_ops(const camera2_device_t *, + const camera2_request_queue_src_ops *queue_src_ops); + static int notify_request_queue_not_empty(const camera2_device_t *); + + /** Output frame queue */ + static int set_frame_queue_dst_ops(const camera2_device_t *, + const camera2_frame_queue_dst_ops *queue_dst_ops); + + /** In-progress request management */ + static int get_in_progress_count(const camera2_device_t *); + + static int flush_captures_in_progress(const camera2_device_t *); + + /** Request template creation */ + static int construct_default_request(const camera2_device_t *, + int request_template, + camera_metadata_t **request); + + /** Stream management */ + static int allocate_stream(const camera2_device_t *, + uint32_t width, + uint32_t height, + int format, + const camera2_stream_ops_t *stream_ops, + uint32_t *stream_id, + uint32_t *format_actual, + uint32_t *usage, + uint32_t *max_buffers); + + static int register_stream_buffers(const camera2_device_t *, + uint32_t stream_id, + int num_buffers, + buffer_handle_t *buffers); + + static int release_stream(const camera2_device_t *, + uint32_t stream_id); + + static int allocate_reprocess_stream(const camera2_device_t *, + uint32_t width, + uint32_t height, + uint32_t format, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id, + uint32_t *consumer_usage, + uint32_t *max_buffers); + + static int allocate_reprocess_stream_from_stream(const camera2_device_t *, + uint32_t output_stream_id, + const camera2_stream_in_ops_t *reprocess_stream_ops, + uint32_t *stream_id); + + static int release_reprocess_stream(const camera2_device_t *, + uint32_t stream_id); + + /** 3A triggers*/ + static int trigger_action(const camera2_device_t *, + uint32_t trigger_id, + int ext1, + int ext2); + + /** Notifications to application */ + static int set_notify_callback(const camera2_device_t *, + camera2_notify_callback notify_cb, + void *user); + + /** Vendor metadata registration */ + static int get_metadata_vendor_tag_ops(const camera2_device_t *, + vendor_tag_query_ops_t **ops); + // for get_metadata_vendor_tag_ops + static const char* get_camera_vendor_section_name( + const vendor_tag_query_ops_t *, + uint32_t tag); + static const char* get_camera_vendor_tag_name( + const vendor_tag_query_ops_t *, + uint32_t tag); + static int get_camera_vendor_tag_type( + const vendor_tag_query_ops_t *, + uint32_t tag); + + static int dump(const camera2_device_t *, int fd); + + /** For hw_device_t ops */ + static int close(struct hw_device_t* device); + + /**************************************************************************** + * Data members shared with implementations + ***************************************************************************/ + protected: + /** Mutex for calls through camera2 device interface */ + Mutex mMutex; + + bool mStatusPresent; + + const camera2_request_queue_src_ops *mRequestQueueSrc; + const camera2_frame_queue_dst_ops *mFrameQueueDst; + + struct TagOps : public vendor_tag_query_ops { + EmulatedCamera2 *parent; + }; + TagOps mVendorTagOps; + + void sendNotification(int32_t msgType, + int32_t ext1, int32_t ext2, int32_t ext3); + + /**************************************************************************** + * Data members + ***************************************************************************/ + private: + static camera2_device_ops_t sDeviceOps; + camera2_notify_callback mNotifyCb; + void* mNotifyUserPtr; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_CAMERA2_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.cpp new file mode 100644 index 0000000..e9110cc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.cpp @@ -0,0 +1,271 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Contains implementation of a class EmulatedCamera that encapsulates + * functionality common to all version 3.0 emulated camera devices. Instances + * of this class (for each emulated camera) are created during the construction + * of the EmulatedCameraFactory instance. This class serves as an entry point + * for all camera API calls that defined by camera3_device_ops_t API. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera3_Camera" +#include + +#include "EmulatedCamera3.h" +#include "system/camera_metadata.h" + +namespace android { + +/** + * Constructs EmulatedCamera3 instance. + * Param: + * cameraId - Zero based camera identifier, which is an index of the camera + * instance in camera factory's array. + * module - Emulated camera HAL module descriptor. + */ +EmulatedCamera3::EmulatedCamera3(int cameraId, + struct hw_module_t* module): + EmulatedBaseCamera(cameraId, + CAMERA_DEVICE_API_VERSION_3_3, + &common, + module), + mStatus(STATUS_ERROR) +{ + common.close = EmulatedCamera3::close; + ops = &sDeviceOps; + + mCallbackOps = NULL; + +} + +/* Destructs EmulatedCamera3 instance. */ +EmulatedCamera3::~EmulatedCamera3() { +} + +/**************************************************************************** + * Abstract API + ***************************************************************************/ + +/**************************************************************************** + * Public API + ***************************************************************************/ + +status_t EmulatedCamera3::Initialize() { + ALOGV("%s", __FUNCTION__); + + mStatus = STATUS_CLOSED; + return NO_ERROR; +} + +/**************************************************************************** + * Camera API implementation + ***************************************************************************/ + +status_t EmulatedCamera3::connectCamera(hw_device_t** device) { + ALOGV("%s", __FUNCTION__); + if (device == NULL) return BAD_VALUE; + + if (mStatus != STATUS_CLOSED) { + ALOGE("%s: Trying to open a camera in state %d!", + __FUNCTION__, mStatus); + return INVALID_OPERATION; + } + + *device = &common; + mStatus = STATUS_OPEN; + return NO_ERROR; +} + +status_t EmulatedCamera3::closeCamera() { + mStatus = STATUS_CLOSED; + return NO_ERROR; +} + +status_t EmulatedCamera3::getCameraInfo(struct camera_info* info) { + return EmulatedBaseCamera::getCameraInfo(info); +} + +/**************************************************************************** + * Camera Device API implementation. + * These methods are called from the camera API callback routines. + ***************************************************************************/ + +status_t EmulatedCamera3::initializeDevice( + const camera3_callback_ops *callbackOps) { + if (callbackOps == NULL) { + ALOGE("%s: NULL callback ops provided to HAL!", + __FUNCTION__); + return BAD_VALUE; + } + + if (mStatus != STATUS_OPEN) { + ALOGE("%s: Trying to initialize a camera in state %d!", + __FUNCTION__, mStatus); + return INVALID_OPERATION; + } + + mCallbackOps = callbackOps; + mStatus = STATUS_READY; + + return NO_ERROR; +} + +status_t EmulatedCamera3::configureStreams( + camera3_stream_configuration *streamList) { + ALOGE("%s: Not implemented", __FUNCTION__); + return INVALID_OPERATION; +} + +status_t EmulatedCamera3::registerStreamBuffers( + const camera3_stream_buffer_set *bufferSet) { + ALOGE("%s: Not implemented", __FUNCTION__); + return INVALID_OPERATION; +} + +const camera_metadata_t* EmulatedCamera3::constructDefaultRequestSettings( + int type) { + ALOGE("%s: Not implemented", __FUNCTION__); + return NULL; +} + +status_t EmulatedCamera3::processCaptureRequest( + camera3_capture_request *request) { + ALOGE("%s: Not implemented", __FUNCTION__); + return INVALID_OPERATION; +} + +status_t EmulatedCamera3::flush() { + ALOGE("%s: Not implemented", __FUNCTION__); + return INVALID_OPERATION; +} + +/** Debug methods */ + +void EmulatedCamera3::dump(int fd) { + ALOGE("%s: Not implemented", __FUNCTION__); + return; +} + +/**************************************************************************** + * Protected API. Callbacks to the framework. + ***************************************************************************/ + +void EmulatedCamera3::sendCaptureResult(camera3_capture_result_t *result) { + mCallbackOps->process_capture_result(mCallbackOps, result); +} + +void EmulatedCamera3::sendNotify(camera3_notify_msg_t *msg) { + mCallbackOps->notify(mCallbackOps, msg); +} + +/**************************************************************************** + * Private API. + ***************************************************************************/ + +/**************************************************************************** + * Camera API callbacks as defined by camera3_device_ops structure. See + * hardware/libhardware/include/hardware/camera3.h for information on each + * of these callbacks. Implemented in this class, these callbacks simply + * dispatch the call into an instance of EmulatedCamera3 class defined by the + * 'camera_device3' parameter, or set a member value in the same. + ***************************************************************************/ + +EmulatedCamera3* getInstance(const camera3_device_t *d) { + const EmulatedCamera3* cec = static_cast(d); + return const_cast(cec); +} + +int EmulatedCamera3::initialize(const struct camera3_device *d, + const camera3_callback_ops_t *callback_ops) { + EmulatedCamera3* ec = getInstance(d); + return ec->initializeDevice(callback_ops); +} + +int EmulatedCamera3::configure_streams(const struct camera3_device *d, + camera3_stream_configuration_t *stream_list) { + EmulatedCamera3* ec = getInstance(d); + return ec->configureStreams(stream_list); +} + +int EmulatedCamera3::register_stream_buffers( + const struct camera3_device *d, + const camera3_stream_buffer_set_t *buffer_set) { + EmulatedCamera3* ec = getInstance(d); + return ec->registerStreamBuffers(buffer_set); +} + +int EmulatedCamera3::process_capture_request( + const struct camera3_device *d, + camera3_capture_request_t *request) { + EmulatedCamera3* ec = getInstance(d); + return ec->processCaptureRequest(request); +} + +const camera_metadata_t* EmulatedCamera3::construct_default_request_settings( + const camera3_device_t *d, int type) { + EmulatedCamera3* ec = getInstance(d); + return ec->constructDefaultRequestSettings(type); +} + +void EmulatedCamera3::dump(const camera3_device_t *d, int fd) { + EmulatedCamera3* ec = getInstance(d); + ec->dump(fd); +} + +int EmulatedCamera3::flush(const camera3_device_t *d) { + EmulatedCamera3* ec = getInstance(d); + return ec->flush(); +} + +int EmulatedCamera3::close(struct hw_device_t* device) { + EmulatedCamera3* ec = + static_cast( + reinterpret_cast(device) ); + if (ec == NULL) { + ALOGE("%s: Unexpected NULL camera3 device", __FUNCTION__); + return BAD_VALUE; + } + return ec->closeCamera(); +} + +camera3_device_ops_t EmulatedCamera3::sDeviceOps = { + EmulatedCamera3::initialize, + EmulatedCamera3::configure_streams, + /* DEPRECATED: register_stream_buffers */ nullptr, + EmulatedCamera3::construct_default_request_settings, + EmulatedCamera3::process_capture_request, + /* DEPRECATED: get_metadata_vendor_tag_ops */ nullptr, + EmulatedCamera3::dump, + EmulatedCamera3::flush +}; + +const char* EmulatedCamera3::sAvailableCapabilitiesStrings[NUM_CAPABILITIES] = { + "BACKWARD_COMPATIBLE", + "MANUAL_SENSOR", + "MANUAL_POST_PROCESSING", + "RAW", + "PRIVATE_REPROCESSING", + "READ_SENSOR_SETTINGS", + "BURST_CAPTURE", + "YUV_REPROCESSING", + "DEPTH_OUTPUT", + "CONSTRAINED_HIGH_SPEED_VIDEO", + "FULL_LEVEL" +}; + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.h new file mode 100644 index 0000000..9d2d7b2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCamera3.h @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA3_H +#define HW_EMULATOR_CAMERA_EMULATED_CAMERA3_H + +/** + * Contains declaration of a class EmulatedCamera that encapsulates + * functionality common to all version 3.0 emulated camera devices. Instances + * of this class (for each emulated camera) are created during the construction + * of the EmulatedCameraFactory instance. This class serves as an entry point + * for all camera API calls that defined by camera3_device_ops_t API. + */ + +#include "hardware/camera3.h" +#include "system/camera_metadata.h" +#include "EmulatedBaseCamera.h" + +namespace android { + +/** + * Encapsulates functionality common to all version 3.0 emulated camera devices + * + * Note that EmulatedCameraFactory instantiates an object of this class just + * once, when EmulatedCameraFactory instance gets constructed. Connection to / + * disconnection from the actual camera device is handled by calls to + * connectDevice(), and closeCamera() methods of this class that are invoked in + * response to hw_module_methods_t::open, and camera_device::close callbacks. + */ +class EmulatedCamera3 : public camera3_device, public EmulatedBaseCamera { +public: + /* Constructs EmulatedCamera3 instance. + * Param: + * cameraId - Zero based camera identifier, which is an index of the camera + * instance in camera factory's array. + * module - Emulated camera HAL module descriptor. + */ + EmulatedCamera3(int cameraId, + struct hw_module_t* module); + + /* Destructs EmulatedCamera2 instance. */ + virtual ~EmulatedCamera3(); + + /* List of all defined capabilities plus useful HW levels */ + enum AvailableCapabilities { + BACKWARD_COMPATIBLE, + MANUAL_SENSOR, + MANUAL_POST_PROCESSING, + RAW, + PRIVATE_REPROCESSING, + READ_SENSOR_SETTINGS, + BURST_CAPTURE, + YUV_REPROCESSING, + DEPTH_OUTPUT, + CONSTRAINED_HIGH_SPEED_VIDEO, + // Levels + FULL_LEVEL, + + NUM_CAPABILITIES + }; + + // Char strings for above enum, with size NUM_CAPABILITIES + static const char *sAvailableCapabilitiesStrings[]; + + /**************************************************************************** + * Abstract API + ***************************************************************************/ + +public: + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + virtual status_t Initialize(); + + /**************************************************************************** + * Camera module API and generic hardware device API implementation + ***************************************************************************/ + +public: + virtual status_t connectCamera(hw_device_t** device); + + virtual status_t closeCamera(); + + virtual status_t getCameraInfo(struct camera_info* info); + + /**************************************************************************** + * Camera API implementation. + * These methods are called from the camera API callback routines. + ***************************************************************************/ + +protected: + + virtual status_t initializeDevice( + const camera3_callback_ops *callbackOps); + + virtual status_t configureStreams( + camera3_stream_configuration *streamList); + + virtual status_t registerStreamBuffers( + const camera3_stream_buffer_set *bufferSet) ; + + virtual const camera_metadata_t* constructDefaultRequestSettings( + int type); + + virtual status_t processCaptureRequest(camera3_capture_request *request); + + virtual status_t flush(); + + /** Debug methods */ + + virtual void dump(int fd); + + /**************************************************************************** + * Camera API callbacks as defined by camera3_device_ops structure. See + * hardware/libhardware/include/hardware/camera3.h for information on each + * of these callbacks. Implemented in this class, these callbacks simply + * dispatch the call into an instance of EmulatedCamera3 class defined in + * the 'camera_device3' parameter. + ***************************************************************************/ + +private: + + /** Startup */ + static int initialize(const struct camera3_device *, + const camera3_callback_ops_t *callback_ops); + + /** Stream configuration and buffer registration */ + + static int configure_streams(const struct camera3_device *, + camera3_stream_configuration_t *stream_list); + + static int register_stream_buffers(const struct camera3_device *, + const camera3_stream_buffer_set_t *buffer_set); + + /** Template request settings provision */ + + static const camera_metadata_t* construct_default_request_settings( + const struct camera3_device *, int type); + + /** Submission of capture requests to HAL */ + + static int process_capture_request(const struct camera3_device *, + camera3_capture_request_t *request); + + static void dump(const camera3_device_t *, int fd); + + static int flush(const camera3_device_t *); + + /** For hw_device_t ops */ + static int close(struct hw_device_t* device); + + /**************************************************************************** + * Data members shared with implementations + ***************************************************************************/ + protected: + + enum { + // State at construction time, and after a device operation error + STATUS_ERROR = 0, + // State after startup-time init and after device instance close + STATUS_CLOSED, + // State after being opened, before device instance init + STATUS_OPEN, + // State after device instance initialization + STATUS_READY, + // State while actively capturing data + STATUS_ACTIVE + } mStatus; + + /** + * Callbacks back to the framework + */ + + void sendCaptureResult(camera3_capture_result_t *result); + void sendNotify(camera3_notify_msg_t *msg); + + /**************************************************************************** + * Data members + ***************************************************************************/ + private: + static camera3_device_ops_t sDeviceOps; + const camera3_callback_ops_t *mCallbackOps; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_CAMERA3_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraCommon.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraCommon.h new file mode 100644 index 0000000..c1d575c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraCommon.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H +#define HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H + +/* + * Contains common declarations that are used across the camera emulation. + */ + +#include +#include + +/* A helper class that tracks a routine execution. + * Basically, it dumps an enry message in its constructor, and an exit message + * in its destructor. Use LOGRE() macro (declared bellow) to create instances + * of this class at the beginning of the tracked routines / methods. + */ +class HWERoutineTracker { +public: + /* Constructor that prints an "entry" trace message. */ + explicit HWERoutineTracker(const char* name) + : mName(name) { + ALOGV("Entering %s", mName); + } + + /* Destructor that prints a "leave" trace message. */ + ~HWERoutineTracker() { + ALOGV("Leaving %s", mName); + } + +private: + /* Stores the routine name. */ + const char* mName; +}; + +/* Logs an execution of a routine / method. */ +#define LOGRE() HWERoutineTracker hwertracker_##__LINE__(__FUNCTION__) + +/* + * min / max macros + */ + +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#define max(a,b) (((a) > (b)) ? (a) : (b)) + +#endif /* HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.cpp new file mode 100644 index 0000000..c8e5640 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.cpp @@ -0,0 +1,413 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of an abstract class EmulatedCameraDevice that defines + * functionality expected from an emulated physical camera device: + * - Obtaining and setting camera parameters + * - Capturing frames + * - Streaming video + * - etc. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_Device" +#include +#include +#include +#include "EmulatedCameraDevice.h" + +namespace android { + +const float GAMMA_CORRECTION = 2.2f; +EmulatedCameraDevice::EmulatedCameraDevice(EmulatedCamera* camera_hal) + : mObjectLock(), + mCurFrameTimestamp(0), + mCameraHAL(camera_hal), + mCurrentFrame(NULL), + mExposureCompensation(1.0f), + mWhiteBalanceScale(NULL), + mSupportedWhiteBalanceScale(), + mState(ECDS_CONSTRUCTED) +{ +} + +EmulatedCameraDevice::~EmulatedCameraDevice() +{ + ALOGV("EmulatedCameraDevice destructor"); + if (mCurrentFrame != NULL) { + delete[] mCurrentFrame; + } + for (size_t i = 0; i < mSupportedWhiteBalanceScale.size(); ++i) { + if (mSupportedWhiteBalanceScale.valueAt(i) != NULL) { + delete[] mSupportedWhiteBalanceScale.valueAt(i); + } + } +} + +/**************************************************************************** + * Emulated camera device public API + ***************************************************************************/ + +status_t EmulatedCameraDevice::Initialize() +{ + if (isInitialized()) { + ALOGW("%s: Emulated camera device is already initialized: mState = %d", + __FUNCTION__, mState); + return NO_ERROR; + } + + /* Instantiate worker thread object. */ + mWorkerThread = new WorkerThread(this); + if (getWorkerThread() == NULL) { + ALOGE("%s: Unable to instantiate worker thread object", __FUNCTION__); + return ENOMEM; + } + + mState = ECDS_INITIALIZED; + + return NO_ERROR; +} + +status_t EmulatedCameraDevice::startDeliveringFrames(bool one_burst) +{ + ALOGV("%s", __FUNCTION__); + + if (!isStarted()) { + ALOGE("%s: Device is not started", __FUNCTION__); + return EINVAL; + } + + /* Frames will be delivered from the thread routine. */ + const status_t res = startWorkerThread(one_burst); + ALOGE_IF(res != NO_ERROR, "%s: startWorkerThread failed", __FUNCTION__); + return res; +} + +status_t EmulatedCameraDevice::stopDeliveringFrames() +{ + ALOGV("%s", __FUNCTION__); + + if (!isStarted()) { + ALOGW("%s: Device is not started", __FUNCTION__); + return NO_ERROR; + } + + const status_t res = stopWorkerThread(); + ALOGE_IF(res != NO_ERROR, "%s: startWorkerThread failed", __FUNCTION__); + return res; +} + +void EmulatedCameraDevice::setExposureCompensation(const float ev) { + ALOGV("%s", __FUNCTION__); + + if (!isStarted()) { + ALOGW("%s: Fake camera device is not started.", __FUNCTION__); + } + + mExposureCompensation = std::pow(2.0f, ev / GAMMA_CORRECTION); + ALOGV("New exposure compensation is %f", mExposureCompensation); +} + +void EmulatedCameraDevice::initializeWhiteBalanceModes(const char* mode, + const float r_scale, + const float b_scale) { + ALOGV("%s with %s, %f, %f", __FUNCTION__, mode, r_scale, b_scale); + float* value = new float[3]; + value[0] = r_scale; value[1] = 1.0f; value[2] = b_scale; + mSupportedWhiteBalanceScale.add(String8(mode), value); +} + +void EmulatedCameraDevice::setWhiteBalanceMode(const char* mode) { + ALOGV("%s with white balance %s", __FUNCTION__, mode); + mWhiteBalanceScale = + mSupportedWhiteBalanceScale.valueFor(String8(mode)); +} + +/* Computes the pixel value after adjusting the white balance to the current + * one. The input the y, u, v channel of the pixel and the adjusted value will + * be stored in place. The adjustment is done in RGB space. + */ +void EmulatedCameraDevice::changeWhiteBalance(uint8_t& y, + uint8_t& u, + uint8_t& v) const { + float r_scale = mWhiteBalanceScale[0]; + float b_scale = mWhiteBalanceScale[2]; + int r = static_cast(YUV2R(y, u, v)) / r_scale; + int g = YUV2G(y, u, v); + int b = static_cast(YUV2B(y, u, v)) / b_scale; + + y = RGB2Y(r, g, b); + u = RGB2U(r, g, b); + v = RGB2V(r, g, b); +} + +status_t EmulatedCameraDevice::getCurrentPreviewFrame(void* buffer) +{ + if (!isStarted()) { + ALOGE("%s: Device is not started", __FUNCTION__); + return EINVAL; + } + if (mCurrentFrame == NULL || buffer == NULL) { + ALOGE("%s: No framebuffer", __FUNCTION__); + return EINVAL; + } + + /* In emulation the framebuffer is never RGB. */ + switch (mPixelFormat) { + case V4L2_PIX_FMT_YVU420: + YV12ToRGB32(mCurrentFrame, buffer, mFrameWidth, mFrameHeight); + return NO_ERROR; + case V4L2_PIX_FMT_YUV420: + YU12ToRGB32(mCurrentFrame, buffer, mFrameWidth, mFrameHeight); + return NO_ERROR; + case V4L2_PIX_FMT_NV21: + NV21ToRGB32(mCurrentFrame, buffer, mFrameWidth, mFrameHeight); + return NO_ERROR; + case V4L2_PIX_FMT_NV12: + NV12ToRGB32(mCurrentFrame, buffer, mFrameWidth, mFrameHeight); + return NO_ERROR; + + default: + ALOGE("%s: Unknown pixel format %.4s", + __FUNCTION__, reinterpret_cast(&mPixelFormat)); + return EINVAL; + } +} + +/**************************************************************************** + * Emulated camera device private API + ***************************************************************************/ + +status_t EmulatedCameraDevice::commonStartDevice(int width, + int height, + uint32_t pix_fmt) +{ + /* Validate pixel format, and calculate framebuffer size at the same time. */ + switch (pix_fmt) { + case V4L2_PIX_FMT_YVU420: + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_NV21: + case V4L2_PIX_FMT_NV12: + mFrameBufferSize = (width * height * 12) / 8; + break; + + default: + ALOGE("%s: Unknown pixel format %.4s", + __FUNCTION__, reinterpret_cast(&pix_fmt)); + return EINVAL; + } + + /* Cache framebuffer info. */ + mFrameWidth = width; + mFrameHeight = height; + mPixelFormat = pix_fmt; + mTotalPixels = width * height; + + /* Allocate framebuffer. */ + mCurrentFrame = new uint8_t[mFrameBufferSize]; + if (mCurrentFrame == NULL) { + ALOGE("%s: Unable to allocate framebuffer", __FUNCTION__); + return ENOMEM; + } + ALOGV("%s: Allocated %p %zu bytes for %d pixels in %.4s[%dx%d] frame", + __FUNCTION__, mCurrentFrame, mFrameBufferSize, mTotalPixels, + reinterpret_cast(&mPixelFormat), mFrameWidth, mFrameHeight); + return NO_ERROR; +} + +void EmulatedCameraDevice::commonStopDevice() +{ + mFrameWidth = mFrameHeight = mTotalPixels = 0; + mPixelFormat = 0; + + if (mCurrentFrame != NULL) { + delete[] mCurrentFrame; + mCurrentFrame = NULL; + } +} + +/**************************************************************************** + * Worker thread management. + ***************************************************************************/ + +status_t EmulatedCameraDevice::startWorkerThread(bool one_burst) +{ + ALOGV("%s", __FUNCTION__); + + if (!isInitialized()) { + ALOGE("%s: Emulated camera device is not initialized", __FUNCTION__); + return EINVAL; + } + + const status_t res = getWorkerThread()->startThread(one_burst); + ALOGE_IF(res != NO_ERROR, "%s: Unable to start worker thread", __FUNCTION__); + return res; +} + +status_t EmulatedCameraDevice::stopWorkerThread() +{ + ALOGV("%s", __FUNCTION__); + + if (!isInitialized()) { + ALOGE("%s: Emulated camera device is not initialized", __FUNCTION__); + return EINVAL; + } + + const status_t res = getWorkerThread()->stopThread(); + ALOGE_IF(res != NO_ERROR, "%s: Unable to stop worker thread", __FUNCTION__); + return res; +} + +bool EmulatedCameraDevice::inWorkerThread() +{ + /* This will end the thread loop, and will terminate the thread. Derived + * classes must override this method. */ + return false; +} + +/**************************************************************************** + * Worker thread implementation. + ***************************************************************************/ + +status_t EmulatedCameraDevice::WorkerThread::readyToRun() +{ + ALOGV("Starting emulated camera device worker thread..."); + + ALOGW_IF(mThreadControl >= 0 || mControlFD >= 0, + "%s: Thread control FDs are opened", __FUNCTION__); + /* Create a pair of FDs that would be used to control the thread. */ + int thread_fds[2]; + status_t ret; + Mutex::Autolock lock(mCameraDevice->mObjectLock); + if (pipe(thread_fds) == 0) { + mThreadControl = thread_fds[1]; + mControlFD = thread_fds[0]; + ALOGV("Emulated device's worker thread has been started."); + ret = NO_ERROR; + } else { + ALOGE("%s: Unable to create thread control FDs: %d -> %s", + __FUNCTION__, errno, strerror(errno)); + ret = errno; + } + + mSetup.signal(); + return ret; +} + +status_t EmulatedCameraDevice::WorkerThread::stopThread() +{ + ALOGV("Stopping emulated camera device's worker thread..."); + + status_t res = EINVAL; + + // Limit the scope of the Autolock + { + // If thread is running and readyToRun() has not finished running, + // then wait until it is done. + Mutex::Autolock lock(mCameraDevice->mObjectLock); + if (isRunning() && (mThreadControl < 0 || mControlFD < 0)) { + mSetup.wait(mCameraDevice->mObjectLock); + } + } + + if (mThreadControl >= 0) { + /* Send "stop" message to the thread loop. */ + const ControlMessage msg = THREAD_STOP; + const int wres = + TEMP_FAILURE_RETRY(write(mThreadControl, &msg, sizeof(msg))); + if (wres == sizeof(msg)) { + /* Stop the thread, and wait till it's terminated. */ + res = requestExitAndWait(); + if (res == NO_ERROR) { + /* Close control FDs. */ + if (mThreadControl >= 0) { + close(mThreadControl); + mThreadControl = -1; + } + if (mControlFD >= 0) { + close(mControlFD); + mControlFD = -1; + } + ALOGV("Emulated camera device's worker thread has been stopped."); + } else { + ALOGE("%s: requestExitAndWait failed: %d -> %s", + __FUNCTION__, res, strerror(-res)); + } + } else { + ALOGE("%s: Unable to send THREAD_STOP message: %d -> %s", + __FUNCTION__, errno, strerror(errno)); + res = errno ? errno : EINVAL; + } + } else { + ALOGE("%s: Thread control FDs are not opened", __FUNCTION__); + } + + return res; +} + +EmulatedCameraDevice::WorkerThread::SelectRes +EmulatedCameraDevice::WorkerThread::Select(int fd, int timeout) +{ + fd_set fds[1]; + struct timeval tv, *tvp = NULL; + + const int fd_num = (fd >= 0) ? max(fd, mControlFD) + 1 : + mControlFD + 1; + FD_ZERO(fds); + FD_SET(mControlFD, fds); + if (fd >= 0) { + FD_SET(fd, fds); + } + if (timeout) { + tv.tv_sec = timeout / 1000000; + tv.tv_usec = timeout % 1000000; + tvp = &tv; + } + int res = TEMP_FAILURE_RETRY(select(fd_num, fds, NULL, NULL, tvp)); + if (res < 0) { + ALOGE("%s: select returned %d and failed: %d -> %s", + __FUNCTION__, res, errno, strerror(errno)); + return ERROR; + } else if (res == 0) { + /* Timeout. */ + return TIMEOUT; + } else if (FD_ISSET(mControlFD, fds)) { + /* A control event. Lets read the message. */ + ControlMessage msg; + res = TEMP_FAILURE_RETRY(read(mControlFD, &msg, sizeof(msg))); + if (res != sizeof(msg)) { + ALOGE("%s: Unexpected message size %d, or an error %d -> %s", + __FUNCTION__, res, errno, strerror(errno)); + return ERROR; + } + /* THREAD_STOP is the only message expected here. */ + if (msg == THREAD_STOP) { + ALOGV("%s: THREAD_STOP message is received", __FUNCTION__); + return EXIT_THREAD; + } else { + ALOGE("Unknown worker thread message %d", msg); + return ERROR; + } + } else { + /* Must be an FD. */ + ALOGW_IF(fd < 0 || !FD_ISSET(fd, fds), "%s: Undefined 'select' result", + __FUNCTION__); + return READY; + } +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.h new file mode 100644 index 0000000..fff11fa --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraDevice.h @@ -0,0 +1,546 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_DEVICE_H +#define HW_EMULATOR_CAMERA_EMULATED_CAMERA_DEVICE_H + +/* + * Contains declaration of an abstract class EmulatedCameraDevice that defines + * functionality expected from an emulated physical camera device: + * - Obtaining and setting camera device parameters + * - Capturing frames + * - Streaming video + * - etc. + */ + +#include +#include +#include +#include "EmulatedCameraCommon.h" +#include "Converters.h" + +namespace android { + +class EmulatedCamera; + +/* Encapsulates an abstract class EmulatedCameraDevice that defines + * functionality expected from an emulated physical camera device: + * - Obtaining and setting camera device parameters + * - Capturing frames + * - Streaming video + * - etc. + */ +class EmulatedCameraDevice { +public: + /* Constructs EmulatedCameraDevice instance. + * Param: + * camera_hal - Emulated camera that implements the camera HAL API, and + * manages (contains) this object. + */ + explicit EmulatedCameraDevice(EmulatedCamera* camera_hal); + + /* Destructs EmulatedCameraDevice instance. */ + virtual ~EmulatedCameraDevice(); + + /*************************************************************************** + * Emulated camera device abstract interface + **************************************************************************/ + +public: + /* Connects to the camera device. + * This method must be called on an initialized instance of this class. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t connectDevice() = 0; + + /* Disconnects from the camera device. + * Return: + * NO_ERROR on success, or an appropriate error status. If this method is + * called for already disconnected, or uninitialized instance of this class, + * a successful status must be returned from this method. If this method is + * called for an instance that is in the "started" state, this method must + * return a failure. + */ + virtual status_t disconnectDevice() = 0; + + /* Starts the camera device. + * This method tells the camera device to start capturing frames of the given + * dimensions for the given pixel format. Note that this method doesn't start + * the delivery of the captured frames to the emulated camera. Call + * startDeliveringFrames method to start delivering frames. This method must + * be called on a connected instance of this class. If it is called on a + * disconnected instance, this method must return a failure. + * Param: + * width, height - Frame dimensions to use when capturing video frames. + * pix_fmt - Pixel format to use when capturing video frames. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t startDevice(int width, int height, uint32_t pix_fmt) = 0; + + /* Stops the camera device. + * This method tells the camera device to stop capturing frames. Note that + * this method doesn't stop delivering frames to the emulated camera. Always + * call stopDeliveringFrames prior to calling this method. + * Return: + * NO_ERROR on success, or an appropriate error status. If this method is + * called for an object that is not capturing frames, or is disconnected, + * or is uninitialized, a successful status must be returned from this + * method. + */ + virtual status_t stopDevice() = 0; + + /*************************************************************************** + * Emulated camera device public API + **************************************************************************/ + +public: + /* Initializes EmulatedCameraDevice instance. + * Derived classes should override this method in order to cache static + * properties of the physical device (list of supported pixel formats, frame + * sizes, etc.) If this method is called on an already initialized instance, + * it must return a successful status. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t Initialize(); + + /* Initializes the white balance modes parameters. + * The parameters are passed by each individual derived camera API to + * represent that different camera manufacturers may have different + * preferences on the white balance parameters. Green channel in the RGB + * color space is fixed to keep the luminance to be reasonably constant. + * + * Param: + * mode the text describing the current white balance mode + * r_scale the scale factor for the R channel in RGB space + * b_scale the scale factor for the B channel in RGB space. + */ + void initializeWhiteBalanceModes(const char* mode, + const float r_scale, + const float b_scale); + + /* Starts delivering frames captured from the camera device. + * This method will start the worker thread that would be pulling frames from + * the camera device, and will deliver the pulled frames back to the emulated + * camera via onNextFrameAvailable callback. This method must be called on a + * connected instance of this class with a started camera device. If it is + * called on a disconnected instance, or camera device has not been started, + * this method must return a failure. + * Param: + * one_burst - Controls how many frames should be delivered. If this + * parameter is 'true', only one captured frame will be delivered to the + * emulated camera. If this parameter is 'false', frames will keep + * coming until stopDeliveringFrames method is called. Typically, this + * parameter is set to 'true' only in order to obtain a single frame + * that will be used as a "picture" in takePicture method of the + * emulated camera. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t startDeliveringFrames(bool one_burst); + + /* Stops delivering frames captured from the camera device. + * This method will stop the worker thread started by startDeliveringFrames. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t stopDeliveringFrames(); + + /* Sets the exposure compensation for the camera device. + */ + void setExposureCompensation(const float ev); + + /* Sets the white balance mode for the device. + */ + void setWhiteBalanceMode(const char* mode); + + /* Gets current framebuffer, converted into preview frame format. + * This method must be called on a connected instance of this class with a + * started camera device. If it is called on a disconnected instance, or + * camera device has not been started, this method must return a failure. + * Note that this method should be called only after at least one frame has + * been captured and delivered. Otherwise it will return garbage in the + * preview frame buffer. Typically, this method shuld be called from + * onNextFrameAvailable callback. + * Param: + * buffer - Buffer, large enough to contain the entire preview frame. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t getCurrentPreviewFrame(void* buffer); + + /* Gets width of the frame obtained from the physical device. + * Return: + * Width of the frame obtained from the physical device. Note that value + * returned from this method is valid only in case if camera device has been + * started. + */ + inline int getFrameWidth() const + { + ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__); + return mFrameWidth; + } + + /* Gets height of the frame obtained from the physical device. + * Return: + * Height of the frame obtained from the physical device. Note that value + * returned from this method is valid only in case if camera device has been + * started. + */ + inline int getFrameHeight() const + { + ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__); + return mFrameHeight; + } + + /* Gets byte size of the current frame buffer. + * Return: + * Byte size of the frame buffer. Note that value returned from this method + * is valid only in case if camera device has been started. + */ + inline size_t getFrameBufferSize() const + { + ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__); + return mFrameBufferSize; + } + + /* Gets number of pixels in the current frame buffer. + * Return: + * Number of pixels in the frame buffer. Note that value returned from this + * method is valid only in case if camera device has been started. + */ + inline int getPixelNum() const + { + ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__); + return mTotalPixels; + } + + /* Gets pixel format of the frame that camera device streams to this class. + * Throughout camera framework, there are three different forms of pixel + * format representation: + * - Original format, as reported by the actual camera device. Values for + * this format are declared in bionic/libc/kernel/common/linux/videodev2.h + * - String representation as defined in CameraParameters::PIXEL_FORMAT_XXX + * strings in frameworks/base/include/camera/CameraParameters.h + * - HAL_PIXEL_FORMAT_XXX format, as defined in system/core/include/system/graphics.h + * Since emulated camera device gets its data from the actual device, it gets + * pixel format in the original form. And that's the pixel format + * representation that will be returned from this method. HAL components will + * need to translate value returned from this method to the appropriate form. + * This method must be called only on started instance of this class, since + * it's applicable only when camera device is ready to stream frames. + * Param: + * pix_fmt - Upon success contains the original pixel format. + * Return: + * Current framebuffer's pixel format. Note that value returned from this + * method is valid only in case if camera device has been started. + */ + inline uint32_t getOriginalPixelFormat() const + { + ALOGE_IF(!isStarted(), "%s: Device is not started", __FUNCTION__); + return mPixelFormat; + } + + /* + * State checkers. + */ + + inline bool isInitialized() const { + /* Instance is initialized when the worker thread has been successfuly + * created (but not necessarily started). */ + return mWorkerThread.get() != NULL && mState != ECDS_CONSTRUCTED; + } + inline bool isConnected() const { + /* Instance is connected when its status is either"connected", or + * "started". */ + return mState == ECDS_CONNECTED || mState == ECDS_STARTED; + } + inline bool isStarted() const { + return mState == ECDS_STARTED; + } + + /**************************************************************************** + * Emulated camera device private API + ***************************************************************************/ +protected: + /* Performs common validation and calculation of startDevice parameters. + * Param: + * width, height, pix_fmt - Parameters passed to the startDevice method. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t commonStartDevice(int width, int height, uint32_t pix_fmt); + + /* Performs common cleanup on stopDevice. + * This method will undo what commonStartDevice had done. + */ + virtual void commonStopDevice(); + + /** Computes a luminance value after taking the exposure compensation. + * value into account. + * + * Param: + * inputY - The input luminance value. + * Return: + * The luminance value after adjusting the exposure compensation. + */ + inline uint8_t changeExposure(const uint8_t& inputY) const { + return static_cast(clamp(static_cast(inputY) * + mExposureCompensation)); + } + + /** Computes the pixel value in YUV space after adjusting to the current + * white balance mode. + */ + void changeWhiteBalance(uint8_t& y, uint8_t& u, uint8_t& v) const; + + /**************************************************************************** + * Worker thread management. + * Typicaly when emulated camera device starts capturing frames from the + * actual device, it does that in a worker thread created in StartCapturing, + * and terminated in StopCapturing. Since this is such a typical scenario, + * it makes sence to encapsulate worker thread management in the base class + * for all emulated camera devices. + ***************************************************************************/ + +protected: + /* Starts the worker thread. + * Typically, worker thread is started from startDeliveringFrames method of + * this class. + * Param: + * one_burst - Controls how many times thread loop should run. If this + * parameter is 'true', thread routine will run only once If this + * parameter is 'false', thread routine will run until stopWorkerThread + * method is called. See startDeliveringFrames for more info. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t startWorkerThread(bool one_burst); + + /* Stops the worker thread. + * Note that this method will always wait for the worker thread to terminate. + * Typically, worker thread is started from stopDeliveringFrames method of + * this class. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t stopWorkerThread(); + + /* Implementation of the worker thread routine. + * In the default implementation of the worker thread routine we simply + * return 'false' forcing the thread loop to exit, and the thread to + * terminate. Derived class should override that method to provide there the + * actual frame delivery. + * Return: + * true To continue thread loop (this method will be called again), or false + * to exit the thread loop and to terminate the thread. + */ + virtual bool inWorkerThread(); + + /* Encapsulates a worker thread used by the emulated camera device. + */ + friend class WorkerThread; + class WorkerThread : public Thread { + + /**************************************************************************** + * Public API + ***************************************************************************/ + + public: + inline explicit WorkerThread(EmulatedCameraDevice* camera_dev) + : Thread(true), // Callbacks may involve Java calls. + mCameraDevice(camera_dev), + mThreadControl(-1), + mControlFD(-1) + { + } + + inline ~WorkerThread() + { + ALOGW_IF(mThreadControl >= 0 || mControlFD >= 0, + "%s: Control FDs are opened in the destructor", + __FUNCTION__); + if (mThreadControl >= 0) { + close(mThreadControl); + } + if (mControlFD >= 0) { + close(mControlFD); + } + } + + /* Starts the thread + * Param: + * one_burst - Controls how many times thread loop should run. If + * this parameter is 'true', thread routine will run only once + * If this parameter is 'false', thread routine will run until + * stopThread method is called. See startWorkerThread for more + * info. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + inline status_t startThread(bool one_burst) + { + mOneBurst = one_burst; + return run("Camera_startThread", ANDROID_PRIORITY_URGENT_DISPLAY, 0); + } + + /* Overriden base class method. + * It is overriden in order to provide one-time initialization just + * prior to starting the thread routine. + */ + status_t readyToRun(); + + /* Stops the thread. */ + status_t stopThread(); + + /* Values returned from the Select method of this class. */ + enum SelectRes { + /* A timeout has occurred. */ + TIMEOUT, + /* Data are available for read on the provided FD. */ + READY, + /* Thread exit request has been received. */ + EXIT_THREAD, + /* An error has occurred. */ + ERROR + }; + + /* Select on an FD event, keeping in mind thread exit message. + * Param: + * fd - File descriptor on which to wait for an event. This + * parameter may be negative. If it is negative this method will + * only wait on a control message to the thread. + * timeout - Timeout in microseconds. 0 indicates no timeout (wait + * forever). + * Return: + * See SelectRes enum comments. + */ + SelectRes Select(int fd, int timeout); + + /**************************************************************************** + * Private API + ***************************************************************************/ + + private: + /* Implements abstract method of the base Thread class. */ + bool threadLoop() + { + /* Simply dispatch the call to the containing camera device. */ + if (mCameraDevice->inWorkerThread()) { + /* Respect "one burst" parameter (see startThread). */ + return !mOneBurst; + } else { + return false; + } + } + + /* Containing camera device object. */ + EmulatedCameraDevice* mCameraDevice; + + /* FD that is used to send control messages into the thread. */ + int mThreadControl; + + /* FD that thread uses to receive control messages. */ + int mControlFD; + + /* Controls number of times the thread loop runs. + * See startThread for more information. */ + bool mOneBurst; + + /* Enumerates control messages that can be sent into the thread. */ + enum ControlMessage { + /* Stop the thread. */ + THREAD_STOP + }; + + Condition mSetup; + }; + + /* Worker thread accessor. */ + inline WorkerThread* getWorkerThread() const + { + return mWorkerThread.get(); + } + + /**************************************************************************** + * Data members + ***************************************************************************/ + +protected: + /* Locks this instance for parameters, state, etc. change. */ + Mutex mObjectLock; + + /* Worker thread that is used in frame capturing. */ + sp mWorkerThread; + + /* Timestamp of the current frame. */ + nsecs_t mCurFrameTimestamp; + + /* Emulated camera object containing this instance. */ + EmulatedCamera* mCameraHAL; + + /* Framebuffer containing the current frame. */ + uint8_t* mCurrentFrame; + + /* + * Framebuffer properties. + */ + + /* Byte size of the framebuffer. */ + size_t mFrameBufferSize; + + /* Original pixel format (one of the V4L2_PIX_FMT_XXX values, as defined in + * bionic/libc/kernel/common/linux/videodev2.h */ + uint32_t mPixelFormat; + + /* Frame width */ + int mFrameWidth; + + /* Frame height */ + int mFrameHeight; + + /* Total number of pixels */ + int mTotalPixels; + + /* Exposure compensation value */ + float mExposureCompensation; + + float* mWhiteBalanceScale; + + DefaultKeyedVector mSupportedWhiteBalanceScale; + + /* Defines possible states of the emulated camera device object. + */ + enum EmulatedCameraDeviceState { + /* Object has been constructed. */ + ECDS_CONSTRUCTED, + /* Object has been initialized. */ + ECDS_INITIALIZED, + /* Object has been connected to the physical device. */ + ECDS_CONNECTED, + /* Camera device has been started. */ + ECDS_STARTED, + }; + + /* Object state. */ + EmulatedCameraDeviceState mState; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_CAMERA_DEVICE_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.cpp new file mode 100644 index 0000000..137d8ab --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.cpp @@ -0,0 +1,542 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedCameraFactory that manages cameras + * available for emulation. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_Factory" +#include +#include +#include "EmulatedQemuCamera.h" +#include "EmulatedFakeCamera.h" +#include "EmulatedFakeCamera2.h" +#include "EmulatedFakeCamera3.h" +#include "EmulatedCameraHotplugThread.h" +#include "EmulatedCameraFactory.h" + +extern camera_module_t HAL_MODULE_INFO_SYM; + +/* A global instance of EmulatedCameraFactory is statically instantiated and + * initialized when camera emulation HAL is loaded. + */ +android::EmulatedCameraFactory gEmulatedCameraFactory; + +namespace android { + +EmulatedCameraFactory::EmulatedCameraFactory() + : mQemuClient(), + mEmulatedCameras(NULL), + mEmulatedCameraNum(0), + mFakeCameraNum(0), + mConstructedOK(false), + mCallbacks(NULL) +{ + status_t res; + /* Connect to the factory service in the emulator, and create Qemu cameras. */ + if (mQemuClient.connectClient(NULL) == NO_ERROR) { + /* Connection has succeeded. Create emulated cameras for each camera + * device, reported by the service. */ + createQemuCameras(); + } + + if (isBackFakeCameraEmulationOn()) { + /* Camera ID. */ + const int camera_id = mEmulatedCameraNum; + /* Use fake camera to emulate back-facing camera. */ + mEmulatedCameraNum++; + + /* Make sure that array is allocated (in case there were no 'qemu' + * cameras created. Note that we preallocate the array so it may contain + * two fake cameras: one facing back, and another facing front. */ + if (mEmulatedCameras == NULL) { + mEmulatedCameras = new EmulatedBaseCamera*[mEmulatedCameraNum + 1]; + if (mEmulatedCameras == NULL) { + ALOGE("%s: Unable to allocate emulated camera array for %d entries", + __FUNCTION__, mEmulatedCameraNum); + return; + } + memset(mEmulatedCameras, 0, + (mEmulatedCameraNum + 1) * sizeof(EmulatedBaseCamera*)); + } + + /* Create, and initialize the fake camera */ + switch (getBackCameraHalVersion()) { + case 1: + mEmulatedCameras[camera_id] = + new EmulatedFakeCamera(camera_id, true, + &HAL_MODULE_INFO_SYM.common); + break; + case 2: + mEmulatedCameras[camera_id] = + new EmulatedFakeCamera2(camera_id, true, + &HAL_MODULE_INFO_SYM.common); + break; + case 3: + mEmulatedCameras[camera_id] = + new EmulatedFakeCamera3(camera_id, true, + &HAL_MODULE_INFO_SYM.common); + break; + default: + ALOGE("%s: Unknown back camera hal version requested: %d", __FUNCTION__, + getBackCameraHalVersion()); + } + if (mEmulatedCameras[camera_id] != NULL) { + ALOGV("%s: Back camera device version is %d", __FUNCTION__, + getBackCameraHalVersion()); + res = mEmulatedCameras[camera_id]->Initialize(); + if (res != NO_ERROR) { + ALOGE("%s: Unable to intialize back camera %d: %s (%d)", + __FUNCTION__, camera_id, strerror(-res), res); + delete mEmulatedCameras[camera_id]; + mEmulatedCameraNum--; + } + } else { + mEmulatedCameraNum--; + ALOGE("%s: Unable to instantiate fake camera class", __FUNCTION__); + } + } + + if (isFrontFakeCameraEmulationOn()) { + /* Camera ID. */ + const int camera_id = mEmulatedCameraNum; + /* Use fake camera to emulate front-facing camera. */ + mEmulatedCameraNum++; + + /* Make sure that array is allocated (in case there were no 'qemu' + * cameras created. */ + if (mEmulatedCameras == NULL) { + mEmulatedCameras = new EmulatedBaseCamera*[mEmulatedCameraNum]; + if (mEmulatedCameras == NULL) { + ALOGE("%s: Unable to allocate emulated camera array for %d entries", + __FUNCTION__, mEmulatedCameraNum); + return; + } + memset(mEmulatedCameras, 0, + mEmulatedCameraNum * sizeof(EmulatedBaseCamera*)); + } + + /* Create, and initialize the fake camera */ + switch (getFrontCameraHalVersion()) { + case 1: + mEmulatedCameras[camera_id] = + new EmulatedFakeCamera(camera_id, false, + &HAL_MODULE_INFO_SYM.common); + break; + case 2: + mEmulatedCameras[camera_id] = + new EmulatedFakeCamera2(camera_id, false, + &HAL_MODULE_INFO_SYM.common); + break; + case 3: + mEmulatedCameras[camera_id] = + new EmulatedFakeCamera3(camera_id, false, + &HAL_MODULE_INFO_SYM.common); + break; + default: + ALOGE("%s: Unknown front camera hal version requested: %d", + __FUNCTION__, + getFrontCameraHalVersion()); + } + if (mEmulatedCameras[camera_id] != NULL) { + ALOGV("%s: Front camera device version is %d", __FUNCTION__, + getFrontCameraHalVersion()); + res = mEmulatedCameras[camera_id]->Initialize(); + if (res != NO_ERROR) { + ALOGE("%s: Unable to intialize front camera %d: %s (%d)", + __FUNCTION__, camera_id, strerror(-res), res); + delete mEmulatedCameras[camera_id]; + mEmulatedCameraNum--; + } + } else { + mEmulatedCameraNum--; + ALOGE("%s: Unable to instantiate fake camera class", __FUNCTION__); + } + } + + ALOGV("%d cameras are being emulated. %d of them are fake cameras.", + mEmulatedCameraNum, mFakeCameraNum); + + /* Create hotplug thread */ + { + Vector cameraIdVector; + for (int i = 0; i < mEmulatedCameraNum; ++i) { + cameraIdVector.push_back(i); + } + mHotplugThread = new EmulatedCameraHotplugThread(&cameraIdVector[0], + mEmulatedCameraNum); + mHotplugThread->run("EmulatedCameraHotplugThread"); + } + + mConstructedOK = true; +} + +EmulatedCameraFactory::~EmulatedCameraFactory() +{ + if (mEmulatedCameras != NULL) { + for (int n = 0; n < mEmulatedCameraNum; n++) { + if (mEmulatedCameras[n] != NULL) { + delete mEmulatedCameras[n]; + } + } + delete[] mEmulatedCameras; + } + + if (mHotplugThread != NULL) { + mHotplugThread->requestExit(); + mHotplugThread->join(); + } +} + +/**************************************************************************** + * Camera HAL API handlers. + * + * Each handler simply verifies existence of an appropriate EmulatedBaseCamera + * instance, and dispatches the call to that instance. + * + ***************************************************************************/ + +int EmulatedCameraFactory::cameraDeviceOpen(int camera_id, hw_device_t** device) +{ + ALOGV("%s: id = %d", __FUNCTION__, camera_id); + + *device = NULL; + + if (!isConstructedOK()) { + ALOGE("%s: EmulatedCameraFactory has failed to initialize", __FUNCTION__); + return -EINVAL; + } + + if (camera_id < 0 || camera_id >= getEmulatedCameraNum()) { + ALOGE("%s: Camera id %d is out of bounds (%d)", + __FUNCTION__, camera_id, getEmulatedCameraNum()); + return -ENODEV; + } + + return mEmulatedCameras[camera_id]->connectCamera(device); +} + +int EmulatedCameraFactory::getCameraInfo(int camera_id, struct camera_info* info) +{ + ALOGV("%s: id = %d", __FUNCTION__, camera_id); + + if (!isConstructedOK()) { + ALOGE("%s: EmulatedCameraFactory has failed to initialize", __FUNCTION__); + return -EINVAL; + } + + if (camera_id < 0 || camera_id >= getEmulatedCameraNum()) { + ALOGE("%s: Camera id %d is out of bounds (%d)", + __FUNCTION__, camera_id, getEmulatedCameraNum()); + return -ENODEV; + } + + return mEmulatedCameras[camera_id]->getCameraInfo(info); +} + +int EmulatedCameraFactory::setCallbacks( + const camera_module_callbacks_t *callbacks) +{ + ALOGV("%s: callbacks = %p", __FUNCTION__, callbacks); + + mCallbacks = callbacks; + + return OK; +} + +void EmulatedCameraFactory::getVendorTagOps(vendor_tag_ops_t* ops) { + ALOGV("%s: ops = %p", __FUNCTION__, ops); + + // No vendor tags defined for emulator yet, so not touching ops +} + +/**************************************************************************** + * Camera HAL API callbacks. + ***************************************************************************/ + +int EmulatedCameraFactory::device_open(const hw_module_t* module, + const char* name, + hw_device_t** device) +{ + /* + * Simply verify the parameters, and dispatch the call inside the + * EmulatedCameraFactory instance. + */ + + if (module != &HAL_MODULE_INFO_SYM.common) { + ALOGE("%s: Invalid module %p expected %p", + __FUNCTION__, module, &HAL_MODULE_INFO_SYM.common); + return -EINVAL; + } + if (name == NULL) { + ALOGE("%s: NULL name is not expected here", __FUNCTION__); + return -EINVAL; + } + + return gEmulatedCameraFactory.cameraDeviceOpen(atoi(name), device); +} + +int EmulatedCameraFactory::get_number_of_cameras(void) +{ + return gEmulatedCameraFactory.getEmulatedCameraNum(); +} + +int EmulatedCameraFactory::get_camera_info(int camera_id, + struct camera_info* info) +{ + return gEmulatedCameraFactory.getCameraInfo(camera_id, info); +} + +int EmulatedCameraFactory::set_callbacks( + const camera_module_callbacks_t *callbacks) +{ + return gEmulatedCameraFactory.setCallbacks(callbacks); +} + +void EmulatedCameraFactory::get_vendor_tag_ops(vendor_tag_ops_t* ops) +{ + gEmulatedCameraFactory.getVendorTagOps(ops); +} + +int EmulatedCameraFactory::open_legacy(const struct hw_module_t* module, + const char* id, uint32_t halVersion, struct hw_device_t** device) { + // Not supporting legacy open + return -ENOSYS; +} + +/******************************************************************************** + * Internal API + *******************************************************************************/ + +/* + * Camera information tokens passed in response to the "list" factory query. + */ + +/* Device name token. */ +static const char lListNameToken[] = "name="; +/* Frame dimensions token. */ +static const char lListDimsToken[] = "framedims="; +/* Facing direction token. */ +static const char lListDirToken[] = "dir="; + +void EmulatedCameraFactory::createQemuCameras() +{ + /* Obtain camera list. */ + char* camera_list = NULL; + status_t res = mQemuClient.listCameras(&camera_list); + /* Empty list, or list containing just an EOL means that there were no + * connected cameras found. */ + if (res != NO_ERROR || camera_list == NULL || *camera_list == '\0' || + *camera_list == '\n') { + if (camera_list != NULL) { + free(camera_list); + } + return; + } + + /* + * Calculate number of connected cameras. Number of EOLs in the camera list + * is the number of the connected cameras. + */ + + int num = 0; + const char* eol = strchr(camera_list, '\n'); + while (eol != NULL) { + num++; + eol = strchr(eol + 1, '\n'); + } + + /* Allocate the array for emulated camera instances. Note that we allocate + * two more entries for back and front fake camera emulation. */ + mEmulatedCameras = new EmulatedBaseCamera*[num + 2]; + if (mEmulatedCameras == NULL) { + ALOGE("%s: Unable to allocate emulated camera array for %d entries", + __FUNCTION__, num + 1); + free(camera_list); + return; + } + memset(mEmulatedCameras, 0, sizeof(EmulatedBaseCamera*) * (num + 1)); + + /* + * Iterate the list, creating, and initializin emulated qemu cameras for each + * entry (line) in the list. + */ + + int index = 0; + char* cur_entry = camera_list; + while (cur_entry != NULL && *cur_entry != '\0' && index < num) { + /* Find the end of the current camera entry, and terminate it with zero + * for simpler string manipulation. */ + char* next_entry = strchr(cur_entry, '\n'); + if (next_entry != NULL) { + *next_entry = '\0'; + next_entry++; // Start of the next entry. + } + + /* Find 'name', 'framedims', and 'dir' tokens that are required here. */ + char* name_start = strstr(cur_entry, lListNameToken); + char* dim_start = strstr(cur_entry, lListDimsToken); + char* dir_start = strstr(cur_entry, lListDirToken); + if (name_start != NULL && dim_start != NULL && dir_start != NULL) { + /* Advance to the token values. */ + name_start += strlen(lListNameToken); + dim_start += strlen(lListDimsToken); + dir_start += strlen(lListDirToken); + + /* Terminate token values with zero. */ + char* s = strchr(name_start, ' '); + if (s != NULL) { + *s = '\0'; + } + s = strchr(dim_start, ' '); + if (s != NULL) { + *s = '\0'; + } + s = strchr(dir_start, ' '); + if (s != NULL) { + *s = '\0'; + } + + /* Create and initialize qemu camera. */ + EmulatedQemuCamera* qemu_cam = + new EmulatedQemuCamera(index, &HAL_MODULE_INFO_SYM.common); + if (NULL != qemu_cam) { + res = qemu_cam->Initialize(name_start, dim_start, dir_start); + if (res == NO_ERROR) { + mEmulatedCameras[index] = qemu_cam; + index++; + } else { + delete qemu_cam; + } + } else { + ALOGE("%s: Unable to instantiate EmulatedQemuCamera", + __FUNCTION__); + } + } else { + ALOGW("%s: Bad camera information: %s", __FUNCTION__, cur_entry); + } + + cur_entry = next_entry; + } + + mEmulatedCameraNum = index; +} + +bool EmulatedCameraFactory::isBackFakeCameraEmulationOn() +{ + /* Defined by 'qemu.sf.fake_camera' boot property: if property exist, and + * is set to 'both', or 'back', then fake camera is used to emulate back + * camera. */ + char prop[PROPERTY_VALUE_MAX]; + if ((property_get("qemu.sf.fake_camera", prop, NULL) > 0) && + (!strcmp(prop, "both") || !strcmp(prop, "back"))) { + return true; + } else { + return false; + } +} + +int EmulatedCameraFactory::getBackCameraHalVersion() +{ + /* Defined by 'qemu.sf.back_camera_hal_version' boot property: if the + * property doesn't exist, it is assumed to be 1. */ + char prop[PROPERTY_VALUE_MAX]; + if (property_get("qemu.sf.back_camera_hal", prop, NULL) > 0) { + char *prop_end = prop; + int val = strtol(prop, &prop_end, 10); + if (*prop_end == '\0') { + return val; + } + // Badly formatted property, should just be a number + ALOGE("qemu.sf.back_camera_hal is not a number: %s", prop); + } + return 1; +} + +bool EmulatedCameraFactory::isFrontFakeCameraEmulationOn() +{ + /* Defined by 'qemu.sf.fake_camera' boot property: if property exist, and + * is set to 'both', or 'front', then fake camera is used to emulate front + * camera. */ + char prop[PROPERTY_VALUE_MAX]; + if ((property_get("qemu.sf.fake_camera", prop, NULL) > 0) && + (!strcmp(prop, "both") || !strcmp(prop, "front"))) { + return true; + } else { + return false; + } +} + +int EmulatedCameraFactory::getFrontCameraHalVersion() +{ + /* Defined by 'qemu.sf.front_camera_hal_version' boot property: if the + * property doesn't exist, it is assumed to be 1. */ + char prop[PROPERTY_VALUE_MAX]; + if (property_get("qemu.sf.front_camera_hal", prop, NULL) > 0) { + char *prop_end = prop; + int val = strtol(prop, &prop_end, 10); + if (*prop_end == '\0') { + return val; + } + // Badly formatted property, should just be a number + ALOGE("qemu.sf.front_camera_hal is not a number: %s", prop); + } + return 1; +} + +void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus) { + + EmulatedBaseCamera *cam = mEmulatedCameras[cameraId]; + if (!cam) { + ALOGE("%s: Invalid camera ID %d", __FUNCTION__, cameraId); + return; + } + + /** + * (Order is important) + * Send the callback first to framework, THEN close the camera. + */ + + if (newStatus == cam->getHotplugStatus()) { + ALOGW("%s: Ignoring transition to the same status", __FUNCTION__); + return; + } + + const camera_module_callbacks_t* cb = mCallbacks; + if (cb != NULL && cb->camera_device_status_change != NULL) { + cb->camera_device_status_change(cb, cameraId, newStatus); + } + + if (newStatus == CAMERA_DEVICE_STATUS_NOT_PRESENT) { + cam->unplugCamera(); + } else if (newStatus == CAMERA_DEVICE_STATUS_PRESENT) { + cam->plugCamera(); + } + +} + +/******************************************************************************** + * Initializer for the static member structure. + *******************************************************************************/ + +/* Entry point for camera HAL API. */ +struct hw_module_methods_t EmulatedCameraFactory::mCameraModuleMethods = { + open: EmulatedCameraFactory::device_open +}; + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.h new file mode 100644 index 0000000..3f19be1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraFactory.h @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_FACTORY_H +#define HW_EMULATOR_CAMERA_EMULATED_CAMERA_FACTORY_H + +#include +#include "EmulatedBaseCamera.h" +#include "QemuClient.h" + +namespace android { + +struct EmulatedCameraHotplugThread; + +/* + * Contains declaration of a class EmulatedCameraFactory that manages cameras + * available for the emulation. A global instance of this class is statically + * instantiated and initialized when camera emulation HAL is loaded. + */ + +/* Class EmulatedCameraFactoryManages cameras available for the emulation. + * + * When the global static instance of this class is created on the module load, + * it enumerates cameras available for the emulation by connecting to the + * emulator's 'camera' service. For every camera found out there it creates an + * instance of an appropriate class, and stores it an in array of emulated + * cameras. In addition to the cameras reported by the emulator, a fake camera + * emulator is always created, so there is always at least one camera that is + * available. + * + * Instance of this class is also used as the entry point for the camera HAL API, + * including: + * - hw_module_methods_t::open entry point + * - camera_module_t::get_number_of_cameras entry point + * - camera_module_t::get_camera_info entry point + * + */ +class EmulatedCameraFactory { +public: + /* Constructs EmulatedCameraFactory instance. + * In this constructor the factory will create and initialize a list of + * emulated cameras. All errors that occur on this constructor are reported + * via mConstructedOK data member of this class. + */ + EmulatedCameraFactory(); + + /* Destructs EmulatedCameraFactory instance. */ + ~EmulatedCameraFactory(); + + /**************************************************************************** + * Camera HAL API handlers. + ***************************************************************************/ + +public: + /* Opens (connects to) a camera device. + * This method is called in response to hw_module_methods_t::open callback. + */ + int cameraDeviceOpen(int camera_id, hw_device_t** device); + + /* Gets emulated camera information. + * This method is called in response to camera_module_t::get_camera_info callback. + */ + int getCameraInfo(int camera_id, struct camera_info *info); + + /* Sets emulated camera callbacks. + * This method is called in response to camera_module_t::set_callbacks callback. + */ + int setCallbacks(const camera_module_callbacks_t *callbacks); + + /* Fill in vendor tags for the module + * This method is called in response to camera_module_t::get_vendor_tag_ops callback. + */ + void getVendorTagOps(vendor_tag_ops_t* ops); + + /**************************************************************************** + * Camera HAL API callbacks. + ***************************************************************************/ + +public: + /* camera_module_t::get_number_of_cameras callback entry point. */ + static int get_number_of_cameras(void); + + /* camera_module_t::get_camera_info callback entry point. */ + static int get_camera_info(int camera_id, struct camera_info *info); + + /* camera_module_t::set_callbacks callback entry point. */ + static int set_callbacks(const camera_module_callbacks_t *callbacks); + + /* camera_module_t::get_vendor_tag_ops callback entry point */ + static void get_vendor_tag_ops(vendor_tag_ops_t* ops); + + /* camera_module_t::open_legacy callback entry point */ + static int open_legacy(const struct hw_module_t* module, const char* id, + uint32_t halVersion, struct hw_device_t** device); + +private: + /* hw_module_methods_t::open callback entry point. */ + static int device_open(const hw_module_t* module, + const char* name, + hw_device_t** device); + + /**************************************************************************** + * Public API. + ***************************************************************************/ + +public: + + /* Gets fake camera orientation. */ + int getFakeCameraOrientation() { + /* TODO: Have a boot property that controls that. */ + return 90; + } + + /* Gets qemu camera orientation. */ + int getQemuCameraOrientation() { + /* TODO: Have a boot property that controls that. */ + return 270; + } + + /* Gets number of emulated cameras. + */ + int getEmulatedCameraNum() const { + return mEmulatedCameraNum; + } + + /* Checks whether or not the constructor has succeeded. + */ + bool isConstructedOK() const { + return mConstructedOK; + } + + void onStatusChanged(int cameraId, int newStatus); + + /**************************************************************************** + * Private API + ***************************************************************************/ + +private: + /* Populates emulated cameras array with cameras that are available via + * 'camera' service in the emulator. For each such camera and instance of + * the EmulatedCameraQemud will be created and added to the mEmulatedCameras + * array. + */ + void createQemuCameras(); + + /* Checks if fake camera emulation is on for the camera facing back. */ + bool isBackFakeCameraEmulationOn(); + + /* Gets camera device version number to use for back camera emulation */ + int getBackCameraHalVersion(); + + /* Checks if fake camera emulation is on for the camera facing front. */ + bool isFrontFakeCameraEmulationOn(); + + /* Gets camera device version number to use for front camera emulation */ + int getFrontCameraHalVersion(); + + /**************************************************************************** + * Data members. + ***************************************************************************/ + +private: + /* Connection to the camera service in the emulator. */ + FactoryQemuClient mQemuClient; + + /* Array of cameras available for the emulation. */ + EmulatedBaseCamera** mEmulatedCameras; + + /* Number of emulated cameras (including the fake ones). */ + int mEmulatedCameraNum; + + /* Number of emulated fake cameras. */ + int mFakeCameraNum; + + /* Flags whether or not constructor has succeeded. */ + bool mConstructedOK; + + /* Camera callbacks (for status changing) */ + const camera_module_callbacks_t* mCallbacks; + + /* Hotplug thread (to call onStatusChanged) */ + sp mHotplugThread; + +public: + /* Contains device open entry point, as required by HAL API. */ + static struct hw_module_methods_t mCameraModuleMethods; +}; + +}; /* namespace android */ + +/* References the global EmulatedCameraFactory instance. */ +extern android::EmulatedCameraFactory gEmulatedCameraFactory; + +#endif /* HW_EMULATOR_CAMERA_EMULATED_CAMERA_FACTORY_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHal.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHal.cpp new file mode 100644 index 0000000..b1f8b3a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHal.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of the camera HAL layer in the system running + * under the emulator. + * + * This file contains only required HAL header, which directs all the API calls + * to the EmulatedCameraFactory class implementation, wich is responsible for + * managing emulated cameras. + */ + +#include "EmulatedCameraFactory.h" + +/* + * Required HAL header. + */ +camera_module_t HAL_MODULE_INFO_SYM = { + common: { + tag: HARDWARE_MODULE_TAG, + module_api_version: CAMERA_MODULE_API_VERSION_2_3, + hal_api_version: HARDWARE_HAL_API_VERSION, + id: CAMERA_HARDWARE_MODULE_ID, + name: "Emulated Camera Module", + author: "The Android Open Source Project", + methods: &android::EmulatedCameraFactory::mCameraModuleMethods, + dso: NULL, + reserved: {0}, + }, + get_number_of_cameras: android::EmulatedCameraFactory::get_number_of_cameras, + get_camera_info: android::EmulatedCameraFactory::get_camera_info, + set_callbacks: android::EmulatedCameraFactory::set_callbacks, + get_vendor_tag_ops: android::EmulatedCameraFactory::get_vendor_tag_ops, + open_legacy: android::EmulatedCameraFactory::open_legacy +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.cpp new file mode 100644 index 0000000..bc629c1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.cpp @@ -0,0 +1,372 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_HotplugThread" +#include + +#include +#include +#include +#include + +#include "EmulatedCameraHotplugThread.h" +#include "EmulatedCameraFactory.h" + +#define FAKE_HOTPLUG_FILE "/data/misc/media/emulator.camera.hotplug" + +#define EVENT_SIZE (sizeof(struct inotify_event)) +#define EVENT_BUF_LEN (1024*(EVENT_SIZE+16)) + +#define SubscriberInfo EmulatedCameraHotplugThread::SubscriberInfo + +namespace android { + +EmulatedCameraHotplugThread::EmulatedCameraHotplugThread( + const int* cameraIdArray, + size_t size) : + Thread(/*canCallJava*/false) { + + mRunning = true; + mInotifyFd = 0; + + for (size_t i = 0; i < size; ++i) { + int id = cameraIdArray[i]; + + if (createFileIfNotExists(id)) { + mSubscribedCameraIds.push_back(id); + } + } +} + +EmulatedCameraHotplugThread::~EmulatedCameraHotplugThread() { +} + +status_t EmulatedCameraHotplugThread::requestExitAndWait() { + ALOGE("%s: Not implemented. Use requestExit + join instead", + __FUNCTION__); + return INVALID_OPERATION; +} + +void EmulatedCameraHotplugThread::requestExit() { + Mutex::Autolock al(mMutex); + + ALOGV("%s: Requesting thread exit", __FUNCTION__); + mRunning = false; + + bool rmWatchFailed = false; + Vector::iterator it; + for (it = mSubscribers.begin(); it != mSubscribers.end(); ++it) { + + if (inotify_rm_watch(mInotifyFd, it->WatchID) == -1) { + + ALOGE("%s: Could not remove watch for camID '%d'," + " error: '%s' (%d)", + __FUNCTION__, it->CameraID, strerror(errno), + errno); + + rmWatchFailed = true ; + } else { + ALOGV("%s: Removed watch for camID '%d'", + __FUNCTION__, it->CameraID); + } + } + + if (rmWatchFailed) { // unlikely + // Give the thread a fighting chance to error out on the next + // read + if (close(mInotifyFd) == -1) { + ALOGE("%s: close failure error: '%s' (%d)", + __FUNCTION__, strerror(errno), errno); + } + } + + ALOGV("%s: Request exit complete.", __FUNCTION__); +} + +status_t EmulatedCameraHotplugThread::readyToRun() { + Mutex::Autolock al(mMutex); + + mInotifyFd = -1; + + do { + ALOGV("%s: Initializing inotify", __FUNCTION__); + + mInotifyFd = inotify_init(); + if (mInotifyFd == -1) { + ALOGE("%s: inotify_init failure error: '%s' (%d)", + __FUNCTION__, strerror(errno), errno); + mRunning = false; + break; + } + + /** + * For each fake camera file, add a watch for when + * the file is closed (if it was written to) + */ + Vector::const_iterator it, end; + it = mSubscribedCameraIds.begin(); + end = mSubscribedCameraIds.end(); + for (; it != end; ++it) { + int cameraId = *it; + if (!addWatch(cameraId)) { + mRunning = false; + break; + } + } + } while(false); + + if (!mRunning) { + status_t err = -errno; + + if (mInotifyFd != -1) { + close(mInotifyFd); + } + + return err; + } + + return OK; +} + +bool EmulatedCameraHotplugThread::threadLoop() { + + // If requestExit was already called, mRunning will be false + while (mRunning) { + char buffer[EVENT_BUF_LEN]; + int length = TEMP_FAILURE_RETRY( + read(mInotifyFd, buffer, EVENT_BUF_LEN)); + + if (length < 0) { + ALOGE("%s: Error reading from inotify FD, error: '%s' (%d)", + __FUNCTION__, strerror(errno), + errno); + mRunning = false; + break; + } + + ALOGV("%s: Read %d bytes from inotify FD", __FUNCTION__, length); + + int i = 0; + while (i < length) { + inotify_event* event = (inotify_event*) &buffer[i]; + + if (event->mask & IN_IGNORED) { + Mutex::Autolock al(mMutex); + if (!mRunning) { + ALOGV("%s: Shutting down thread", __FUNCTION__); + break; + } else { + ALOGE("%s: File was deleted, aborting", + __FUNCTION__); + mRunning = false; + break; + } + } else if (event->mask & IN_CLOSE_WRITE) { + int cameraId = getCameraId(event->wd); + + if (cameraId < 0) { + ALOGE("%s: Got bad camera ID from WD '%d", + __FUNCTION__, event->wd); + } else { + // Check the file for the new hotplug event + String8 filePath = getFilePath(cameraId); + /** + * NOTE: we carefully avoid getting an inotify + * for the same exact file because it's opened for + * read-only, but our inotify is for write-only + */ + int newStatus = readFile(filePath); + + if (newStatus < 0) { + mRunning = false; + break; + } + + int halStatus = newStatus ? + CAMERA_DEVICE_STATUS_PRESENT : + CAMERA_DEVICE_STATUS_NOT_PRESENT; + gEmulatedCameraFactory.onStatusChanged(cameraId, + halStatus); + } + + } else { + ALOGW("%s: Unknown mask 0x%x", + __FUNCTION__, event->mask); + } + + i += EVENT_SIZE + event->len; + } + } + + if (!mRunning) { + close(mInotifyFd); + return false; + } + + return true; +} + +String8 EmulatedCameraHotplugThread::getFilePath(int cameraId) const { + return String8::format(FAKE_HOTPLUG_FILE ".%d", cameraId); +} + +bool EmulatedCameraHotplugThread::createFileIfNotExists(int cameraId) const +{ + String8 filePath = getFilePath(cameraId); + // make sure this file exists and we have access to it + int fd = TEMP_FAILURE_RETRY( + open(filePath.string(), O_WRONLY | O_CREAT | O_TRUNC, + /* mode = ug+rwx */ S_IRWXU | S_IRWXG )); + if (fd == -1) { + ALOGE("%s: Could not create file '%s', error: '%s' (%d)", + __FUNCTION__, filePath.string(), strerror(errno), errno); + return false; + } + + // File has '1' by default since we are plugged in by default + if (TEMP_FAILURE_RETRY(write(fd, "1\n", /*count*/2)) == -1) { + ALOGE("%s: Could not write '1' to file '%s', error: '%s' (%d)", + __FUNCTION__, filePath.string(), strerror(errno), errno); + return false; + } + + close(fd); + return true; +} + +int EmulatedCameraHotplugThread::getCameraId(String8 filePath) const { + Vector::const_iterator it, end; + it = mSubscribedCameraIds.begin(); + end = mSubscribedCameraIds.end(); + for (; it != end; ++it) { + String8 camPath = getFilePath(*it); + + if (camPath == filePath) { + return *it; + } + } + + return NAME_NOT_FOUND; +} + +int EmulatedCameraHotplugThread::getCameraId(int wd) const { + for (size_t i = 0; i < mSubscribers.size(); ++i) { + if (mSubscribers[i].WatchID == wd) { + return mSubscribers[i].CameraID; + } + } + + return NAME_NOT_FOUND; +} + +SubscriberInfo* EmulatedCameraHotplugThread::getSubscriberInfo(int cameraId) +{ + for (size_t i = 0; i < mSubscribers.size(); ++i) { + if (mSubscribers[i].CameraID == cameraId) { + return (SubscriberInfo*)&mSubscribers[i]; + } + } + + return NULL; +} + +bool EmulatedCameraHotplugThread::addWatch(int cameraId) { + String8 camPath = getFilePath(cameraId); + int wd = inotify_add_watch(mInotifyFd, + camPath.string(), + IN_CLOSE_WRITE); + + if (wd == -1) { + ALOGE("%s: Could not add watch for '%s', error: '%s' (%d)", + __FUNCTION__, camPath.string(), strerror(errno), + errno); + + mRunning = false; + return false; + } + + ALOGV("%s: Watch added for camID='%d', wd='%d'", + __FUNCTION__, cameraId, wd); + + SubscriberInfo si = { cameraId, wd }; + mSubscribers.push_back(si); + + return true; +} + +bool EmulatedCameraHotplugThread::removeWatch(int cameraId) { + SubscriberInfo* si = getSubscriberInfo(cameraId); + + if (!si) return false; + + if (inotify_rm_watch(mInotifyFd, si->WatchID) == -1) { + + ALOGE("%s: Could not remove watch for camID '%d', error: '%s' (%d)", + __FUNCTION__, cameraId, strerror(errno), + errno); + + return false; + } + + Vector::iterator it; + for (it = mSubscribers.begin(); it != mSubscribers.end(); ++it) { + if (it->CameraID == cameraId) { + break; + } + } + + if (it != mSubscribers.end()) { + mSubscribers.erase(it); + } + + return true; +} + +int EmulatedCameraHotplugThread::readFile(String8 filePath) const { + + int fd = TEMP_FAILURE_RETRY( + open(filePath.string(), O_RDONLY, /*mode*/0)); + if (fd == -1) { + ALOGE("%s: Could not open file '%s', error: '%s' (%d)", + __FUNCTION__, filePath.string(), strerror(errno), errno); + return -1; + } + + char buffer[1]; + int length; + + length = TEMP_FAILURE_RETRY( + read(fd, buffer, sizeof(buffer))); + + int retval; + + ALOGV("%s: Read file '%s', length='%d', buffer='%c'", + __FUNCTION__, filePath.string(), length, buffer[0]); + + if (length == 0) { // EOF + retval = 0; // empty file is the same thing as 0 + } else if (buffer[0] == '0') { + retval = 0; + } else { // anything non-empty that's not beginning with '0' + retval = 1; + } + + close(fd); + + return retval; +} + +} //namespace android diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.h new file mode 100644 index 0000000..3e26e71 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedCameraHotplugThread.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_HOTPLUG_H +#define HW_EMULATOR_CAMERA_EMULATED_CAMERA_HOTPLUG_H + +/** + * This class emulates hotplug events by inotifying on a file, specific + * to a camera ID. When the file changes between 1/0 the hotplug + * status goes between PRESENT and NOT_PRESENT. + * + * Refer to FAKE_HOTPLUG_FILE in EmulatedCameraHotplugThread.cpp + */ + +#include "EmulatedCamera2.h" +#include +#include + +namespace android { +class EmulatedCameraHotplugThread : public Thread { + public: + EmulatedCameraHotplugThread(const int* cameraIdArray, size_t size); + ~EmulatedCameraHotplugThread(); + + virtual void requestExit(); + virtual status_t requestExitAndWait(); + + private: + + + virtual status_t readyToRun(); + virtual bool threadLoop(); + + struct SubscriberInfo { + int CameraID; + int WatchID; + }; + + bool addWatch(int cameraId); + bool removeWatch(int cameraId); + SubscriberInfo* getSubscriberInfo(int cameraId); + + int getCameraId(String8 filePath) const; + int getCameraId(int wd) const; + + String8 getFilePath(int cameraId) const; + int readFile(String8 filePath) const; + + bool createFileIfNotExists(int cameraId) const; + + int mInotifyFd; + Vector mSubscribedCameraIds; + Vector mSubscribers; + + // variables above are unguarded: + // -- accessed in thread loop or in constructor only + + Mutex mMutex; + + bool mRunning; // guarding only when it's important +}; +} // namespace android + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.cpp new file mode 100644 index 0000000..457850d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedFakeCamera that encapsulates + * functionality of a fake camera. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_FakeCamera" +#include +#include +#include "EmulatedFakeCamera.h" +#include "EmulatedCameraFactory.h" + +namespace android { + +EmulatedFakeCamera::EmulatedFakeCamera(int cameraId, + bool facingBack, + struct hw_module_t* module) + : EmulatedCamera(cameraId, module), + mFacingBack(facingBack), + mFakeCameraDevice(this) +{ +} + +EmulatedFakeCamera::~EmulatedFakeCamera() +{ +} + +/**************************************************************************** + * Public API overrides + ***************************************************************************/ + +status_t EmulatedFakeCamera::Initialize() +{ + status_t res = mFakeCameraDevice.Initialize(); + if (res != NO_ERROR) { + return res; + } + + const char* facing = mFacingBack ? EmulatedCamera::FACING_BACK : + EmulatedCamera::FACING_FRONT; + + mParameters.set(EmulatedCamera::FACING_KEY, facing); + ALOGD("%s: Fake camera is facing %s", __FUNCTION__, facing); + + mParameters.set(EmulatedCamera::ORIENTATION_KEY, + gEmulatedCameraFactory.getFakeCameraOrientation()); + + res = EmulatedCamera::Initialize(); + if (res != NO_ERROR) { + return res; + } + + /* + * Parameters provided by the camera device. + */ + + /* 352x288 and 320x240 frame dimensions are required by the framework for + * video mode preview and video recording. */ + mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, + "640x480,352x288,320x240"); + mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, + "640x480,352x288,320x240"); + mParameters.setPreviewSize(640, 480); + mParameters.setPictureSize(640, 480); + + return NO_ERROR; +} + +EmulatedCameraDevice* EmulatedFakeCamera::getCameraDevice() +{ + return &mFakeCameraDevice; +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.h new file mode 100644 index 0000000..4bfbd70 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA_H +#define HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA_H + +/* + * Contains declaration of a class EmulatedFakeCamera that encapsulates + * functionality of a fake camera. This class is nothing more than a placeholder + * for EmulatedFakeCameraDevice instance. + */ + +#include "EmulatedCamera.h" +#include "EmulatedFakeCameraDevice.h" + +namespace android { + +/* Encapsulates functionality of a fake camera. + * This class is nothing more than a placeholder for EmulatedFakeCameraDevice + * instance that emulates a fake camera device. + */ +class EmulatedFakeCamera : public EmulatedCamera { +public: + /* Constructs EmulatedFakeCamera instance. */ + EmulatedFakeCamera(int cameraId, bool facingBack, struct hw_module_t* module); + + /* Destructs EmulatedFakeCamera instance. */ + ~EmulatedFakeCamera(); + + /**************************************************************************** + * EmulatedCamera virtual overrides. + ***************************************************************************/ + +public: + /* Initializes EmulatedFakeCamera instance. */ + status_t Initialize(); + + /**************************************************************************** + * EmulatedCamera abstract API implementation. + ***************************************************************************/ + +protected: + /* Gets emulated camera device ised by this instance of the emulated camera. + */ + EmulatedCameraDevice* getCameraDevice(); + + /**************************************************************************** + * Data memebers. + ***************************************************************************/ + +protected: + /* Facing back (true) or front (false) switch. */ + bool mFacingBack; + + /* Contained fake camera device object. */ + EmulatedFakeCameraDevice mFakeCameraDevice; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.cpp new file mode 100644 index 0000000..d1beb92 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.cpp @@ -0,0 +1,2717 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedFakeCamera2 that encapsulates + * functionality of an advanced fake camera. + */ + +#include + +//#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_FakeCamera2" +#include + +#include "EmulatedFakeCamera2.h" +#include "EmulatedCameraFactory.h" +#include +#include +#include "gralloc_cb.h" + +#define ERROR_CAMERA_NOT_PRESENT -EPIPE + +#define CAMERA2_EXT_TRIGGER_TESTING_DISCONNECT 0xFFFFFFFF + +namespace android { + +const int64_t USEC = 1000LL; +const int64_t MSEC = USEC * 1000LL; +const int64_t SEC = MSEC * 1000LL; + +const uint32_t EmulatedFakeCamera2::kAvailableFormats[4] = { + HAL_PIXEL_FORMAT_RAW16, + HAL_PIXEL_FORMAT_BLOB, + HAL_PIXEL_FORMAT_RGBA_8888, + // HAL_PIXEL_FORMAT_YV12, + HAL_PIXEL_FORMAT_YCrCb_420_SP +}; + +const uint32_t EmulatedFakeCamera2::kAvailableRawSizes[2] = { + 640, 480 + // Sensor::kResolution[0], Sensor::kResolution[1] +}; + +const uint64_t EmulatedFakeCamera2::kAvailableRawMinDurations[1] = { + static_cast(Sensor::kFrameDurationRange[0]) +}; + +const uint32_t EmulatedFakeCamera2::kAvailableProcessedSizesBack[4] = { + 640, 480, 320, 240 + // Sensor::kResolution[0], Sensor::kResolution[1] +}; + +const uint32_t EmulatedFakeCamera2::kAvailableProcessedSizesFront[4] = { + 320, 240, 160, 120 + // Sensor::kResolution[0], Sensor::kResolution[1] +}; + +const uint64_t EmulatedFakeCamera2::kAvailableProcessedMinDurations[1] = { + static_cast(Sensor::kFrameDurationRange[0]) +}; + +const uint32_t EmulatedFakeCamera2::kAvailableJpegSizesBack[2] = { + 640, 480 + // Sensor::kResolution[0], Sensor::kResolution[1] +}; + +const uint32_t EmulatedFakeCamera2::kAvailableJpegSizesFront[2] = { + 320, 240 + // Sensor::kResolution[0], Sensor::kResolution[1] +}; + + +const uint64_t EmulatedFakeCamera2::kAvailableJpegMinDurations[1] = { + static_cast(Sensor::kFrameDurationRange[0]) +}; + + +EmulatedFakeCamera2::EmulatedFakeCamera2(int cameraId, + bool facingBack, + struct hw_module_t* module) + : EmulatedCamera2(cameraId,module), + mFacingBack(facingBack), + mIsConnected(false) +{ + ALOGD("Constructing emulated fake camera 2 facing %s", + facingBack ? "back" : "front"); +} + +EmulatedFakeCamera2::~EmulatedFakeCamera2() { + if (mCameraInfo != NULL) { + free_camera_metadata(mCameraInfo); + } +} + +/**************************************************************************** + * Public API overrides + ***************************************************************************/ + +status_t EmulatedFakeCamera2::Initialize() { + status_t res; + + res = constructStaticInfo(&mCameraInfo, true); + if (res != OK) { + ALOGE("%s: Unable to allocate static info: %s (%d)", + __FUNCTION__, strerror(-res), res); + return res; + } + res = constructStaticInfo(&mCameraInfo, false); + if (res != OK) { + ALOGE("%s: Unable to fill in static info: %s (%d)", + __FUNCTION__, strerror(-res), res); + return res; + } + if (res != OK) return res; + + mNextStreamId = 1; + mNextReprocessStreamId = 1; + mRawStreamCount = 0; + mProcessedStreamCount = 0; + mJpegStreamCount = 0; + mReprocessStreamCount = 0; + + return NO_ERROR; +} + +/**************************************************************************** + * Camera module API overrides + ***************************************************************************/ + +status_t EmulatedFakeCamera2::connectCamera(hw_device_t** device) { + status_t res; + ALOGV("%s", __FUNCTION__); + + { + Mutex::Autolock l(mMutex); + if (!mStatusPresent) { + ALOGE("%s: Camera ID %d is unplugged", __FUNCTION__, + mCameraID); + return -ENODEV; + } + } + + mConfigureThread = new ConfigureThread(this); + mReadoutThread = new ReadoutThread(this); + mControlThread = new ControlThread(this); + mSensor = new Sensor(); + mJpegCompressor = new JpegCompressor(); + + mNextStreamId = 1; + mNextReprocessStreamId = 1; + + res = mSensor->startUp(); + if (res != NO_ERROR) return res; + + res = mConfigureThread->run("EmulatedFakeCamera2::configureThread"); + if (res != NO_ERROR) return res; + + res = mReadoutThread->run("EmulatedFakeCamera2::readoutThread"); + if (res != NO_ERROR) return res; + + res = mControlThread->run("EmulatedFakeCamera2::controlThread"); + if (res != NO_ERROR) return res; + + status_t ret = EmulatedCamera2::connectCamera(device); + + if (ret >= 0) { + mIsConnected = true; + } + + return ret; +} + +status_t EmulatedFakeCamera2::plugCamera() { + { + Mutex::Autolock l(mMutex); + + if (!mStatusPresent) { + ALOGI("%s: Plugged back in", __FUNCTION__); + mStatusPresent = true; + } + } + + return NO_ERROR; +} + +status_t EmulatedFakeCamera2::unplugCamera() { + { + Mutex::Autolock l(mMutex); + + if (mStatusPresent) { + ALOGI("%s: Unplugged camera", __FUNCTION__); + mStatusPresent = false; + } + } + + return closeCamera(); +} + +camera_device_status_t EmulatedFakeCamera2::getHotplugStatus() { + Mutex::Autolock l(mMutex); + return mStatusPresent ? + CAMERA_DEVICE_STATUS_PRESENT : + CAMERA_DEVICE_STATUS_NOT_PRESENT; +} + + + +status_t EmulatedFakeCamera2::closeCamera() { + { + Mutex::Autolock l(mMutex); + + status_t res; + ALOGV("%s", __FUNCTION__); + + if (!mIsConnected) { + return NO_ERROR; + } + + res = mSensor->shutDown(); + if (res != NO_ERROR) { + ALOGE("%s: Unable to shut down sensor: %d", __FUNCTION__, res); + return res; + } + + mConfigureThread->requestExit(); + mReadoutThread->requestExit(); + mControlThread->requestExit(); + mJpegCompressor->cancel(); + } + + // give up the lock since we will now block and the threads + // can call back into this object + mConfigureThread->join(); + mReadoutThread->join(); + mControlThread->join(); + + ALOGV("%s exit", __FUNCTION__); + + { + Mutex::Autolock l(mMutex); + mIsConnected = false; + } + + return NO_ERROR; +} + +status_t EmulatedFakeCamera2::getCameraInfo(struct camera_info *info) { + info->facing = mFacingBack ? CAMERA_FACING_BACK : CAMERA_FACING_FRONT; + info->orientation = gEmulatedCameraFactory.getFakeCameraOrientation(); + return EmulatedCamera2::getCameraInfo(info); +} + +/**************************************************************************** + * Camera device API overrides + ***************************************************************************/ + +/** Request input queue */ + +int EmulatedFakeCamera2::requestQueueNotify() { + ALOGV("Request queue notification received"); + + ALOG_ASSERT(mRequestQueueSrc != NULL, + "%s: Request queue src not set, but received queue notification!", + __FUNCTION__); + ALOG_ASSERT(mFrameQueueDst != NULL, + "%s: Request queue src not set, but received queue notification!", + __FUNCTION__); + ALOG_ASSERT(mStreams.size() != 0, + "%s: No streams allocated, but received queue notification!", + __FUNCTION__); + return mConfigureThread->newRequestAvailable(); +} + +int EmulatedFakeCamera2::getInProgressCount() { + Mutex::Autolock l(mMutex); + + if (!mStatusPresent) { + ALOGW("%s: Camera was physically disconnected", __FUNCTION__); + return ERROR_CAMERA_NOT_PRESENT; + } + + int requestCount = 0; + requestCount += mConfigureThread->getInProgressCount(); + requestCount += mReadoutThread->getInProgressCount(); + requestCount += mJpegCompressor->isBusy() ? 1 : 0; + + return requestCount; +} + +int EmulatedFakeCamera2::constructDefaultRequest( + int request_template, + camera_metadata_t **request) { + + if (request == NULL) return BAD_VALUE; + if (request_template < 0 || request_template >= CAMERA2_TEMPLATE_COUNT) { + return BAD_VALUE; + } + + { + Mutex::Autolock l(mMutex); + if (!mStatusPresent) { + ALOGW("%s: Camera was physically disconnected", __FUNCTION__); + return ERROR_CAMERA_NOT_PRESENT; + } + } + + status_t res; + // Pass 1, calculate size and allocate + res = constructDefaultRequest(request_template, + request, + true); + if (res != OK) { + return res; + } + // Pass 2, build request + res = constructDefaultRequest(request_template, + request, + false); + if (res != OK) { + ALOGE("Unable to populate new request for template %d", + request_template); + } + + return res; +} + +int EmulatedFakeCamera2::allocateStream( + uint32_t width, + uint32_t height, + int format, + const camera2_stream_ops_t *stream_ops, + uint32_t *stream_id, + uint32_t *format_actual, + uint32_t *usage, + uint32_t *max_buffers) { + Mutex::Autolock l(mMutex); + + if (!mStatusPresent) { + ALOGW("%s: Camera was physically disconnected", __FUNCTION__); + return ERROR_CAMERA_NOT_PRESENT; + } + + // Temporary shim until FORMAT_ZSL is removed + if (format == CAMERA2_HAL_PIXEL_FORMAT_ZSL) { + format = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; + } + + if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { + unsigned int numFormats = sizeof(kAvailableFormats) / sizeof(uint32_t); + unsigned int formatIdx = 0; + unsigned int sizeOffsetIdx = 0; + for (; formatIdx < numFormats; formatIdx++) { + if (format == (int)kAvailableFormats[formatIdx]) break; + } + if (formatIdx == numFormats) { + ALOGE("%s: Format 0x%x is not supported", __FUNCTION__, format); + return BAD_VALUE; + } + } + + const uint32_t *availableSizes; + size_t availableSizeCount; + switch (format) { + case HAL_PIXEL_FORMAT_RAW16: + availableSizes = kAvailableRawSizes; + availableSizeCount = sizeof(kAvailableRawSizes)/sizeof(uint32_t); + break; + case HAL_PIXEL_FORMAT_BLOB: + availableSizes = mFacingBack ? + kAvailableJpegSizesBack : kAvailableJpegSizesFront; + availableSizeCount = mFacingBack ? + sizeof(kAvailableJpegSizesBack)/sizeof(uint32_t) : + sizeof(kAvailableJpegSizesFront)/sizeof(uint32_t); + break; + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_YV12: + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + availableSizes = mFacingBack ? + kAvailableProcessedSizesBack : kAvailableProcessedSizesFront; + availableSizeCount = mFacingBack ? + sizeof(kAvailableProcessedSizesBack)/sizeof(uint32_t) : + sizeof(kAvailableProcessedSizesFront)/sizeof(uint32_t); + break; + default: + ALOGE("%s: Unknown format 0x%x", __FUNCTION__, format); + return BAD_VALUE; + } + + unsigned int resIdx = 0; + for (; resIdx < availableSizeCount; resIdx++) { + if (availableSizes[resIdx * 2] == width && + availableSizes[resIdx * 2 + 1] == height) break; + } + if (resIdx == availableSizeCount) { + ALOGE("%s: Format 0x%x does not support resolution %d, %d", __FUNCTION__, + format, width, height); + return BAD_VALUE; + } + + switch (format) { + case HAL_PIXEL_FORMAT_RAW16: + if (mRawStreamCount >= kMaxRawStreamCount) { + ALOGE("%s: Cannot allocate another raw stream (%d already allocated)", + __FUNCTION__, mRawStreamCount); + return INVALID_OPERATION; + } + mRawStreamCount++; + break; + case HAL_PIXEL_FORMAT_BLOB: + if (mJpegStreamCount >= kMaxJpegStreamCount) { + ALOGE("%s: Cannot allocate another JPEG stream (%d already allocated)", + __FUNCTION__, mJpegStreamCount); + return INVALID_OPERATION; + } + mJpegStreamCount++; + break; + default: + if (mProcessedStreamCount >= kMaxProcessedStreamCount) { + ALOGE("%s: Cannot allocate another processed stream (%d already allocated)", + __FUNCTION__, mProcessedStreamCount); + return INVALID_OPERATION; + } + mProcessedStreamCount++; + } + + Stream newStream; + newStream.ops = stream_ops; + newStream.width = width; + newStream.height = height; + newStream.format = format; + // TODO: Query stride from gralloc + newStream.stride = width; + + mStreams.add(mNextStreamId, newStream); + + *stream_id = mNextStreamId; + if (format_actual) *format_actual = format; + *usage = GRALLOC_USAGE_HW_CAMERA_WRITE; + *max_buffers = kMaxBufferCount; + + ALOGV("Stream allocated: %d, %d x %d, 0x%x. U: %x, B: %d", + *stream_id, width, height, format, *usage, *max_buffers); + + mNextStreamId++; + return NO_ERROR; +} + +int EmulatedFakeCamera2::registerStreamBuffers( + uint32_t stream_id, + int num_buffers, + buffer_handle_t *buffers) { + Mutex::Autolock l(mMutex); + + if (!mStatusPresent) { + ALOGW("%s: Camera was physically disconnected", __FUNCTION__); + return ERROR_CAMERA_NOT_PRESENT; + } + + ALOGV("%s: Stream %d registering %d buffers", __FUNCTION__, + stream_id, num_buffers); + // Need to find out what the final concrete pixel format for our stream is + // Assumes that all buffers have the same format. + if (num_buffers < 1) { + ALOGE("%s: Stream %d only has %d buffers!", + __FUNCTION__, stream_id, num_buffers); + return BAD_VALUE; + } + const cb_handle_t *streamBuffer = + reinterpret_cast(buffers[0]); + + int finalFormat = streamBuffer->format; + + if (finalFormat == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { + ALOGE("%s: Stream %d: Bad final pixel format " + "HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; " + "concrete pixel format required!", __FUNCTION__, stream_id); + return BAD_VALUE; + } + + ssize_t streamIndex = mStreams.indexOfKey(stream_id); + if (streamIndex < 0) { + ALOGE("%s: Unknown stream id %d!", __FUNCTION__, stream_id); + return BAD_VALUE; + } + + Stream &stream = mStreams.editValueAt(streamIndex); + + ALOGV("%s: Stream %d format set to %x, previously %x", + __FUNCTION__, stream_id, finalFormat, stream.format); + + stream.format = finalFormat; + + return NO_ERROR; +} + +int EmulatedFakeCamera2::releaseStream(uint32_t stream_id) { + Mutex::Autolock l(mMutex); + + ssize_t streamIndex = mStreams.indexOfKey(stream_id); + if (streamIndex < 0) { + ALOGE("%s: Unknown stream id %d!", __FUNCTION__, stream_id); + return BAD_VALUE; + } + + if (isStreamInUse(stream_id)) { + ALOGE("%s: Cannot release stream %d; in use!", __FUNCTION__, + stream_id); + return BAD_VALUE; + } + + switch(mStreams.valueAt(streamIndex).format) { + case HAL_PIXEL_FORMAT_RAW16: + mRawStreamCount--; + break; + case HAL_PIXEL_FORMAT_BLOB: + mJpegStreamCount--; + break; + default: + mProcessedStreamCount--; + break; + } + + mStreams.removeItemsAt(streamIndex); + + return NO_ERROR; +} + +int EmulatedFakeCamera2::allocateReprocessStreamFromStream( + uint32_t output_stream_id, + const camera2_stream_in_ops_t *stream_ops, + uint32_t *stream_id) { + Mutex::Autolock l(mMutex); + + if (!mStatusPresent) { + ALOGW("%s: Camera was physically disconnected", __FUNCTION__); + return ERROR_CAMERA_NOT_PRESENT; + } + + ssize_t baseStreamIndex = mStreams.indexOfKey(output_stream_id); + if (baseStreamIndex < 0) { + ALOGE("%s: Unknown output stream id %d!", __FUNCTION__, output_stream_id); + return BAD_VALUE; + } + + const Stream &baseStream = mStreams[baseStreamIndex]; + + // We'll reprocess anything we produced + + if (mReprocessStreamCount >= kMaxReprocessStreamCount) { + ALOGE("%s: Cannot allocate another reprocess stream (%d already allocated)", + __FUNCTION__, mReprocessStreamCount); + return INVALID_OPERATION; + } + mReprocessStreamCount++; + + ReprocessStream newStream; + newStream.ops = stream_ops; + newStream.width = baseStream.width; + newStream.height = baseStream.height; + newStream.format = baseStream.format; + newStream.stride = baseStream.stride; + newStream.sourceStreamId = output_stream_id; + + *stream_id = mNextReprocessStreamId; + mReprocessStreams.add(mNextReprocessStreamId, newStream); + + ALOGV("Reprocess stream allocated: %d: %d, %d, 0x%x. Parent stream: %d", + *stream_id, newStream.width, newStream.height, newStream.format, + output_stream_id); + + mNextReprocessStreamId++; + return NO_ERROR; +} + +int EmulatedFakeCamera2::releaseReprocessStream(uint32_t stream_id) { + Mutex::Autolock l(mMutex); + + ssize_t streamIndex = mReprocessStreams.indexOfKey(stream_id); + if (streamIndex < 0) { + ALOGE("%s: Unknown reprocess stream id %d!", __FUNCTION__, stream_id); + return BAD_VALUE; + } + + if (isReprocessStreamInUse(stream_id)) { + ALOGE("%s: Cannot release reprocessing stream %d; in use!", __FUNCTION__, + stream_id); + return BAD_VALUE; + } + + mReprocessStreamCount--; + mReprocessStreams.removeItemsAt(streamIndex); + + return NO_ERROR; +} + +int EmulatedFakeCamera2::triggerAction(uint32_t trigger_id, + int32_t ext1, + int32_t ext2) { + Mutex::Autolock l(mMutex); + + if (trigger_id == CAMERA2_EXT_TRIGGER_TESTING_DISCONNECT) { + ALOGI("%s: Disconnect trigger - camera must be closed", __FUNCTION__); + mStatusPresent = false; + + gEmulatedCameraFactory.onStatusChanged( + mCameraID, + CAMERA_DEVICE_STATUS_NOT_PRESENT); + } + + if (!mStatusPresent) { + ALOGW("%s: Camera was physically disconnected", __FUNCTION__); + return ERROR_CAMERA_NOT_PRESENT; + } + + return mControlThread->triggerAction(trigger_id, + ext1, ext2); +} + +/** Shutdown and debug methods */ + +int EmulatedFakeCamera2::dump(int fd) { + String8 result; + + result.appendFormat(" Camera HAL device: EmulatedFakeCamera2\n"); + result.appendFormat(" Streams:\n"); + for (size_t i = 0; i < mStreams.size(); i++) { + int id = mStreams.keyAt(i); + const Stream& s = mStreams.valueAt(i); + result.appendFormat( + " Stream %d: %d x %d, format 0x%x, stride %d\n", + id, s.width, s.height, s.format, s.stride); + } + + write(fd, result.string(), result.size()); + + return NO_ERROR; +} + +void EmulatedFakeCamera2::signalError() { + // TODO: Let parent know so we can shut down cleanly + ALOGE("Worker thread is signaling a serious error"); +} + +/** Pipeline control worker thread methods */ + +EmulatedFakeCamera2::ConfigureThread::ConfigureThread(EmulatedFakeCamera2 *parent): + Thread(false), + mParent(parent), + mRequestCount(0), + mNextBuffers(NULL) { + mRunning = false; +} + +EmulatedFakeCamera2::ConfigureThread::~ConfigureThread() { +} + +status_t EmulatedFakeCamera2::ConfigureThread::readyToRun() { + Mutex::Autolock lock(mInputMutex); + + ALOGV("Starting up ConfigureThread"); + mRequest = NULL; + mActive = false; + mRunning = true; + + mInputSignal.signal(); + return NO_ERROR; +} + +status_t EmulatedFakeCamera2::ConfigureThread::waitUntilRunning() { + Mutex::Autolock lock(mInputMutex); + if (!mRunning) { + ALOGV("Waiting for configure thread to start"); + mInputSignal.wait(mInputMutex); + } + return OK; +} + +status_t EmulatedFakeCamera2::ConfigureThread::newRequestAvailable() { + waitUntilRunning(); + + Mutex::Autolock lock(mInputMutex); + + mActive = true; + mInputSignal.signal(); + + return OK; +} + +bool EmulatedFakeCamera2::ConfigureThread::isStreamInUse(uint32_t id) { + Mutex::Autolock lock(mInternalsMutex); + + if (mNextBuffers == NULL) return false; + for (size_t i=0; i < mNextBuffers->size(); i++) { + if ((*mNextBuffers)[i].streamId == (int)id) return true; + } + return false; +} + +int EmulatedFakeCamera2::ConfigureThread::getInProgressCount() { + Mutex::Autolock lock(mInputMutex); + return mRequestCount; +} + +bool EmulatedFakeCamera2::ConfigureThread::threadLoop() { + status_t res; + + // Check if we're currently processing or just waiting + { + Mutex::Autolock lock(mInputMutex); + if (!mActive) { + // Inactive, keep waiting until we've been signaled + status_t res; + res = mInputSignal.waitRelative(mInputMutex, kWaitPerLoop); + if (res != NO_ERROR && res != TIMED_OUT) { + ALOGE("%s: Error waiting for input requests: %d", + __FUNCTION__, res); + return false; + } + if (!mActive) return true; + ALOGV("New request available"); + } + // Active + } + + if (mRequest == NULL) { + Mutex::Autolock il(mInternalsMutex); + + ALOGV("Configure: Getting next request"); + res = mParent->mRequestQueueSrc->dequeue_request( + mParent->mRequestQueueSrc, + &mRequest); + if (res != NO_ERROR) { + ALOGE("%s: Error dequeuing next request: %d", __FUNCTION__, res); + mParent->signalError(); + return false; + } + if (mRequest == NULL) { + ALOGV("Configure: Request queue empty, going inactive"); + // No requests available, go into inactive mode + Mutex::Autolock lock(mInputMutex); + mActive = false; + return true; + } else { + Mutex::Autolock lock(mInputMutex); + mRequestCount++; + } + + camera_metadata_entry_t type; + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_TYPE, + &type); + if (res != NO_ERROR) { + ALOGE("%s: error reading request type", __FUNCTION__); + mParent->signalError(); + return false; + } + bool success = false;; + switch (type.data.u8[0]) { + case ANDROID_REQUEST_TYPE_CAPTURE: + success = setupCapture(); + break; + case ANDROID_REQUEST_TYPE_REPROCESS: + success = setupReprocess(); + break; + default: + ALOGE("%s: Unexpected request type %d", + __FUNCTION__, type.data.u8[0]); + mParent->signalError(); + break; + } + if (!success) return false; + + } + + if (mWaitingForReadout) { + bool readoutDone; + readoutDone = mParent->mReadoutThread->waitForReady(kWaitPerLoop); + if (!readoutDone) return true; + + if (mNextNeedsJpeg) { + ALOGV("Configure: Waiting for JPEG compressor"); + } else { + ALOGV("Configure: Waiting for sensor"); + } + mWaitingForReadout = false; + } + + if (mNextNeedsJpeg) { + bool jpegDone; + jpegDone = mParent->mJpegCompressor->waitForDone(kWaitPerLoop); + if (!jpegDone) return true; + + ALOGV("Configure: Waiting for sensor"); + mNextNeedsJpeg = false; + } + + if (mNextIsCapture) { + return configureNextCapture(); + } else { + return configureNextReprocess(); + } +} + +bool EmulatedFakeCamera2::ConfigureThread::setupCapture() { + status_t res; + + mNextIsCapture = true; + // Get necessary parameters for sensor config + mParent->mControlThread->processRequest(mRequest); + + camera_metadata_entry_t streams; + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_OUTPUT_STREAMS, + &streams); + if (res != NO_ERROR) { + ALOGE("%s: error reading output stream tag", __FUNCTION__); + mParent->signalError(); + return false; + } + + mNextBuffers = new Buffers; + mNextNeedsJpeg = false; + ALOGV("Configure: Setting up buffers for capture"); + for (size_t i = 0; i < streams.count; i++) { + int streamId = streams.data.i32[i]; + const Stream &s = mParent->getStreamInfo(streamId); + if (s.format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { + ALOGE("%s: Stream %d does not have a concrete pixel format, but " + "is included in a request!", __FUNCTION__, streamId); + mParent->signalError(); + return false; + } + StreamBuffer b; + b.streamId = streams.data.u8[i]; + b.width = s.width; + b.height = s.height; + b.format = s.format; + b.stride = s.stride; + mNextBuffers->push_back(b); + ALOGV("Configure: Buffer %zu: Stream %d, %d x %d, format 0x%x, " + "stride %d", + i, b.streamId, b.width, b.height, b.format, b.stride); + if (b.format == HAL_PIXEL_FORMAT_BLOB) { + mNextNeedsJpeg = true; + } + } + + camera_metadata_entry_t e; + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_FRAME_COUNT, + &e); + if (res != NO_ERROR) { + ALOGE("%s: error reading frame count tag: %s (%d)", + __FUNCTION__, strerror(-res), res); + mParent->signalError(); + return false; + } + mNextFrameNumber = *e.data.i32; + + res = find_camera_metadata_entry(mRequest, + ANDROID_SENSOR_EXPOSURE_TIME, + &e); + if (res != NO_ERROR) { + ALOGE("%s: error reading exposure time tag: %s (%d)", + __FUNCTION__, strerror(-res), res); + mParent->signalError(); + return false; + } + mNextExposureTime = *e.data.i64; + + res = find_camera_metadata_entry(mRequest, + ANDROID_SENSOR_FRAME_DURATION, + &e); + if (res != NO_ERROR) { + ALOGE("%s: error reading frame duration tag", __FUNCTION__); + mParent->signalError(); + return false; + } + mNextFrameDuration = *e.data.i64; + + if (mNextFrameDuration < + mNextExposureTime + Sensor::kMinVerticalBlank) { + mNextFrameDuration = mNextExposureTime + Sensor::kMinVerticalBlank; + } + res = find_camera_metadata_entry(mRequest, + ANDROID_SENSOR_SENSITIVITY, + &e); + if (res != NO_ERROR) { + ALOGE("%s: error reading sensitivity tag", __FUNCTION__); + mParent->signalError(); + return false; + } + mNextSensitivity = *e.data.i32; + + // Start waiting on readout thread + mWaitingForReadout = true; + ALOGV("Configure: Waiting for readout thread"); + + return true; +} + +bool EmulatedFakeCamera2::ConfigureThread::configureNextCapture() { + bool vsync = mParent->mSensor->waitForVSync(kWaitPerLoop); + if (!vsync) return true; + + Mutex::Autolock il(mInternalsMutex); + ALOGV("Configure: Configuring sensor for capture %d", mNextFrameNumber); + mParent->mSensor->setExposureTime(mNextExposureTime); + mParent->mSensor->setFrameDuration(mNextFrameDuration); + mParent->mSensor->setSensitivity(mNextSensitivity); + + getBuffers(); + + ALOGV("Configure: Done configure for capture %d", mNextFrameNumber); + mParent->mReadoutThread->setNextOperation(true, mRequest, mNextBuffers); + mParent->mSensor->setDestinationBuffers(mNextBuffers); + + mRequest = NULL; + mNextBuffers = NULL; + + Mutex::Autolock lock(mInputMutex); + mRequestCount--; + + return true; +} + +bool EmulatedFakeCamera2::ConfigureThread::setupReprocess() { + status_t res; + + mNextNeedsJpeg = true; + mNextIsCapture = false; + + camera_metadata_entry_t reprocessStreams; + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_INPUT_STREAMS, + &reprocessStreams); + if (res != NO_ERROR) { + ALOGE("%s: error reading output stream tag", __FUNCTION__); + mParent->signalError(); + return false; + } + + mNextBuffers = new Buffers; + + ALOGV("Configure: Setting up input buffers for reprocess"); + for (size_t i = 0; i < reprocessStreams.count; i++) { + int streamId = reprocessStreams.data.i32[i]; + const ReprocessStream &s = mParent->getReprocessStreamInfo(streamId); + if (s.format != HAL_PIXEL_FORMAT_RGB_888) { + ALOGE("%s: Only ZSL reprocessing supported!", + __FUNCTION__); + mParent->signalError(); + return false; + } + StreamBuffer b; + b.streamId = -streamId; + b.width = s.width; + b.height = s.height; + b.format = s.format; + b.stride = s.stride; + mNextBuffers->push_back(b); + } + + camera_metadata_entry_t streams; + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_OUTPUT_STREAMS, + &streams); + if (res != NO_ERROR) { + ALOGE("%s: error reading output stream tag", __FUNCTION__); + mParent->signalError(); + return false; + } + + ALOGV("Configure: Setting up output buffers for reprocess"); + for (size_t i = 0; i < streams.count; i++) { + int streamId = streams.data.i32[i]; + const Stream &s = mParent->getStreamInfo(streamId); + if (s.format != HAL_PIXEL_FORMAT_BLOB) { + // TODO: Support reprocess to YUV + ALOGE("%s: Non-JPEG output stream %d for reprocess not supported", + __FUNCTION__, streamId); + mParent->signalError(); + return false; + } + StreamBuffer b; + b.streamId = streams.data.u8[i]; + b.width = s.width; + b.height = s.height; + b.format = s.format; + b.stride = s.stride; + mNextBuffers->push_back(b); + ALOGV("Configure: Buffer %zu: Stream %d, %d x %d, format 0x%x, " + "stride %d", + i, b.streamId, b.width, b.height, b.format, b.stride); + } + + camera_metadata_entry_t e; + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_FRAME_COUNT, + &e); + if (res != NO_ERROR) { + ALOGE("%s: error reading frame count tag: %s (%d)", + __FUNCTION__, strerror(-res), res); + mParent->signalError(); + return false; + } + mNextFrameNumber = *e.data.i32; + + return true; +} + +bool EmulatedFakeCamera2::ConfigureThread::configureNextReprocess() { + Mutex::Autolock il(mInternalsMutex); + + getBuffers(); + + ALOGV("Configure: Done configure for reprocess %d", mNextFrameNumber); + mParent->mReadoutThread->setNextOperation(false, mRequest, mNextBuffers); + + mRequest = NULL; + mNextBuffers = NULL; + + Mutex::Autolock lock(mInputMutex); + mRequestCount--; + + return true; +} + +bool EmulatedFakeCamera2::ConfigureThread::getBuffers() { + status_t res; + /** Get buffers to fill for this frame */ + for (size_t i = 0; i < mNextBuffers->size(); i++) { + StreamBuffer &b = mNextBuffers->editItemAt(i); + + if (b.streamId > 0) { + Stream s = mParent->getStreamInfo(b.streamId); + ALOGV("Configure: Dequeing buffer from stream %d", b.streamId); + res = s.ops->dequeue_buffer(s.ops, &(b.buffer) ); + if (res != NO_ERROR || b.buffer == NULL) { + ALOGE("%s: Unable to dequeue buffer from stream %d: %s (%d)", + __FUNCTION__, b.streamId, strerror(-res), res); + mParent->signalError(); + return false; + } + + /* Lock the buffer from the perspective of the graphics mapper */ + const Rect rect(s.width, s.height); + + res = GraphicBufferMapper::get().lock(*(b.buffer), + GRALLOC_USAGE_HW_CAMERA_WRITE, + rect, (void**)&(b.img) ); + + if (res != NO_ERROR) { + ALOGE("%s: grbuffer_mapper.lock failure: %s (%d)", + __FUNCTION__, strerror(-res), res); + s.ops->cancel_buffer(s.ops, + b.buffer); + mParent->signalError(); + return false; + } + } else { + ReprocessStream s = mParent->getReprocessStreamInfo(-b.streamId); + ALOGV("Configure: Acquiring buffer from reprocess stream %d", + -b.streamId); + res = s.ops->acquire_buffer(s.ops, &(b.buffer) ); + if (res != NO_ERROR || b.buffer == NULL) { + ALOGE("%s: Unable to acquire buffer from reprocess stream %d: " + "%s (%d)", __FUNCTION__, -b.streamId, + strerror(-res), res); + mParent->signalError(); + return false; + } + + /* Lock the buffer from the perspective of the graphics mapper */ + const Rect rect(s.width, s.height); + + res = GraphicBufferMapper::get().lock(*(b.buffer), + GRALLOC_USAGE_HW_CAMERA_READ, + rect, (void**)&(b.img) ); + if (res != NO_ERROR) { + ALOGE("%s: grbuffer_mapper.lock failure: %s (%d)", + __FUNCTION__, strerror(-res), res); + s.ops->release_buffer(s.ops, + b.buffer); + mParent->signalError(); + return false; + } + } + } + return true; +} + +EmulatedFakeCamera2::ReadoutThread::ReadoutThread(EmulatedFakeCamera2 *parent): + Thread(false), + mParent(parent), + mRunning(false), + mActive(false), + mRequestCount(0), + mRequest(NULL), + mBuffers(NULL) { + mInFlightQueue = new InFlightQueue[kInFlightQueueSize]; + mInFlightHead = 0; + mInFlightTail = 0; +} + +EmulatedFakeCamera2::ReadoutThread::~ReadoutThread() { + delete mInFlightQueue; +} + +status_t EmulatedFakeCamera2::ReadoutThread::readyToRun() { + Mutex::Autolock lock(mInputMutex); + ALOGV("Starting up ReadoutThread"); + mRunning = true; + mInputSignal.signal(); + return NO_ERROR; +} + +status_t EmulatedFakeCamera2::ReadoutThread::waitUntilRunning() { + Mutex::Autolock lock(mInputMutex); + if (!mRunning) { + ALOGV("Waiting for readout thread to start"); + mInputSignal.wait(mInputMutex); + } + return OK; +} + +bool EmulatedFakeCamera2::ReadoutThread::waitForReady(nsecs_t timeout) { + status_t res; + Mutex::Autolock lock(mInputMutex); + while (!readyForNextCapture()) { + res = mReadySignal.waitRelative(mInputMutex, timeout); + if (res == TIMED_OUT) return false; + if (res != OK) { + ALOGE("%s: Error waiting for ready: %s (%d)", __FUNCTION__, + strerror(-res), res); + return false; + } + } + return true; +} + +bool EmulatedFakeCamera2::ReadoutThread::readyForNextCapture() { + return (mInFlightTail + 1) % kInFlightQueueSize != mInFlightHead; +} + +void EmulatedFakeCamera2::ReadoutThread::setNextOperation( + bool isCapture, + camera_metadata_t *request, + Buffers *buffers) { + Mutex::Autolock lock(mInputMutex); + if ( !readyForNextCapture() ) { + ALOGE("In flight queue full, dropping captures"); + mParent->signalError(); + return; + } + mInFlightQueue[mInFlightTail].isCapture = isCapture; + mInFlightQueue[mInFlightTail].request = request; + mInFlightQueue[mInFlightTail].buffers = buffers; + mInFlightTail = (mInFlightTail + 1) % kInFlightQueueSize; + mRequestCount++; + + if (!mActive) { + mActive = true; + mInputSignal.signal(); + } +} + +bool EmulatedFakeCamera2::ReadoutThread::isStreamInUse(uint32_t id) { + // acquire in same order as threadLoop + Mutex::Autolock iLock(mInternalsMutex); + Mutex::Autolock lock(mInputMutex); + + size_t i = mInFlightHead; + while (i != mInFlightTail) { + for (size_t j = 0; j < mInFlightQueue[i].buffers->size(); j++) { + if ( (*(mInFlightQueue[i].buffers))[j].streamId == (int)id ) + return true; + } + i = (i + 1) % kInFlightQueueSize; + } + + + if (mBuffers != NULL) { + for (i = 0; i < mBuffers->size(); i++) { + if ( (*mBuffers)[i].streamId == (int)id) return true; + } + } + + return false; +} + +int EmulatedFakeCamera2::ReadoutThread::getInProgressCount() { + Mutex::Autolock lock(mInputMutex); + + return mRequestCount; +} + +bool EmulatedFakeCamera2::ReadoutThread::threadLoop() { + static const nsecs_t kWaitPerLoop = 10000000L; // 10 ms + status_t res; + int32_t frameNumber; + + // Check if we're currently processing or just waiting + { + Mutex::Autolock lock(mInputMutex); + if (!mActive) { + // Inactive, keep waiting until we've been signaled + res = mInputSignal.waitRelative(mInputMutex, kWaitPerLoop); + if (res != NO_ERROR && res != TIMED_OUT) { + ALOGE("%s: Error waiting for capture requests: %d", + __FUNCTION__, res); + mParent->signalError(); + return false; + } + if (!mActive) return true; + } + // Active, see if we need a new request + if (mRequest == NULL) { + if (mInFlightHead == mInFlightTail) { + // Go inactive + ALOGV("Waiting for sensor data"); + mActive = false; + return true; + } else { + Mutex::Autolock iLock(mInternalsMutex); + mReadySignal.signal(); + mIsCapture = mInFlightQueue[mInFlightHead].isCapture; + mRequest = mInFlightQueue[mInFlightHead].request; + mBuffers = mInFlightQueue[mInFlightHead].buffers; + mInFlightQueue[mInFlightHead].request = NULL; + mInFlightQueue[mInFlightHead].buffers = NULL; + mInFlightHead = (mInFlightHead + 1) % kInFlightQueueSize; + ALOGV("Ready to read out request %p, %zu buffers", + mRequest, mBuffers->size()); + } + } + } + + // Active with request, wait on sensor to complete + + nsecs_t captureTime; + + if (mIsCapture) { + bool gotFrame; + gotFrame = mParent->mSensor->waitForNewFrame(kWaitPerLoop, + &captureTime); + + if (!gotFrame) return true; + } + + Mutex::Autolock iLock(mInternalsMutex); + + camera_metadata_entry_t entry; + if (!mIsCapture) { + res = find_camera_metadata_entry(mRequest, + ANDROID_SENSOR_TIMESTAMP, + &entry); + if (res != NO_ERROR) { + ALOGE("%s: error reading reprocessing timestamp: %s (%d)", + __FUNCTION__, strerror(-res), res); + mParent->signalError(); + return false; + } + captureTime = entry.data.i64[0]; + } + + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_FRAME_COUNT, + &entry); + if (res != NO_ERROR) { + ALOGE("%s: error reading frame count tag: %s (%d)", + __FUNCTION__, strerror(-res), res); + mParent->signalError(); + return false; + } + frameNumber = *entry.data.i32; + + res = find_camera_metadata_entry(mRequest, + ANDROID_REQUEST_METADATA_MODE, + &entry); + if (res != NO_ERROR) { + ALOGE("%s: error reading metadata mode tag: %s (%d)", + __FUNCTION__, strerror(-res), res); + mParent->signalError(); + return false; + } + + // Got sensor data and request, construct frame and send it out + ALOGV("Readout: Constructing metadata and frames for request %d", + frameNumber); + + if (*entry.data.u8 == ANDROID_REQUEST_METADATA_MODE_FULL) { + ALOGV("Readout: Metadata requested, constructing"); + + camera_metadata_t *frame = NULL; + + size_t frame_entries = get_camera_metadata_entry_count(mRequest); + size_t frame_data = get_camera_metadata_data_count(mRequest); + + // TODO: Dynamically calculate based on enabled statistics, etc + frame_entries += 10; + frame_data += 100; + + res = mParent->mFrameQueueDst->dequeue_frame(mParent->mFrameQueueDst, + frame_entries, frame_data, &frame); + + if (res != NO_ERROR || frame == NULL) { + ALOGE("%s: Unable to dequeue frame metadata buffer", __FUNCTION__); + mParent->signalError(); + return false; + } + + res = append_camera_metadata(frame, mRequest); + if (res != NO_ERROR) { + ALOGE("Unable to append request metadata"); + } + + if (mIsCapture) { + add_camera_metadata_entry(frame, + ANDROID_SENSOR_TIMESTAMP, + &captureTime, + 1); + + collectStatisticsMetadata(frame); + // TODO: Collect all final values used from sensor in addition to timestamp + } + + ALOGV("Readout: Enqueue frame %d", frameNumber); + mParent->mFrameQueueDst->enqueue_frame(mParent->mFrameQueueDst, + frame); + } + ALOGV("Readout: Free request"); + res = mParent->mRequestQueueSrc->free_request(mParent->mRequestQueueSrc, mRequest); + if (res != NO_ERROR) { + ALOGE("%s: Unable to return request buffer to queue: %d", + __FUNCTION__, res); + mParent->signalError(); + return false; + } + mRequest = NULL; + + int compressedBufferIndex = -1; + ALOGV("Readout: Processing %zu buffers", mBuffers->size()); + for (size_t i = 0; i < mBuffers->size(); i++) { + const StreamBuffer &b = (*mBuffers)[i]; + ALOGV("Readout: Buffer %zu: Stream %d, %d x %d, format 0x%x, stride %d", + i, b.streamId, b.width, b.height, b.format, b.stride); + if (b.streamId > 0) { + if (b.format == HAL_PIXEL_FORMAT_BLOB) { + // Assumes only one BLOB buffer type per capture + compressedBufferIndex = i; + } else { + ALOGV("Readout: Sending image buffer %zu (%p) to output stream %d", + i, (void*)*(b.buffer), b.streamId); + GraphicBufferMapper::get().unlock(*(b.buffer)); + const Stream &s = mParent->getStreamInfo(b.streamId); + res = s.ops->enqueue_buffer(s.ops, captureTime, b.buffer); + if (res != OK) { + ALOGE("Error enqueuing image buffer %p: %s (%d)", b.buffer, + strerror(-res), res); + mParent->signalError(); + } + } + } + } + + if (compressedBufferIndex == -1) { + delete mBuffers; + } else { + ALOGV("Readout: Starting JPEG compression for buffer %d, stream %d", + compressedBufferIndex, + (*mBuffers)[compressedBufferIndex].streamId); + mJpegTimestamp = captureTime; + // Takes ownership of mBuffers + mParent->mJpegCompressor->start(mBuffers, this); + } + mBuffers = NULL; + + Mutex::Autolock l(mInputMutex); + mRequestCount--; + ALOGV("Readout: Done with request %d", frameNumber); + return true; +} + +void EmulatedFakeCamera2::ReadoutThread::onJpegDone( + const StreamBuffer &jpegBuffer, bool success) { + status_t res; + if (!success) { + ALOGE("%s: Error queueing compressed image buffer %p", + __FUNCTION__, jpegBuffer.buffer); + mParent->signalError(); + return; + } + + // Write to JPEG output stream + ALOGV("%s: Compression complete, pushing to stream %d", __FUNCTION__, + jpegBuffer.streamId); + + GraphicBufferMapper::get().unlock(*(jpegBuffer.buffer)); + const Stream &s = mParent->getStreamInfo(jpegBuffer.streamId); + res = s.ops->enqueue_buffer(s.ops, mJpegTimestamp, jpegBuffer.buffer); +} + +void EmulatedFakeCamera2::ReadoutThread::onJpegInputDone( + const StreamBuffer &inputBuffer) { + status_t res; + GraphicBufferMapper::get().unlock(*(inputBuffer.buffer)); + const ReprocessStream &s = + mParent->getReprocessStreamInfo(-inputBuffer.streamId); + res = s.ops->release_buffer(s.ops, inputBuffer.buffer); + if (res != OK) { + ALOGE("Error releasing reprocess buffer %p: %s (%d)", + inputBuffer.buffer, strerror(-res), res); + mParent->signalError(); + } +} + +status_t EmulatedFakeCamera2::ReadoutThread::collectStatisticsMetadata( + camera_metadata_t *frame) { + // Completely fake face rectangles, don't correspond to real faces in scene + ALOGV("Readout: Collecting statistics metadata"); + + status_t res; + camera_metadata_entry_t entry; + res = find_camera_metadata_entry(frame, + ANDROID_STATISTICS_FACE_DETECT_MODE, + &entry); + if (res != OK) { + ALOGE("%s: Unable to find face detect mode!", __FUNCTION__); + return BAD_VALUE; + } + + if (entry.data.u8[0] == ANDROID_STATISTICS_FACE_DETECT_MODE_OFF) return OK; + + // The coordinate system for the face regions is the raw sensor pixel + // coordinates. Here, we map from the scene coordinates (0-19 in both axis) + // to raw pixels, for the scene defined in fake-pipeline2/Scene.cpp. We + // approximately place two faces on top of the windows of the house. No + // actual faces exist there, but might one day. Note that this doesn't + // account for the offsets used to account for aspect ratio differences, so + // the rectangles don't line up quite right. + const size_t numFaces = 2; + int32_t rects[numFaces * 4] = { + static_cast(Sensor::kResolution[0] * 10 / 20), + static_cast(Sensor::kResolution[1] * 15 / 20), + static_cast(Sensor::kResolution[0] * 12 / 20), + static_cast(Sensor::kResolution[1] * 17 / 20), + + static_cast(Sensor::kResolution[0] * 16 / 20), + static_cast(Sensor::kResolution[1] * 15 / 20), + static_cast(Sensor::kResolution[0] * 18 / 20), + static_cast(Sensor::kResolution[1] * 17 / 20) + }; + // To simulate some kind of real detection going on, we jitter the rectangles on + // each frame by a few pixels in each dimension. + for (size_t i = 0; i < numFaces * 4; i++) { + rects[i] += (int32_t)(((float)rand() / RAND_MAX) * 6 - 3); + } + // The confidence scores (0-100) are similarly jittered. + uint8_t scores[numFaces] = { 85, 95 }; + for (size_t i = 0; i < numFaces; i++) { + scores[i] += (int32_t)(((float)rand() / RAND_MAX) * 10 - 5); + } + + res = add_camera_metadata_entry(frame, ANDROID_STATISTICS_FACE_RECTANGLES, + rects, numFaces * 4); + if (res != OK) { + ALOGE("%s: Unable to add face rectangles!", __FUNCTION__); + return BAD_VALUE; + } + + res = add_camera_metadata_entry(frame, ANDROID_STATISTICS_FACE_SCORES, + scores, numFaces); + if (res != OK) { + ALOGE("%s: Unable to add face scores!", __FUNCTION__); + return BAD_VALUE; + } + + if (entry.data.u8[0] == ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE) return OK; + + // Advanced face detection options - add eye/mouth coordinates. The + // coordinates in order are (leftEyeX, leftEyeY, rightEyeX, rightEyeY, + // mouthX, mouthY). The mapping is the same as the face rectangles. + int32_t features[numFaces * 6] = { + static_cast(Sensor::kResolution[0] * 10.5 / 20), + static_cast(Sensor::kResolution[1] * 16 / 20), + static_cast(Sensor::kResolution[0] * 11.5 / 20), + static_cast(Sensor::kResolution[1] * 16 / 20), + static_cast(Sensor::kResolution[0] * 11 / 20), + static_cast(Sensor::kResolution[1] * 16.5 / 20), + + static_cast(Sensor::kResolution[0] * 16.5 / 20), + static_cast(Sensor::kResolution[1] * 16 / 20), + static_cast(Sensor::kResolution[0] * 17.5 / 20), + static_cast(Sensor::kResolution[1] * 16 / 20), + static_cast(Sensor::kResolution[0] * 17 / 20), + static_cast(Sensor::kResolution[1] * 16.5 / 20), + }; + // Jitter these a bit less than the rects + for (size_t i = 0; i < numFaces * 6; i++) { + features[i] += (int32_t)(((float)rand() / RAND_MAX) * 4 - 2); + } + // These are unique IDs that are used to identify each face while it's + // visible to the detector (if a face went away and came back, it'd get a + // new ID). + int32_t ids[numFaces] = { + 100, 200 + }; + + res = add_camera_metadata_entry(frame, ANDROID_STATISTICS_FACE_LANDMARKS, + features, numFaces * 6); + if (res != OK) { + ALOGE("%s: Unable to add face landmarks!", __FUNCTION__); + return BAD_VALUE; + } + + res = add_camera_metadata_entry(frame, ANDROID_STATISTICS_FACE_IDS, + ids, numFaces); + if (res != OK) { + ALOGE("%s: Unable to add face scores!", __FUNCTION__); + return BAD_VALUE; + } + + return OK; +} + +EmulatedFakeCamera2::ControlThread::ControlThread(EmulatedFakeCamera2 *parent): + Thread(false), + mParent(parent) { + mRunning = false; +} + +EmulatedFakeCamera2::ControlThread::~ControlThread() { +} + +status_t EmulatedFakeCamera2::ControlThread::readyToRun() { + Mutex::Autolock lock(mInputMutex); + + ALOGV("Starting up ControlThread"); + mRunning = true; + mStartAf = false; + mCancelAf = false; + mStartPrecapture = false; + + mControlMode = ANDROID_CONTROL_MODE_AUTO; + + mEffectMode = ANDROID_CONTROL_EFFECT_MODE_OFF; + mSceneMode = ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY; + + mAfMode = ANDROID_CONTROL_AF_MODE_AUTO; + mAfModeChange = false; + + mAeMode = ANDROID_CONTROL_AE_MODE_ON; + mAwbMode = ANDROID_CONTROL_AWB_MODE_AUTO; + + mAfTriggerId = 0; + mPrecaptureTriggerId = 0; + + mAfState = ANDROID_CONTROL_AF_STATE_INACTIVE; + mAeState = ANDROID_CONTROL_AE_STATE_INACTIVE; + mAwbState = ANDROID_CONTROL_AWB_STATE_INACTIVE; + + mExposureTime = kNormalExposureTime; + + mInputSignal.signal(); + return NO_ERROR; +} + +status_t EmulatedFakeCamera2::ControlThread::waitUntilRunning() { + Mutex::Autolock lock(mInputMutex); + if (!mRunning) { + ALOGV("Waiting for control thread to start"); + mInputSignal.wait(mInputMutex); + } + return OK; +} + +// Override android.control.* fields with 3A values before sending request to sensor +status_t EmulatedFakeCamera2::ControlThread::processRequest(camera_metadata_t *request) { + Mutex::Autolock lock(mInputMutex); + // TODO: Add handling for all android.control.* fields here + camera_metadata_entry_t mode; + status_t res; + +#define READ_IF_OK(res, what, def) \ + (((res) == OK) ? (what) : (uint8_t)(def)) + + res = find_camera_metadata_entry(request, + ANDROID_CONTROL_MODE, + &mode); + mControlMode = READ_IF_OK(res, mode.data.u8[0], ANDROID_CONTROL_MODE_OFF); + + // disable all 3A + if (mControlMode == ANDROID_CONTROL_MODE_OFF) { + mEffectMode = ANDROID_CONTROL_EFFECT_MODE_OFF; + mSceneMode = ANDROID_CONTROL_SCENE_MODE_DISABLED; + mAfMode = ANDROID_CONTROL_AF_MODE_OFF; + mAeLock = ANDROID_CONTROL_AE_LOCK_ON; + mAeMode = ANDROID_CONTROL_AE_MODE_OFF; + mAfModeChange = true; + mStartAf = false; + mCancelAf = true; + mAeState = ANDROID_CONTROL_AE_STATE_INACTIVE; + mAwbMode = ANDROID_CONTROL_AWB_MODE_OFF; + return res; + } + + res = find_camera_metadata_entry(request, + ANDROID_CONTROL_EFFECT_MODE, + &mode); + mEffectMode = READ_IF_OK(res, mode.data.u8[0], + ANDROID_CONTROL_EFFECT_MODE_OFF); + + res = find_camera_metadata_entry(request, + ANDROID_CONTROL_SCENE_MODE, + &mode); + mSceneMode = READ_IF_OK(res, mode.data.u8[0], + ANDROID_CONTROL_SCENE_MODE_DISABLED); + + res = find_camera_metadata_entry(request, + ANDROID_CONTROL_AF_MODE, + &mode); + if (mAfMode != mode.data.u8[0]) { + ALOGV("AF new mode: %d, old mode %d", mode.data.u8[0], mAfMode); + mAfMode = mode.data.u8[0]; + mAfModeChange = true; + mStartAf = false; + mCancelAf = false; + } + + res = find_camera_metadata_entry(request, + ANDROID_CONTROL_AE_MODE, + &mode); + mAeMode = READ_IF_OK(res, mode.data.u8[0], + ANDROID_CONTROL_AE_MODE_OFF); + + res = find_camera_metadata_entry(request, + ANDROID_CONTROL_AE_LOCK, + &mode); + uint8_t aeLockVal = READ_IF_OK(res, mode.data.u8[0], + ANDROID_CONTROL_AE_LOCK_ON); + bool aeLock = (aeLockVal == ANDROID_CONTROL_AE_LOCK_ON); + if (mAeLock && !aeLock) { + mAeState = ANDROID_CONTROL_AE_STATE_INACTIVE; + } + mAeLock = aeLock; + + res = find_camera_metadata_entry(request, + ANDROID_CONTROL_AWB_MODE, + &mode); + mAwbMode = READ_IF_OK(res, mode.data.u8[0], + ANDROID_CONTROL_AWB_MODE_OFF); + + // TODO: Override more control fields + + if (mAeMode != ANDROID_CONTROL_AE_MODE_OFF) { + camera_metadata_entry_t exposureTime; + res = find_camera_metadata_entry(request, + ANDROID_SENSOR_EXPOSURE_TIME, + &exposureTime); + if (res == OK) { + exposureTime.data.i64[0] = mExposureTime; + } + } + +#undef READ_IF_OK + + return OK; +} + +status_t EmulatedFakeCamera2::ControlThread::triggerAction(uint32_t msgType, + int32_t ext1, int32_t ext2) { + ALOGV("%s: Triggering %d (%d, %d)", __FUNCTION__, msgType, ext1, ext2); + Mutex::Autolock lock(mInputMutex); + switch (msgType) { + case CAMERA2_TRIGGER_AUTOFOCUS: + mAfTriggerId = ext1; + mStartAf = true; + mCancelAf = false; + break; + case CAMERA2_TRIGGER_CANCEL_AUTOFOCUS: + mAfTriggerId = ext1; + mStartAf = false; + mCancelAf = true; + break; + case CAMERA2_TRIGGER_PRECAPTURE_METERING: + mPrecaptureTriggerId = ext1; + mStartPrecapture = true; + break; + default: + ALOGE("%s: Unknown action triggered: %d (arguments %d %d)", + __FUNCTION__, msgType, ext1, ext2); + return BAD_VALUE; + } + return OK; +} + +const nsecs_t EmulatedFakeCamera2::ControlThread::kControlCycleDelay = 100 * MSEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kMinAfDuration = 500 * MSEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kMaxAfDuration = 900 * MSEC; +const float EmulatedFakeCamera2::ControlThread::kAfSuccessRate = 0.9; + // Once every 5 seconds +const float EmulatedFakeCamera2::ControlThread::kContinuousAfStartRate = + kControlCycleDelay / 5.0 * SEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kMinAeDuration = 500 * MSEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kMaxAeDuration = 2 * SEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kMinPrecaptureAeDuration = 100 * MSEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kMaxPrecaptureAeDuration = 400 * MSEC; + // Once every 3 seconds +const float EmulatedFakeCamera2::ControlThread::kAeScanStartRate = + kControlCycleDelay / 3000000000.0; + +const nsecs_t EmulatedFakeCamera2::ControlThread::kNormalExposureTime = 10 * MSEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kExposureJump = 2 * MSEC; +const nsecs_t EmulatedFakeCamera2::ControlThread::kMinExposureTime = 1 * MSEC; + +bool EmulatedFakeCamera2::ControlThread::threadLoop() { + bool afModeChange = false; + bool afTriggered = false; + bool afCancelled = false; + uint8_t afState; + uint8_t afMode; + int32_t afTriggerId; + bool precaptureTriggered = false; + uint8_t aeState; + uint8_t aeMode; + bool aeLock; + int32_t precaptureTriggerId; + nsecs_t nextSleep = kControlCycleDelay; + + { + Mutex::Autolock lock(mInputMutex); + if (mStartAf) { + ALOGD("Starting AF trigger processing"); + afTriggered = true; + mStartAf = false; + } else if (mCancelAf) { + ALOGD("Starting cancel AF trigger processing"); + afCancelled = true; + mCancelAf = false; + } + afState = mAfState; + afMode = mAfMode; + afModeChange = mAfModeChange; + mAfModeChange = false; + + afTriggerId = mAfTriggerId; + + if(mStartPrecapture) { + ALOGD("Starting precapture trigger processing"); + precaptureTriggered = true; + mStartPrecapture = false; + } + aeState = mAeState; + aeMode = mAeMode; + aeLock = mAeLock; + precaptureTriggerId = mPrecaptureTriggerId; + } + + if (afCancelled || afModeChange) { + ALOGV("Resetting AF state due to cancel/mode change"); + afState = ANDROID_CONTROL_AF_STATE_INACTIVE; + updateAfState(afState, afTriggerId); + mAfScanDuration = 0; + mLockAfterPassiveScan = false; + } + + uint8_t oldAfState = afState; + + if (afTriggered) { + afState = processAfTrigger(afMode, afState); + } + + afState = maybeStartAfScan(afMode, afState); + afState = updateAfScan(afMode, afState, &nextSleep); + updateAfState(afState, afTriggerId); + + if (precaptureTriggered) { + aeState = processPrecaptureTrigger(aeMode, aeState); + } + + aeState = maybeStartAeScan(aeMode, aeLock, aeState); + aeState = updateAeScan(aeMode, aeLock, aeState, &nextSleep); + updateAeState(aeState, precaptureTriggerId); + + int ret; + timespec t; + t.tv_sec = 0; + t.tv_nsec = nextSleep; + do { + ret = nanosleep(&t, &t); + } while (ret != 0); + + if (mAfScanDuration > 0) { + mAfScanDuration -= nextSleep; + } + if (mAeScanDuration > 0) { + mAeScanDuration -= nextSleep; + } + + return true; +} + +int EmulatedFakeCamera2::ControlThread::processAfTrigger(uint8_t afMode, + uint8_t afState) { + switch (afMode) { + case ANDROID_CONTROL_AF_MODE_OFF: + case ANDROID_CONTROL_AF_MODE_EDOF: + // Do nothing + break; + case ANDROID_CONTROL_AF_MODE_MACRO: + case ANDROID_CONTROL_AF_MODE_AUTO: + switch (afState) { + case ANDROID_CONTROL_AF_STATE_INACTIVE: + case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED: + case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: + // Start new focusing cycle + mAfScanDuration = ((double)rand() / RAND_MAX) * + (kMaxAfDuration - kMinAfDuration) + kMinAfDuration; + afState = ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN; + ALOGV("%s: AF scan start, duration %" PRId64 " ms", + __FUNCTION__, mAfScanDuration / 1000000); + break; + case ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN: + // Ignore new request, already scanning + break; + default: + ALOGE("Unexpected AF state in AUTO/MACRO AF mode: %d", + afState); + } + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + switch (afState) { + // Picture mode waits for passive scan to complete + case ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN: + mLockAfterPassiveScan = true; + break; + case ANDROID_CONTROL_AF_STATE_INACTIVE: + afState = ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED; + break; + case ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED: + afState = ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED; + break; + case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED: + case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: + // Must cancel to get out of these states + break; + default: + ALOGE("Unexpected AF state in CONTINUOUS_PICTURE AF mode: %d", + afState); + } + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + switch (afState) { + // Video mode does not wait for passive scan to complete + case ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN: + case ANDROID_CONTROL_AF_STATE_INACTIVE: + afState = ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED; + break; + case ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED: + afState = ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED; + break; + case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED: + case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: + // Must cancel to get out of these states + break; + default: + ALOGE("Unexpected AF state in CONTINUOUS_VIDEO AF mode: %d", + afState); + } + break; + default: + break; + } + return afState; +} + +int EmulatedFakeCamera2::ControlThread::maybeStartAfScan(uint8_t afMode, + uint8_t afState) { + if ((afMode == ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO || + afMode == ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE) && + (afState == ANDROID_CONTROL_AF_STATE_INACTIVE || + afState == ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED)) { + + bool startScan = ((double)rand() / RAND_MAX) < kContinuousAfStartRate; + if (startScan) { + // Start new passive focusing cycle + mAfScanDuration = ((double)rand() / RAND_MAX) * + (kMaxAfDuration - kMinAfDuration) + kMinAfDuration; + afState = ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN; + ALOGV("%s: AF passive scan start, duration %" PRId64 " ms", + __FUNCTION__, mAfScanDuration / 1000000); + } + } + return afState; +} + +int EmulatedFakeCamera2::ControlThread::updateAfScan(uint8_t afMode, + uint8_t afState, nsecs_t *maxSleep) { + if (! (afState == ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN || + afState == ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN ) ) { + return afState; + } + + if (mAfScanDuration <= 0) { + ALOGV("%s: AF scan done", __FUNCTION__); + switch (afMode) { + case ANDROID_CONTROL_AF_MODE_MACRO: + case ANDROID_CONTROL_AF_MODE_AUTO: { + bool success = ((double)rand() / RAND_MAX) < kAfSuccessRate; + if (success) { + afState = ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED; + } else { + afState = ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED; + } + break; + } + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + if (mLockAfterPassiveScan) { + afState = ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED; + mLockAfterPassiveScan = false; + } else { + afState = ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED; + } + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + afState = ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED; + break; + default: + ALOGE("Unexpected AF mode in scan state"); + } + } else { + if (mAfScanDuration <= *maxSleep) { + *maxSleep = mAfScanDuration; + } + } + return afState; +} + +void EmulatedFakeCamera2::ControlThread::updateAfState(uint8_t newState, + int32_t triggerId) { + Mutex::Autolock lock(mInputMutex); + if (mAfState != newState) { + ALOGV("%s: Autofocus state now %d, id %d", __FUNCTION__, + newState, triggerId); + mAfState = newState; + mParent->sendNotification(CAMERA2_MSG_AUTOFOCUS, + newState, triggerId, 0); + } +} + +int EmulatedFakeCamera2::ControlThread::processPrecaptureTrigger(uint8_t aeMode, + uint8_t aeState) { + switch (aeMode) { + case ANDROID_CONTROL_AE_MODE_OFF: + // Don't do anything for these + return aeState; + case ANDROID_CONTROL_AE_MODE_ON: + case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH: + case ANDROID_CONTROL_AE_MODE_ON_ALWAYS_FLASH: + case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE: + // Trigger a precapture cycle + aeState = ANDROID_CONTROL_AE_STATE_PRECAPTURE; + mAeScanDuration = ((double)rand() / RAND_MAX) * + (kMaxPrecaptureAeDuration - kMinPrecaptureAeDuration) + + kMinPrecaptureAeDuration; + ALOGD("%s: AE precapture scan start, duration %" PRId64 " ms", + __FUNCTION__, mAeScanDuration / 1000000); + + } + return aeState; +} + +int EmulatedFakeCamera2::ControlThread::maybeStartAeScan(uint8_t aeMode, + bool aeLocked, + uint8_t aeState) { + if (aeLocked) return aeState; + switch (aeMode) { + case ANDROID_CONTROL_AE_MODE_OFF: + break; + case ANDROID_CONTROL_AE_MODE_ON: + case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH: + case ANDROID_CONTROL_AE_MODE_ON_ALWAYS_FLASH: + case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE: { + if (aeState != ANDROID_CONTROL_AE_STATE_INACTIVE && + aeState != ANDROID_CONTROL_AE_STATE_CONVERGED) break; + + bool startScan = ((double)rand() / RAND_MAX) < kAeScanStartRate; + if (startScan) { + mAeScanDuration = ((double)rand() / RAND_MAX) * + (kMaxAeDuration - kMinAeDuration) + kMinAeDuration; + aeState = ANDROID_CONTROL_AE_STATE_SEARCHING; + ALOGV("%s: AE scan start, duration %" PRId64 " ms", + __FUNCTION__, mAeScanDuration / 1000000); + } + } + } + + return aeState; +} + +int EmulatedFakeCamera2::ControlThread::updateAeScan(uint8_t aeMode, + bool aeLock, uint8_t aeState, nsecs_t *maxSleep) { + if (aeLock && aeState != ANDROID_CONTROL_AE_STATE_PRECAPTURE) { + mAeScanDuration = 0; + aeState = ANDROID_CONTROL_AE_STATE_LOCKED; + } else if ((aeState == ANDROID_CONTROL_AE_STATE_SEARCHING) || + (aeState == ANDROID_CONTROL_AE_STATE_PRECAPTURE ) ) { + if (mAeScanDuration <= 0) { + ALOGV("%s: AE scan done", __FUNCTION__); + aeState = aeLock ? + ANDROID_CONTROL_AE_STATE_LOCKED :ANDROID_CONTROL_AE_STATE_CONVERGED; + + Mutex::Autolock lock(mInputMutex); + mExposureTime = kNormalExposureTime; + } else { + if (mAeScanDuration <= *maxSleep) { + *maxSleep = mAeScanDuration; + } + + int64_t exposureDelta = + ((double)rand() / RAND_MAX) * 2 * kExposureJump - + kExposureJump; + Mutex::Autolock lock(mInputMutex); + mExposureTime = mExposureTime + exposureDelta; + if (mExposureTime < kMinExposureTime) mExposureTime = kMinExposureTime; + } + } + + return aeState; +} + + +void EmulatedFakeCamera2::ControlThread::updateAeState(uint8_t newState, + int32_t triggerId) { + Mutex::Autolock lock(mInputMutex); + if (mAeState != newState) { + ALOGV("%s: Autoexposure state now %d, id %d", __FUNCTION__, + newState, triggerId); + mAeState = newState; + mParent->sendNotification(CAMERA2_MSG_AUTOEXPOSURE, + newState, triggerId, 0); + } +} + +/** Private methods */ + +status_t EmulatedFakeCamera2::constructStaticInfo( + camera_metadata_t **info, + bool sizeRequest) const { + + size_t entryCount = 0; + size_t dataCount = 0; + status_t ret; + +#define ADD_OR_SIZE( tag, data, count ) \ + if ( ( ret = addOrSize(*info, sizeRequest, &entryCount, &dataCount, \ + tag, data, count) ) != OK ) return ret + + // android.lens + + // 5 cm min focus distance for back camera, infinity (fixed focus) for front + const float minFocusDistance = mFacingBack ? 1.0/0.05 : 0.0; + ADD_OR_SIZE(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, + &minFocusDistance, 1); + // 5 m hyperfocal distance for back camera, infinity (fixed focus) for front + const float hyperFocalDistance = mFacingBack ? 1.0/5.0 : 0.0; + ADD_OR_SIZE(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, + &minFocusDistance, 1); + + static const float focalLength = 3.30f; // mm + ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, + &focalLength, 1); + static const float aperture = 2.8f; + ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_APERTURES, + &aperture, 1); + static const float filterDensity = 0; + ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES, + &filterDensity, 1); + static const uint8_t availableOpticalStabilization = + ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF; + ADD_OR_SIZE(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, + &availableOpticalStabilization, 1); + + static const int32_t lensShadingMapSize[] = {1, 1}; + ADD_OR_SIZE(ANDROID_LENS_INFO_SHADING_MAP_SIZE, lensShadingMapSize, + sizeof(lensShadingMapSize)/sizeof(int32_t)); + + int32_t lensFacing = mFacingBack ? + ANDROID_LENS_FACING_BACK : ANDROID_LENS_FACING_FRONT; + ADD_OR_SIZE(ANDROID_LENS_FACING, &lensFacing, 1); + + // android.sensor + + ADD_OR_SIZE(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, + Sensor::kExposureTimeRange, 2); + + ADD_OR_SIZE(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, + &Sensor::kFrameDurationRange[1], 1); + + ADD_OR_SIZE(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, + Sensor::kSensitivityRange, + sizeof(Sensor::kSensitivityRange) + /sizeof(int32_t)); + + ADD_OR_SIZE(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, + &Sensor::kColorFilterArrangement, 1); + + static const float sensorPhysicalSize[2] = {3.20f, 2.40f}; // mm + ADD_OR_SIZE(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + sensorPhysicalSize, 2); + + ADD_OR_SIZE(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, + Sensor::kResolution, 2); + + ADD_OR_SIZE(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, + Sensor::kResolution, 2); + + ADD_OR_SIZE(ANDROID_SENSOR_INFO_WHITE_LEVEL, + &Sensor::kMaxRawValue, 1); + + static const int32_t blackLevelPattern[4] = { + static_cast(Sensor::kBlackLevel), + static_cast(Sensor::kBlackLevel), + static_cast(Sensor::kBlackLevel), + static_cast(Sensor::kBlackLevel) + }; + ADD_OR_SIZE(ANDROID_SENSOR_BLACK_LEVEL_PATTERN, + blackLevelPattern, sizeof(blackLevelPattern)/sizeof(int32_t)); + + //TODO: sensor color calibration fields + + // android.flash + static const uint8_t flashAvailable = 0; + ADD_OR_SIZE(ANDROID_FLASH_INFO_AVAILABLE, &flashAvailable, 1); + + static const int64_t flashChargeDuration = 0; + ADD_OR_SIZE(ANDROID_FLASH_INFO_CHARGE_DURATION, &flashChargeDuration, 1); + + // android.tonemap + + static const int32_t tonemapCurvePoints = 128; + ADD_OR_SIZE(ANDROID_TONEMAP_MAX_CURVE_POINTS, &tonemapCurvePoints, 1); + + // android.scaler + + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_FORMATS, + kAvailableFormats, + sizeof(kAvailableFormats)/sizeof(uint32_t)); + + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_SIZES, + kAvailableRawSizes, + sizeof(kAvailableRawSizes)/sizeof(uint32_t)); + + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS, + kAvailableRawMinDurations, + sizeof(kAvailableRawMinDurations)/sizeof(uint64_t)); + + if (mFacingBack) { + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, + kAvailableProcessedSizesBack, + sizeof(kAvailableProcessedSizesBack)/sizeof(uint32_t)); + } else { + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, + kAvailableProcessedSizesFront, + sizeof(kAvailableProcessedSizesFront)/sizeof(uint32_t)); + } + + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS, + kAvailableProcessedMinDurations, + sizeof(kAvailableProcessedMinDurations)/sizeof(uint64_t)); + + if (mFacingBack) { + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES, + kAvailableJpegSizesBack, + sizeof(kAvailableJpegSizesBack)/sizeof(uint32_t)); + } else { + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_SIZES, + kAvailableJpegSizesFront, + sizeof(kAvailableJpegSizesFront)/sizeof(uint32_t)); + } + + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS, + kAvailableJpegMinDurations, + sizeof(kAvailableJpegMinDurations)/sizeof(uint64_t)); + + static const float maxZoom = 10; + ADD_OR_SIZE(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, + &maxZoom, 1); + + // android.jpeg + + static const int32_t jpegThumbnailSizes[] = { + 0, 0, + 160, 120, + 320, 240 + }; + ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, + jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t)); + + static const int32_t jpegMaxSize = JpegCompressor::kMaxJpegSize; + ADD_OR_SIZE(ANDROID_JPEG_MAX_SIZE, &jpegMaxSize, 1); + + // android.stats + + static const uint8_t availableFaceDetectModes[] = { + ANDROID_STATISTICS_FACE_DETECT_MODE_OFF, + ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE, + ANDROID_STATISTICS_FACE_DETECT_MODE_FULL + }; + + ADD_OR_SIZE(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, + availableFaceDetectModes, + sizeof(availableFaceDetectModes)); + + static const int32_t maxFaceCount = 8; + ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, + &maxFaceCount, 1); + + static const int32_t histogramSize = 64; + ADD_OR_SIZE(ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT, + &histogramSize, 1); + + static const int32_t maxHistogramCount = 1000; + ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT, + &maxHistogramCount, 1); + + static const int32_t sharpnessMapSize[2] = {64, 64}; + ADD_OR_SIZE(ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE, + sharpnessMapSize, sizeof(sharpnessMapSize)/sizeof(int32_t)); + + static const int32_t maxSharpnessMapValue = 1000; + ADD_OR_SIZE(ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE, + &maxSharpnessMapValue, 1); + + // android.control + + static const uint8_t availableSceneModes[] = { + ANDROID_CONTROL_SCENE_MODE_DISABLED + }; + ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_SCENE_MODES, + availableSceneModes, sizeof(availableSceneModes)); + + static const uint8_t availableEffects[] = { + ANDROID_CONTROL_EFFECT_MODE_OFF + }; + ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS, + availableEffects, sizeof(availableEffects)); + + static const int32_t max3aRegions[] = {/*AE*/ 0,/*AWB*/ 0,/*AF*/ 0}; + ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS, + max3aRegions, sizeof(max3aRegions)/sizeof(max3aRegions[0])); + + static const uint8_t availableAeModes[] = { + ANDROID_CONTROL_AE_MODE_OFF, + ANDROID_CONTROL_AE_MODE_ON + }; + ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES, + availableAeModes, sizeof(availableAeModes)); + + static const camera_metadata_rational exposureCompensationStep = { + 1, 3 + }; + ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_STEP, + &exposureCompensationStep, 1); + + int32_t exposureCompensationRange[] = {-9, 9}; + ADD_OR_SIZE(ANDROID_CONTROL_AE_COMPENSATION_RANGE, + exposureCompensationRange, + sizeof(exposureCompensationRange)/sizeof(int32_t)); + + static const int32_t availableTargetFpsRanges[] = { + 5, 30, 15, 30 + }; + ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + availableTargetFpsRanges, + sizeof(availableTargetFpsRanges)/sizeof(int32_t)); + + static const uint8_t availableAntibandingModes[] = { + ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF, + ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO + }; + ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, + availableAntibandingModes, sizeof(availableAntibandingModes)); + + static const uint8_t availableAwbModes[] = { + ANDROID_CONTROL_AWB_MODE_OFF, + ANDROID_CONTROL_AWB_MODE_AUTO, + ANDROID_CONTROL_AWB_MODE_INCANDESCENT, + ANDROID_CONTROL_AWB_MODE_FLUORESCENT, + ANDROID_CONTROL_AWB_MODE_DAYLIGHT, + ANDROID_CONTROL_AWB_MODE_SHADE + }; + ADD_OR_SIZE(ANDROID_CONTROL_AWB_AVAILABLE_MODES, + availableAwbModes, sizeof(availableAwbModes)); + + static const uint8_t availableAfModesBack[] = { + ANDROID_CONTROL_AF_MODE_OFF, + ANDROID_CONTROL_AF_MODE_AUTO, + ANDROID_CONTROL_AF_MODE_MACRO, + ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO, + ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE + }; + + static const uint8_t availableAfModesFront[] = { + ANDROID_CONTROL_AF_MODE_OFF + }; + + if (mFacingBack) { + ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES, + availableAfModesBack, sizeof(availableAfModesBack)); + } else { + ADD_OR_SIZE(ANDROID_CONTROL_AF_AVAILABLE_MODES, + availableAfModesFront, sizeof(availableAfModesFront)); + } + + static const uint8_t availableVstabModes[] = { + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF + }; + ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, + availableVstabModes, sizeof(availableVstabModes)); + +#undef ADD_OR_SIZE + /** Allocate metadata if sizing */ + if (sizeRequest) { + ALOGV("Allocating %zu entries, %zu extra bytes for " + "static camera info", + entryCount, dataCount); + *info = allocate_camera_metadata(entryCount, dataCount); + if (*info == NULL) { + ALOGE("Unable to allocate camera static info" + "(%zu entries, %zu bytes extra data)", + entryCount, dataCount); + return NO_MEMORY; + } + } + return OK; +} + +status_t EmulatedFakeCamera2::constructDefaultRequest( + int request_template, + camera_metadata_t **request, + bool sizeRequest) const { + + size_t entryCount = 0; + size_t dataCount = 0; + status_t ret; + +#define ADD_OR_SIZE( tag, data, count ) \ + if ( ( ret = addOrSize(*request, sizeRequest, &entryCount, &dataCount, \ + tag, data, count) ) != OK ) return ret + + /** android.request */ + + static const uint8_t requestType = ANDROID_REQUEST_TYPE_CAPTURE; + ADD_OR_SIZE(ANDROID_REQUEST_TYPE, &requestType, 1); + + static const uint8_t metadataMode = ANDROID_REQUEST_METADATA_MODE_FULL; + ADD_OR_SIZE(ANDROID_REQUEST_METADATA_MODE, &metadataMode, 1); + + static const int32_t id = 0; + ADD_OR_SIZE(ANDROID_REQUEST_ID, &id, 1); + + static const int32_t frameCount = 0; + ADD_OR_SIZE(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1); + + // OUTPUT_STREAMS set by user + entryCount += 1; + dataCount += 5; // TODO: Should be maximum stream number + + /** android.lens */ + + static const float focusDistance = 0; + ADD_OR_SIZE(ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1); + + static const float aperture = 2.8f; + ADD_OR_SIZE(ANDROID_LENS_APERTURE, &aperture, 1); + + static const float focalLength = 5.0f; + ADD_OR_SIZE(ANDROID_LENS_FOCAL_LENGTH, &focalLength, 1); + + static const float filterDensity = 0; + ADD_OR_SIZE(ANDROID_LENS_FILTER_DENSITY, &filterDensity, 1); + + static const uint8_t opticalStabilizationMode = + ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF; + ADD_OR_SIZE(ANDROID_LENS_OPTICAL_STABILIZATION_MODE, + &opticalStabilizationMode, 1); + + // FOCUS_RANGE set only in frame + + /** android.sensor */ + + static const int64_t exposureTime = 10 * MSEC; + ADD_OR_SIZE(ANDROID_SENSOR_EXPOSURE_TIME, &exposureTime, 1); + + static const int64_t frameDuration = 33333333L; // 1/30 s + ADD_OR_SIZE(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1); + + static const int32_t sensitivity = 100; + ADD_OR_SIZE(ANDROID_SENSOR_SENSITIVITY, &sensitivity, 1); + + // TIMESTAMP set only in frame + + /** android.flash */ + + static const uint8_t flashMode = ANDROID_FLASH_MODE_OFF; + ADD_OR_SIZE(ANDROID_FLASH_MODE, &flashMode, 1); + + static const uint8_t flashPower = 10; + ADD_OR_SIZE(ANDROID_FLASH_FIRING_POWER, &flashPower, 1); + + static const int64_t firingTime = 0; + ADD_OR_SIZE(ANDROID_FLASH_FIRING_TIME, &firingTime, 1); + + /** Processing block modes */ + uint8_t hotPixelMode = 0; + uint8_t demosaicMode = 0; + uint8_t noiseMode = 0; + uint8_t shadingMode = 0; + uint8_t colorMode = 0; + uint8_t tonemapMode = 0; + uint8_t edgeMode = 0; + switch (request_template) { + case CAMERA2_TEMPLATE_STILL_CAPTURE: + // fall-through + case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT: + // fall-through + case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG: + hotPixelMode = ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY; + demosaicMode = ANDROID_DEMOSAIC_MODE_HIGH_QUALITY; + noiseMode = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY; + shadingMode = ANDROID_SHADING_MODE_HIGH_QUALITY; + colorMode = ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY; + tonemapMode = ANDROID_TONEMAP_MODE_HIGH_QUALITY; + edgeMode = ANDROID_EDGE_MODE_HIGH_QUALITY; + break; + case CAMERA2_TEMPLATE_PREVIEW: + // fall-through + case CAMERA2_TEMPLATE_VIDEO_RECORD: + // fall-through + default: + hotPixelMode = ANDROID_HOT_PIXEL_MODE_FAST; + demosaicMode = ANDROID_DEMOSAIC_MODE_FAST; + noiseMode = ANDROID_NOISE_REDUCTION_MODE_FAST; + shadingMode = ANDROID_SHADING_MODE_FAST; + colorMode = ANDROID_COLOR_CORRECTION_MODE_FAST; + tonemapMode = ANDROID_TONEMAP_MODE_FAST; + edgeMode = ANDROID_EDGE_MODE_FAST; + break; + } + ADD_OR_SIZE(ANDROID_HOT_PIXEL_MODE, &hotPixelMode, 1); + ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1); + ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_MODE, &noiseMode, 1); + ADD_OR_SIZE(ANDROID_SHADING_MODE, &shadingMode, 1); + ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_MODE, &colorMode, 1); + ADD_OR_SIZE(ANDROID_TONEMAP_MODE, &tonemapMode, 1); + ADD_OR_SIZE(ANDROID_EDGE_MODE, &edgeMode, 1); + + /** android.noise */ + static const uint8_t noiseStrength = 5; + ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_STRENGTH, &noiseStrength, 1); + + /** android.color */ + static const float colorTransform[9] = { + 1.0f, 0.f, 0.f, + 0.f, 1.f, 0.f, + 0.f, 0.f, 1.f + }; + ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_TRANSFORM, colorTransform, 9); + + /** android.tonemap */ + static const float tonemapCurve[4] = { + 0.f, 0.f, + 1.f, 1.f + }; + ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_RED, tonemapCurve, 4); + ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_GREEN, tonemapCurve, 4); + ADD_OR_SIZE(ANDROID_TONEMAP_CURVE_BLUE, tonemapCurve, 4); + + /** android.edge */ + static const uint8_t edgeStrength = 5; + ADD_OR_SIZE(ANDROID_EDGE_STRENGTH, &edgeStrength, 1); + + /** android.scaler */ + static const int32_t cropRegion[3] = { + 0, 0, static_cast(Sensor::kResolution[0]) + }; + ADD_OR_SIZE(ANDROID_SCALER_CROP_REGION, cropRegion, 3); + + /** android.jpeg */ + static const int32_t jpegQuality = 80; + ADD_OR_SIZE(ANDROID_JPEG_QUALITY, &jpegQuality, 1); + + static const int32_t thumbnailSize[2] = { + 640, 480 + }; + ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2); + + static const int32_t thumbnailQuality = 80; + ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_QUALITY, &thumbnailQuality, 1); + + static const double gpsCoordinates[2] = { + 0, 0 + }; + ADD_OR_SIZE(ANDROID_JPEG_GPS_COORDINATES, gpsCoordinates, 2); + + static const uint8_t gpsProcessingMethod[32] = "None"; + ADD_OR_SIZE(ANDROID_JPEG_GPS_PROCESSING_METHOD, gpsProcessingMethod, 32); + + static const int64_t gpsTimestamp = 0; + ADD_OR_SIZE(ANDROID_JPEG_GPS_TIMESTAMP, &gpsTimestamp, 1); + + static const int32_t jpegOrientation = 0; + ADD_OR_SIZE(ANDROID_JPEG_ORIENTATION, &jpegOrientation, 1); + + /** android.stats */ + + static const uint8_t faceDetectMode = + ANDROID_STATISTICS_FACE_DETECT_MODE_OFF; + ADD_OR_SIZE(ANDROID_STATISTICS_FACE_DETECT_MODE, &faceDetectMode, 1); + + static const uint8_t histogramMode = ANDROID_STATISTICS_HISTOGRAM_MODE_OFF; + ADD_OR_SIZE(ANDROID_STATISTICS_HISTOGRAM_MODE, &histogramMode, 1); + + static const uint8_t sharpnessMapMode = + ANDROID_STATISTICS_SHARPNESS_MAP_MODE_OFF; + ADD_OR_SIZE(ANDROID_STATISTICS_SHARPNESS_MAP_MODE, &sharpnessMapMode, 1); + + // faceRectangles, faceScores, faceLandmarks, faceIds, histogram, + // sharpnessMap only in frames + + /** android.control */ + + uint8_t controlIntent = 0; + switch (request_template) { + case CAMERA2_TEMPLATE_PREVIEW: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW; + break; + case CAMERA2_TEMPLATE_STILL_CAPTURE: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE; + break; + case CAMERA2_TEMPLATE_VIDEO_RECORD: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD; + break; + case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT; + break; + case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG; + break; + default: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM; + break; + } + ADD_OR_SIZE(ANDROID_CONTROL_CAPTURE_INTENT, &controlIntent, 1); + + static const uint8_t controlMode = ANDROID_CONTROL_MODE_AUTO; + ADD_OR_SIZE(ANDROID_CONTROL_MODE, &controlMode, 1); + + static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_MODE_OFF; + ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1); + + static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY; + ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1); + + static const uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH; + ADD_OR_SIZE(ANDROID_CONTROL_AE_MODE, &aeMode, 1); + + static const uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF; + ADD_OR_SIZE(ANDROID_CONTROL_AE_LOCK, &aeLock, 1); + + static const int32_t controlRegions[5] = { + 0, 0, + static_cast(Sensor::kResolution[0]), + static_cast(Sensor::kResolution[1]), + 1000 + }; + ADD_OR_SIZE(ANDROID_CONTROL_AE_REGIONS, controlRegions, 5); + + static const int32_t aeExpCompensation = 0; + ADD_OR_SIZE(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, &aeExpCompensation, 1); + + static const int32_t aeTargetFpsRange[2] = { + 10, 30 + }; + ADD_OR_SIZE(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, aeTargetFpsRange, 2); + + static const uint8_t aeAntibandingMode = + ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO; + ADD_OR_SIZE(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1); + + static const uint8_t awbMode = + ANDROID_CONTROL_AWB_MODE_AUTO; + ADD_OR_SIZE(ANDROID_CONTROL_AWB_MODE, &awbMode, 1); + + static const uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF; + ADD_OR_SIZE(ANDROID_CONTROL_AWB_LOCK, &awbLock, 1); + + ADD_OR_SIZE(ANDROID_CONTROL_AWB_REGIONS, controlRegions, 5); + + uint8_t afMode = 0; + switch (request_template) { + case CAMERA2_TEMPLATE_PREVIEW: + afMode = ANDROID_CONTROL_AF_MODE_AUTO; + break; + case CAMERA2_TEMPLATE_STILL_CAPTURE: + afMode = ANDROID_CONTROL_AF_MODE_AUTO; + break; + case CAMERA2_TEMPLATE_VIDEO_RECORD: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO; + break; + case CAMERA2_TEMPLATE_VIDEO_SNAPSHOT: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO; + break; + case CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE; + break; + default: + afMode = ANDROID_CONTROL_AF_MODE_AUTO; + break; + } + ADD_OR_SIZE(ANDROID_CONTROL_AF_MODE, &afMode, 1); + + ADD_OR_SIZE(ANDROID_CONTROL_AF_REGIONS, controlRegions, 5); + + static const uint8_t vstabMode = + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF; + ADD_OR_SIZE(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &vstabMode, 1); + + // aeState, awbState, afState only in frame + + /** Allocate metadata if sizing */ + if (sizeRequest) { + ALOGV("Allocating %zu entries, %zu extra bytes for " + "request template type %d", + entryCount, dataCount, request_template); + *request = allocate_camera_metadata(entryCount, dataCount); + if (*request == NULL) { + ALOGE("Unable to allocate new request template type %d " + "(%zu entries, %zu bytes extra data)", request_template, + entryCount, dataCount); + return NO_MEMORY; + } + } + return OK; +#undef ADD_OR_SIZE +} + +status_t EmulatedFakeCamera2::addOrSize(camera_metadata_t *request, + bool sizeRequest, + size_t *entryCount, + size_t *dataCount, + uint32_t tag, + const void *entryData, + size_t entryDataCount) { + status_t res; + if (!sizeRequest) { + return add_camera_metadata_entry(request, tag, entryData, + entryDataCount); + } else { + int type = get_camera_metadata_tag_type(tag); + if (type < 0 ) return BAD_VALUE; + (*entryCount)++; + (*dataCount) += calculate_camera_metadata_entry_data_size(type, + entryDataCount); + return OK; + } +} + +bool EmulatedFakeCamera2::isStreamInUse(uint32_t id) { + // Assumes mMutex is locked; otherwise new requests could enter + // configureThread while readoutThread is being checked + + // Order of isStreamInUse calls matters + if (mConfigureThread->isStreamInUse(id) || + mReadoutThread->isStreamInUse(id) || + mJpegCompressor->isStreamInUse(id) ) { + ALOGE("%s: Stream %d is in use in active requests!", + __FUNCTION__, id); + return true; + } + return false; +} + +bool EmulatedFakeCamera2::isReprocessStreamInUse(uint32_t id) { + // TODO: implement + return false; +} + +const Stream& EmulatedFakeCamera2::getStreamInfo(uint32_t streamId) { + Mutex::Autolock lock(mMutex); + + return mStreams.valueFor(streamId); +} + +const ReprocessStream& EmulatedFakeCamera2::getReprocessStreamInfo(uint32_t streamId) { + Mutex::Autolock lock(mMutex); + + return mReprocessStreams.valueFor(streamId); +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.h new file mode 100644 index 0000000..64c8667 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera2.h @@ -0,0 +1,429 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA2_H +#define HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA2_H + +/* + * Contains declaration of a class EmulatedFakeCamera2 that encapsulates + * functionality of a fake camera that implements version 2 of the camera device + * interface. + */ + +#include "EmulatedCamera2.h" +#include "fake-pipeline2/Base.h" +#include "fake-pipeline2/Sensor.h" +#include "fake-pipeline2/JpegCompressor.h" +#include +#include +#include +#include + +namespace android { + +/* Encapsulates functionality of an advanced fake camera. This camera contains + * a simple simulation of a scene, sensor, and image processing pipeline. + */ +class EmulatedFakeCamera2 : public EmulatedCamera2 { +public: + /* Constructs EmulatedFakeCamera instance. */ + EmulatedFakeCamera2(int cameraId, bool facingBack, struct hw_module_t* module); + + /* Destructs EmulatedFakeCamera instance. */ + ~EmulatedFakeCamera2(); + + /**************************************************************************** + * EmulatedCamera2 virtual overrides. + ***************************************************************************/ + +public: + /* Initializes EmulatedFakeCamera2 instance. */ + status_t Initialize(); + + /**************************************************************************** + * Camera Module API and generic hardware device API implementation + ***************************************************************************/ +public: + + virtual status_t connectCamera(hw_device_t** device); + + virtual status_t plugCamera(); + virtual status_t unplugCamera(); + virtual camera_device_status_t getHotplugStatus(); + + virtual status_t closeCamera(); + + virtual status_t getCameraInfo(struct camera_info *info); + + /**************************************************************************** + * EmulatedCamera2 abstract API implementation. + ***************************************************************************/ +protected: + /** Request input queue */ + + virtual int requestQueueNotify(); + + /** Count of requests in flight */ + virtual int getInProgressCount(); + + /** Cancel all captures in flight */ + //virtual int flushCapturesInProgress(); + + /** Construct default request */ + virtual int constructDefaultRequest( + int request_template, + camera_metadata_t **request); + + virtual int allocateStream( + uint32_t width, + uint32_t height, + int format, + const camera2_stream_ops_t *stream_ops, + uint32_t *stream_id, + uint32_t *format_actual, + uint32_t *usage, + uint32_t *max_buffers); + + virtual int registerStreamBuffers( + uint32_t stream_id, + int num_buffers, + buffer_handle_t *buffers); + + virtual int releaseStream(uint32_t stream_id); + + // virtual int allocateReprocessStream( + // uint32_t width, + // uint32_t height, + // uint32_t format, + // const camera2_stream_ops_t *stream_ops, + // uint32_t *stream_id, + // uint32_t *format_actual, + // uint32_t *usage, + // uint32_t *max_buffers); + + virtual int allocateReprocessStreamFromStream( + uint32_t output_stream_id, + const camera2_stream_in_ops_t *stream_ops, + uint32_t *stream_id); + + virtual int releaseReprocessStream(uint32_t stream_id); + + virtual int triggerAction(uint32_t trigger_id, + int32_t ext1, + int32_t ext2); + + /** Debug methods */ + + virtual int dump(int fd); + +public: + /**************************************************************************** + * Utility methods called by configure/readout threads and pipeline + ***************************************************************************/ + + // Get information about a given stream. Will lock mMutex + const Stream &getStreamInfo(uint32_t streamId); + const ReprocessStream &getReprocessStreamInfo(uint32_t streamId); + + // Notifies rest of camera subsystem of serious error + void signalError(); + +private: + /**************************************************************************** + * Utility methods + ***************************************************************************/ + /** Construct static camera metadata, two-pass */ + status_t constructStaticInfo( + camera_metadata_t **info, + bool sizeRequest) const; + + /** Two-pass implementation of constructDefaultRequest */ + status_t constructDefaultRequest( + int request_template, + camera_metadata_t **request, + bool sizeRequest) const; + /** Helper function for constructDefaultRequest */ + static status_t addOrSize( camera_metadata_t *request, + bool sizeRequest, + size_t *entryCount, + size_t *dataCount, + uint32_t tag, + const void *entry_data, + size_t entry_count); + + /** Determine if the stream id is listed in any currently-in-flight + * requests. Assumes mMutex is locked */ + bool isStreamInUse(uint32_t streamId); + + /** Determine if the reprocess stream id is listed in any + * currently-in-flight requests. Assumes mMutex is locked */ + bool isReprocessStreamInUse(uint32_t streamId); + + /**************************************************************************** + * Pipeline controller threads + ***************************************************************************/ + + class ConfigureThread: public Thread { + public: + ConfigureThread(EmulatedFakeCamera2 *parent); + ~ConfigureThread(); + + status_t waitUntilRunning(); + status_t newRequestAvailable(); + status_t readyToRun(); + + bool isStreamInUse(uint32_t id); + int getInProgressCount(); + private: + EmulatedFakeCamera2 *mParent; + static const nsecs_t kWaitPerLoop = 10000000L; // 10 ms + + bool mRunning; + bool threadLoop(); + + bool setupCapture(); + bool setupReprocess(); + + bool configureNextCapture(); + bool configureNextReprocess(); + + bool getBuffers(); + + Mutex mInputMutex; // Protects mActive, mRequestCount + Condition mInputSignal; + bool mActive; // Whether we're waiting for input requests or actively + // working on them + size_t mRequestCount; + + camera_metadata_t *mRequest; + + Mutex mInternalsMutex; // Lock before accessing below members. + bool mWaitingForReadout; + bool mNextNeedsJpeg; + bool mNextIsCapture; + int32_t mNextFrameNumber; + int64_t mNextExposureTime; + int64_t mNextFrameDuration; + int32_t mNextSensitivity; + Buffers *mNextBuffers; + }; + + class ReadoutThread: public Thread, private JpegCompressor::JpegListener { + public: + ReadoutThread(EmulatedFakeCamera2 *parent); + ~ReadoutThread(); + + status_t readyToRun(); + + // Input + status_t waitUntilRunning(); + bool waitForReady(nsecs_t timeout); + void setNextOperation(bool isCapture, + camera_metadata_t *request, + Buffers *buffers); + bool isStreamInUse(uint32_t id); + int getInProgressCount(); + private: + EmulatedFakeCamera2 *mParent; + + bool mRunning; + bool threadLoop(); + + bool readyForNextCapture(); + status_t collectStatisticsMetadata(camera_metadata_t *frame); + + // Inputs + Mutex mInputMutex; // Protects mActive, mInFlightQueue, mRequestCount + Condition mInputSignal; + Condition mReadySignal; + + bool mActive; + + static const int kInFlightQueueSize = 4; + struct InFlightQueue { + bool isCapture; + camera_metadata_t *request; + Buffers *buffers; + } *mInFlightQueue; + + size_t mInFlightHead; + size_t mInFlightTail; + + size_t mRequestCount; + + // Internals + Mutex mInternalsMutex; + + bool mIsCapture; + camera_metadata_t *mRequest; + Buffers *mBuffers; + + // Jpeg completion listeners + void onJpegDone(const StreamBuffer &jpegBuffer, bool success); + void onJpegInputDone(const StreamBuffer &inputBuffer); + nsecs_t mJpegTimestamp; + }; + + // 3A management thread (auto-exposure, focus, white balance) + class ControlThread: public Thread { + public: + ControlThread(EmulatedFakeCamera2 *parent); + ~ControlThread(); + + status_t readyToRun(); + + status_t waitUntilRunning(); + + // Interpret request's control parameters and override + // capture settings as needed + status_t processRequest(camera_metadata_t *request); + + status_t triggerAction(uint32_t msgType, + int32_t ext1, int32_t ext2); + private: + ControlThread(const ControlThread &t); + ControlThread& operator=(const ControlThread &t); + + // Constants controlling fake 3A behavior + static const nsecs_t kControlCycleDelay; + static const nsecs_t kMinAfDuration; + static const nsecs_t kMaxAfDuration; + static const float kAfSuccessRate; + static const float kContinuousAfStartRate; + + static const float kAeScanStartRate; + static const nsecs_t kMinAeDuration; + static const nsecs_t kMaxAeDuration; + static const nsecs_t kMinPrecaptureAeDuration; + static const nsecs_t kMaxPrecaptureAeDuration; + + static const nsecs_t kNormalExposureTime; + static const nsecs_t kExposureJump; + static const nsecs_t kMinExposureTime; + + EmulatedFakeCamera2 *mParent; + + bool mRunning; + bool threadLoop(); + + Mutex mInputMutex; // Protects input methods + Condition mInputSignal; + + // Trigger notifications + bool mStartAf; + bool mCancelAf; + bool mStartPrecapture; + + // Latest state for 3A request fields + uint8_t mControlMode; + + uint8_t mEffectMode; + uint8_t mSceneMode; + + uint8_t mAfMode; + bool mAfModeChange; + + uint8_t mAwbMode; + uint8_t mAeMode; + + // Latest trigger IDs + int32_t mAfTriggerId; + int32_t mPrecaptureTriggerId; + + // Current state for 3A algorithms + uint8_t mAfState; + uint8_t mAeState; + uint8_t mAwbState; + bool mAeLock; + + // Current control parameters + nsecs_t mExposureTime; + + // Private to threadLoop and its utility methods + + nsecs_t mAfScanDuration; + nsecs_t mAeScanDuration; + bool mLockAfterPassiveScan; + + // Utility methods for AF + int processAfTrigger(uint8_t afMode, uint8_t afState); + int maybeStartAfScan(uint8_t afMode, uint8_t afState); + int updateAfScan(uint8_t afMode, uint8_t afState, nsecs_t *maxSleep); + void updateAfState(uint8_t newState, int32_t triggerId); + + // Utility methods for precapture trigger + int processPrecaptureTrigger(uint8_t aeMode, uint8_t aeState); + int maybeStartAeScan(uint8_t aeMode, bool aeLock, uint8_t aeState); + int updateAeScan(uint8_t aeMode, bool aeLock, uint8_t aeState, + nsecs_t *maxSleep); + void updateAeState(uint8_t newState, int32_t triggerId); + }; + + /**************************************************************************** + * Static configuration information + ***************************************************************************/ +private: + static const uint32_t kMaxRawStreamCount = 1; + static const uint32_t kMaxProcessedStreamCount = 3; + static const uint32_t kMaxJpegStreamCount = 1; + static const uint32_t kMaxReprocessStreamCount = 2; + static const uint32_t kMaxBufferCount = 4; + static const uint32_t kAvailableFormats[]; + static const uint32_t kAvailableRawSizes[]; + static const uint64_t kAvailableRawMinDurations[]; + static const uint32_t kAvailableProcessedSizesBack[]; + static const uint32_t kAvailableProcessedSizesFront[]; + static const uint64_t kAvailableProcessedMinDurations[]; + static const uint32_t kAvailableJpegSizesBack[]; + static const uint32_t kAvailableJpegSizesFront[]; + static const uint64_t kAvailableJpegMinDurations[]; + + /**************************************************************************** + * Data members. + ***************************************************************************/ + +protected: + /* Facing back (true) or front (false) switch. */ + bool mFacingBack; + +private: + bool mIsConnected; + + /** Stream manipulation */ + uint32_t mNextStreamId; + uint32_t mRawStreamCount; + uint32_t mProcessedStreamCount; + uint32_t mJpegStreamCount; + + uint32_t mNextReprocessStreamId; + uint32_t mReprocessStreamCount; + + KeyedVector mStreams; + KeyedVector mReprocessStreams; + + /** Simulated hardware interfaces */ + sp mSensor; + sp mJpegCompressor; + + /** Pipeline control threads */ + sp mConfigureThread; + sp mReadoutThread; + sp mControlThread; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA2_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.cpp new file mode 100644 index 0000000..50d6096 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.cpp @@ -0,0 +1,2519 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedFakeCamera3 that encapsulates + * functionality of an advanced fake camera. + */ + +#include + +//#define LOG_NDEBUG 0 +//#define LOG_NNDEBUG 0 +#define LOG_TAG "EmulatedCamera_FakeCamera3" +#include +#include + +#include "EmulatedFakeCamera3.h" +#include "EmulatedCameraFactory.h" +#include +#include +#include +#include "gralloc_cb.h" + +#include "fake-pipeline2/Sensor.h" +#include "fake-pipeline2/JpegCompressor.h" +#include + +#include + +#if defined(LOG_NNDEBUG) && LOG_NNDEBUG == 0 +#define ALOGVV ALOGV +#else +#define ALOGVV(...) ((void)0) +#endif + +namespace android { + +/** + * Constants for camera capabilities + */ + +const int64_t USEC = 1000LL; +const int64_t MSEC = USEC * 1000LL; +const int64_t SEC = MSEC * 1000LL; + +const int32_t EmulatedFakeCamera3::kAvailableFormats[] = { + HAL_PIXEL_FORMAT_RAW16, + HAL_PIXEL_FORMAT_BLOB, + HAL_PIXEL_FORMAT_RGBA_8888, + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, + // These are handled by YCbCr_420_888 + // HAL_PIXEL_FORMAT_YV12, + // HAL_PIXEL_FORMAT_YCrCb_420_SP, + HAL_PIXEL_FORMAT_YCbCr_420_888, + HAL_PIXEL_FORMAT_Y16 +}; + +/** + * 3A constants + */ + +// Default exposure and gain targets for different scenarios +const nsecs_t EmulatedFakeCamera3::kNormalExposureTime = 10 * MSEC; +const nsecs_t EmulatedFakeCamera3::kFacePriorityExposureTime = 30 * MSEC; +const int EmulatedFakeCamera3::kNormalSensitivity = 100; +const int EmulatedFakeCamera3::kFacePrioritySensitivity = 400; +const float EmulatedFakeCamera3::kExposureTrackRate = 0.1; +const int EmulatedFakeCamera3::kPrecaptureMinFrames = 10; +const int EmulatedFakeCamera3::kStableAeMaxFrames = 100; +const float EmulatedFakeCamera3::kExposureWanderMin = -2; +const float EmulatedFakeCamera3::kExposureWanderMax = 1; + +/** + * Camera device lifecycle methods + */ + +EmulatedFakeCamera3::EmulatedFakeCamera3(int cameraId, bool facingBack, + struct hw_module_t* module) : + EmulatedCamera3(cameraId, module), + mFacingBack(facingBack) { + ALOGI("Constructing emulated fake camera 3: ID %d, facing %s", + mCameraID, facingBack ? "back" : "front"); + + for (size_t i = 0; i < CAMERA3_TEMPLATE_COUNT; i++) { + mDefaultTemplates[i] = NULL; + } + +} + +EmulatedFakeCamera3::~EmulatedFakeCamera3() { + for (size_t i = 0; i < CAMERA3_TEMPLATE_COUNT; i++) { + if (mDefaultTemplates[i] != NULL) { + free_camera_metadata(mDefaultTemplates[i]); + } + } +} + +status_t EmulatedFakeCamera3::Initialize() { + ALOGV("%s: E", __FUNCTION__); + status_t res; + + if (mStatus != STATUS_ERROR) { + ALOGE("%s: Already initialized!", __FUNCTION__); + return INVALID_OPERATION; + } + + res = getCameraCapabilities(); + if (res != OK) { + ALOGE("%s: Unable to get camera capabilities: %s (%d)", + __FUNCTION__, strerror(-res), res); + return res; + } + + res = constructStaticInfo(); + if (res != OK) { + ALOGE("%s: Unable to allocate static info: %s (%d)", + __FUNCTION__, strerror(-res), res); + return res; + } + + return EmulatedCamera3::Initialize(); +} + +status_t EmulatedFakeCamera3::connectCamera(hw_device_t** device) { + ALOGV("%s: E", __FUNCTION__); + Mutex::Autolock l(mLock); + status_t res; + + if (mStatus != STATUS_CLOSED) { + ALOGE("%s: Can't connect in state %d", __FUNCTION__, mStatus); + return INVALID_OPERATION; + } + + mSensor = new Sensor(); + mSensor->setSensorListener(this); + + res = mSensor->startUp(); + if (res != NO_ERROR) return res; + + mReadoutThread = new ReadoutThread(this); + mJpegCompressor = new JpegCompressor(); + + res = mReadoutThread->run("EmuCam3::readoutThread"); + if (res != NO_ERROR) return res; + + // Initialize fake 3A + + mControlMode = ANDROID_CONTROL_MODE_AUTO; + mFacePriority = false; + mAeMode = ANDROID_CONTROL_AE_MODE_ON; + mAfMode = ANDROID_CONTROL_AF_MODE_AUTO; + mAwbMode = ANDROID_CONTROL_AWB_MODE_AUTO; + mAeState = ANDROID_CONTROL_AE_STATE_INACTIVE; + mAfState = ANDROID_CONTROL_AF_STATE_INACTIVE; + mAwbState = ANDROID_CONTROL_AWB_STATE_INACTIVE; + mAeCounter = 0; + mAeTargetExposureTime = kNormalExposureTime; + mAeCurrentExposureTime = kNormalExposureTime; + mAeCurrentSensitivity = kNormalSensitivity; + + return EmulatedCamera3::connectCamera(device); +} + +status_t EmulatedFakeCamera3::closeCamera() { + ALOGV("%s: E", __FUNCTION__); + status_t res; + { + Mutex::Autolock l(mLock); + if (mStatus == STATUS_CLOSED) return OK; + + res = mSensor->shutDown(); + if (res != NO_ERROR) { + ALOGE("%s: Unable to shut down sensor: %d", __FUNCTION__, res); + return res; + } + mSensor.clear(); + + mReadoutThread->requestExit(); + } + + mReadoutThread->join(); + + { + Mutex::Autolock l(mLock); + // Clear out private stream information + for (StreamIterator s = mStreams.begin(); s != mStreams.end(); s++) { + PrivateStreamInfo *privStream = + static_cast((*s)->priv); + delete privStream; + (*s)->priv = NULL; + } + mStreams.clear(); + mReadoutThread.clear(); + } + + return EmulatedCamera3::closeCamera(); +} + +status_t EmulatedFakeCamera3::getCameraInfo(struct camera_info *info) { + info->facing = mFacingBack ? CAMERA_FACING_BACK : CAMERA_FACING_FRONT; + info->orientation = gEmulatedCameraFactory.getFakeCameraOrientation(); + return EmulatedCamera3::getCameraInfo(info); +} + +/** + * Camera3 interface methods + */ + +status_t EmulatedFakeCamera3::configureStreams( + camera3_stream_configuration *streamList) { + Mutex::Autolock l(mLock); + ALOGV("%s: %d streams", __FUNCTION__, streamList->num_streams); + + if (mStatus != STATUS_OPEN && mStatus != STATUS_READY) { + ALOGE("%s: Cannot configure streams in state %d", + __FUNCTION__, mStatus); + return NO_INIT; + } + + /** + * Sanity-check input list. + */ + if (streamList == NULL) { + ALOGE("%s: NULL stream configuration", __FUNCTION__); + return BAD_VALUE; + } + + if (streamList->streams == NULL) { + ALOGE("%s: NULL stream list", __FUNCTION__); + return BAD_VALUE; + } + + if (streamList->num_streams < 1) { + ALOGE("%s: Bad number of streams requested: %d", __FUNCTION__, + streamList->num_streams); + return BAD_VALUE; + } + + camera3_stream_t *inputStream = NULL; + for (size_t i = 0; i < streamList->num_streams; i++) { + camera3_stream_t *newStream = streamList->streams[i]; + + if (newStream == NULL) { + ALOGE("%s: Stream index %zu was NULL", + __FUNCTION__, i); + return BAD_VALUE; + } + + ALOGV("%s: Stream %p (id %zu), type %d, usage 0x%x, format 0x%x", + __FUNCTION__, newStream, i, newStream->stream_type, + newStream->usage, + newStream->format); + + if (newStream->stream_type == CAMERA3_STREAM_INPUT || + newStream->stream_type == CAMERA3_STREAM_BIDIRECTIONAL) { + if (inputStream != NULL) { + + ALOGE("%s: Multiple input streams requested!", __FUNCTION__); + return BAD_VALUE; + } + inputStream = newStream; + } + + bool validFormat = false; + for (size_t f = 0; + f < sizeof(kAvailableFormats)/sizeof(kAvailableFormats[0]); + f++) { + if (newStream->format == kAvailableFormats[f]) { + validFormat = true; + break; + } + } + if (!validFormat) { + ALOGE("%s: Unsupported stream format 0x%x requested", + __FUNCTION__, newStream->format); + return BAD_VALUE; + } + } + mInputStream = inputStream; + + /** + * Initially mark all existing streams as not alive + */ + for (StreamIterator s = mStreams.begin(); s != mStreams.end(); ++s) { + PrivateStreamInfo *privStream = + static_cast((*s)->priv); + privStream->alive = false; + } + + /** + * Find new streams and mark still-alive ones + */ + for (size_t i = 0; i < streamList->num_streams; i++) { + camera3_stream_t *newStream = streamList->streams[i]; + if (newStream->priv == NULL) { + // New stream, construct info + PrivateStreamInfo *privStream = new PrivateStreamInfo(); + privStream->alive = true; + + newStream->max_buffers = kMaxBufferCount; + newStream->priv = privStream; + mStreams.push_back(newStream); + } else { + // Existing stream, mark as still alive. + PrivateStreamInfo *privStream = + static_cast(newStream->priv); + privStream->alive = true; + } + // Always update usage and max buffers + newStream->max_buffers = kMaxBufferCount; + switch (newStream->stream_type) { + case CAMERA3_STREAM_OUTPUT: + newStream->usage = GRALLOC_USAGE_HW_CAMERA_WRITE; + break; + case CAMERA3_STREAM_INPUT: + newStream->usage = GRALLOC_USAGE_HW_CAMERA_READ; + break; + case CAMERA3_STREAM_BIDIRECTIONAL: + newStream->usage = GRALLOC_USAGE_HW_CAMERA_READ | + GRALLOC_USAGE_HW_CAMERA_WRITE; + break; + } + } + + /** + * Reap the dead streams + */ + for (StreamIterator s = mStreams.begin(); s != mStreams.end();) { + PrivateStreamInfo *privStream = + static_cast((*s)->priv); + if (!privStream->alive) { + (*s)->priv = NULL; + delete privStream; + s = mStreams.erase(s); + } else { + ++s; + } + } + + /** + * Can't reuse settings across configure call + */ + mPrevSettings.clear(); + + return OK; +} + +status_t EmulatedFakeCamera3::registerStreamBuffers( + const camera3_stream_buffer_set *bufferSet) { + ALOGV("%s: E", __FUNCTION__); + Mutex::Autolock l(mLock); + + // Should not be called in HAL versions >= 3.2 + + ALOGE("%s: Should not be invoked on new HALs!", + __FUNCTION__); + return NO_INIT; +} + +const camera_metadata_t* EmulatedFakeCamera3::constructDefaultRequestSettings( + int type) { + ALOGV("%s: E", __FUNCTION__); + Mutex::Autolock l(mLock); + + if (type < 0 || type >= CAMERA3_TEMPLATE_COUNT) { + ALOGE("%s: Unknown request settings template: %d", + __FUNCTION__, type); + return NULL; + } + + if (!hasCapability(BACKWARD_COMPATIBLE) && type != CAMERA3_TEMPLATE_PREVIEW) { + ALOGE("%s: Template %d not supported w/o BACKWARD_COMPATIBLE capability", + __FUNCTION__, type); + return NULL; + } + + /** + * Cache is not just an optimization - pointer returned has to live at + * least as long as the camera device instance does. + */ + if (mDefaultTemplates[type] != NULL) { + return mDefaultTemplates[type]; + } + + CameraMetadata settings; + + /** android.request */ + + static const uint8_t metadataMode = ANDROID_REQUEST_METADATA_MODE_FULL; + settings.update(ANDROID_REQUEST_METADATA_MODE, &metadataMode, 1); + + static const int32_t id = 0; + settings.update(ANDROID_REQUEST_ID, &id, 1); + + static const int32_t frameCount = 0; + settings.update(ANDROID_REQUEST_FRAME_COUNT, &frameCount, 1); + + /** android.lens */ + + static const float focalLength = 5.0f; + settings.update(ANDROID_LENS_FOCAL_LENGTH, &focalLength, 1); + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const float focusDistance = 0; + settings.update(ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1); + + static const float aperture = 2.8f; + settings.update(ANDROID_LENS_APERTURE, &aperture, 1); + + static const float filterDensity = 0; + settings.update(ANDROID_LENS_FILTER_DENSITY, &filterDensity, 1); + + static const uint8_t opticalStabilizationMode = + ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF; + settings.update(ANDROID_LENS_OPTICAL_STABILIZATION_MODE, + &opticalStabilizationMode, 1); + + // FOCUS_RANGE set only in frame + } + + /** android.sensor */ + + if (hasCapability(MANUAL_SENSOR)) { + static const int64_t exposureTime = 10 * MSEC; + settings.update(ANDROID_SENSOR_EXPOSURE_TIME, &exposureTime, 1); + + static const int64_t frameDuration = 33333333L; // 1/30 s + settings.update(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1); + + static const int32_t sensitivity = 100; + settings.update(ANDROID_SENSOR_SENSITIVITY, &sensitivity, 1); + } + + // TIMESTAMP set only in frame + + /** android.flash */ + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t flashMode = ANDROID_FLASH_MODE_OFF; + settings.update(ANDROID_FLASH_MODE, &flashMode, 1); + + static const uint8_t flashPower = 10; + settings.update(ANDROID_FLASH_FIRING_POWER, &flashPower, 1); + + static const int64_t firingTime = 0; + settings.update(ANDROID_FLASH_FIRING_TIME, &firingTime, 1); + } + + /** Processing block modes */ + if (hasCapability(MANUAL_POST_PROCESSING)) { + uint8_t hotPixelMode = 0; + uint8_t demosaicMode = 0; + uint8_t noiseMode = 0; + uint8_t shadingMode = 0; + uint8_t colorMode = 0; + uint8_t tonemapMode = 0; + uint8_t edgeMode = 0; + switch (type) { + case CAMERA3_TEMPLATE_STILL_CAPTURE: + // fall-through + case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT: + // fall-through + case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG: + hotPixelMode = ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY; + demosaicMode = ANDROID_DEMOSAIC_MODE_HIGH_QUALITY; + noiseMode = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY; + shadingMode = ANDROID_SHADING_MODE_HIGH_QUALITY; + colorMode = ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY; + tonemapMode = ANDROID_TONEMAP_MODE_HIGH_QUALITY; + edgeMode = ANDROID_EDGE_MODE_HIGH_QUALITY; + break; + case CAMERA3_TEMPLATE_PREVIEW: + // fall-through + case CAMERA3_TEMPLATE_VIDEO_RECORD: + // fall-through + default: + hotPixelMode = ANDROID_HOT_PIXEL_MODE_FAST; + demosaicMode = ANDROID_DEMOSAIC_MODE_FAST; + noiseMode = ANDROID_NOISE_REDUCTION_MODE_FAST; + shadingMode = ANDROID_SHADING_MODE_FAST; + colorMode = ANDROID_COLOR_CORRECTION_MODE_FAST; + tonemapMode = ANDROID_TONEMAP_MODE_FAST; + edgeMode = ANDROID_EDGE_MODE_FAST; + break; + } + settings.update(ANDROID_HOT_PIXEL_MODE, &hotPixelMode, 1); + settings.update(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1); + settings.update(ANDROID_NOISE_REDUCTION_MODE, &noiseMode, 1); + settings.update(ANDROID_SHADING_MODE, &shadingMode, 1); + settings.update(ANDROID_COLOR_CORRECTION_MODE, &colorMode, 1); + settings.update(ANDROID_TONEMAP_MODE, &tonemapMode, 1); + settings.update(ANDROID_EDGE_MODE, &edgeMode, 1); + } + + /** android.colorCorrection */ + + if (hasCapability(MANUAL_POST_PROCESSING)) { + static const camera_metadata_rational colorTransform[9] = { + {1,1}, {0,1}, {0,1}, + {0,1}, {1,1}, {0,1}, + {0,1}, {0,1}, {1,1} + }; + settings.update(ANDROID_COLOR_CORRECTION_TRANSFORM, colorTransform, 9); + + static const float colorGains[4] = { + 1.0f, 1.0f, 1.0f, 1.0f + }; + settings.update(ANDROID_COLOR_CORRECTION_GAINS, colorGains, 4); + } + + /** android.tonemap */ + + if (hasCapability(MANUAL_POST_PROCESSING)) { + static const float tonemapCurve[4] = { + 0.f, 0.f, + 1.f, 1.f + }; + settings.update(ANDROID_TONEMAP_CURVE_RED, tonemapCurve, 4); + settings.update(ANDROID_TONEMAP_CURVE_GREEN, tonemapCurve, 4); + settings.update(ANDROID_TONEMAP_CURVE_BLUE, tonemapCurve, 4); + } + + /** android.scaler */ + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const int32_t cropRegion[4] = { + 0, 0, (int32_t)Sensor::kResolution[0], (int32_t)Sensor::kResolution[1] + }; + settings.update(ANDROID_SCALER_CROP_REGION, cropRegion, 4); + } + + /** android.jpeg */ + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t jpegQuality = 80; + settings.update(ANDROID_JPEG_QUALITY, &jpegQuality, 1); + + static const int32_t thumbnailSize[2] = { + 640, 480 + }; + settings.update(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2); + + static const uint8_t thumbnailQuality = 80; + settings.update(ANDROID_JPEG_THUMBNAIL_QUALITY, &thumbnailQuality, 1); + + static const double gpsCoordinates[2] = { + 0, 0 + }; + settings.update(ANDROID_JPEG_GPS_COORDINATES, gpsCoordinates, 2); + + static const uint8_t gpsProcessingMethod[32] = "None"; + settings.update(ANDROID_JPEG_GPS_PROCESSING_METHOD, gpsProcessingMethod, 32); + + static const int64_t gpsTimestamp = 0; + settings.update(ANDROID_JPEG_GPS_TIMESTAMP, &gpsTimestamp, 1); + + static const int32_t jpegOrientation = 0; + settings.update(ANDROID_JPEG_ORIENTATION, &jpegOrientation, 1); + } + + /** android.stats */ + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t faceDetectMode = + ANDROID_STATISTICS_FACE_DETECT_MODE_OFF; + settings.update(ANDROID_STATISTICS_FACE_DETECT_MODE, &faceDetectMode, 1); + + static const uint8_t hotPixelMapMode = + ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF; + settings.update(ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE, &hotPixelMapMode, 1); + } + + // faceRectangles, faceScores, faceLandmarks, faceIds, histogram, + // sharpnessMap only in frames + + /** android.control */ + + uint8_t controlIntent = 0; + switch (type) { + case CAMERA3_TEMPLATE_PREVIEW: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW; + break; + case CAMERA3_TEMPLATE_STILL_CAPTURE: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE; + break; + case CAMERA3_TEMPLATE_VIDEO_RECORD: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD; + break; + case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT; + break; + case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG; + break; + case CAMERA3_TEMPLATE_MANUAL: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL; + break; + default: + controlIntent = ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM; + break; + } + settings.update(ANDROID_CONTROL_CAPTURE_INTENT, &controlIntent, 1); + + const uint8_t controlMode = (type == CAMERA3_TEMPLATE_MANUAL) ? + ANDROID_CONTROL_MODE_OFF : + ANDROID_CONTROL_MODE_AUTO; + settings.update(ANDROID_CONTROL_MODE, &controlMode, 1); + + int32_t aeTargetFpsRange[2] = { + 5, 30 + }; + if (type == CAMERA3_TEMPLATE_VIDEO_RECORD || type == CAMERA3_TEMPLATE_VIDEO_SNAPSHOT) { + aeTargetFpsRange[0] = 30; + } + settings.update(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, aeTargetFpsRange, 2); + + if (hasCapability(BACKWARD_COMPATIBLE)) { + + static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_MODE_OFF; + settings.update(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1); + + static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY; + settings.update(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1); + + const uint8_t aeMode = (type == CAMERA3_TEMPLATE_MANUAL) ? + ANDROID_CONTROL_AE_MODE_OFF : + ANDROID_CONTROL_AE_MODE_ON; + settings.update(ANDROID_CONTROL_AE_MODE, &aeMode, 1); + + static const uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF; + settings.update(ANDROID_CONTROL_AE_LOCK, &aeLock, 1); + + static const int32_t controlRegions[5] = { + 0, 0, 0, 0, 0 + }; + settings.update(ANDROID_CONTROL_AE_REGIONS, controlRegions, 5); + + static const int32_t aeExpCompensation = 0; + settings.update(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, &aeExpCompensation, 1); + + + static const uint8_t aeAntibandingMode = + ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO; + settings.update(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1); + + static const uint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE; + settings.update(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, &aePrecaptureTrigger, 1); + + const uint8_t awbMode = (type == CAMERA3_TEMPLATE_MANUAL) ? + ANDROID_CONTROL_AWB_MODE_OFF : + ANDROID_CONTROL_AWB_MODE_AUTO; + settings.update(ANDROID_CONTROL_AWB_MODE, &awbMode, 1); + + static const uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF; + settings.update(ANDROID_CONTROL_AWB_LOCK, &awbLock, 1); + + uint8_t afMode = 0; + switch (type) { + case CAMERA3_TEMPLATE_PREVIEW: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE; + break; + case CAMERA3_TEMPLATE_STILL_CAPTURE: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE; + break; + case CAMERA3_TEMPLATE_VIDEO_RECORD: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO; + break; + case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO; + break; + case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG: + afMode = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE; + break; + case CAMERA3_TEMPLATE_MANUAL: + afMode = ANDROID_CONTROL_AF_MODE_OFF; + break; + default: + afMode = ANDROID_CONTROL_AF_MODE_AUTO; + break; + } + settings.update(ANDROID_CONTROL_AF_MODE, &afMode, 1); + + settings.update(ANDROID_CONTROL_AF_REGIONS, controlRegions, 5); + + static const uint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE; + settings.update(ANDROID_CONTROL_AF_TRIGGER, &afTrigger, 1); + + static const uint8_t vstabMode = + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF; + settings.update(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, &vstabMode, 1); + + static const uint8_t blackLevelLock = ANDROID_BLACK_LEVEL_LOCK_OFF; + settings.update(ANDROID_BLACK_LEVEL_LOCK, &blackLevelLock, 1); + + static const uint8_t lensShadingMapMode = ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF; + settings.update(ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, &lensShadingMapMode, 1); + + static const uint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_FAST; + settings.update(ANDROID_COLOR_CORRECTION_ABERRATION_MODE, &aberrationMode, 1); + + static const int32_t testPatternMode = ANDROID_SENSOR_TEST_PATTERN_MODE_OFF; + settings.update(ANDROID_SENSOR_TEST_PATTERN_MODE, &testPatternMode, 1); + } + + mDefaultTemplates[type] = settings.release(); + + return mDefaultTemplates[type]; +} + +status_t EmulatedFakeCamera3::processCaptureRequest( + camera3_capture_request *request) { + + Mutex::Autolock l(mLock); + status_t res; + + /** Validation */ + + if (mStatus < STATUS_READY) { + ALOGE("%s: Can't submit capture requests in state %d", __FUNCTION__, + mStatus); + return INVALID_OPERATION; + } + + if (request == NULL) { + ALOGE("%s: NULL request!", __FUNCTION__); + return BAD_VALUE; + } + + uint32_t frameNumber = request->frame_number; + + if (request->settings == NULL && mPrevSettings.isEmpty()) { + ALOGE("%s: Request %d: NULL settings for first request after" + "configureStreams()", __FUNCTION__, frameNumber); + return BAD_VALUE; + } + + if (request->input_buffer != NULL && + request->input_buffer->stream != mInputStream) { + ALOGE("%s: Request %d: Input buffer not from input stream!", + __FUNCTION__, frameNumber); + ALOGV("%s: Bad stream %p, expected: %p", + __FUNCTION__, request->input_buffer->stream, + mInputStream); + ALOGV("%s: Bad stream type %d, expected stream type %d", + __FUNCTION__, request->input_buffer->stream->stream_type, + mInputStream ? mInputStream->stream_type : -1); + + return BAD_VALUE; + } + + if (request->num_output_buffers < 1 || request->output_buffers == NULL) { + ALOGE("%s: Request %d: No output buffers provided!", + __FUNCTION__, frameNumber); + return BAD_VALUE; + } + + // Validate all buffers, starting with input buffer if it's given + + ssize_t idx; + const camera3_stream_buffer_t *b; + if (request->input_buffer != NULL) { + idx = -1; + b = request->input_buffer; + } else { + idx = 0; + b = request->output_buffers; + } + do { + PrivateStreamInfo *priv = + static_cast(b->stream->priv); + if (priv == NULL) { + ALOGE("%s: Request %d: Buffer %zu: Unconfigured stream!", + __FUNCTION__, frameNumber, idx); + return BAD_VALUE; + } + if (!priv->alive) { + ALOGE("%s: Request %d: Buffer %zu: Dead stream!", + __FUNCTION__, frameNumber, idx); + return BAD_VALUE; + } + if (b->status != CAMERA3_BUFFER_STATUS_OK) { + ALOGE("%s: Request %d: Buffer %zu: Status not OK!", + __FUNCTION__, frameNumber, idx); + return BAD_VALUE; + } + if (b->release_fence != -1) { + ALOGE("%s: Request %d: Buffer %zu: Has a release fence!", + __FUNCTION__, frameNumber, idx); + return BAD_VALUE; + } + if (b->buffer == NULL) { + ALOGE("%s: Request %d: Buffer %zu: NULL buffer handle!", + __FUNCTION__, frameNumber, idx); + return BAD_VALUE; + } + idx++; + b = &(request->output_buffers[idx]); + } while (idx < (ssize_t)request->num_output_buffers); + + // TODO: Validate settings parameters + + /** + * Start processing this request + */ + + mStatus = STATUS_ACTIVE; + + CameraMetadata settings; + + if (request->settings == NULL) { + settings.acquire(mPrevSettings); + } else { + settings = request->settings; + } + + res = process3A(settings); + if (res != OK) { + return res; + } + + // TODO: Handle reprocessing + + /** + * Get ready for sensor config + */ + + nsecs_t exposureTime; + nsecs_t frameDuration; + uint32_t sensitivity; + bool needJpeg = false; + camera_metadata_entry_t entry; + + entry = settings.find(ANDROID_SENSOR_EXPOSURE_TIME); + exposureTime = (entry.count > 0) ? entry.data.i64[0] : Sensor::kExposureTimeRange[0]; + entry = settings.find(ANDROID_SENSOR_FRAME_DURATION); + frameDuration = (entry.count > 0)? entry.data.i64[0] : Sensor::kFrameDurationRange[0]; + entry = settings.find(ANDROID_SENSOR_SENSITIVITY); + sensitivity = (entry.count > 0) ? entry.data.i32[0] : Sensor::kSensitivityRange[0]; + + if (exposureTime > frameDuration) { + frameDuration = exposureTime + Sensor::kMinVerticalBlank; + settings.update(ANDROID_SENSOR_FRAME_DURATION, &frameDuration, 1); + } + + Buffers *sensorBuffers = new Buffers(); + HalBufferVector *buffers = new HalBufferVector(); + + sensorBuffers->setCapacity(request->num_output_buffers); + buffers->setCapacity(request->num_output_buffers); + + // Process all the buffers we got for output, constructing internal buffer + // structures for them, and lock them for writing. + for (size_t i = 0; i < request->num_output_buffers; i++) { + const camera3_stream_buffer &srcBuf = request->output_buffers[i]; + const cb_handle_t *privBuffer = + static_cast(*srcBuf.buffer); + StreamBuffer destBuf; + destBuf.streamId = kGenericStreamId; + destBuf.width = srcBuf.stream->width; + destBuf.height = srcBuf.stream->height; + destBuf.format = privBuffer->format; // Use real private format + destBuf.stride = srcBuf.stream->width; // TODO: query from gralloc + destBuf.dataSpace = srcBuf.stream->data_space; + destBuf.buffer = srcBuf.buffer; + + if (destBuf.format == HAL_PIXEL_FORMAT_BLOB) { + needJpeg = true; + } + + // Wait on fence + sp bufferAcquireFence = new Fence(srcBuf.acquire_fence); + res = bufferAcquireFence->wait(kFenceTimeoutMs); + if (res == TIMED_OUT) { + ALOGE("%s: Request %d: Buffer %zu: Fence timed out after %d ms", + __FUNCTION__, frameNumber, i, kFenceTimeoutMs); + } + if (res == OK) { + // Lock buffer for writing + const Rect rect(destBuf.width, destBuf.height); + if (srcBuf.stream->format == HAL_PIXEL_FORMAT_YCbCr_420_888) { + if (privBuffer->format == HAL_PIXEL_FORMAT_YCrCb_420_SP) { + android_ycbcr ycbcr = android_ycbcr(); + res = GraphicBufferMapper::get().lockYCbCr( + *(destBuf.buffer), + GRALLOC_USAGE_HW_CAMERA_WRITE, rect, + &ycbcr); + // This is only valid because we know that emulator's + // YCbCr_420_888 is really contiguous NV21 under the hood + destBuf.img = static_cast(ycbcr.y); + } else { + ALOGE("Unexpected private format for flexible YUV: 0x%x", + privBuffer->format); + res = INVALID_OPERATION; + } + } else { + res = GraphicBufferMapper::get().lock(*(destBuf.buffer), + GRALLOC_USAGE_HW_CAMERA_WRITE, rect, + (void**)&(destBuf.img)); + } + if (res != OK) { + ALOGE("%s: Request %d: Buffer %zu: Unable to lock buffer", + __FUNCTION__, frameNumber, i); + } + } + + if (res != OK) { + // Either waiting or locking failed. Unlock locked buffers and bail + // out. + for (size_t j = 0; j < i; j++) { + GraphicBufferMapper::get().unlock( + *(request->output_buffers[i].buffer)); + } + return NO_INIT; + } + + sensorBuffers->push_back(destBuf); + buffers->push_back(srcBuf); + } + + /** + * Wait for JPEG compressor to not be busy, if needed + */ + if (needJpeg) { + bool ready = mJpegCompressor->waitForDone(kFenceTimeoutMs); + if (!ready) { + ALOGE("%s: Timeout waiting for JPEG compression to complete!", + __FUNCTION__); + return NO_INIT; + } + } + + /** + * Wait until the in-flight queue has room + */ + res = mReadoutThread->waitForReadout(); + if (res != OK) { + ALOGE("%s: Timeout waiting for previous requests to complete!", + __FUNCTION__); + return NO_INIT; + } + + /** + * Wait until sensor's ready. This waits for lengthy amounts of time with + * mLock held, but the interface spec is that no other calls may by done to + * the HAL by the framework while process_capture_request is happening. + */ + int syncTimeoutCount = 0; + while(!mSensor->waitForVSync(kSyncWaitTimeout)) { + if (mStatus == STATUS_ERROR) { + return NO_INIT; + } + if (syncTimeoutCount == kMaxSyncTimeoutCount) { + ALOGE("%s: Request %d: Sensor sync timed out after %" PRId64 " ms", + __FUNCTION__, frameNumber, + kSyncWaitTimeout * kMaxSyncTimeoutCount / 1000000); + return NO_INIT; + } + syncTimeoutCount++; + } + + /** + * Configure sensor and queue up the request to the readout thread + */ + mSensor->setExposureTime(exposureTime); + mSensor->setFrameDuration(frameDuration); + mSensor->setSensitivity(sensitivity); + mSensor->setDestinationBuffers(sensorBuffers); + mSensor->setFrameNumber(request->frame_number); + + ReadoutThread::Request r; + r.frameNumber = request->frame_number; + r.settings = settings; + r.sensorBuffers = sensorBuffers; + r.buffers = buffers; + + mReadoutThread->queueCaptureRequest(r); + ALOGVV("%s: Queued frame %d", __FUNCTION__, request->frame_number); + + // Cache the settings for next time + mPrevSettings.acquire(settings); + + return OK; +} + +status_t EmulatedFakeCamera3::flush() { + ALOGW("%s: Not implemented; ignored", __FUNCTION__); + return OK; +} + +/** Debug methods */ + +void EmulatedFakeCamera3::dump(int fd) { + +} + +/** + * Private methods + */ + +status_t EmulatedFakeCamera3::getCameraCapabilities() { + + const char *key = mFacingBack ? "qemu.sf.back_camera_caps" : "qemu.sf.front_camera_caps"; + + /* Defined by 'qemu.sf.*_camera_caps' boot property: if the + * property doesn't exist, it is assumed to list FULL. */ + char prop[PROPERTY_VALUE_MAX]; + if (property_get(key, prop, NULL) > 0) { + char *saveptr = nullptr; + char *cap = strtok_r(prop, " ,", &saveptr); + while (cap != NULL) { + for (int i = 0; i < NUM_CAPABILITIES; i++) { + if (!strcasecmp(cap, sAvailableCapabilitiesStrings[i])) { + mCapabilities.add(static_cast(i)); + break; + } + } + cap = strtok_r(NULL, " ,", &saveptr); + } + if (mCapabilities.size() == 0) { + ALOGE("qemu.sf.back_camera_caps had no valid capabilities: %s", prop); + } + } + // Default to FULL_LEVEL plus RAW if nothing is defined + if (mCapabilities.size() == 0) { + mCapabilities.add(FULL_LEVEL); + mCapabilities.add(RAW); + } + + // Add level-based caps + if (hasCapability(FULL_LEVEL)) { + mCapabilities.add(BURST_CAPTURE); + mCapabilities.add(READ_SENSOR_SETTINGS); + mCapabilities.add(MANUAL_SENSOR); + mCapabilities.add(MANUAL_POST_PROCESSING); + }; + + // Backwards-compatible is required for most other caps + // Not required for DEPTH_OUTPUT, though. + if (hasCapability(BURST_CAPTURE) || + hasCapability(READ_SENSOR_SETTINGS) || + hasCapability(RAW) || + hasCapability(MANUAL_SENSOR) || + hasCapability(MANUAL_POST_PROCESSING) || + hasCapability(PRIVATE_REPROCESSING) || + hasCapability(YUV_REPROCESSING) || + hasCapability(CONSTRAINED_HIGH_SPEED_VIDEO)) { + mCapabilities.add(BACKWARD_COMPATIBLE); + } + + ALOGI("Camera %d capabilities:", mCameraID); + for (size_t i = 0; i < mCapabilities.size(); i++) { + ALOGI(" %s", sAvailableCapabilitiesStrings[mCapabilities[i]]); + } + + return OK; +} + +bool EmulatedFakeCamera3::hasCapability(AvailableCapabilities cap) { + ssize_t idx = mCapabilities.indexOf(cap); + return idx >= 0; +} + +status_t EmulatedFakeCamera3::constructStaticInfo() { + + CameraMetadata info; + Vector availableCharacteristicsKeys; + status_t res; + +#define ADD_STATIC_ENTRY(name, varptr, count) \ + availableCharacteristicsKeys.add(name); \ + res = info.update(name, varptr, count); \ + if (res != OK) return res + + // android.sensor + + if (hasCapability(MANUAL_SENSOR)) { + + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, + Sensor::kExposureTimeRange, 2); + + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, + &Sensor::kFrameDurationRange[1], 1); + + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, + Sensor::kSensitivityRange, + sizeof(Sensor::kSensitivityRange) + /sizeof(int32_t)); + + ADD_STATIC_ENTRY(ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY, + &Sensor::kSensitivityRange[1], 1); + } + + static const float sensorPhysicalSize[2] = {3.20f, 2.40f}; // mm + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + sensorPhysicalSize, 2); + + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, + (int32_t*)Sensor::kResolution, 2); + + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, + (int32_t*)Sensor::kActiveArray, 4); + + static const int32_t orientation = 90; // Aligned with 'long edge' + ADD_STATIC_ENTRY(ANDROID_SENSOR_ORIENTATION, &orientation, 1); + + static const uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME; + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, ×tampSource, 1); + + if (hasCapability(RAW)) { + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, + &Sensor::kColorFilterArrangement, 1); + + ADD_STATIC_ENTRY(ANDROID_SENSOR_INFO_WHITE_LEVEL, + (int32_t*)&Sensor::kMaxRawValue, 1); + + static const int32_t blackLevelPattern[4] = { + (int32_t)Sensor::kBlackLevel, (int32_t)Sensor::kBlackLevel, + (int32_t)Sensor::kBlackLevel, (int32_t)Sensor::kBlackLevel + }; + ADD_STATIC_ENTRY(ANDROID_SENSOR_BLACK_LEVEL_PATTERN, + blackLevelPattern, sizeof(blackLevelPattern)/sizeof(int32_t)); + } + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const int32_t availableTestPatternModes[] = { + ANDROID_SENSOR_TEST_PATTERN_MODE_OFF + }; + ADD_STATIC_ENTRY(ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, + availableTestPatternModes, sizeof(availableTestPatternModes)/sizeof(int32_t)); + } + + // android.lens + + static const float focalLength = 3.30f; // mm + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, + &focalLength, 1); + + if (hasCapability(BACKWARD_COMPATIBLE)) { + // 5 cm min focus distance for back camera, infinity (fixed focus) for front + const float minFocusDistance = mFacingBack ? 1.0/0.05 : 0.0; + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, + &minFocusDistance, 1); + + // 5 m hyperfocal distance for back camera, infinity (fixed focus) for front + const float hyperFocalDistance = mFacingBack ? 1.0/5.0 : 0.0; + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, + &minFocusDistance, 1); + + static const float aperture = 2.8f; + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_AVAILABLE_APERTURES, + &aperture, 1); + static const float filterDensity = 0; + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES, + &filterDensity, 1); + static const uint8_t availableOpticalStabilization = + ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF; + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, + &availableOpticalStabilization, 1); + + static const int32_t lensShadingMapSize[] = {1, 1}; + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_SHADING_MAP_SIZE, lensShadingMapSize, + sizeof(lensShadingMapSize)/sizeof(int32_t)); + + static const uint8_t lensFocusCalibration = + ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_APPROXIMATE; + ADD_STATIC_ENTRY(ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION, &lensFocusCalibration, 1); + } + + if (hasCapability(DEPTH_OUTPUT)) { + // These could be included for non-DEPTH capability as well, but making this variable for + // testing coverage + + // 90 degree rotation to align with long edge of a phone device that's by default portrait + static const float qO[] = { 0.707107f, 0.f, 0.f, 0.707107f}; + + // Either a 180-degree rotation for back-facing, or no rotation for front-facing + const float qF[] = {0, (mFacingBack ? 1.f : 0.f), 0, (mFacingBack ? 0.f : 1.f)}; + + // Quarternion product, orientation change then facing + const float lensPoseRotation[] = {qO[0]*qF[0] - qO[1]*qF[1] - qO[2]*qF[2] - qO[3]*qF[3], + qO[0]*qF[1] + qO[1]*qF[0] + qO[2]*qF[3] - qO[3]*qF[2], + qO[0]*qF[2] + qO[2]*qF[0] + qO[1]*qF[3] - qO[3]*qF[1], + qO[0]*qF[3] + qO[3]*qF[0] + qO[1]*qF[2] - qO[2]*qF[1]}; + + ADD_STATIC_ENTRY(ANDROID_LENS_POSE_ROTATION, lensPoseRotation, + sizeof(lensPoseRotation)/sizeof(float)); + + // Only one camera facing each way, so 0 translation needed to the center of the 'main' + // camera + static const float lensPoseTranslation[] = {0.f, 0.f, 0.f}; + + ADD_STATIC_ENTRY(ANDROID_LENS_POSE_TRANSLATION, lensPoseTranslation, + sizeof(lensPoseTranslation)/sizeof(float)); + + // Intrinsics are 'ideal' (f_x, f_y, c_x, c_y, s) match focal length and active array size + float f_x = focalLength * Sensor::kActiveArray[2] / sensorPhysicalSize[0]; + float f_y = focalLength * Sensor::kActiveArray[3] / sensorPhysicalSize[1]; + float c_x = Sensor::kActiveArray[2] / 2.f; + float c_y = Sensor::kActiveArray[3] / 2.f; + float s = 0.f; + const float lensIntrinsics[] = { f_x, f_y, c_x, c_y, s }; + + ADD_STATIC_ENTRY(ANDROID_LENS_INTRINSIC_CALIBRATION, lensIntrinsics, + sizeof(lensIntrinsics)/sizeof(float)); + + // No radial or tangential distortion + + float lensRadialDistortion[] = {1.0f, 0.f, 0.f, 0.f, 0.f, 0.f}; + + ADD_STATIC_ENTRY(ANDROID_LENS_RADIAL_DISTORTION, lensRadialDistortion, + sizeof(lensRadialDistortion)/sizeof(float)); + + } + + + static const uint8_t lensFacing = mFacingBack ? + ANDROID_LENS_FACING_BACK : ANDROID_LENS_FACING_FRONT; + ADD_STATIC_ENTRY(ANDROID_LENS_FACING, &lensFacing, 1); + + // android.flash + + static const uint8_t flashAvailable = 0; + ADD_STATIC_ENTRY(ANDROID_FLASH_INFO_AVAILABLE, &flashAvailable, 1); + + // android.tonemap + + if (hasCapability(MANUAL_POST_PROCESSING)) { + static const int32_t tonemapCurvePoints = 128; + ADD_STATIC_ENTRY(ANDROID_TONEMAP_MAX_CURVE_POINTS, &tonemapCurvePoints, 1); + + static const uint8_t availableToneMapModes[] = { + ANDROID_TONEMAP_MODE_CONTRAST_CURVE, ANDROID_TONEMAP_MODE_FAST, + ANDROID_TONEMAP_MODE_HIGH_QUALITY + }; + ADD_STATIC_ENTRY(ANDROID_TONEMAP_AVAILABLE_TONE_MAP_MODES, availableToneMapModes, + sizeof(availableToneMapModes)); + } + + // android.scaler + + const std::vector availableStreamConfigurationsBasic = { + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_YCbCr_420_888, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_RGBA_8888, 320, 240, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_BLOB, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT + }; + const std::vector availableStreamConfigurationsRaw = { + HAL_PIXEL_FORMAT_RAW16, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT + }; + const std::vector availableStreamConfigurationsBurst = { + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_YCbCr_420_888, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_RGBA_8888, 640, 480, ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT + }; + + std::vector availableStreamConfigurations; + + if (hasCapability(BACKWARD_COMPATIBLE)) { + availableStreamConfigurations.insert(availableStreamConfigurations.end(), + availableStreamConfigurationsBasic.begin(), + availableStreamConfigurationsBasic.end()); + } + if (hasCapability(RAW)) { + availableStreamConfigurations.insert(availableStreamConfigurations.end(), + availableStreamConfigurationsRaw.begin(), + availableStreamConfigurationsRaw.end()); + } + if (hasCapability(BURST_CAPTURE)) { + availableStreamConfigurations.insert(availableStreamConfigurations.end(), + availableStreamConfigurationsBurst.begin(), + availableStreamConfigurationsBurst.end()); + } + + if (availableStreamConfigurations.size() > 0) { + ADD_STATIC_ENTRY(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, + &availableStreamConfigurations[0], + availableStreamConfigurations.size()); + } + + const std::vector availableMinFrameDurationsBasic = { + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 320, 240, Sensor::kFrameDurationRange[0], + HAL_PIXEL_FORMAT_YCbCr_420_888, 320, 240, Sensor::kFrameDurationRange[0], + HAL_PIXEL_FORMAT_RGBA_8888, 320, 240, Sensor::kFrameDurationRange[0], + HAL_PIXEL_FORMAT_BLOB, 640, 480, Sensor::kFrameDurationRange[0] + }; + const std::vector availableMinFrameDurationsRaw = { + HAL_PIXEL_FORMAT_RAW16, 640, 480, Sensor::kFrameDurationRange[0] + }; + const std::vector availableMinFrameDurationsBurst = { + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 640, 480, Sensor::kFrameDurationRange[0], + HAL_PIXEL_FORMAT_YCbCr_420_888, 640, 480, Sensor::kFrameDurationRange[0], + HAL_PIXEL_FORMAT_RGBA_8888, 640, 480, Sensor::kFrameDurationRange[0], + }; + + std::vector availableMinFrameDurations; + + if (hasCapability(BACKWARD_COMPATIBLE)) { + availableMinFrameDurations.insert(availableMinFrameDurations.end(), + availableMinFrameDurationsBasic.begin(), + availableMinFrameDurationsBasic.end()); + } + if (hasCapability(RAW)) { + availableMinFrameDurations.insert(availableMinFrameDurations.end(), + availableMinFrameDurationsRaw.begin(), + availableMinFrameDurationsRaw.end()); + } + if (hasCapability(BURST_CAPTURE)) { + availableMinFrameDurations.insert(availableMinFrameDurations.end(), + availableMinFrameDurationsBurst.begin(), + availableMinFrameDurationsBurst.end()); + } + + if (availableMinFrameDurations.size() > 0) { + ADD_STATIC_ENTRY(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, + &availableMinFrameDurations[0], + availableMinFrameDurations.size()); + } + + const std::vector availableStallDurationsBasic = { + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 320, 240, 0, + HAL_PIXEL_FORMAT_YCbCr_420_888, 320, 240, 0, + HAL_PIXEL_FORMAT_RGBA_8888, 320, 240, 0, + HAL_PIXEL_FORMAT_BLOB, 640, 480, Sensor::kFrameDurationRange[0] + }; + const std::vector availableStallDurationsRaw = { + HAL_PIXEL_FORMAT_RAW16, 640, 480, Sensor::kFrameDurationRange[0] + }; + const std::vector availableStallDurationsBurst = { + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 640, 480, 0, + HAL_PIXEL_FORMAT_YCbCr_420_888, 640, 480, 0, + HAL_PIXEL_FORMAT_RGBA_8888, 640, 480, 0 + }; + + std::vector availableStallDurations; + + if (hasCapability(BACKWARD_COMPATIBLE)) { + availableStallDurations.insert(availableStallDurations.end(), + availableStallDurationsBasic.begin(), + availableStallDurationsBasic.end()); + } + if (hasCapability(RAW)) { + availableStallDurations.insert(availableStallDurations.end(), + availableStallDurationsRaw.begin(), + availableStallDurationsRaw.end()); + } + if (hasCapability(BURST_CAPTURE)) { + availableStallDurations.insert(availableStallDurations.end(), + availableStallDurationsBurst.begin(), + availableStallDurationsBurst.end()); + } + + if (availableStallDurations.size() > 0) { + ADD_STATIC_ENTRY(ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, + &availableStallDurations[0], + availableStallDurations.size()); + } + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_FREEFORM; + ADD_STATIC_ENTRY(ANDROID_SCALER_CROPPING_TYPE, + &croppingType, 1); + + static const float maxZoom = 10; + ADD_STATIC_ENTRY(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, + &maxZoom, 1); + } + + // android.jpeg + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const int32_t jpegThumbnailSizes[] = { + 0, 0, + 160, 120, + 320, 240 + }; + ADD_STATIC_ENTRY(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, + jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t)); + + static const int32_t jpegMaxSize = JpegCompressor::kMaxJpegSize; + ADD_STATIC_ENTRY(ANDROID_JPEG_MAX_SIZE, &jpegMaxSize, 1); + } + + // android.stats + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableFaceDetectModes[] = { + ANDROID_STATISTICS_FACE_DETECT_MODE_OFF, + ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE, + ANDROID_STATISTICS_FACE_DETECT_MODE_FULL + }; + ADD_STATIC_ENTRY(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, + availableFaceDetectModes, + sizeof(availableFaceDetectModes)); + + static const int32_t maxFaceCount = 8; + ADD_STATIC_ENTRY(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, + &maxFaceCount, 1); + + + static const uint8_t availableShadingMapModes[] = { + ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF + }; + ADD_STATIC_ENTRY(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES, + availableShadingMapModes, sizeof(availableShadingMapModes)); + } + + // android.sync + + static const int32_t maxLatency = + hasCapability(FULL_LEVEL) ? ANDROID_SYNC_MAX_LATENCY_PER_FRAME_CONTROL : 3; + ADD_STATIC_ENTRY(ANDROID_SYNC_MAX_LATENCY, &maxLatency, 1); + + // android.control + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableControlModes[] = { + ANDROID_CONTROL_MODE_OFF, ANDROID_CONTROL_MODE_AUTO, ANDROID_CONTROL_MODE_USE_SCENE_MODE + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AVAILABLE_MODES, + availableControlModes, sizeof(availableControlModes)); + } else { + static const uint8_t availableControlModes[] = { + ANDROID_CONTROL_MODE_AUTO + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AVAILABLE_MODES, + availableControlModes, sizeof(availableControlModes)); + } + + static const uint8_t availableSceneModes[] = { + hasCapability(BACKWARD_COMPATIBLE) ? + ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY : + ANDROID_CONTROL_SCENE_MODE_DISABLED + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AVAILABLE_SCENE_MODES, + availableSceneModes, sizeof(availableSceneModes)); + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableEffects[] = { + ANDROID_CONTROL_EFFECT_MODE_OFF + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AVAILABLE_EFFECTS, + availableEffects, sizeof(availableEffects)); + } + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const int32_t max3aRegions[] = {/*AE*/ 1,/*AWB*/ 0,/*AF*/ 1}; + ADD_STATIC_ENTRY(ANDROID_CONTROL_MAX_REGIONS, + max3aRegions, sizeof(max3aRegions)/sizeof(max3aRegions[0])); + + static const uint8_t availableAeModes[] = { + ANDROID_CONTROL_AE_MODE_OFF, + ANDROID_CONTROL_AE_MODE_ON + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AE_AVAILABLE_MODES, + availableAeModes, sizeof(availableAeModes)); + + static const camera_metadata_rational exposureCompensationStep = { + 1, 3 + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AE_COMPENSATION_STEP, + &exposureCompensationStep, 1); + + int32_t exposureCompensationRange[] = {-9, 9}; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AE_COMPENSATION_RANGE, + exposureCompensationRange, + sizeof(exposureCompensationRange)/sizeof(int32_t)); + } + + static const int32_t availableTargetFpsRanges[] = { + 5, 30, 15, 30, 15, 15, 30, 30 + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + availableTargetFpsRanges, + sizeof(availableTargetFpsRanges)/sizeof(int32_t)); + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableAntibandingModes[] = { + ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF, + ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, + availableAntibandingModes, sizeof(availableAntibandingModes)); + } + + static const uint8_t aeLockAvailable = hasCapability(BACKWARD_COMPATIBLE) ? + ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE : ANDROID_CONTROL_AE_LOCK_AVAILABLE_FALSE; + + ADD_STATIC_ENTRY(ANDROID_CONTROL_AE_LOCK_AVAILABLE, + &aeLockAvailable, 1); + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableAwbModes[] = { + ANDROID_CONTROL_AWB_MODE_OFF, + ANDROID_CONTROL_AWB_MODE_AUTO, + ANDROID_CONTROL_AWB_MODE_INCANDESCENT, + ANDROID_CONTROL_AWB_MODE_FLUORESCENT, + ANDROID_CONTROL_AWB_MODE_DAYLIGHT, + ANDROID_CONTROL_AWB_MODE_SHADE + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AWB_AVAILABLE_MODES, + availableAwbModes, sizeof(availableAwbModes)); + } + + static const uint8_t awbLockAvailable = hasCapability(BACKWARD_COMPATIBLE) ? + ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE : ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE; + + ADD_STATIC_ENTRY(ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + &awbLockAvailable, 1); + + static const uint8_t availableAfModesBack[] = { + ANDROID_CONTROL_AF_MODE_OFF, + ANDROID_CONTROL_AF_MODE_AUTO, + ANDROID_CONTROL_AF_MODE_MACRO, + ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO, + ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE + }; + + static const uint8_t availableAfModesFront[] = { + ANDROID_CONTROL_AF_MODE_OFF + }; + + if (mFacingBack && hasCapability(BACKWARD_COMPATIBLE)) { + ADD_STATIC_ENTRY(ANDROID_CONTROL_AF_AVAILABLE_MODES, + availableAfModesBack, sizeof(availableAfModesBack)); + } else { + ADD_STATIC_ENTRY(ANDROID_CONTROL_AF_AVAILABLE_MODES, + availableAfModesFront, sizeof(availableAfModesFront)); + } + + static const uint8_t availableVstabModes[] = { + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF + }; + ADD_STATIC_ENTRY(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, + availableVstabModes, sizeof(availableVstabModes)); + + // android.colorCorrection + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableAberrationModes[] = { + ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF, + ANDROID_COLOR_CORRECTION_ABERRATION_MODE_FAST, + ANDROID_COLOR_CORRECTION_ABERRATION_MODE_HIGH_QUALITY + }; + ADD_STATIC_ENTRY(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, + availableAberrationModes, sizeof(availableAberrationModes)); + } else { + static const uint8_t availableAberrationModes[] = { + ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF, + }; + ADD_STATIC_ENTRY(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, + availableAberrationModes, sizeof(availableAberrationModes)); + } + // android.edge + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableEdgeModes[] = { + ANDROID_EDGE_MODE_OFF, ANDROID_EDGE_MODE_FAST, ANDROID_EDGE_MODE_HIGH_QUALITY + }; + ADD_STATIC_ENTRY(ANDROID_EDGE_AVAILABLE_EDGE_MODES, + availableEdgeModes, sizeof(availableEdgeModes)); + } else { + static const uint8_t availableEdgeModes[] = { + ANDROID_EDGE_MODE_OFF + }; + ADD_STATIC_ENTRY(ANDROID_EDGE_AVAILABLE_EDGE_MODES, + availableEdgeModes, sizeof(availableEdgeModes)); + } + + // android.info + + static const uint8_t supportedHardwareLevel = + hasCapability(FULL_LEVEL) ? ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL : + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + ADD_STATIC_ENTRY(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, + &supportedHardwareLevel, + /*count*/1); + + // android.noiseReduction + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableNoiseReductionModes[] = { + ANDROID_NOISE_REDUCTION_MODE_OFF, + ANDROID_NOISE_REDUCTION_MODE_FAST, + ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY + }; + ADD_STATIC_ENTRY(ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + availableNoiseReductionModes, sizeof(availableNoiseReductionModes)); + } else { + static const uint8_t availableNoiseReductionModes[] = { + ANDROID_NOISE_REDUCTION_MODE_OFF, + }; + ADD_STATIC_ENTRY(ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + availableNoiseReductionModes, sizeof(availableNoiseReductionModes)); + } + + // android.depth + + if (hasCapability(DEPTH_OUTPUT)) { + + static const int32_t maxDepthSamples = 100; + ADD_STATIC_ENTRY(ANDROID_DEPTH_MAX_DEPTH_SAMPLES, + &maxDepthSamples, 1); + + static const int32_t availableDepthStreamConfigurations[] = { + HAL_PIXEL_FORMAT_Y16, 160, 120, ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT, + HAL_PIXEL_FORMAT_BLOB, maxDepthSamples,1, ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT + }; + ADD_STATIC_ENTRY(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS, + availableDepthStreamConfigurations, + sizeof(availableDepthStreamConfigurations)/sizeof(int32_t)); + + static const int64_t availableDepthMinFrameDurations[] = { + HAL_PIXEL_FORMAT_Y16, 160, 120, Sensor::kFrameDurationRange[0], + HAL_PIXEL_FORMAT_BLOB, maxDepthSamples,1, Sensor::kFrameDurationRange[0] + }; + ADD_STATIC_ENTRY(ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS, + availableDepthMinFrameDurations, + sizeof(availableDepthMinFrameDurations)/sizeof(int64_t)); + + static const int64_t availableDepthStallDurations[] = { + HAL_PIXEL_FORMAT_Y16, 160, 120, Sensor::kFrameDurationRange[0], + HAL_PIXEL_FORMAT_BLOB, maxDepthSamples,1, Sensor::kFrameDurationRange[0] + }; + ADD_STATIC_ENTRY(ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS, + availableDepthStallDurations, + sizeof(availableDepthStallDurations)/sizeof(int64_t)); + + uint8_t depthIsExclusive = ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE_FALSE; + ADD_STATIC_ENTRY(ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE, + &depthIsExclusive, 1); + } + + // android.shading + + if (hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t availableShadingModes[] = { + ANDROID_SHADING_MODE_OFF, ANDROID_SHADING_MODE_FAST, ANDROID_SHADING_MODE_HIGH_QUALITY + }; + ADD_STATIC_ENTRY(ANDROID_SHADING_AVAILABLE_MODES, availableShadingModes, + sizeof(availableShadingModes)); + } else { + static const uint8_t availableShadingModes[] = { + ANDROID_SHADING_MODE_OFF + }; + ADD_STATIC_ENTRY(ANDROID_SHADING_AVAILABLE_MODES, availableShadingModes, + sizeof(availableShadingModes)); + } + + // android.request + + static const int32_t maxNumOutputStreams[] = { + kMaxRawStreamCount, kMaxProcessedStreamCount, kMaxJpegStreamCount + }; + ADD_STATIC_ENTRY(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, maxNumOutputStreams, 3); + + static const uint8_t maxPipelineDepth = kMaxBufferCount; + ADD_STATIC_ENTRY(ANDROID_REQUEST_PIPELINE_MAX_DEPTH, &maxPipelineDepth, 1); + + static const int32_t partialResultCount = 1; + ADD_STATIC_ENTRY(ANDROID_REQUEST_PARTIAL_RESULT_COUNT, + &partialResultCount, /*count*/1); + + SortedVector caps; + for (size_t i = 0; i < mCapabilities.size(); i++) { + switch(mCapabilities[i]) { + case BACKWARD_COMPATIBLE: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE); + break; + case MANUAL_SENSOR: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR); + break; + case MANUAL_POST_PROCESSING: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING); + break; + case RAW: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); + break; + case PRIVATE_REPROCESSING: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING); + break; + case READ_SENSOR_SETTINGS: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS); + break; + case BURST_CAPTURE: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE); + break; + case YUV_REPROCESSING: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING); + break; + case DEPTH_OUTPUT: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT); + break; + case CONSTRAINED_HIGH_SPEED_VIDEO: + caps.add(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO); + break; + default: + // Ignore LEVELs + break; + } + } + ADD_STATIC_ENTRY(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, caps.array(), caps.size()); + + // Scan a default request template for included request keys + Vector availableRequestKeys; + const camera_metadata_t *previewRequest = + constructDefaultRequestSettings(CAMERA3_TEMPLATE_PREVIEW); + for (size_t i = 0; i < get_camera_metadata_entry_count(previewRequest); i++) { + camera_metadata_ro_entry_t entry; + get_camera_metadata_ro_entry(previewRequest, i, &entry); + availableRequestKeys.add(entry.tag); + } + ADD_STATIC_ENTRY(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, availableRequestKeys.array(), + availableRequestKeys.size()); + + // Add a few more result keys. Must be kept up to date with the various places that add these + + Vector availableResultKeys(availableRequestKeys); + if (hasCapability(BACKWARD_COMPATIBLE)) { + availableResultKeys.add(ANDROID_CONTROL_AE_STATE); + availableResultKeys.add(ANDROID_CONTROL_AF_STATE); + availableResultKeys.add(ANDROID_CONTROL_AWB_STATE); + availableResultKeys.add(ANDROID_FLASH_STATE); + availableResultKeys.add(ANDROID_LENS_STATE); + availableResultKeys.add(ANDROID_LENS_FOCUS_RANGE); + availableResultKeys.add(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW); + availableResultKeys.add(ANDROID_STATISTICS_SCENE_FLICKER); + } + + if (hasCapability(DEPTH_OUTPUT)) { + availableResultKeys.add(ANDROID_LENS_POSE_ROTATION); + availableResultKeys.add(ANDROID_LENS_POSE_TRANSLATION); + availableResultKeys.add(ANDROID_LENS_INTRINSIC_CALIBRATION); + availableResultKeys.add(ANDROID_LENS_RADIAL_DISTORTION); + } + + availableResultKeys.add(ANDROID_REQUEST_PIPELINE_DEPTH); + availableResultKeys.add(ANDROID_SENSOR_TIMESTAMP); + + ADD_STATIC_ENTRY(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, availableResultKeys.array(), + availableResultKeys.size()); + + // Needs to be last, to collect all the keys set + + availableCharacteristicsKeys.add(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS); + info.update(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, + availableCharacteristicsKeys); + + mCameraInfo = info.release(); + +#undef ADD_STATIC_ENTRY + return OK; +} + +status_t EmulatedFakeCamera3::process3A(CameraMetadata &settings) { + /** + * Extract top-level 3A controls + */ + status_t res; + + bool facePriority = false; + + camera_metadata_entry e; + + e = settings.find(ANDROID_CONTROL_MODE); + if (e.count == 0) { + ALOGE("%s: No control mode entry!", __FUNCTION__); + return BAD_VALUE; + } + uint8_t controlMode = e.data.u8[0]; + + if (controlMode == ANDROID_CONTROL_MODE_OFF) { + mAeState = ANDROID_CONTROL_AE_STATE_INACTIVE; + mAfState = ANDROID_CONTROL_AF_STATE_INACTIVE; + mAwbState = ANDROID_CONTROL_AWB_STATE_INACTIVE; + update3A(settings); + return OK; + } else if (controlMode == ANDROID_CONTROL_MODE_USE_SCENE_MODE) { + if (!hasCapability(BACKWARD_COMPATIBLE)) { + ALOGE("%s: Can't use scene mode when BACKWARD_COMPATIBLE not supported!", + __FUNCTION__); + return BAD_VALUE; + } + + e = settings.find(ANDROID_CONTROL_SCENE_MODE); + if (e.count == 0) { + ALOGE("%s: No scene mode entry!", __FUNCTION__); + return BAD_VALUE; + } + uint8_t sceneMode = e.data.u8[0]; + + switch(sceneMode) { + case ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY: + mFacePriority = true; + break; + default: + ALOGE("%s: Emulator doesn't support scene mode %d", + __FUNCTION__, sceneMode); + return BAD_VALUE; + } + } else { + mFacePriority = false; + } + + // controlMode == AUTO or sceneMode = FACE_PRIORITY + // Process individual 3A controls + + res = doFakeAE(settings); + if (res != OK) return res; + + res = doFakeAF(settings); + if (res != OK) return res; + + res = doFakeAWB(settings); + if (res != OK) return res; + + update3A(settings); + return OK; +} + +status_t EmulatedFakeCamera3::doFakeAE(CameraMetadata &settings) { + camera_metadata_entry e; + + e = settings.find(ANDROID_CONTROL_AE_MODE); + if (e.count == 0 && hasCapability(BACKWARD_COMPATIBLE)) { + ALOGE("%s: No AE mode entry!", __FUNCTION__); + return BAD_VALUE; + } + uint8_t aeMode = (e.count > 0) ? e.data.u8[0] : (uint8_t)ANDROID_CONTROL_AE_MODE_ON; + + switch (aeMode) { + case ANDROID_CONTROL_AE_MODE_OFF: + // AE is OFF + mAeState = ANDROID_CONTROL_AE_STATE_INACTIVE; + return OK; + case ANDROID_CONTROL_AE_MODE_ON: + // OK for AUTO modes + break; + default: + // Mostly silently ignore unsupported modes + ALOGV("%s: Emulator doesn't support AE mode %d, assuming ON", + __FUNCTION__, aeMode); + break; + } + + e = settings.find(ANDROID_CONTROL_AE_LOCK); + bool aeLocked = (e.count > 0) ? (e.data.u8[0] == ANDROID_CONTROL_AE_LOCK_ON) : false; + + e = settings.find(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER); + bool precaptureTrigger = false; + if (e.count != 0) { + precaptureTrigger = + (e.data.u8[0] == ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_START); + } + + if (precaptureTrigger) { + ALOGV("%s: Pre capture trigger = %d", __FUNCTION__, precaptureTrigger); + } else if (e.count > 0) { + ALOGV("%s: Pre capture trigger was present? %zu", + __FUNCTION__, + e.count); + } + + if (precaptureTrigger || mAeState == ANDROID_CONTROL_AE_STATE_PRECAPTURE) { + // Run precapture sequence + if (mAeState != ANDROID_CONTROL_AE_STATE_PRECAPTURE) { + mAeCounter = 0; + } + + if (mFacePriority) { + mAeTargetExposureTime = kFacePriorityExposureTime; + } else { + mAeTargetExposureTime = kNormalExposureTime; + } + + if (mAeCounter > kPrecaptureMinFrames && + (mAeTargetExposureTime - mAeCurrentExposureTime) < + mAeTargetExposureTime / 10) { + // Done with precapture + mAeCounter = 0; + mAeState = aeLocked ? ANDROID_CONTROL_AE_STATE_LOCKED : + ANDROID_CONTROL_AE_STATE_CONVERGED; + } else { + // Converge some more + mAeCurrentExposureTime += + (mAeTargetExposureTime - mAeCurrentExposureTime) * + kExposureTrackRate; + mAeCounter++; + mAeState = ANDROID_CONTROL_AE_STATE_PRECAPTURE; + } + + } else if (!aeLocked) { + // Run standard occasional AE scan + switch (mAeState) { + case ANDROID_CONTROL_AE_STATE_CONVERGED: + case ANDROID_CONTROL_AE_STATE_INACTIVE: + mAeCounter++; + if (mAeCounter > kStableAeMaxFrames) { + mAeTargetExposureTime = + mFacePriority ? kFacePriorityExposureTime : + kNormalExposureTime; + float exposureStep = ((double)rand() / RAND_MAX) * + (kExposureWanderMax - kExposureWanderMin) + + kExposureWanderMin; + mAeTargetExposureTime *= std::pow(2, exposureStep); + mAeState = ANDROID_CONTROL_AE_STATE_SEARCHING; + } + break; + case ANDROID_CONTROL_AE_STATE_SEARCHING: + mAeCurrentExposureTime += + (mAeTargetExposureTime - mAeCurrentExposureTime) * + kExposureTrackRate; + if (abs(mAeTargetExposureTime - mAeCurrentExposureTime) < + mAeTargetExposureTime / 10) { + // Close enough + mAeState = ANDROID_CONTROL_AE_STATE_CONVERGED; + mAeCounter = 0; + } + break; + case ANDROID_CONTROL_AE_STATE_LOCKED: + mAeState = ANDROID_CONTROL_AE_STATE_CONVERGED; + mAeCounter = 0; + break; + default: + ALOGE("%s: Emulator in unexpected AE state %d", + __FUNCTION__, mAeState); + return INVALID_OPERATION; + } + } else { + // AE is locked + mAeState = ANDROID_CONTROL_AE_STATE_LOCKED; + } + + return OK; +} + +status_t EmulatedFakeCamera3::doFakeAF(CameraMetadata &settings) { + camera_metadata_entry e; + + e = settings.find(ANDROID_CONTROL_AF_MODE); + if (e.count == 0 && hasCapability(BACKWARD_COMPATIBLE)) { + ALOGE("%s: No AF mode entry!", __FUNCTION__); + return BAD_VALUE; + } + uint8_t afMode = (e.count > 0) ? e.data.u8[0] : (uint8_t)ANDROID_CONTROL_AF_MODE_OFF; + + e = settings.find(ANDROID_CONTROL_AF_TRIGGER); + typedef camera_metadata_enum_android_control_af_trigger af_trigger_t; + af_trigger_t afTrigger; + if (e.count != 0) { + afTrigger = static_cast(e.data.u8[0]); + + ALOGV("%s: AF trigger set to 0x%x", __FUNCTION__, afTrigger); + ALOGV("%s: AF mode is 0x%x", __FUNCTION__, afMode); + } else { + afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE; + } + + switch (afMode) { + case ANDROID_CONTROL_AF_MODE_OFF: + mAfState = ANDROID_CONTROL_AF_STATE_INACTIVE; + return OK; + case ANDROID_CONTROL_AF_MODE_AUTO: + case ANDROID_CONTROL_AF_MODE_MACRO: + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + if (!mFacingBack) { + ALOGE("%s: Front camera doesn't support AF mode %d", + __FUNCTION__, afMode); + return BAD_VALUE; + } + // OK, handle transitions lower on + break; + default: + ALOGE("%s: Emulator doesn't support AF mode %d", + __FUNCTION__, afMode); + return BAD_VALUE; + } + + bool afModeChanged = mAfMode != afMode; + mAfMode = afMode; + + /** + * Simulate AF triggers. Transition at most 1 state per frame. + * - Focusing always succeeds (goes into locked, or PASSIVE_SCAN). + */ + + bool afTriggerStart = false; + bool afTriggerCancel = false; + switch (afTrigger) { + case ANDROID_CONTROL_AF_TRIGGER_IDLE: + break; + case ANDROID_CONTROL_AF_TRIGGER_START: + afTriggerStart = true; + break; + case ANDROID_CONTROL_AF_TRIGGER_CANCEL: + afTriggerCancel = true; + // Cancel trigger always transitions into INACTIVE + mAfState = ANDROID_CONTROL_AF_STATE_INACTIVE; + + ALOGV("%s: AF State transition to STATE_INACTIVE", __FUNCTION__); + + // Stay in 'inactive' until at least next frame + return OK; + default: + ALOGE("%s: Unknown af trigger value %d", __FUNCTION__, afTrigger); + return BAD_VALUE; + } + + // If we get down here, we're either in an autofocus mode + // or in a continuous focus mode (and no other modes) + + int oldAfState = mAfState; + switch (mAfState) { + case ANDROID_CONTROL_AF_STATE_INACTIVE: + if (afTriggerStart) { + switch (afMode) { + case ANDROID_CONTROL_AF_MODE_AUTO: + // fall-through + case ANDROID_CONTROL_AF_MODE_MACRO: + mAfState = ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN; + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + // fall-through + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + mAfState = ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED; + break; + } + } else { + // At least one frame stays in INACTIVE + if (!afModeChanged) { + switch (afMode) { + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + // fall-through + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + mAfState = ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN; + break; + } + } + } + break; + case ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN: + /** + * When the AF trigger is activated, the algorithm should finish + * its PASSIVE_SCAN if active, and then transition into AF_FOCUSED + * or AF_NOT_FOCUSED as appropriate + */ + if (afTriggerStart) { + // Randomly transition to focused or not focused + if (rand() % 3) { + mAfState = ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED; + } else { + mAfState = ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED; + } + } + /** + * When the AF trigger is not involved, the AF algorithm should + * start in INACTIVE state, and then transition into PASSIVE_SCAN + * and PASSIVE_FOCUSED states + */ + else if (!afTriggerCancel) { + // Randomly transition to passive focus + if (rand() % 3 == 0) { + mAfState = ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED; + } + } + + break; + case ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED: + if (afTriggerStart) { + // Randomly transition to focused or not focused + if (rand() % 3) { + mAfState = ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED; + } else { + mAfState = ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED; + } + } + // TODO: initiate passive scan (PASSIVE_SCAN) + break; + case ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN: + // Simulate AF sweep completing instantaneously + + // Randomly transition to focused or not focused + if (rand() % 3) { + mAfState = ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED; + } else { + mAfState = ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED; + } + break; + case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED: + if (afTriggerStart) { + switch (afMode) { + case ANDROID_CONTROL_AF_MODE_AUTO: + // fall-through + case ANDROID_CONTROL_AF_MODE_MACRO: + mAfState = ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN; + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + // fall-through + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + // continuous autofocus => trigger start has no effect + break; + } + } + break; + case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: + if (afTriggerStart) { + switch (afMode) { + case ANDROID_CONTROL_AF_MODE_AUTO: + // fall-through + case ANDROID_CONTROL_AF_MODE_MACRO: + mAfState = ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN; + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + // fall-through + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + // continuous autofocus => trigger start has no effect + break; + } + } + break; + default: + ALOGE("%s: Bad af state %d", __FUNCTION__, mAfState); + } + + { + char afStateString[100] = {0,}; + camera_metadata_enum_snprint(ANDROID_CONTROL_AF_STATE, + oldAfState, + afStateString, + sizeof(afStateString)); + + char afNewStateString[100] = {0,}; + camera_metadata_enum_snprint(ANDROID_CONTROL_AF_STATE, + mAfState, + afNewStateString, + sizeof(afNewStateString)); + ALOGVV("%s: AF state transitioned from %s to %s", + __FUNCTION__, afStateString, afNewStateString); + } + + + return OK; +} + +status_t EmulatedFakeCamera3::doFakeAWB(CameraMetadata &settings) { + camera_metadata_entry e; + + e = settings.find(ANDROID_CONTROL_AWB_MODE); + if (e.count == 0 && hasCapability(BACKWARD_COMPATIBLE)) { + ALOGE("%s: No AWB mode entry!", __FUNCTION__); + return BAD_VALUE; + } + uint8_t awbMode = (e.count > 0) ? e.data.u8[0] : (uint8_t)ANDROID_CONTROL_AWB_MODE_AUTO; + + // TODO: Add white balance simulation + + switch (awbMode) { + case ANDROID_CONTROL_AWB_MODE_OFF: + mAwbState = ANDROID_CONTROL_AWB_STATE_INACTIVE; + return OK; + case ANDROID_CONTROL_AWB_MODE_AUTO: + case ANDROID_CONTROL_AWB_MODE_INCANDESCENT: + case ANDROID_CONTROL_AWB_MODE_FLUORESCENT: + case ANDROID_CONTROL_AWB_MODE_DAYLIGHT: + case ANDROID_CONTROL_AWB_MODE_SHADE: + // OK + break; + default: + ALOGE("%s: Emulator doesn't support AWB mode %d", + __FUNCTION__, awbMode); + return BAD_VALUE; + } + + return OK; +} + + +void EmulatedFakeCamera3::update3A(CameraMetadata &settings) { + if (mAeMode != ANDROID_CONTROL_AE_MODE_OFF) { + settings.update(ANDROID_SENSOR_EXPOSURE_TIME, + &mAeCurrentExposureTime, 1); + settings.update(ANDROID_SENSOR_SENSITIVITY, + &mAeCurrentSensitivity, 1); + } + + settings.update(ANDROID_CONTROL_AE_STATE, + &mAeState, 1); + settings.update(ANDROID_CONTROL_AF_STATE, + &mAfState, 1); + settings.update(ANDROID_CONTROL_AWB_STATE, + &mAwbState, 1); + + uint8_t lensState; + switch (mAfState) { + case ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN: + case ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN: + lensState = ANDROID_LENS_STATE_MOVING; + break; + case ANDROID_CONTROL_AF_STATE_INACTIVE: + case ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED: + case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED: + case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: + case ANDROID_CONTROL_AF_STATE_PASSIVE_UNFOCUSED: + default: + lensState = ANDROID_LENS_STATE_STATIONARY; + break; + } + settings.update(ANDROID_LENS_STATE, &lensState, 1); + +} + +void EmulatedFakeCamera3::signalReadoutIdle() { + Mutex::Autolock l(mLock); + // Need to chek isIdle again because waiting on mLock may have allowed + // something to be placed in the in-flight queue. + if (mStatus == STATUS_ACTIVE && mReadoutThread->isIdle()) { + ALOGV("Now idle"); + mStatus = STATUS_READY; + } +} + +void EmulatedFakeCamera3::onSensorEvent(uint32_t frameNumber, Event e, + nsecs_t timestamp) { + switch(e) { + case Sensor::SensorListener::EXPOSURE_START: { + ALOGVV("%s: Frame %d: Sensor started exposure at %lld", + __FUNCTION__, frameNumber, timestamp); + // Trigger shutter notify to framework + camera3_notify_msg_t msg; + msg.type = CAMERA3_MSG_SHUTTER; + msg.message.shutter.frame_number = frameNumber; + msg.message.shutter.timestamp = timestamp; + sendNotify(&msg); + break; + } + default: + ALOGW("%s: Unexpected sensor event %d at %" PRId64, __FUNCTION__, + e, timestamp); + break; + } +} + +EmulatedFakeCamera3::ReadoutThread::ReadoutThread(EmulatedFakeCamera3 *parent) : + mParent(parent), mJpegWaiting(false) { +} + +EmulatedFakeCamera3::ReadoutThread::~ReadoutThread() { + for (List::iterator i = mInFlightQueue.begin(); + i != mInFlightQueue.end(); i++) { + delete i->buffers; + delete i->sensorBuffers; + } +} + +void EmulatedFakeCamera3::ReadoutThread::queueCaptureRequest(const Request &r) { + Mutex::Autolock l(mLock); + + mInFlightQueue.push_back(r); + mInFlightSignal.signal(); +} + +bool EmulatedFakeCamera3::ReadoutThread::isIdle() { + Mutex::Autolock l(mLock); + return mInFlightQueue.empty() && !mThreadActive; +} + +status_t EmulatedFakeCamera3::ReadoutThread::waitForReadout() { + status_t res; + Mutex::Autolock l(mLock); + int loopCount = 0; + while (mInFlightQueue.size() >= kMaxQueueSize) { + res = mInFlightSignal.waitRelative(mLock, kWaitPerLoop); + if (res != OK && res != TIMED_OUT) { + ALOGE("%s: Error waiting for in-flight queue to shrink", + __FUNCTION__); + return INVALID_OPERATION; + } + if (loopCount == kMaxWaitLoops) { + ALOGE("%s: Timed out waiting for in-flight queue to shrink", + __FUNCTION__); + return TIMED_OUT; + } + loopCount++; + } + return OK; +} + +bool EmulatedFakeCamera3::ReadoutThread::threadLoop() { + status_t res; + + ALOGVV("%s: ReadoutThread waiting for request", __FUNCTION__); + + // First wait for a request from the in-flight queue + + if (mCurrentRequest.settings.isEmpty()) { + Mutex::Autolock l(mLock); + if (mInFlightQueue.empty()) { + res = mInFlightSignal.waitRelative(mLock, kWaitPerLoop); + if (res == TIMED_OUT) { + ALOGVV("%s: ReadoutThread: Timed out waiting for request", + __FUNCTION__); + return true; + } else if (res != NO_ERROR) { + ALOGE("%s: Error waiting for capture requests: %d", + __FUNCTION__, res); + return false; + } + } + mCurrentRequest.frameNumber = mInFlightQueue.begin()->frameNumber; + mCurrentRequest.settings.acquire(mInFlightQueue.begin()->settings); + mCurrentRequest.buffers = mInFlightQueue.begin()->buffers; + mCurrentRequest.sensorBuffers = mInFlightQueue.begin()->sensorBuffers; + mInFlightQueue.erase(mInFlightQueue.begin()); + mInFlightSignal.signal(); + mThreadActive = true; + ALOGVV("%s: Beginning readout of frame %d", __FUNCTION__, + mCurrentRequest.frameNumber); + } + + // Then wait for it to be delivered from the sensor + ALOGVV("%s: ReadoutThread: Wait for frame to be delivered from sensor", + __FUNCTION__); + + nsecs_t captureTime; + bool gotFrame = + mParent->mSensor->waitForNewFrame(kWaitPerLoop, &captureTime); + if (!gotFrame) { + ALOGVV("%s: ReadoutThread: Timed out waiting for sensor frame", + __FUNCTION__); + return true; + } + + ALOGVV("Sensor done with readout for frame %d, captured at %lld ", + mCurrentRequest.frameNumber, captureTime); + + // Check if we need to JPEG encode a buffer, and send it for async + // compression if so. Otherwise prepare the buffer for return. + bool needJpeg = false; + HalBufferVector::iterator buf = mCurrentRequest.buffers->begin(); + while(buf != mCurrentRequest.buffers->end()) { + bool goodBuffer = true; + if ( buf->stream->format == + HAL_PIXEL_FORMAT_BLOB && buf->stream->data_space != HAL_DATASPACE_DEPTH) { + Mutex::Autolock jl(mJpegLock); + if (mJpegWaiting) { + // This shouldn't happen, because processCaptureRequest should + // be stalling until JPEG compressor is free. + ALOGE("%s: Already processing a JPEG!", __FUNCTION__); + goodBuffer = false; + } + if (goodBuffer) { + // Compressor takes ownership of sensorBuffers here + res = mParent->mJpegCompressor->start(mCurrentRequest.sensorBuffers, + this); + goodBuffer = (res == OK); + } + if (goodBuffer) { + needJpeg = true; + + mJpegHalBuffer = *buf; + mJpegFrameNumber = mCurrentRequest.frameNumber; + mJpegWaiting = true; + + mCurrentRequest.sensorBuffers = NULL; + buf = mCurrentRequest.buffers->erase(buf); + + continue; + } + ALOGE("%s: Error compressing output buffer: %s (%d)", + __FUNCTION__, strerror(-res), res); + // fallthrough for cleanup + } + GraphicBufferMapper::get().unlock(*(buf->buffer)); + + buf->status = goodBuffer ? CAMERA3_BUFFER_STATUS_OK : + CAMERA3_BUFFER_STATUS_ERROR; + buf->acquire_fence = -1; + buf->release_fence = -1; + + ++buf; + } // end while + + // Construct result for all completed buffers and results + + camera3_capture_result result; + + if (mParent->hasCapability(BACKWARD_COMPATIBLE)) { + static const uint8_t sceneFlicker = ANDROID_STATISTICS_SCENE_FLICKER_NONE; + mCurrentRequest.settings.update(ANDROID_STATISTICS_SCENE_FLICKER, + &sceneFlicker, 1); + + static const uint8_t flashState = ANDROID_FLASH_STATE_UNAVAILABLE; + mCurrentRequest.settings.update(ANDROID_FLASH_STATE, + &flashState, 1); + + nsecs_t rollingShutterSkew = Sensor::kFrameDurationRange[0]; + mCurrentRequest.settings.update(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, + &rollingShutterSkew, 1); + + float focusRange[] = { 1.0f/5.0f, 0 }; // 5 m to infinity in focus + mCurrentRequest.settings.update(ANDROID_LENS_FOCUS_RANGE, + focusRange, sizeof(focusRange)/sizeof(float)); + } + + if (mParent->hasCapability(DEPTH_OUTPUT)) { + camera_metadata_entry_t entry; + + find_camera_metadata_entry(mParent->mCameraInfo, ANDROID_LENS_POSE_TRANSLATION, &entry); + mCurrentRequest.settings.update(ANDROID_LENS_POSE_TRANSLATION, + entry.data.f, entry.count); + + find_camera_metadata_entry(mParent->mCameraInfo, ANDROID_LENS_POSE_ROTATION, &entry); + mCurrentRequest.settings.update(ANDROID_LENS_POSE_ROTATION, + entry.data.f, entry.count); + + find_camera_metadata_entry(mParent->mCameraInfo, ANDROID_LENS_INTRINSIC_CALIBRATION, &entry); + mCurrentRequest.settings.update(ANDROID_LENS_INTRINSIC_CALIBRATION, + entry.data.f, entry.count); + + find_camera_metadata_entry(mParent->mCameraInfo, ANDROID_LENS_RADIAL_DISTORTION, &entry); + mCurrentRequest.settings.update(ANDROID_LENS_RADIAL_DISTORTION, + entry.data.f, entry.count); + } + + mCurrentRequest.settings.update(ANDROID_SENSOR_TIMESTAMP, + &captureTime, 1); + + + // JPEGs take a stage longer + const uint8_t pipelineDepth = needJpeg ? kMaxBufferCount : kMaxBufferCount - 1; + mCurrentRequest.settings.update(ANDROID_REQUEST_PIPELINE_DEPTH, + &pipelineDepth, 1); + + result.frame_number = mCurrentRequest.frameNumber; + result.result = mCurrentRequest.settings.getAndLock(); + result.num_output_buffers = mCurrentRequest.buffers->size(); + result.output_buffers = mCurrentRequest.buffers->array(); + result.input_buffer = nullptr; + result.partial_result = 1; + + // Go idle if queue is empty, before sending result + bool signalIdle = false; + { + Mutex::Autolock l(mLock); + if (mInFlightQueue.empty()) { + mThreadActive = false; + signalIdle = true; + } + } + if (signalIdle) mParent->signalReadoutIdle(); + + // Send it off to the framework + ALOGVV("%s: ReadoutThread: Send result to framework", + __FUNCTION__); + mParent->sendCaptureResult(&result); + + // Clean up + mCurrentRequest.settings.unlock(result.result); + + delete mCurrentRequest.buffers; + mCurrentRequest.buffers = NULL; + if (!needJpeg) { + delete mCurrentRequest.sensorBuffers; + mCurrentRequest.sensorBuffers = NULL; + } + mCurrentRequest.settings.clear(); + + return true; +} + +void EmulatedFakeCamera3::ReadoutThread::onJpegDone( + const StreamBuffer &jpegBuffer, bool success) { + Mutex::Autolock jl(mJpegLock); + + GraphicBufferMapper::get().unlock(*(jpegBuffer.buffer)); + + mJpegHalBuffer.status = success ? + CAMERA3_BUFFER_STATUS_OK : CAMERA3_BUFFER_STATUS_ERROR; + mJpegHalBuffer.acquire_fence = -1; + mJpegHalBuffer.release_fence = -1; + mJpegWaiting = false; + + camera3_capture_result result; + result.frame_number = mJpegFrameNumber; + result.result = NULL; + result.num_output_buffers = 1; + result.output_buffers = &mJpegHalBuffer; + + if (!success) { + ALOGE("%s: Compression failure, returning error state buffer to" + " framework", __FUNCTION__); + } else { + ALOGV("%s: Compression complete, returning buffer to framework", + __FUNCTION__); + } + + mParent->sendCaptureResult(&result); +} + +void EmulatedFakeCamera3::ReadoutThread::onJpegInputDone( + const StreamBuffer &inputBuffer) { + // Should never get here, since the input buffer has to be returned + // by end of processCaptureRequest + ALOGE("%s: Unexpected input buffer from JPEG compressor!", __FUNCTION__); +} + + +}; // namespace android diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.h new file mode 100644 index 0000000..4835009 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCamera3.h @@ -0,0 +1,289 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA3_H +#define HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA3_H + +/** + * Contains declaration of a class EmulatedCamera that encapsulates + * functionality of a fake camera that implements version 3 of the camera device + * interace. + */ + +#include "EmulatedCamera3.h" +#include "fake-pipeline2/Base.h" +#include "fake-pipeline2/Sensor.h" +#include "fake-pipeline2/JpegCompressor.h" +#include +#include +#include +#include + +namespace android { + +/** + * Encapsulates functionality for a v3 HAL camera which produces synthetic data. + * + * Note that EmulatedCameraFactory instantiates an object of this class just + * once, when EmulatedCameraFactory instance gets constructed. Connection to / + * disconnection from the actual camera device is handled by calls to + * connectDevice(), and closeCamera() methods of this class that are invoked in + * response to hw_module_methods_t::open, and camera_device::close callbacks. + */ +class EmulatedFakeCamera3 : public EmulatedCamera3, + private Sensor::SensorListener { +public: + + EmulatedFakeCamera3(int cameraId, bool facingBack, + struct hw_module_t* module); + + virtual ~EmulatedFakeCamera3(); + + /**************************************************************************** + * EmulatedCamera3 virtual overrides + ***************************************************************************/ + +public: + + virtual status_t Initialize(); + + /**************************************************************************** + * Camera module API and generic hardware device API implementation + ***************************************************************************/ + +public: + virtual status_t connectCamera(hw_device_t** device); + + virtual status_t closeCamera(); + + virtual status_t getCameraInfo(struct camera_info *info); + + /**************************************************************************** + * EmulatedCamera3 abstract API implementation + ***************************************************************************/ + +protected: + + virtual status_t configureStreams( + camera3_stream_configuration *streamList); + + virtual status_t registerStreamBuffers( + const camera3_stream_buffer_set *bufferSet) ; + + virtual const camera_metadata_t* constructDefaultRequestSettings( + int type); + + virtual status_t processCaptureRequest(camera3_capture_request *request); + + virtual status_t flush(); + + /** Debug methods */ + + virtual void dump(int fd); + +private: + + /** + * Get the requested capability set for this camera + */ + status_t getCameraCapabilities(); + + bool hasCapability(AvailableCapabilities cap); + + /** + * Build the static info metadata buffer for this device + */ + status_t constructStaticInfo(); + + /** + * Run the fake 3A algorithms as needed. May override/modify settings + * values. + */ + status_t process3A(CameraMetadata &settings); + + status_t doFakeAE(CameraMetadata &settings); + status_t doFakeAF(CameraMetadata &settings); + status_t doFakeAWB(CameraMetadata &settings); + void update3A(CameraMetadata &settings); + + /** Signal from readout thread that it doesn't have anything to do */ + void signalReadoutIdle(); + + /** Handle interrupt events from the sensor */ + void onSensorEvent(uint32_t frameNumber, Event e, nsecs_t timestamp); + + /**************************************************************************** + * Static configuration information + ***************************************************************************/ +private: + static const uint32_t kMaxRawStreamCount = 1; + static const uint32_t kMaxProcessedStreamCount = 3; + static const uint32_t kMaxJpegStreamCount = 1; + static const uint32_t kMaxReprocessStreamCount = 2; + static const uint32_t kMaxBufferCount = 4; + // We need a positive stream ID to distinguish external buffers from + // sensor-generated buffers which use a nonpositive ID. Otherwise, HAL3 has + // no concept of a stream id. + static const uint32_t kGenericStreamId = 1; + static const int32_t kAvailableFormats[]; + + static const int64_t kSyncWaitTimeout = 10000000; // 10 ms + static const int32_t kMaxSyncTimeoutCount = 1000; // 1000 kSyncWaitTimeouts + static const uint32_t kFenceTimeoutMs = 2000; // 2 s + + /**************************************************************************** + * Data members. + ***************************************************************************/ + + /* HAL interface serialization lock. */ + Mutex mLock; + + /* Facing back (true) or front (false) switch. */ + bool mFacingBack; + + SortedVector mCapabilities; + + /** + * Cache for default templates. Once one is requested, the pointer must be + * valid at least until close() is called on the device + */ + camera_metadata_t *mDefaultTemplates[CAMERA3_TEMPLATE_COUNT]; + + /** + * Private stream information, stored in camera3_stream_t->priv. + */ + struct PrivateStreamInfo { + bool alive; + }; + + // Shortcut to the input stream + camera3_stream_t* mInputStream; + + typedef List StreamList; + typedef List::iterator StreamIterator; + typedef Vector HalBufferVector; + + // All streams, including input stream + StreamList mStreams; + + // Cached settings from latest submitted request + CameraMetadata mPrevSettings; + + /** Fake hardware interfaces */ + sp mSensor; + sp mJpegCompressor; + friend class JpegCompressor; + + /** Processing thread for sending out results */ + + class ReadoutThread : public Thread, private JpegCompressor::JpegListener { + public: + ReadoutThread(EmulatedFakeCamera3 *parent); + ~ReadoutThread(); + + struct Request { + uint32_t frameNumber; + CameraMetadata settings; + HalBufferVector *buffers; + Buffers *sensorBuffers; + }; + + /** + * Interface to parent class + */ + + // Place request in the in-flight queue to wait for sensor capture + void queueCaptureRequest(const Request &r); + + // Test if the readout thread is idle (no in-flight requests, not + // currently reading out anything + bool isIdle(); + + // Wait until isIdle is true + status_t waitForReadout(); + + private: + static const nsecs_t kWaitPerLoop = 10000000L; // 10 ms + static const nsecs_t kMaxWaitLoops = 1000; + static const size_t kMaxQueueSize = 2; + + EmulatedFakeCamera3 *mParent; + Mutex mLock; + + List mInFlightQueue; + Condition mInFlightSignal; + bool mThreadActive; + + virtual bool threadLoop(); + + // Only accessed by threadLoop + + Request mCurrentRequest; + + // Jpeg completion callbacks + + Mutex mJpegLock; + bool mJpegWaiting; + camera3_stream_buffer mJpegHalBuffer; + uint32_t mJpegFrameNumber; + virtual void onJpegDone(const StreamBuffer &jpegBuffer, bool success); + virtual void onJpegInputDone(const StreamBuffer &inputBuffer); + }; + + sp mReadoutThread; + + /** Fake 3A constants */ + + static const nsecs_t kNormalExposureTime; + static const nsecs_t kFacePriorityExposureTime; + static const int kNormalSensitivity; + static const int kFacePrioritySensitivity; + // Rate of converging AE to new target value, as fraction of difference between + // current and target value. + static const float kExposureTrackRate; + // Minimum duration for precapture state. May be longer if slow to converge + // to target exposure + static const int kPrecaptureMinFrames; + // How often to restart AE 'scanning' + static const int kStableAeMaxFrames; + // Maximum stop below 'normal' exposure time that we'll wander to while + // pretending to converge AE. In powers of 2. (-2 == 1/4 as bright) + static const float kExposureWanderMin; + // Maximum stop above 'normal' exposure time that we'll wander to while + // pretending to converge AE. In powers of 2. (2 == 4x as bright) + static const float kExposureWanderMax; + + /** Fake 3A state */ + + uint8_t mControlMode; + bool mFacePriority; + uint8_t mAeState; + uint8_t mAfState; + uint8_t mAwbState; + uint8_t mAeMode; + uint8_t mAfMode; + uint8_t mAwbMode; + + int mAeCounter; + nsecs_t mAeCurrentExposureTime; + nsecs_t mAeTargetExposureTime; + int mAeCurrentSensitivity; + +}; + +} // namespace android + +#endif // HW_EMULATOR_CAMERA_EMULATED_CAMERA3_H diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.cpp new file mode 100644 index 0000000..4afadc1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.cpp @@ -0,0 +1,437 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedFakeCameraDevice that encapsulates + * fake camera device. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_FakeDevice" +#include +#include "EmulatedFakeCamera.h" +#include "EmulatedFakeCameraDevice.h" + +namespace android { + +EmulatedFakeCameraDevice::EmulatedFakeCameraDevice(EmulatedFakeCamera* camera_hal) + : EmulatedCameraDevice(camera_hal), + mBlackYUV(kBlack32), + mWhiteYUV(kWhite32), + mRedYUV(kRed8), + mGreenYUV(kGreen8), + mBlueYUV(kBlue8), + mLastRedrawn(0), + mCheckX(0), + mCheckY(0), + mCcounter(0) +#if EFCD_ROTATE_FRAME + , mLastRotatedAt(0), + mCurrentFrameType(0), + mCurrentColor(&mWhiteYUV) +#endif // EFCD_ROTATE_FRAME +{ + // Makes the image with the original exposure compensation darker. + // So the effects of changing the exposure compensation can be seen. + mBlackYUV.Y = mBlackYUV.Y / 2; + mWhiteYUV.Y = mWhiteYUV.Y / 2; + mRedYUV.Y = mRedYUV.Y / 2; + mGreenYUV.Y = mGreenYUV.Y / 2; + mBlueYUV.Y = mBlueYUV.Y / 2; +} + +EmulatedFakeCameraDevice::~EmulatedFakeCameraDevice() +{ +} + +/**************************************************************************** + * Emulated camera device abstract interface implementation. + ***************************************************************************/ + +status_t EmulatedFakeCameraDevice::connectDevice() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isInitialized()) { + ALOGE("%s: Fake camera device is not initialized.", __FUNCTION__); + return EINVAL; + } + if (isConnected()) { + ALOGW("%s: Fake camera device is already connected.", __FUNCTION__); + return NO_ERROR; + } + + /* There is no device to connect to. */ + mState = ECDS_CONNECTED; + + return NO_ERROR; +} + +status_t EmulatedFakeCameraDevice::disconnectDevice() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isConnected()) { + ALOGW("%s: Fake camera device is already disconnected.", __FUNCTION__); + return NO_ERROR; + } + if (isStarted()) { + ALOGE("%s: Cannot disconnect from the started device.", __FUNCTION__); + return EINVAL; + } + + /* There is no device to disconnect from. */ + mState = ECDS_INITIALIZED; + + return NO_ERROR; +} + +status_t EmulatedFakeCameraDevice::startDevice(int width, + int height, + uint32_t pix_fmt) +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isConnected()) { + ALOGE("%s: Fake camera device is not connected.", __FUNCTION__); + return EINVAL; + } + if (isStarted()) { + ALOGE("%s: Fake camera device is already started.", __FUNCTION__); + return EINVAL; + } + + /* Initialize the base class. */ + const status_t res = + EmulatedCameraDevice::commonStartDevice(width, height, pix_fmt); + if (res == NO_ERROR) { + /* Calculate U/V panes inside the framebuffer. */ + switch (mPixelFormat) { + case V4L2_PIX_FMT_YVU420: + mFrameV = mCurrentFrame + mTotalPixels; + mFrameU = mFrameU + mTotalPixels / 4; + mUVStep = 1; + mUVTotalNum = mTotalPixels / 4; + break; + + case V4L2_PIX_FMT_YUV420: + mFrameU = mCurrentFrame + mTotalPixels; + mFrameV = mFrameU + mTotalPixels / 4; + mUVStep = 1; + mUVTotalNum = mTotalPixels / 4; + break; + + case V4L2_PIX_FMT_NV21: + /* Interleaved UV pane, V first. */ + mFrameV = mCurrentFrame + mTotalPixels; + mFrameU = mFrameV + 1; + mUVStep = 2; + mUVTotalNum = mTotalPixels / 4; + break; + + case V4L2_PIX_FMT_NV12: + /* Interleaved UV pane, U first. */ + mFrameU = mCurrentFrame + mTotalPixels; + mFrameV = mFrameU + 1; + mUVStep = 2; + mUVTotalNum = mTotalPixels / 4; + break; + + default: + ALOGE("%s: Unknown pixel format %.4s", __FUNCTION__, + reinterpret_cast(&mPixelFormat)); + return EINVAL; + } + /* Number of items in a single row inside U/V panes. */ + mUVInRow = (width / 2) * mUVStep; + mState = ECDS_STARTED; + } else { + ALOGE("%s: commonStartDevice failed", __FUNCTION__); + } + + return res; +} + +status_t EmulatedFakeCameraDevice::stopDevice() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isStarted()) { + ALOGW("%s: Fake camera device is not started.", __FUNCTION__); + return NO_ERROR; + } + + mFrameU = mFrameV = NULL; + EmulatedCameraDevice::commonStopDevice(); + mState = ECDS_CONNECTED; + + return NO_ERROR; +} + +/**************************************************************************** + * Worker thread management overrides. + ***************************************************************************/ + +bool EmulatedFakeCameraDevice::inWorkerThread() +{ + /* Wait till FPS timeout expires, or thread exit message is received. */ + WorkerThread::SelectRes res = + getWorkerThread()->Select(-1, 1000000 / mEmulatedFPS); + if (res == WorkerThread::EXIT_THREAD) { + ALOGV("%s: Worker thread has been terminated.", __FUNCTION__); + return false; + } + + /* Lets see if we need to generate a new frame. */ + if ((systemTime(SYSTEM_TIME_MONOTONIC) - mLastRedrawn) >= mRedrawAfter) { + /* + * Time to generate a new frame. + */ + +#if EFCD_ROTATE_FRAME + const int frame_type = rotateFrame(); + switch (frame_type) { + case 0: + drawCheckerboard(); + break; + case 1: + drawStripes(); + break; + case 2: + drawSolid(mCurrentColor); + break; + } +#else + /* Draw the checker board. */ + drawCheckerboard(); + +#endif // EFCD_ROTATE_FRAME + + mLastRedrawn = systemTime(SYSTEM_TIME_MONOTONIC); + } + + /* Timestamp the current frame, and notify the camera HAL about new frame. */ + mCurFrameTimestamp = systemTime(SYSTEM_TIME_MONOTONIC); + mCameraHAL->onNextFrameAvailable(mCurrentFrame, mCurFrameTimestamp, this); + + return true; +} + +/**************************************************************************** + * Fake camera device private API + ***************************************************************************/ + +void EmulatedFakeCameraDevice::drawCheckerboard() +{ + const int size = mFrameWidth / 10; + bool black = true; + + if (size == 0) { + // When this happens, it happens at a very high rate, + // so don't log any messages and just return. + return; + } + + + if((mCheckX / size) & 1) + black = false; + if((mCheckY / size) & 1) + black = !black; + + int county = mCheckY % size; + int checkxremainder = mCheckX % size; + uint8_t* Y = mCurrentFrame; + uint8_t* U_pos = mFrameU; + uint8_t* V_pos = mFrameV; + uint8_t* U = U_pos; + uint8_t* V = V_pos; + + YUVPixel adjustedWhite = YUVPixel(mWhiteYUV); + changeWhiteBalance(adjustedWhite.Y, adjustedWhite.U, adjustedWhite.V); + + for(int y = 0; y < mFrameHeight; y++) { + int countx = checkxremainder; + bool current = black; + for(int x = 0; x < mFrameWidth; x += 2) { + if (current) { + mBlackYUV.get(Y, U, V); + } else { + adjustedWhite.get(Y, U, V); + } + *Y = changeExposure(*Y); + Y[1] = *Y; + Y += 2; U += mUVStep; V += mUVStep; + countx += 2; + if(countx >= size) { + countx = 0; + current = !current; + } + } + if (y & 0x1) { + U_pos = U; + V_pos = V; + } else { + U = U_pos; + V = V_pos; + } + if(county++ >= size) { + county = 0; + black = !black; + } + } + mCheckX += 3; + mCheckY++; + + /* Run the square. */ + int sqx = ((mCcounter * 3) & 255); + if(sqx > 128) sqx = 255 - sqx; + int sqy = ((mCcounter * 5) & 255); + if(sqy > 128) sqy = 255 - sqy; + const int sqsize = mFrameWidth / 10; + drawSquare(sqx * sqsize / 32, sqy * sqsize / 32, (sqsize * 5) >> 1, + (mCcounter & 0x100) ? &mRedYUV : &mGreenYUV); + mCcounter++; +} + +void EmulatedFakeCameraDevice::drawSquare(int x, + int y, + int size, + const YUVPixel* color) +{ + const int square_xstop = min(mFrameWidth, x + size); + const int square_ystop = min(mFrameHeight, y + size); + uint8_t* Y_pos = mCurrentFrame + y * mFrameWidth + x; + + YUVPixel adjustedColor = *color; + changeWhiteBalance(adjustedColor.Y, adjustedColor.U, adjustedColor.V); + + // Draw the square. + for (; y < square_ystop; y++) { + const int iUV = (y / 2) * mUVInRow + (x / 2) * mUVStep; + uint8_t* sqU = mFrameU + iUV; + uint8_t* sqV = mFrameV + iUV; + uint8_t* sqY = Y_pos; + for (int i = x; i < square_xstop; i += 2) { + adjustedColor.get(sqY, sqU, sqV); + *sqY = changeExposure(*sqY); + sqY[1] = *sqY; + sqY += 2; sqU += mUVStep; sqV += mUVStep; + } + Y_pos += mFrameWidth; + } +} + +#if EFCD_ROTATE_FRAME + +void EmulatedFakeCameraDevice::drawSolid(YUVPixel* color) +{ + YUVPixel adjustedColor = *color; + changeWhiteBalance(adjustedColor.Y, adjustedColor.U, adjustedColor.V); + + /* All Ys are the same. */ + memset(mCurrentFrame, changeExposure(adjustedColor.Y), mTotalPixels); + + /* Fill U, and V panes. */ + uint8_t* U = mFrameU; + uint8_t* V = mFrameV; + for (int k = 0; k < mUVTotalNum; k++, U += mUVStep, V += mUVStep) { + *U = color->U; + *V = color->V; + } +} + +void EmulatedFakeCameraDevice::drawStripes() +{ + /* Divide frame into 4 stripes. */ + const int change_color_at = mFrameHeight / 4; + const int each_in_row = mUVInRow / mUVStep; + uint8_t* pY = mCurrentFrame; + for (int y = 0; y < mFrameHeight; y++, pY += mFrameWidth) { + /* Select the color. */ + YUVPixel* color; + const int color_index = y / change_color_at; + if (color_index == 0) { + /* White stripe on top. */ + color = &mWhiteYUV; + } else if (color_index == 1) { + /* Then the red stripe. */ + color = &mRedYUV; + } else if (color_index == 2) { + /* Then the green stripe. */ + color = &mGreenYUV; + } else { + /* And the blue stripe at the bottom. */ + color = &mBlueYUV; + } + changeWhiteBalance(color->Y, color->U, color->V); + + /* All Ys at the row are the same. */ + memset(pY, changeExposure(color->Y), mFrameWidth); + + /* Offset of the current row inside U/V panes. */ + const int uv_off = (y / 2) * mUVInRow; + /* Fill U, and V panes. */ + uint8_t* U = mFrameU + uv_off; + uint8_t* V = mFrameV + uv_off; + for (int k = 0; k < each_in_row; k++, U += mUVStep, V += mUVStep) { + *U = color->U; + *V = color->V; + } + } +} + +int EmulatedFakeCameraDevice::rotateFrame() +{ + if ((systemTime(SYSTEM_TIME_MONOTONIC) - mLastRotatedAt) >= mRotateFreq) { + mLastRotatedAt = systemTime(SYSTEM_TIME_MONOTONIC); + mCurrentFrameType++; + if (mCurrentFrameType > 2) { + mCurrentFrameType = 0; + } + if (mCurrentFrameType == 2) { + ALOGD("********** Rotated to the SOLID COLOR frame **********"); + /* Solid color: lets rotate color too. */ + if (mCurrentColor == &mWhiteYUV) { + ALOGD("----- Painting a solid RED frame -----"); + mCurrentColor = &mRedYUV; + } else if (mCurrentColor == &mRedYUV) { + ALOGD("----- Painting a solid GREEN frame -----"); + mCurrentColor = &mGreenYUV; + } else if (mCurrentColor == &mGreenYUV) { + ALOGD("----- Painting a solid BLUE frame -----"); + mCurrentColor = &mBlueYUV; + } else { + /* Back to white. */ + ALOGD("----- Painting a solid WHITE frame -----"); + mCurrentColor = &mWhiteYUV; + } + } else if (mCurrentFrameType == 0) { + ALOGD("********** Rotated to the CHECKERBOARD frame **********"); + } else if (mCurrentFrameType == 1) { + ALOGD("********** Rotated to the STRIPED frame **********"); + } + } + + return mCurrentFrameType; +} + +#endif // EFCD_ROTATE_FRAME + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.h new file mode 100644 index 0000000..f66f076 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedFakeCameraDevice.h @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA_DEVICE_H +#define HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA_DEVICE_H + +/* + * Contains declaration of a class EmulatedFakeCameraDevice that encapsulates + * a fake camera device. + */ + +#include "Converters.h" +#include "EmulatedCameraDevice.h" + +/* This is used for debugging format / conversion issues. If EFCD_ROTATE_FRAME is + * set to 0, the frame content will be always the "checkerboard". Otherwise, if + * EFCD_ROTATE_FRAME is set to a non-zero value, the frame content will "rotate" + * from a "checkerboard" frame to a "white/red/green/blue stripes" frame, to a + * "white/red/green/blue" frame. Frame content rotation helps finding bugs in + * format conversions. + */ +#define EFCD_ROTATE_FRAME 0 + +namespace android { + +class EmulatedFakeCamera; + +/* Encapsulates a fake camera device. + * Fake camera device emulates a camera device by providing frames containing + * a black and white checker board, moving diagonally towards the 0,0 corner. + * There is also a green, or red square that bounces inside the frame, changing + * its color when bouncing off the 0,0 corner. + */ +class EmulatedFakeCameraDevice : public EmulatedCameraDevice { +public: + /* Constructs EmulatedFakeCameraDevice instance. */ + explicit EmulatedFakeCameraDevice(EmulatedFakeCamera* camera_hal); + + /* Destructs EmulatedFakeCameraDevice instance. */ + ~EmulatedFakeCameraDevice(); + + /*************************************************************************** + * Emulated camera device abstract interface implementation. + * See declarations of these methods in EmulatedCameraDevice class for + * information on each of these methods. + **************************************************************************/ + +public: + /* Connects to the camera device. + * Since there is no real device to connect to, this method does nothing, + * but changes the state. + */ + status_t connectDevice(); + + /* Disconnects from the camera device. + * Since there is no real device to disconnect from, this method does + * nothing, but changes the state. + */ + status_t disconnectDevice(); + + /* Starts the camera device. */ + status_t startDevice(int width, int height, uint32_t pix_fmt); + + /* Stops the camera device. */ + status_t stopDevice(); + + /* Gets current preview fame into provided buffer. */ + status_t getPreviewFrame(void* buffer); + + /*************************************************************************** + * Worker thread management overrides. + * See declarations of these methods in EmulatedCameraDevice class for + * information on each of these methods. + **************************************************************************/ + +protected: + /* Implementation of the worker thread routine. + * This method simply sleeps for a period of time defined by the FPS property + * of the fake camera (simulating frame frequency), and then calls emulated + * camera's onNextFrameAvailable method. + */ + bool inWorkerThread(); + + /**************************************************************************** + * Fake camera device private API + ***************************************************************************/ + +private: + + /* Draws a black and white checker board in the current frame buffer. */ + void drawCheckerboard(); + + /* Draws a square of the given color in the current frame buffer. + * Param: + * x, y - Coordinates of the top left corner of the square in the buffer. + * size - Size of the square's side. + * color - Square's color. + */ + void drawSquare(int x, int y, int size, const YUVPixel* color); + +#if EFCD_ROTATE_FRAME + void drawSolid(YUVPixel* color); + void drawStripes(); + int rotateFrame(); +#endif // EFCD_ROTATE_FRAME + + /**************************************************************************** + * Fake camera device data members + ***************************************************************************/ + +private: + /* + * Pixel colors in YUV format used when drawing the checker board. + */ + + YUVPixel mBlackYUV; + YUVPixel mWhiteYUV; + YUVPixel mRedYUV; + YUVPixel mGreenYUV; + YUVPixel mBlueYUV; + + /* Last time the frame has been redrawn. */ + nsecs_t mLastRedrawn; + + /* + * Precalculated values related to U/V panes. + */ + + /* U pane inside the framebuffer. */ + uint8_t* mFrameU; + + /* V pane inside the framebuffer. */ + uint8_t* mFrameV; + + /* Defines byte distance between adjacent U, and V values. */ + int mUVStep; + + /* Defines number of Us and Vs in a row inside the U/V panes. + * Note that if U/V panes are interleaved, this value reflects the total + * number of both, Us and Vs in a single row in the interleaved UV pane. */ + int mUVInRow; + + /* Total number of each, U, and V elements in the framebuffer. */ + int mUVTotalNum; + + /* + * Checkerboard drawing related stuff + */ + + int mCheckX; + int mCheckY; + int mCcounter; + + /* Emulated FPS (frames per second). + * We will emulate 50 FPS. */ + static const int mEmulatedFPS = 50; + + /* Defines time (in nanoseconds) between redrawing the checker board. + * We will redraw the checker board every 15 milliseconds. */ + static const nsecs_t mRedrawAfter = 15000000LL; + +#if EFCD_ROTATE_FRAME + /* Frame rotation frequency in nanosec (currently - 3 sec) */ + static const nsecs_t mRotateFreq = 3000000000LL; + + /* Last time the frame has rotated. */ + nsecs_t mLastRotatedAt; + + /* Type of the frame to display in the current rotation: + * 0 - Checkerboard. + * 1 - White/Red/Green/Blue horisontal stripes + * 2 - Solid color. */ + int mCurrentFrameType; + + /* Color to use to paint the solid color frame. Colors will rotate between + * white, red, gree, and blue each time rotation comes to the solid color + * frame. */ + YUVPixel* mCurrentColor; +#endif // EFCD_ROTATE_FRAME +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_FAKE_CAMERA_DEVICE_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.cpp new file mode 100644 index 0000000..af1e324 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedQemuCamera that encapsulates + * functionality of an emulated camera connected to the host. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_QemuCamera" +#include +#include "EmulatedQemuCamera.h" +#include "EmulatedCameraFactory.h" + +namespace android { + +EmulatedQemuCamera::EmulatedQemuCamera(int cameraId, struct hw_module_t* module) + : EmulatedCamera(cameraId, module), + mQemuCameraDevice(this) +{ +} + +EmulatedQemuCamera::~EmulatedQemuCamera() +{ +} + +/**************************************************************************** + * EmulatedCamera virtual overrides. + ***************************************************************************/ + +status_t EmulatedQemuCamera::Initialize(const char* device_name, + const char* frame_dims, + const char* facing_dir) +{ + ALOGV("%s:\n Name=%s\n Facing '%s'\n Dimensions=%s", + __FUNCTION__, device_name, facing_dir, frame_dims); + /* Save dimensions. */ + mFrameDims = frame_dims; + + /* Initialize camera device. */ + status_t res = mQemuCameraDevice.Initialize(device_name); + if (res != NO_ERROR) { + return res; + } + + /* Initialize base class. */ + res = EmulatedCamera::Initialize(); + if (res != NO_ERROR) { + return res; + } + + /* + * Set customizable parameters. + */ + + mParameters.set(EmulatedCamera::FACING_KEY, facing_dir); + mParameters.set(EmulatedCamera::ORIENTATION_KEY, + gEmulatedCameraFactory.getQemuCameraOrientation()); + mParameters.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, frame_dims); + mParameters.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, frame_dims); + + /* + * Use first dimension reported by the device to set current preview and + * picture sizes. + */ + + char first_dim[128]; + /* Dimensions are separated with ',' */ + const char* c = strchr(frame_dims, ','); + if (c == NULL) { + strncpy(first_dim, frame_dims, sizeof(first_dim)); + first_dim[sizeof(first_dim)-1] = '\0'; + } else if (static_cast(c - frame_dims) < sizeof(first_dim)) { + memcpy(first_dim, frame_dims, c - frame_dims); + first_dim[c - frame_dims] = '\0'; + } else { + memcpy(first_dim, frame_dims, sizeof(first_dim)); + first_dim[sizeof(first_dim)-1] = '\0'; + } + + /* Width and height are separated with 'x' */ + char* sep = strchr(first_dim, 'x'); + if (sep == NULL) { + ALOGE("%s: Invalid first dimension format in %s", + __FUNCTION__, frame_dims); + return EINVAL; + } + + *sep = '\0'; + const int x = atoi(first_dim); + const int y = atoi(sep + 1); + mParameters.setPreviewSize(x, y); + mParameters.setPictureSize(x, y); + + ALOGV("%s: Qemu camera %s is initialized. Current frame is %dx%d", + __FUNCTION__, device_name, x, y); + + return NO_ERROR; +} + +EmulatedCameraDevice* EmulatedQemuCamera::getCameraDevice() +{ + return &mQemuCameraDevice; +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.h new file mode 100644 index 0000000..1b826c7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_H +#define HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_H + +/* + * Contains declaration of a class EmulatedQemuCamera that encapsulates + * functionality of an emulated camera connected to the host. + */ + +#include "EmulatedCamera.h" +#include "EmulatedQemuCameraDevice.h" + +namespace android { + +/* Encapsulates functionality of an emulated camera connected to the host. + */ +class EmulatedQemuCamera : public EmulatedCamera { +public: + /* Constructs EmulatedQemuCamera instance. */ + EmulatedQemuCamera(int cameraId, struct hw_module_t* module); + + /* Destructs EmulatedQemuCamera instance. */ + ~EmulatedQemuCamera(); + + /*************************************************************************** + * EmulatedCamera virtual overrides. + **************************************************************************/ + +public: + /* Initializes EmulatedQemuCamera instance. */ + status_t Initialize(const char* device_name, + const char* frame_dims, + const char* facing_dir); + + /*************************************************************************** + * EmulatedCamera abstract API implementation. + **************************************************************************/ + +protected: + /* Gets emulated camera device ised by this instance of the emulated camera. + */ + EmulatedCameraDevice* getCameraDevice(); + + /*************************************************************************** + * Data memebers. + **************************************************************************/ + +protected: + /* Contained qemu camera device object. */ + EmulatedQemuCameraDevice mQemuCameraDevice; + + /* Supported frame dimensions reported by the camera device. */ + String8 mFrameDims; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.cpp new file mode 100644 index 0000000..2c94f0e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedQemuCamera2 that encapsulates + * functionality of a host webcam with further processing to simulate the + * capabilities of a v2 camera device. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_QemuCamera2" +#include +#include +#include "EmulatedQemuCamera2.h" +#include "EmulatedCameraFactory.h" + +namespace android { + +EmulatedQemuCamera2::EmulatedQemuCamera2(int cameraId, + bool facingBack, + struct hw_module_t* module) + : EmulatedCamera2(cameraId,module), + mFacingBack(facingBack) +{ + ALOGD("Constructing emulated qemu camera 2 facing %s", + facingBack ? "back" : "front"); +} + +EmulatedQemuCamera2::~EmulatedQemuCamera2() +{ +} + +/**************************************************************************** + * Public API overrides + ***************************************************************************/ + +status_t EmulatedQemuCamera2::Initialize() +{ + return NO_ERROR; +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.h new file mode 100644 index 0000000..520ccce --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCamera2.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA2_H +#define HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA2_H + +/* + * Contains declaration of a class EmulatedQemuCamera2 that encapsulates + * functionality of a host webcam with added processing to implement version 2 + * of the camera device interface. + */ + +#include "EmulatedCamera2.h" + +namespace android { + +/* Encapsulates functionality of an advanced fake camera based on real host camera data. + */ +class EmulatedQemuCamera2 : public EmulatedCamera2 { +public: + /* Constructs EmulatedFakeCamera instance. */ + EmulatedQemuCamera2(int cameraId, bool facingBack, struct hw_module_t* module); + + /* Destructs EmulatedFakeCamera instance. */ + ~EmulatedQemuCamera2(); + + /**************************************************************************** + * EmulatedCamera2 virtual overrides. + ***************************************************************************/ + +public: + /* Initializes EmulatedQemuCamera2 instance. */ + status_t Initialize(); + + /**************************************************************************** + * EmulatedCamera abstract API implementation. + ***************************************************************************/ + +protected: + + /**************************************************************************** + * Data memebers. + ***************************************************************************/ + +protected: + /* Facing back (true) or front (false) switch. */ + bool mFacingBack; + +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA2_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.cpp new file mode 100644 index 0000000..07837af --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.cpp @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class EmulatedQemuCameraDevice that encapsulates + * an emulated camera device connected to the host. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_QemuDevice" +#include +#include "EmulatedQemuCamera.h" +#include "EmulatedQemuCameraDevice.h" + +namespace android { + +EmulatedQemuCameraDevice::EmulatedQemuCameraDevice(EmulatedQemuCamera* camera_hal) + : EmulatedCameraDevice(camera_hal), + mQemuClient(), + mPreviewFrame(NULL) +{ +} + +EmulatedQemuCameraDevice::~EmulatedQemuCameraDevice() +{ + if (mPreviewFrame != NULL) { + delete[] mPreviewFrame; + } +} + +/**************************************************************************** + * Public API + ***************************************************************************/ + +status_t EmulatedQemuCameraDevice::Initialize(const char* device_name) +{ + /* Connect to the service. */ + char connect_str[256]; + snprintf(connect_str, sizeof(connect_str), "name=%s", device_name); + status_t res = mQemuClient.connectClient(connect_str); + if (res != NO_ERROR) { + return res; + } + + /* Initialize base class. */ + res = EmulatedCameraDevice::Initialize(); + if (res == NO_ERROR) { + ALOGV("%s: Connected to the emulated camera service '%s'", + __FUNCTION__, device_name); + mDeviceName = device_name; + } else { + mQemuClient.queryDisconnect(); + } + + return res; +} + +/**************************************************************************** + * Emulated camera device abstract interface implementation. + ***************************************************************************/ + +status_t EmulatedQemuCameraDevice::connectDevice() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isInitialized()) { + ALOGE("%s: Qemu camera device is not initialized.", __FUNCTION__); + return EINVAL; + } + if (isConnected()) { + ALOGW("%s: Qemu camera device '%s' is already connected.", + __FUNCTION__, (const char*)mDeviceName); + return NO_ERROR; + } + + /* Connect to the camera device via emulator. */ + const status_t res = mQemuClient.queryConnect(); + if (res == NO_ERROR) { + ALOGV("%s: Connected to device '%s'", + __FUNCTION__, (const char*)mDeviceName); + mState = ECDS_CONNECTED; + } else { + ALOGE("%s: Connection to device '%s' failed", + __FUNCTION__, (const char*)mDeviceName); + } + + return res; +} + +status_t EmulatedQemuCameraDevice::disconnectDevice() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isConnected()) { + ALOGW("%s: Qemu camera device '%s' is already disconnected.", + __FUNCTION__, (const char*)mDeviceName); + return NO_ERROR; + } + if (isStarted()) { + ALOGE("%s: Cannot disconnect from the started device '%s.", + __FUNCTION__, (const char*)mDeviceName); + return EINVAL; + } + + /* Disconnect from the camera device via emulator. */ + const status_t res = mQemuClient.queryDisconnect(); + if (res == NO_ERROR) { + ALOGV("%s: Disonnected from device '%s'", + __FUNCTION__, (const char*)mDeviceName); + mState = ECDS_INITIALIZED; + } else { + ALOGE("%s: Disconnection from device '%s' failed", + __FUNCTION__, (const char*)mDeviceName); + } + + return res; +} + +status_t EmulatedQemuCameraDevice::startDevice(int width, + int height, + uint32_t pix_fmt) +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isConnected()) { + ALOGE("%s: Qemu camera device '%s' is not connected.", + __FUNCTION__, (const char*)mDeviceName); + return EINVAL; + } + if (isStarted()) { + ALOGW("%s: Qemu camera device '%s' is already started.", + __FUNCTION__, (const char*)mDeviceName); + return NO_ERROR; + } + + status_t res = EmulatedCameraDevice::commonStartDevice(width, height, pix_fmt); + if (res != NO_ERROR) { + ALOGE("%s: commonStartDevice failed", __FUNCTION__); + return res; + } + + /* Allocate preview frame buffer. */ + /* TODO: Watch out for preview format changes! At this point we implement + * RGB32 only.*/ + mPreviewFrame = new uint32_t[mTotalPixels]; + if (mPreviewFrame == NULL) { + ALOGE("%s: Unable to allocate %d bytes for preview frame", + __FUNCTION__, mTotalPixels); + return ENOMEM; + } + + /* Start the actual camera device. */ + res = mQemuClient.queryStart(mPixelFormat, mFrameWidth, mFrameHeight); + if (res == NO_ERROR) { + ALOGV("%s: Qemu camera device '%s' is started for %.4s[%dx%d] frames", + __FUNCTION__, (const char*)mDeviceName, + reinterpret_cast(&mPixelFormat), + mFrameWidth, mFrameHeight); + mState = ECDS_STARTED; + } else { + ALOGE("%s: Unable to start device '%s' for %.4s[%dx%d] frames", + __FUNCTION__, (const char*)mDeviceName, + reinterpret_cast(&pix_fmt), width, height); + } + + return res; +} + +status_t EmulatedQemuCameraDevice::stopDevice() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + if (!isStarted()) { + ALOGW("%s: Qemu camera device '%s' is not started.", + __FUNCTION__, (const char*)mDeviceName); + return NO_ERROR; + } + + /* Stop the actual camera device. */ + status_t res = mQemuClient.queryStop(); + if (res == NO_ERROR) { + if (mPreviewFrame == NULL) { + delete[] mPreviewFrame; + mPreviewFrame = NULL; + } + EmulatedCameraDevice::commonStopDevice(); + mState = ECDS_CONNECTED; + ALOGV("%s: Qemu camera device '%s' is stopped", + __FUNCTION__, (const char*)mDeviceName); + } else { + ALOGE("%s: Unable to stop device '%s'", + __FUNCTION__, (const char*)mDeviceName); + } + + return res; +} + +/**************************************************************************** + * EmulatedCameraDevice virtual overrides + ***************************************************************************/ + +status_t EmulatedQemuCameraDevice::getCurrentPreviewFrame(void* buffer) +{ + ALOGW_IF(mPreviewFrame == NULL, "%s: No preview frame", __FUNCTION__); + if (mPreviewFrame != NULL) { + memcpy(buffer, mPreviewFrame, mTotalPixels * 4); + return 0; + } else { + return EmulatedCameraDevice::getCurrentPreviewFrame(buffer); + } +} + +/**************************************************************************** + * Worker thread management overrides. + ***************************************************************************/ + +bool EmulatedQemuCameraDevice::inWorkerThread() +{ + /* Wait till FPS timeout expires, or thread exit message is received. */ + WorkerThread::SelectRes res = + getWorkerThread()->Select(-1, 1000000 / mEmulatedFPS); + if (res == WorkerThread::EXIT_THREAD) { + ALOGV("%s: Worker thread has been terminated.", __FUNCTION__); + return false; + } + + /* Query frames from the service. */ + status_t query_res = mQemuClient.queryFrame(mCurrentFrame, mPreviewFrame, + mFrameBufferSize, + mTotalPixels * 4, + mWhiteBalanceScale[0], + mWhiteBalanceScale[1], + mWhiteBalanceScale[2], + mExposureCompensation); + if (query_res == NO_ERROR) { + /* Timestamp the current frame, and notify the camera HAL. */ + mCurFrameTimestamp = systemTime(SYSTEM_TIME_MONOTONIC); + mCameraHAL->onNextFrameAvailable(mCurrentFrame, mCurFrameTimestamp, this); + return true; + } else { + ALOGE("%s: Unable to get current video frame: %s", + __FUNCTION__, strerror(query_res)); + mCameraHAL->onCameraDeviceError(CAMERA_ERROR_SERVER_DIED); + return false; + } +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.h b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.h new file mode 100644 index 0000000..8ef562b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/EmulatedQemuCameraDevice.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H +#define HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H + +/* + * Contains declaration of a class EmulatedQemuCameraDevice that encapsulates + * an emulated camera device connected to the host. + */ + +#include "EmulatedCameraDevice.h" +#include "QemuClient.h" + +namespace android { + +class EmulatedQemuCamera; + +/* Encapsulates an emulated camera device connected to the host. + */ +class EmulatedQemuCameraDevice : public EmulatedCameraDevice { +public: + /* Constructs EmulatedQemuCameraDevice instance. */ + explicit EmulatedQemuCameraDevice(EmulatedQemuCamera* camera_hal); + + /* Destructs EmulatedQemuCameraDevice instance. */ + ~EmulatedQemuCameraDevice(); + + /*************************************************************************** + * Public API + **************************************************************************/ + +public: + /* Initializes EmulatedQemuCameraDevice instance. + * Param: + * device_name - Name of the camera device connected to the host. The name + * that is used here must have been reported by the 'factory' camera + * service when it listed camera devices connected to the host. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + status_t Initialize(const char* device_name); + + /*************************************************************************** + * Emulated camera device abstract interface implementation. + * See declarations of these methods in EmulatedCameraDevice class for + * information on each of these methods. + **************************************************************************/ + +public: + /* Connects to the camera device. */ + status_t connectDevice(); + + /* Disconnects from the camera device. */ + status_t disconnectDevice(); + + /* Starts capturing frames from the camera device. */ + status_t startDevice(int width, int height, uint32_t pix_fmt); + + /* Stops capturing frames from the camera device. */ + status_t stopDevice(); + + /*************************************************************************** + * EmulatedCameraDevice virtual overrides + * See declarations of these methods in EmulatedCameraDevice class for + * information on each of these methods. + **************************************************************************/ + +public: + /* Gets current preview fame into provided buffer. + * We override this method in order to provide preview frames cached in this + * object. + */ + status_t getCurrentPreviewFrame(void* buffer); + + /*************************************************************************** + * Worker thread management overrides. + * See declarations of these methods in EmulatedCameraDevice class for + * information on each of these methods. + **************************************************************************/ + +protected: + /* Implementation of the worker thread routine. */ + bool inWorkerThread(); + + /*************************************************************************** + * Qemu camera device data members + **************************************************************************/ + +private: + /* Qemu client that is used to communicate with the 'emulated camera' + * service, created for this instance in the emulator. */ + CameraQemuClient mQemuClient; + + /* Name of the camera device connected to the host. */ + String8 mDeviceName; + + /* Current preview framebuffer. */ + uint32_t* mPreviewFrame; + + /* Emulated FPS (frames per second). + * We will emulate 50 FPS. */ + static const int mEmulatedFPS = 50; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_EMULATED_QEMU_CAMERA_DEVICE_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.cpp new file mode 100644 index 0000000..8014ccf --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class NV21JpegCompressor that encapsulates a + * converter between NV21, and JPEG formats. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_JPEG" +#include +#include +#include +#include "JpegCompressor.h" + +namespace android { + +void* NV21JpegCompressor::mDl = NULL; + +static void* getSymbol(void* dl, const char* signature) { + void* res = dlsym(dl, signature); + assert (res != NULL); + + return res; +} + +typedef void (*InitFunc)(JpegStub* stub, int* strides); +typedef void (*CleanupFunc)(JpegStub* stub); +typedef int (*CompressFunc)(JpegStub* stub, const void* image, + int width, int height, int quality); +typedef void (*GetCompressedImageFunc)(JpegStub* stub, void* buff); +typedef size_t (*GetCompressedSizeFunc)(JpegStub* stub); + +NV21JpegCompressor::NV21JpegCompressor() +{ + const char dlName[] = "/system/lib/hw/camera.goldfish.jpeg.so"; + if (mDl == NULL) { + mDl = dlopen(dlName, RTLD_NOW); + } + assert(mDl != NULL); + + InitFunc f = (InitFunc)getSymbol(mDl, "JpegStub_init"); + (*f)(&mStub, mStrides); +} + +NV21JpegCompressor::~NV21JpegCompressor() +{ + CleanupFunc f = (CleanupFunc)getSymbol(mDl, "JpegStub_cleanup"); + (*f)(&mStub); +} + +/**************************************************************************** + * Public API + ***************************************************************************/ + +status_t NV21JpegCompressor::compressRawImage(const void* image, + int width, + int height, + int quality) +{ + mStrides[0] = width; + mStrides[1] = width; + CompressFunc f = (CompressFunc)getSymbol(mDl, "JpegStub_compress"); + return (status_t)(*f)(&mStub, image, width, height, quality); +} + + +size_t NV21JpegCompressor::getCompressedSize() +{ + GetCompressedSizeFunc f = (GetCompressedSizeFunc)getSymbol(mDl, + "JpegStub_getCompressedSize"); + return (*f)(&mStub); +} + +void NV21JpegCompressor::getCompressedImage(void* buff) +{ + GetCompressedImageFunc f = (GetCompressedImageFunc)getSymbol(mDl, + "JpegStub_getCompressedImage"); + (*f)(&mStub, buff); +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.h b/src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.h new file mode 100644 index 0000000..a6454d2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/JpegCompressor.h @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_JPEG_COMPRESSOR_H +#define HW_EMULATOR_CAMERA_JPEG_COMPRESSOR_H + +/* + * Contains declaration of a class NV21JpegCompressor that encapsulates a + * converter between YV21, and JPEG formats. + */ + +#include "JpegStub.h" +#include + +namespace android { + +/* Encapsulates a converter between YV12, and JPEG formats. + */ +class NV21JpegCompressor +{ +public: + /* Constructs JpegCompressor instance. */ + NV21JpegCompressor(); + /* Destructs JpegCompressor instance. */ + ~NV21JpegCompressor(); + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + /* Compresses raw NV21 image into a JPEG. + * The compressed image will be saved in mStream member of this class. Use + * getCompressedSize method to obtain buffer size of the compressed image, + * and getCompressedImage to copy out the compressed image. + * Param: + * image - Raw NV21 image. + * width, height - Image dimensions. + * quality - JPEG quality. + * Return: + * NO_ERROR on success, or an appropriate error status. + * + */ + status_t compressRawImage(const void* image, + int width, + int height, + int quality); + + /* Get size of the compressed JPEG buffer. + * This method must be called only after a successful completion of + * compressRawImage call. + * Return: + * Size of the compressed JPEG buffer. + */ + size_t getCompressedSize(); + + /* Copies out compressed JPEG buffer. + * This method must be called only after a successful completion of + * compressRawImage call. + * Param: + * buff - Buffer where to copy the JPEG. Must be large enough to contain the + * entire image. + */ + void getCompressedImage(void* buff); + + /**************************************************************************** + * Class data + ***************************************************************************/ + +protected: + /* Strides for Y (the first element), and UV (the second one) panes. */ + int mStrides[2]; + +private: + // library handle to dlopen + static void* mDl; + JpegStub mStub; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_JPEG_COMPRESSOR_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.cpp new file mode 100644 index 0000000..084f5fc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_JPEGStub" +#include +#include +#include + +#include "JpegStub.h" + + +extern "C" void JpegStub_init(JpegStub* stub, int* strides) { + stub->mInternalEncoder = (void*) new Yuv420SpToJpegEncoder(strides); + stub->mInternalStream = (void*)new SkDynamicMemoryWStream(); +} + +extern "C" void JpegStub_cleanup(JpegStub* stub) { + delete((Yuv420SpToJpegEncoder*)stub->mInternalEncoder); + delete((SkDynamicMemoryWStream*)stub->mInternalStream); +} + +extern "C" int JpegStub_compress(JpegStub* stub, const void* image, + int width, int height, int quality) +{ + void* pY = const_cast(image); + int offsets[2]; + offsets[0] = 0; + offsets[1] = width * height; + + Yuv420SpToJpegEncoder* encoder = + (Yuv420SpToJpegEncoder*)stub->mInternalEncoder; + SkDynamicMemoryWStream* stream = + (SkDynamicMemoryWStream*)stub->mInternalStream; + if (encoder->encode(stream, pY, width, height, offsets, quality)) { + ALOGV("%s: Compressed JPEG: %d[%dx%d] -> %zu bytes", + __FUNCTION__, (width * height * 12) / 8, + width, height, stream->getOffset()); + return 0; + } else { + ALOGE("%s: JPEG compression failed", __FUNCTION__); + return errno ? errno: EINVAL; + } +} + +extern "C" void JpegStub_getCompressedImage(JpegStub* stub, void* buff) { + SkDynamicMemoryWStream* stream = + (SkDynamicMemoryWStream*)stub->mInternalStream; + stream->copyTo(buff); +} + +extern "C" size_t JpegStub_getCompressedSize(JpegStub* stub) { + SkDynamicMemoryWStream* stream = + (SkDynamicMemoryWStream*)stub->mInternalStream; + return stream->getOffset(); +} diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.h b/src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.h new file mode 100644 index 0000000..ad00a54 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/JpegStub.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef JPEGSTUB_H_ +#define JPEGSTUB_H_ + +extern "C" { + +struct JpegStub { + void* mInternalEncoder; + void* mInternalStream; +}; + +void JpegStub_init(JpegStub* stub, int* strides); +void JpegStub_cleanup(JpegStub* stub); +int JpegStub_compress(JpegStub* stub, const void* image, + int width, int height, int quality); +void JpegStub_getCompressedImage(JpegStub* stub, void* buff); +size_t JpegStub_getCompressedSize(JpegStub* stub); + +}; +#endif // JPEGSTUB_H_ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.cpp new file mode 100644 index 0000000..4101ed9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.cpp @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of a class PreviewWindow that encapsulates + * functionality of a preview window set via set_preview_window camera HAL API. + */ + +#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_Preview" +#include +#include +#include +#include "EmulatedCameraDevice.h" +#include "PreviewWindow.h" + +namespace android { + +PreviewWindow::PreviewWindow() + : mPreviewWindow(NULL), + mLastPreviewed(0), + mPreviewFrameWidth(0), + mPreviewFrameHeight(0), + mPreviewEnabled(false) +{ +} + +PreviewWindow::~PreviewWindow() +{ +} + +/**************************************************************************** + * Camera API + ***************************************************************************/ + +status_t PreviewWindow::setPreviewWindow(struct preview_stream_ops* window, + int preview_fps) +{ + ALOGV("%s: current: %p -> new: %p", __FUNCTION__, mPreviewWindow, window); + + status_t res = NO_ERROR; + Mutex::Autolock locker(&mObjectLock); + + /* Reset preview info. */ + mPreviewFrameWidth = mPreviewFrameHeight = 0; + mPreviewAfter = 0; + mLastPreviewed = 0; + + if (window != NULL) { + /* The CPU will write each frame to the preview window buffer. + * Note that we delay setting preview window buffer geometry until + * frames start to come in. */ + res = window->set_usage(window, GRALLOC_USAGE_SW_WRITE_OFTEN); + if (res == NO_ERROR) { + /* Set preview frequency. */ + mPreviewAfter = 1000000 / preview_fps; + } else { + window = NULL; + res = -res; // set_usage returns a negative errno. + ALOGE("%s: Error setting preview window usage %d -> %s", + __FUNCTION__, res, strerror(res)); + } + } + mPreviewWindow = window; + + return res; +} + +status_t PreviewWindow::startPreview() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + mPreviewEnabled = true; + + return NO_ERROR; +} + +void PreviewWindow::stopPreview() +{ + ALOGV("%s", __FUNCTION__); + + Mutex::Autolock locker(&mObjectLock); + mPreviewEnabled = false; +} + +/**************************************************************************** + * Public API + ***************************************************************************/ + +void PreviewWindow::onNextFrameAvailable(const void* frame, + nsecs_t timestamp, + EmulatedCameraDevice* camera_dev) +{ + int res; + Mutex::Autolock locker(&mObjectLock); + + if (!isPreviewEnabled() || mPreviewWindow == NULL || !isPreviewTime()) { + return; + } + + /* Make sure that preview window dimensions are OK with the camera device */ + if (adjustPreviewDimensions(camera_dev)) { + /* Need to set / adjust buffer geometry for the preview window. + * Note that in the emulator preview window uses only RGB for pixel + * formats. */ + ALOGV("%s: Adjusting preview windows %p geometry to %dx%d", + __FUNCTION__, mPreviewWindow, mPreviewFrameWidth, + mPreviewFrameHeight); + res = mPreviewWindow->set_buffers_geometry(mPreviewWindow, + mPreviewFrameWidth, + mPreviewFrameHeight, + HAL_PIXEL_FORMAT_RGBA_8888); + if (res != NO_ERROR) { + ALOGE("%s: Error in set_buffers_geometry %d -> %s", + __FUNCTION__, -res, strerror(-res)); + return; + } + } + + /* + * Push new frame to the preview window. + */ + + /* Dequeue preview window buffer for the frame. */ + buffer_handle_t* buffer = NULL; + int stride = 0; + res = mPreviewWindow->dequeue_buffer(mPreviewWindow, &buffer, &stride); + if (res != NO_ERROR || buffer == NULL) { + ALOGE("%s: Unable to dequeue preview window buffer: %d -> %s", + __FUNCTION__, -res, strerror(-res)); + return; + } + + /* Let the preview window to lock the buffer. */ + res = mPreviewWindow->lock_buffer(mPreviewWindow, buffer); + if (res != NO_ERROR) { + ALOGE("%s: Unable to lock preview window buffer: %d -> %s", + __FUNCTION__, -res, strerror(-res)); + mPreviewWindow->cancel_buffer(mPreviewWindow, buffer); + return; + } + + /* Now let the graphics framework to lock the buffer, and provide + * us with the framebuffer data address. */ + void* img = NULL; + const Rect rect(mPreviewFrameWidth, mPreviewFrameHeight); + GraphicBufferMapper& grbuffer_mapper(GraphicBufferMapper::get()); + res = grbuffer_mapper.lock(*buffer, GRALLOC_USAGE_SW_WRITE_OFTEN, rect, &img); + if (res != NO_ERROR) { + ALOGE("%s: grbuffer_mapper.lock failure: %d -> %s", + __FUNCTION__, res, strerror(res)); + mPreviewWindow->cancel_buffer(mPreviewWindow, buffer); + return; + } + + /* Frames come in in YV12/NV12/NV21 format. Since preview window doesn't + * supports those formats, we need to obtain the frame in RGB565. */ + res = camera_dev->getCurrentPreviewFrame(img); + if (res == NO_ERROR) { + /* Show it. */ + mPreviewWindow->set_timestamp(mPreviewWindow, timestamp); + mPreviewWindow->enqueue_buffer(mPreviewWindow, buffer); + } else { + ALOGE("%s: Unable to obtain preview frame: %d", __FUNCTION__, res); + mPreviewWindow->cancel_buffer(mPreviewWindow, buffer); + } + grbuffer_mapper.unlock(*buffer); +} + +/*************************************************************************** + * Private API + **************************************************************************/ + +bool PreviewWindow::adjustPreviewDimensions(EmulatedCameraDevice* camera_dev) +{ + /* Match the cached frame dimensions against the actual ones. */ + if (mPreviewFrameWidth == camera_dev->getFrameWidth() && + mPreviewFrameHeight == camera_dev->getFrameHeight()) { + /* They match. */ + return false; + } + + /* They don't match: adjust the cache. */ + mPreviewFrameWidth = camera_dev->getFrameWidth(); + mPreviewFrameHeight = camera_dev->getFrameHeight(); + + return true; +} + +bool PreviewWindow::isPreviewTime() +{ + timeval cur_time; + gettimeofday(&cur_time, NULL); + const uint64_t cur_mks = cur_time.tv_sec * 1000000LL + cur_time.tv_usec; + if ((cur_mks - mLastPreviewed) >= mPreviewAfter) { + mLastPreviewed = cur_mks; + return true; + } + return false; +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.h b/src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.h new file mode 100644 index 0000000..d037c95 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/PreviewWindow.h @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_PREVIEW_WINDOW_H +#define HW_EMULATOR_CAMERA_PREVIEW_WINDOW_H + +/* + * Contains declaration of a class PreviewWindow that encapsulates functionality + * of a preview window set via set_preview_window camera HAL API. + */ + +namespace android { + +class EmulatedCameraDevice; + +/* Encapsulates functionality of a preview window set via set_preview_window + * camera HAL API. + * + * Objects of this class are contained in EmulatedCamera objects, and handle + * relevant camera API callbacks. + */ +class PreviewWindow { +public: + /* Constructs PreviewWindow instance. */ + PreviewWindow(); + + /* Destructs PreviewWindow instance. */ + ~PreviewWindow(); + + /*************************************************************************** + * Camera API + **************************************************************************/ + +public: + /* Actual handler for camera_device_ops_t::set_preview_window callback. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::set_preview_window callback. + * Param: + * window - Preview window to set. This parameter might be NULL, which + * indicates preview window reset. + * preview_fps - Preview's frame frequency. This parameter determins when + * a frame received via onNextFrameAvailable call will be pushed to + * the preview window. If 'window' parameter passed to this method is + * NULL, this parameter is ignored. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + status_t setPreviewWindow(struct preview_stream_ops* window, + int preview_fps); + + /* Starts the preview. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::start_preview callback. + */ + status_t startPreview(); + + /* Stops the preview. + * This method is called by the containing emulated camera object when it is + * handing the camera_device_ops_t::start_preview callback. + */ + void stopPreview(); + + /* Checks if preview is enabled. */ + inline bool isPreviewEnabled() + { + return mPreviewEnabled; + } + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + /* Next frame is available in the camera device. + * This is a notification callback that is invoked by the camera device when + * a new frame is available. + * Note that most likely this method is called in context of a worker thread + * that camera device has created for frame capturing. + * Param: + * frame - Captured frame, or NULL if camera device didn't pull the frame + * yet. If NULL is passed in this parameter use GetCurrentFrame method + * of the camera device class to obtain the next frame. Also note that + * the size of the frame that is passed here (as well as the frame + * returned from the GetCurrentFrame method) is defined by the current + * frame settings (width + height + pixel format) for the camera device. + * timestamp - Frame's timestamp. + * camera_dev - Camera device instance that delivered the frame. + */ + void onNextFrameAvailable(const void* frame, + nsecs_t timestamp, + EmulatedCameraDevice* camera_dev); + + /*************************************************************************** + * Private API + **************************************************************************/ + +protected: + /* Adjusts cached dimensions of the preview window frame according to the + * frame dimensions used by the camera device. + * + * When preview is started, it's not known (hard to define) what are going + * to be the dimensions of the frames that are going to be displayed. Plus, + * it might be possible, that such dimensions can be changed on the fly. So, + * in order to be always in sync with frame dimensions, this method is + * called for each frame passed to onNextFrameAvailable method, in order to + * properly adjust frame dimensions, used by the preview window. + * Note that this method must be called while object is locked. + * Param: + * camera_dev - Camera device, prpviding frames displayed in the preview + * window. + * Return: + * true if cached dimensions have been adjusted, or false if cached + * dimensions match device's frame dimensions. + */ + bool adjustPreviewDimensions(EmulatedCameraDevice* camera_dev); + + /* Checks if it's the time to push new frame to the preview window. + * Note that this method must be called while object is locked. */ + bool isPreviewTime(); + + /*************************************************************************** + * Data members + **************************************************************************/ + +protected: + /* Locks this instance for data changes. */ + Mutex mObjectLock; + + /* Preview window instance. */ + preview_stream_ops* mPreviewWindow; + + /* Timestamp (abs. microseconds) when last frame has been pushed to the + * preview window. */ + uint64_t mLastPreviewed; + + /* Preview frequency in microseconds. */ + uint32_t mPreviewAfter; + + /* + * Cached preview window frame dimensions. + */ + + int mPreviewFrameWidth; + int mPreviewFrameHeight; + + /* Preview status. */ + bool mPreviewEnabled; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_PREVIEW_WINDOW_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.cpp new file mode 100644 index 0000000..111cbb8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.cpp @@ -0,0 +1,559 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Contains implementation of classes that encapsulate connection to camera + * services in the emulator via qemu pipe. + */ + +#define LOG_NDEBUG 1 +#define LOG_TAG "EmulatedCamera_QemuClient" +#include +#include "EmulatedCamera.h" +#include "QemuClient.h" + +#define LOG_QUERIES 0 +#if LOG_QUERIES +#define LOGQ(...) ALOGD(__VA_ARGS__) +#else +#define LOGQ(...) (void(0)) + +#endif // LOG_QUERIES +namespace android { + +/**************************************************************************** + * Qemu query + ***************************************************************************/ + +QemuQuery::QemuQuery() + : mQuery(mQueryPrealloc), + mQueryDeliveryStatus(NO_ERROR), + mReplyBuffer(NULL), + mReplyData(NULL), + mReplySize(0), + mReplyDataSize(0), + mReplyStatus(0) +{ + *mQuery = '\0'; +} + +QemuQuery::QemuQuery(const char* query_string) + : mQuery(mQueryPrealloc), + mQueryDeliveryStatus(NO_ERROR), + mReplyBuffer(NULL), + mReplyData(NULL), + mReplySize(0), + mReplyDataSize(0), + mReplyStatus(0) +{ + mQueryDeliveryStatus = QemuQuery::createQuery(query_string, NULL); +} + +QemuQuery::QemuQuery(const char* query_name, const char* query_param) + : mQuery(mQueryPrealloc), + mQueryDeliveryStatus(NO_ERROR), + mReplyBuffer(NULL), + mReplyData(NULL), + mReplySize(0), + mReplyDataSize(0), + mReplyStatus(0) +{ + mQueryDeliveryStatus = QemuQuery::createQuery(query_name, query_param); +} + +QemuQuery::~QemuQuery() +{ + QemuQuery::resetQuery(); +} + +status_t QemuQuery::createQuery(const char* name, const char* param) +{ + /* Reset from the previous use. */ + resetQuery(); + + /* Query name cannot be NULL or an empty string. */ + if (name == NULL || *name == '\0') { + ALOGE("%s: NULL or an empty string is passed as query name.", + __FUNCTION__); + mQueryDeliveryStatus = EINVAL; + return EINVAL; + } + + const size_t name_len = strlen(name); + const size_t param_len = (param != NULL) ? strlen(param) : 0; + const size_t required = strlen(name) + (param_len ? (param_len + 2) : 1); + + if (required > sizeof(mQueryPrealloc)) { + /* Preallocated buffer was too small. Allocate a bigger query buffer. */ + mQuery = new char[required]; + if (mQuery == NULL) { + ALOGE("%s: Unable to allocate %zu bytes for query buffer", + __FUNCTION__, required); + mQueryDeliveryStatus = ENOMEM; + return ENOMEM; + } + } + + /* At this point mQuery buffer is big enough for the query. */ + if (param_len) { + sprintf(mQuery, "%s %s", name, param); + } else { + memcpy(mQuery, name, name_len + 1); + } + + return NO_ERROR; +} + +status_t QemuQuery::completeQuery(status_t status) +{ + /* Save query completion status. */ + mQueryDeliveryStatus = status; + if (mQueryDeliveryStatus != NO_ERROR) { + return mQueryDeliveryStatus; + } + + /* Make sure reply buffer contains at least 'ok', or 'ko'. + * Note that 'ok', or 'ko' prefixes are always 3 characters long: in case + * there are more data in the reply, that data will be separated from 'ok'/'ko' + * with a ':'. If there is no more data in the reply, the prefix will be + * zero-terminated, and the terminator will be inculded in the reply. */ + if (mReplyBuffer == NULL || mReplySize < 3) { + ALOGE("%s: Invalid reply to the query", __FUNCTION__); + mQueryDeliveryStatus = EINVAL; + return EINVAL; + } + + /* Lets see the reply status. */ + if (!memcmp(mReplyBuffer, "ok", 2)) { + mReplyStatus = 1; + } else if (!memcmp(mReplyBuffer, "ko", 2)) { + mReplyStatus = 0; + } else { + ALOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer); + mQueryDeliveryStatus = EINVAL; + return EINVAL; + } + + /* Lets see if there are reply data that follow. */ + if (mReplySize > 3) { + /* There are extra data. Make sure they are separated from the status + * with a ':' */ + if (mReplyBuffer[2] != ':') { + ALOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer); + mQueryDeliveryStatus = EINVAL; + return EINVAL; + } + mReplyData = mReplyBuffer + 3; + mReplyDataSize = mReplySize - 3; + } else { + /* Make sure reply buffer containing just 'ok'/'ko' ends with + * zero-terminator. */ + if (mReplyBuffer[2] != '\0') { + ALOGE("%s: Invalid query reply: '%s'", __FUNCTION__, mReplyBuffer); + mQueryDeliveryStatus = EINVAL; + return EINVAL; + } + } + + return NO_ERROR; +} + +void QemuQuery::resetQuery() +{ + if (mQuery != NULL && mQuery != mQueryPrealloc) { + delete[] mQuery; + } + mQuery = mQueryPrealloc; + mQueryDeliveryStatus = NO_ERROR; + if (mReplyBuffer != NULL) { + free(mReplyBuffer); + mReplyBuffer = NULL; + } + mReplyData = NULL; + mReplySize = mReplyDataSize = 0; + mReplyStatus = 0; +} + +/**************************************************************************** + * Qemu client base + ***************************************************************************/ + +/* Camera service name. */ +const char QemuClient::mCameraServiceName[] = "camera"; + +QemuClient::QemuClient() + : mPipeFD(-1) +{ +} + +QemuClient::~QemuClient() +{ + if (mPipeFD >= 0) { + close(mPipeFD); + } +} + +/**************************************************************************** + * Qemu client API + ***************************************************************************/ + +status_t QemuClient::connectClient(const char* param) +{ + ALOGV("%s: '%s'", __FUNCTION__, param ? param : ""); + + /* Make sure that client is not connected already. */ + if (mPipeFD >= 0) { + ALOGE("%s: Qemu client is already connected", __FUNCTION__); + return EINVAL; + } + + /* Select one of the two: 'factory', or 'emulated camera' service */ + if (param == NULL || *param == '\0') { + /* No parameters: connect to the factory service. */ + char pipe_name[512]; + snprintf(pipe_name, sizeof(pipe_name), "qemud:%s", mCameraServiceName); + mPipeFD = qemu_pipe_open(pipe_name); + } else { + /* One extra char ':' that separates service name and parameters + six + * characters for 'qemud:'. This is required by qemu pipe protocol. */ + char* connection_str = new char[strlen(mCameraServiceName) + + strlen(param) + 8]; + sprintf(connection_str, "qemud:%s:%s", mCameraServiceName, param); + + mPipeFD = qemu_pipe_open(connection_str); + delete[] connection_str; + } + if (mPipeFD < 0) { + ALOGE("%s: Unable to connect to the camera service '%s': %s", + __FUNCTION__, param ? param : "Factory", strerror(errno)); + return errno ? errno : EINVAL; + } + + return NO_ERROR; +} + +void QemuClient::disconnectClient() +{ + ALOGV("%s", __FUNCTION__); + + if (mPipeFD >= 0) { + close(mPipeFD); + mPipeFD = -1; + } +} + +status_t QemuClient::sendMessage(const void* data, size_t data_size) +{ + if (mPipeFD < 0) { + ALOGE("%s: Qemu client is not connected", __FUNCTION__); + return EINVAL; + } + + /* Note that we don't use here qemud_client_send, since with qemu pipes we + * don't need to provide payload size prior to payload when we're writing to + * the pipe. So, we can use simple write, and qemu pipe will take care of the + * rest, calling the receiving end with the number of bytes transferred. */ + const size_t written = qemud_fd_write(mPipeFD, data, data_size); + if (written == data_size) { + return NO_ERROR; + } else { + ALOGE("%s: Error sending data via qemu pipe: '%s'", + __FUNCTION__, strerror(errno)); + return errno ? errno : EIO; + } +} + +status_t QemuClient::receiveMessage(void** data, size_t* data_size) +{ + *data = NULL; + *data_size = 0; + + if (mPipeFD < 0) { + ALOGE("%s: Qemu client is not connected", __FUNCTION__); + return EINVAL; + } + + /* The way the service replies to a query, it sends payload size first, and + * then it sends the payload itself. Note that payload size is sent as a + * string, containing 8 characters representing a hexadecimal payload size + * value. Note also, that the string doesn't contain zero-terminator. */ + size_t payload_size; + char payload_size_str[9]; + int rd_res = qemud_fd_read(mPipeFD, payload_size_str, 8); + if (rd_res != 8) { + ALOGE("%s: Unable to obtain payload size: %s", + __FUNCTION__, strerror(errno)); + return errno ? errno : EIO; + } + + /* Convert payload size. */ + errno = 0; + payload_size_str[8] = '\0'; + payload_size = strtol(payload_size_str, NULL, 16); + if (errno) { + ALOGE("%s: Invalid payload size '%s'", __FUNCTION__, payload_size_str); + return EIO; + } + + /* Allocate payload data buffer, and read the payload there. */ + *data = malloc(payload_size); + if (*data == NULL) { + ALOGE("%s: Unable to allocate %zu bytes payload buffer", + __FUNCTION__, payload_size); + return ENOMEM; + } + rd_res = qemud_fd_read(mPipeFD, *data, payload_size); + if (static_cast(rd_res) == payload_size) { + *data_size = payload_size; + return NO_ERROR; + } else { + ALOGE("%s: Read size %d doesnt match expected payload size %zu: %s", + __FUNCTION__, rd_res, payload_size, strerror(errno)); + free(*data); + *data = NULL; + return errno ? errno : EIO; + } +} + +status_t QemuClient::doQuery(QemuQuery* query) +{ + /* Make sure that query has been successfuly constructed. */ + if (query->mQueryDeliveryStatus != NO_ERROR) { + ALOGE("%s: Query is invalid", __FUNCTION__); + return query->mQueryDeliveryStatus; + } + + LOGQ("Send query '%s'", query->mQuery); + + /* Send the query. */ + status_t res = sendMessage(query->mQuery, strlen(query->mQuery) + 1); + if (res == NO_ERROR) { + /* Read the response. */ + res = receiveMessage(reinterpret_cast(&query->mReplyBuffer), + &query->mReplySize); + if (res == NO_ERROR) { + LOGQ("Response to query '%s': Status = '%.2s', %d bytes in response", + query->mQuery, query->mReplyBuffer, query->mReplySize); + } else { + ALOGE("%s Response to query '%s' has failed: %s", + __FUNCTION__, query->mQuery, strerror(res)); + } + } else { + ALOGE("%s: Send query '%s' failed: %s", + __FUNCTION__, query->mQuery, strerror(res)); + } + + /* Complete the query, and return its completion handling status. */ + const status_t res1 = query->completeQuery(res); + ALOGE_IF(res1 != NO_ERROR && res1 != res, + "%s: Error %d in query '%s' completion", + __FUNCTION__, res1, query->mQuery); + return res1; +} + +/**************************************************************************** + * Qemu client for the 'factory' service. + ***************************************************************************/ + +/* + * Factory service queries. + */ + +/* Queries list of cameras connected to the host. */ +const char FactoryQemuClient::mQueryList[] = "list"; + +FactoryQemuClient::FactoryQemuClient() + : QemuClient() +{ +} + +FactoryQemuClient::~FactoryQemuClient() +{ +} + +status_t FactoryQemuClient::listCameras(char** list) +{ + ALOGV("%s", __FUNCTION__); + + QemuQuery query(mQueryList); + if (doQuery(&query) || !query.isQuerySucceeded()) { + ALOGE("%s: List cameras query failed: %s", __FUNCTION__, + query.mReplyData ? query.mReplyData : "No error message"); + return query.getCompletionStatus(); + } + + /* Make sure there is a list returned. */ + if (query.mReplyDataSize == 0) { + ALOGE("%s: No camera list is returned.", __FUNCTION__); + return EINVAL; + } + + /* Copy the list over. */ + *list = (char*)malloc(query.mReplyDataSize); + if (*list != NULL) { + memcpy(*list, query.mReplyData, query.mReplyDataSize); + ALOGD("Emulated camera list: %s", *list); + return NO_ERROR; + } else { + ALOGE("%s: Unable to allocate %zu bytes", + __FUNCTION__, query.mReplyDataSize); + return ENOMEM; + } +} + +/**************************************************************************** + * Qemu client for an 'emulated camera' service. + ***************************************************************************/ + +/* + * Emulated camera queries + */ + +/* Connect to the camera device. */ +const char CameraQemuClient::mQueryConnect[] = "connect"; +/* Disconect from the camera device. */ +const char CameraQemuClient::mQueryDisconnect[] = "disconnect"; +/* Start capturing video from the camera device. */ +const char CameraQemuClient::mQueryStart[] = "start"; +/* Stop capturing video from the camera device. */ +const char CameraQemuClient::mQueryStop[] = "stop"; +/* Get next video frame from the camera device. */ +const char CameraQemuClient::mQueryFrame[] = "frame"; + +CameraQemuClient::CameraQemuClient() + : QemuClient() +{ +} + +CameraQemuClient::~CameraQemuClient() +{ + +} + +status_t CameraQemuClient::queryConnect() +{ + ALOGV("%s", __FUNCTION__); + + QemuQuery query(mQueryConnect); + doQuery(&query); + const status_t res = query.getCompletionStatus(); + ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s", + __FUNCTION__, query.mReplyData ? query.mReplyData : + "No error message"); + return res; +} + +status_t CameraQemuClient::queryDisconnect() +{ + ALOGV("%s", __FUNCTION__); + + QemuQuery query(mQueryDisconnect); + doQuery(&query); + const status_t res = query.getCompletionStatus(); + ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s", + __FUNCTION__, query.mReplyData ? query.mReplyData : + "No error message"); + return res; +} + +status_t CameraQemuClient::queryStart(uint32_t pixel_format, + int width, + int height) +{ + ALOGV("%s", __FUNCTION__); + + char query_str[256]; + snprintf(query_str, sizeof(query_str), "%s dim=%dx%d pix=%d", + mQueryStart, width, height, pixel_format); + QemuQuery query(query_str); + doQuery(&query); + const status_t res = query.getCompletionStatus(); + ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s", + __FUNCTION__, query.mReplyData ? query.mReplyData : + "No error message"); + return res; +} + +status_t CameraQemuClient::queryStop() +{ + ALOGV("%s", __FUNCTION__); + + QemuQuery query(mQueryStop); + doQuery(&query); + const status_t res = query.getCompletionStatus(); + ALOGE_IF(res != NO_ERROR, "%s: Query failed: %s", + __FUNCTION__, query.mReplyData ? query.mReplyData : + "No error message"); + return res; +} + +status_t CameraQemuClient::queryFrame(void* vframe, + void* pframe, + size_t vframe_size, + size_t pframe_size, + float r_scale, + float g_scale, + float b_scale, + float exposure_comp) +{ + ALOGV("%s", __FUNCTION__); + + char query_str[256]; + snprintf(query_str, sizeof(query_str), "%s video=%zu preview=%zu whiteb=%g,%g,%g expcomp=%g", + mQueryFrame, (vframe && vframe_size) ? vframe_size : 0, + (pframe && pframe_size) ? pframe_size : 0, r_scale, g_scale, b_scale, + exposure_comp); + QemuQuery query(query_str); + doQuery(&query); + const status_t res = query.getCompletionStatus(); + if( res != NO_ERROR) { + ALOGE("%s: Query failed: %s", + __FUNCTION__, query.mReplyData ? query.mReplyData : + "No error message"); + return res; + } + + /* Copy requested frames. */ + size_t cur_offset = 0; + const uint8_t* frame = reinterpret_cast(query.mReplyData); + /* Video frame is always first. */ + if (vframe != NULL && vframe_size != 0) { + /* Make sure that video frame is in. */ + if ((query.mReplyDataSize - cur_offset) >= vframe_size) { + memcpy(vframe, frame, vframe_size); + cur_offset += vframe_size; + } else { + ALOGE("%s: Reply %zu bytes is to small to contain %zu bytes video frame", + __FUNCTION__, query.mReplyDataSize - cur_offset, vframe_size); + return EINVAL; + } + } + if (pframe != NULL && pframe_size != 0) { + /* Make sure that preview frame is in. */ + if ((query.mReplyDataSize - cur_offset) >= pframe_size) { + memcpy(pframe, frame + cur_offset, pframe_size); + cur_offset += pframe_size; + } else { + ALOGE("%s: Reply %zu bytes is to small to contain %zu bytes preview frame", + __FUNCTION__, query.mReplyDataSize - cur_offset, pframe_size); + return EINVAL; + } + } + + return NO_ERROR; +} + +}; /* namespace android */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.h b/src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.h new file mode 100644 index 0000000..1644321 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/QemuClient.h @@ -0,0 +1,437 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HW_EMULATOR_CAMERA_QEMU_CLIENT_H +#define HW_EMULATOR_CAMERA_QEMU_CLIENT_H + +/* + * Contains declaration of classes that encapsulate connection to camera services + * in the emulator via qemu pipe. + */ + +#include + +namespace android { + +/**************************************************************************** + * Qemu query + ***************************************************************************/ + +/* Encapsulates a query to the emulator. + * Guest exchanges data with the emulator via queries sent over the qemu pipe. + * The queries as well as replies to the queries are all strings (except for the + * 'frame' query where reply is a framebuffer). + * Each query is formatted as such: + * + * "[ ]", + * + * where is a string representing query name, and are + * optional parameters for the query. If parameters are present, they must be + * separated from the query name with a single space, and they must be formatted + * as such: + * + * "= = ... =" + * + * I.e.: + * - Every parameter must have a name, and a value. + * - Name and value must be separated with '='. + * - No spaces are allowed around '=' separating name and value. + * - Parameters must be separated with a single space character. + * - No '=' character is allowed in name and in value. + * + * There are certain restrictions on strings used in the query: + * - Spaces are allowed only as separators. + * - '=' are allowed only to divide parameter names from parameter values. + * + * Emulator replies to each query in two chunks: + * - 8 bytes encoding the payload size as a string containing hexadecimal + * representation of the payload size value. This is done in order to simplify + * dealing with different endianness on the host, and on the guest. + * - Payload, whose size is defined by the first chunk. + * + * Every payload always begins with two characters, encoding the result of the + * query: + * - 'ok' Encoding the success + * - 'ko' Encoding a failure. + * After that payload may have optional data. If payload has more data following + * the query result, there is a ':' character separating them. If payload carries + * only the result, it always ends with a zero-terminator. So, payload 'ok'/'ko' + * prefix is always 3 bytes long: it either includes a zero-terminator, if there + * is no data, or a ':' separator. + */ +class QemuQuery { +public: + /* Constructs an uninitialized QemuQuery instance. */ + QemuQuery(); + + /* Constructs and initializes QemuQuery instance for a query. + * Param: + * query_string - Query string. This constructor can also be used to + * construct a query that doesn't have parameters. In this case query + * name can be passed as a parameter here. + */ + explicit QemuQuery(const char* query_string); + + /* Constructs and initializes QemuQuery instance for a query with parameters. + * Param: + * query_name - Query name. + * query_param - Query parameters. Can be NULL. + */ + QemuQuery(const char* query_name, const char* query_param); + + /* Destructs QemuQuery instance. */ + ~QemuQuery(); + + /**************************************************************************** + * Public API + ***************************************************************************/ + + /* Creates new query. + * Note: this method will reset this instance prior to creating a new query + * in order to discard possible "leftovers" from the previous query. + * Param: + * query_name - Query name. + * query_param - Query parameters. Can be NULL. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + status_t createQuery(const char* name, const char* param); + + /* Completes the query after a reply from the emulator. + * This method will parse the reply buffer, and calculate the final query + * status, which depends not only on the transport success / failure, but + * also on 'ok' / 'ko' in the reply buffer. + * Param: + * status - Query delivery status. This status doesn't necessarily reflects + * the final query status (which is defined by 'ok'/'ko' prefix in the + * reply buffer). This status simply states whether or not the query has + * been sent, and a reply has been received successfuly. However, if + * this status indicates a failure, it means that the entire query has + * failed. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. Note that + * status returned here just signals whether or not the method has succeeded. + * Use isQuerySucceeded() / getCompletionStatus() methods of this class to + * check the final query status. + */ + status_t completeQuery(status_t status); + + /* Resets the query from a previous use. */ + void resetQuery(); + + /* Checks if query has succeeded. + * Note that this method must be called after completeQuery() method of this + * class has been executed. + */ + inline bool isQuerySucceeded() const { + return mQueryDeliveryStatus == NO_ERROR && mReplyStatus != 0; + } + + /* Gets final completion status of the query. + * Note that this method must be called after completeQuery() method of this + * class has been executed. + * Return: + * NO_ERROR if query has succeeded, or an appropriate error status on query + * failure. + */ + inline status_t getCompletionStatus() const { + if (mQueryDeliveryStatus == NO_ERROR) { + if (mReplyStatus) { + return NO_ERROR; + } else { + return EINVAL; + } + } else { + return mQueryDeliveryStatus; + } + } + + /**************************************************************************** + * Public data memebers + ***************************************************************************/ + +public: + /* Query string. */ + char* mQuery; + /* Query delivery status. */ + status_t mQueryDeliveryStatus; + /* Reply buffer */ + char* mReplyBuffer; + /* Reply data (past 'ok'/'ko'). If NULL, there were no data in reply. */ + char* mReplyData; + /* Reply buffer size. */ + size_t mReplySize; + /* Reply data size. */ + size_t mReplyDataSize; + /* Reply status: 1 - ok, 0 - ko. */ + int mReplyStatus; + + /**************************************************************************** + * Private data memebers + ***************************************************************************/ + +protected: + /* Preallocated buffer for small queries. */ + char mQueryPrealloc[256]; +}; + +/**************************************************************************** + * Qemu client base + ***************************************************************************/ + +/* Encapsulates a connection to the 'camera' service in the emulator via qemu + * pipe. + */ +class QemuClient { +public: + /* Constructs QemuClient instance. */ + QemuClient(); + + /* Destructs QemuClient instance. */ + virtual ~QemuClient(); + + /**************************************************************************** + * Qemu client API + ***************************************************************************/ + +public: + /* Connects to the 'camera' service in the emulator via qemu pipe. + * Param: + * param - Parameters to pass to the camera service. There are two types of + * camera services implemented by the emulator. The first one is a + * 'camera factory' type of service that provides list of cameras + * connected to the host. Another one is an 'emulated camera' type of + * service that provides interface to a camera connected to the host. At + * the connection time emulator makes distinction between the two by + * looking at connection parameters: no parameters means connection to + * the 'factory' service, while connection with parameters means + * connection to an 'emulated camera' service, where camera is identified + * by one of the connection parameters. So, passing NULL, or an empty + * string to this method will establish a connection with the 'factory' + * service, while not empty string passed here will establish connection + * with an 'emulated camera' service. Parameters defining the emulated + * camera must be formatted as such: + * + * "name= [inp_channel=]", + * + * where 'device name' is a required parameter defining name of the + * camera device, and 'input channel' is an optional parameter (positive + * integer), defining the input channel to use on the camera device. + * Note that device name passed here must have been previously obtained + * from the factory service using 'list' query. + * Return: + * NO_ERROR on success, or an appropriate error status. + */ + virtual status_t connectClient(const char* param); + + /* Disconnects from the service. */ + virtual void disconnectClient(); + + /* Sends data to the service. + * Param: + * data, data_size - Data to send. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + virtual status_t sendMessage(const void* data, size_t data_size); + + /* Receives data from the service. + * This method assumes that data to receive will come in two chunks: 8 + * characters encoding the payload size in hexadecimal string, followed by + * the paylod (if any). + * This method will allocate data buffer where to receive the response. + * Param: + * data - Upon success contains address of the allocated data buffer with + * the data received from the service. The caller is responsible for + * freeing allocated data buffer. + * data_size - Upon success contains size of the data received from the + * service. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + virtual status_t receiveMessage(void** data, size_t* data_size); + + /* Sends a query, and receives a response from the service. + * Param: + * query - Query to send to the service. When this method returns, the query + * is completed, and all its relevant data members are properly initialized. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. Note that + * status returned here is not the final query status. Use isQuerySucceeded(), + * or getCompletionStatus() method on the query object to see if it has + * succeeded. However, if this method returns a failure, it means that the + * query has failed, and there is no guarantee that its data members are + * properly initialized (except for the 'mQueryDeliveryStatus', which is + * always in the proper state). + */ + virtual status_t doQuery(QemuQuery* query); + + /**************************************************************************** + * Data members + ***************************************************************************/ + +protected: + /* Qemu pipe handle. */ + int mPipeFD; + +private: + /* Camera service name. */ + static const char mCameraServiceName[]; +}; + +/**************************************************************************** + * Qemu client for the 'factory' service. + ***************************************************************************/ + +/* Encapsulates QemuClient for the 'factory' service. */ +class FactoryQemuClient : public QemuClient { +public: + /* Constructs FactoryQemuClient instance. */ + FactoryQemuClient(); + + /* Destructs FactoryQemuClient instance. */ + ~FactoryQemuClient(); + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + /* Lists camera devices connected to the host. + * Param: + * list - Upon success contains a list of cameras connected to the host. The + * list returned here is represented as a string, containing multiple + * lines separated with '\n', where each line represents a camera. Each + * camera line is formatted as such: + * + * "name= channel= pix= framedims=\n" + * + * Where: + * - 'name' is the name of the camera device attached to the host. This + * name must be used for subsequent connection to the 'emulated camera' + * service for that camera. + * - 'channel' - input channel number (positive int) to use to communicate + * with the camera. + * - 'pix' - pixel format (a "fourcc" uint), chosen for the video frames + * by the camera service. + * - 'framedims' contains a list of frame dimensions supported by the + * camera for the chosen pixel format. Each etry in the list is in form + * 'x', where 'width' and 'height' are numeric values + * for width and height of a supported frame dimension. Entries in + * this list are separated with ',' with no spaces between the entries. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + status_t listCameras(char** list); + + /**************************************************************************** + * Names of the queries available for the emulated camera factory. + ***************************************************************************/ + +private: + /* List cameras connected to the host. */ + static const char mQueryList[]; +}; + +/**************************************************************************** + * Qemu client for an 'emulated camera' service. + ***************************************************************************/ + +/* Encapsulates QemuClient for an 'emulated camera' service. + */ +class CameraQemuClient : public QemuClient { +public: + /* Constructs CameraQemuClient instance. */ + CameraQemuClient(); + + /* Destructs CameraQemuClient instance. */ + ~CameraQemuClient(); + + /**************************************************************************** + * Public API + ***************************************************************************/ + +public: + /* Queries camera connection. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + status_t queryConnect(); + + /* Queries camera disconnection. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + status_t queryDisconnect(); + + /* Queries camera to start capturing video. + * Param: + * pixel_format - Pixel format that is used by the client to push video + * frames to the camera framework. + * width, height - Frame dimensions, requested by the framework. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + status_t queryStart(uint32_t pixel_format, int width, int height); + + /* Queries camera to stop capturing video. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + status_t queryStop(); + + /* Queries camera for the next video frame. + * Param: + * vframe, vframe_size - Define buffer, allocated to receive a video frame. + * Any of these parameters can be 0, indicating that the caller is + * interested only in preview frame. + * pframe, pframe_size - Define buffer, allocated to receive a preview frame. + * Any of these parameters can be 0, indicating that the caller is + * interested only in video frame. + * r_scale, g_scale, b_scale - White balance scale. + * exposure_comp - Expsoure compensation. + * Return: + * NO_ERROR on success, or an appropriate error status on failure. + */ + status_t queryFrame(void* vframe, + void* pframe, + size_t vframe_size, + size_t pframe_size, + float r_scale, + float g_scale, + float b_scale, + float exposure_comp); + + /**************************************************************************** + * Names of the queries available for the emulated camera. + ***************************************************************************/ + +private: + /* Connect to the camera. */ + static const char mQueryConnect[]; + /* Disconnect from the camera. */ + static const char mQueryDisconnect[]; + /* Start video capturing. */ + static const char mQueryStart[]; + /* Stop video capturing. */ + static const char mQueryStop[]; + /* Query frame(s). */ + static const char mQueryFrame[]; +}; + +}; /* namespace android */ + +#endif /* HW_EMULATOR_CAMERA_QEMU_CLIENT_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Base.h b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Base.h new file mode 100644 index 0000000..724b3f9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Base.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This file includes various basic structures that are needed by multiple parts + * of the fake camera 2 implementation. + */ + +#ifndef HW_EMULATOR_CAMERA2_BASE_H +#define HW_EMULATOR_CAMERA2_BASE_H + +#include +#include +#include + +namespace android { + + +/* Internal structure for passing buffers across threads */ +struct StreamBuffer { + // Positive numbers are output streams + // Negative numbers are input reprocess streams + // Zero is an auxillary buffer + int streamId; + uint32_t width, height; + uint32_t format; + uint32_t dataSpace; + uint32_t stride; + buffer_handle_t *buffer; + uint8_t *img; +}; +typedef Vector Buffers; + +struct Stream { + const camera2_stream_ops_t *ops; + uint32_t width, height; + int32_t format; + uint32_t stride; +}; + +struct ReprocessStream { + const camera2_stream_in_ops_t *ops; + uint32_t width, height; + int32_t format; + uint32_t stride; + // -1 if the reprocessing stream is independent + int32_t sourceStreamId; +}; + +} // namespace android; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.cpp new file mode 100644 index 0000000..d0dce26 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.cpp @@ -0,0 +1,286 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera2_JpegCompressor" + +#include +#include + +#include "JpegCompressor.h" +#include "../EmulatedFakeCamera2.h" +#include "../EmulatedFakeCamera3.h" + +namespace android { + +JpegCompressor::JpegCompressor(): + Thread(false), + mIsBusy(false), + mSynchronous(false), + mBuffers(NULL), + mListener(NULL) { +} + +JpegCompressor::~JpegCompressor() { + Mutex::Autolock lock(mMutex); +} + +status_t JpegCompressor::start(Buffers *buffers, JpegListener *listener) { + if (listener == NULL) { + ALOGE("%s: NULL listener not allowed!", __FUNCTION__); + return BAD_VALUE; + } + Mutex::Autolock lock(mMutex); + { + Mutex::Autolock busyLock(mBusyMutex); + + if (mIsBusy) { + ALOGE("%s: Already processing a buffer!", __FUNCTION__); + return INVALID_OPERATION; + } + + mIsBusy = true; + mSynchronous = false; + mBuffers = buffers; + mListener = listener; + } + + status_t res; + res = run("EmulatedFakeCamera2::JpegCompressor"); + if (res != OK) { + ALOGE("%s: Unable to start up compression thread: %s (%d)", + __FUNCTION__, strerror(-res), res); + delete mBuffers; + } + return res; +} + +status_t JpegCompressor::compressSynchronous(Buffers *buffers) { + status_t res; + + Mutex::Autolock lock(mMutex); + { + Mutex::Autolock busyLock(mBusyMutex); + + if (mIsBusy) { + ALOGE("%s: Already processing a buffer!", __FUNCTION__); + return INVALID_OPERATION; + } + + mIsBusy = true; + mSynchronous = true; + mBuffers = buffers; + } + + res = compress(); + + cleanUp(); + + return res; +} + +status_t JpegCompressor::cancel() { + requestExitAndWait(); + return OK; +} + +status_t JpegCompressor::readyToRun() { + return OK; +} + +bool JpegCompressor::threadLoop() { + status_t res; + ALOGV("%s: Starting compression thread", __FUNCTION__); + + res = compress(); + + mListener->onJpegDone(mJpegBuffer, res == OK); + + cleanUp(); + + return false; +} + +status_t JpegCompressor::compress() { + // Find source and target buffers. Assumes only one buffer matches + // each condition! + + bool foundJpeg = false, mFoundAux = false; + for (size_t i = 0; i < mBuffers->size(); i++) { + const StreamBuffer &b = (*mBuffers)[i]; + if (b.format == HAL_PIXEL_FORMAT_BLOB) { + mJpegBuffer = b; + mFoundJpeg = true; + } else if (b.streamId <= 0) { + mAuxBuffer = b; + mFoundAux = true; + } + if (mFoundJpeg && mFoundAux) break; + } + if (!mFoundJpeg || !mFoundAux) { + ALOGE("%s: Unable to find buffers for JPEG source/destination", + __FUNCTION__); + return BAD_VALUE; + } + + // Set up error management + + mJpegErrorInfo = NULL; + JpegError error; + error.parent = this; + + mCInfo.err = jpeg_std_error(&error); + mCInfo.err->error_exit = jpegErrorHandler; + + jpeg_create_compress(&mCInfo); + if (checkError("Error initializing compression")) return NO_INIT; + + // Route compressed data straight to output stream buffer + + JpegDestination jpegDestMgr; + jpegDestMgr.parent = this; + jpegDestMgr.init_destination = jpegInitDestination; + jpegDestMgr.empty_output_buffer = jpegEmptyOutputBuffer; + jpegDestMgr.term_destination = jpegTermDestination; + + mCInfo.dest = &jpegDestMgr; + + // Set up compression parameters + + mCInfo.image_width = mAuxBuffer.width; + mCInfo.image_height = mAuxBuffer.height; + mCInfo.input_components = 3; + mCInfo.in_color_space = JCS_RGB; + + jpeg_set_defaults(&mCInfo); + if (checkError("Error configuring defaults")) return NO_INIT; + + // Do compression + + jpeg_start_compress(&mCInfo, TRUE); + if (checkError("Error starting compression")) return NO_INIT; + + size_t rowStride = mAuxBuffer.stride * 3; + const size_t kChunkSize = 32; + while (mCInfo.next_scanline < mCInfo.image_height) { + JSAMPROW chunk[kChunkSize]; + for (size_t i = 0 ; i < kChunkSize; i++) { + chunk[i] = (JSAMPROW) + (mAuxBuffer.img + (i + mCInfo.next_scanline) * rowStride); + } + jpeg_write_scanlines(&mCInfo, chunk, kChunkSize); + if (checkError("Error while compressing")) return NO_INIT; + if (exitPending()) { + ALOGV("%s: Cancel called, exiting early", __FUNCTION__); + return TIMED_OUT; + } + } + + jpeg_finish_compress(&mCInfo); + if (checkError("Error while finishing compression")) return NO_INIT; + + // All done + + return OK; +} + +bool JpegCompressor::isBusy() { + Mutex::Autolock busyLock(mBusyMutex); + return mIsBusy; +} + +bool JpegCompressor::isStreamInUse(uint32_t id) { + Mutex::Autolock lock(mBusyMutex); + + if (mBuffers && mIsBusy) { + for (size_t i = 0; i < mBuffers->size(); i++) { + if ( (*mBuffers)[i].streamId == (int)id ) return true; + } + } + return false; +} + +bool JpegCompressor::waitForDone(nsecs_t timeout) { + Mutex::Autolock lock(mBusyMutex); + status_t res = OK; + if (mIsBusy) { + res = mDone.waitRelative(mBusyMutex, timeout); + } + return (res == OK); +} + +bool JpegCompressor::checkError(const char *msg) { + if (mJpegErrorInfo) { + char errBuffer[JMSG_LENGTH_MAX]; + mJpegErrorInfo->err->format_message(mJpegErrorInfo, errBuffer); + ALOGE("%s: %s: %s", + __FUNCTION__, msg, errBuffer); + mJpegErrorInfo = NULL; + return true; + } + return false; +} + +void JpegCompressor::cleanUp() { + status_t res; + jpeg_destroy_compress(&mCInfo); + Mutex::Autolock lock(mBusyMutex); + + if (mFoundAux) { + if (mAuxBuffer.streamId == 0) { + delete[] mAuxBuffer.img; + } else if (!mSynchronous) { + mListener->onJpegInputDone(mAuxBuffer); + } + } + if (!mSynchronous) { + delete mBuffers; + } + + mBuffers = NULL; + + mIsBusy = false; + mDone.signal(); +} + +void JpegCompressor::jpegErrorHandler(j_common_ptr cinfo) { + JpegError *error = static_cast(cinfo->err); + error->parent->mJpegErrorInfo = cinfo; +} + +void JpegCompressor::jpegInitDestination(j_compress_ptr cinfo) { + JpegDestination *dest= static_cast(cinfo->dest); + ALOGV("%s: Setting destination to %p, size %zu", + __FUNCTION__, dest->parent->mJpegBuffer.img, kMaxJpegSize); + dest->next_output_byte = (JOCTET*)(dest->parent->mJpegBuffer.img); + dest->free_in_buffer = kMaxJpegSize; +} + +boolean JpegCompressor::jpegEmptyOutputBuffer(j_compress_ptr cinfo) { + ALOGE("%s: JPEG destination buffer overflow!", + __FUNCTION__); + return true; +} + +void JpegCompressor::jpegTermDestination(j_compress_ptr cinfo) { + ALOGV("%s: Done writing JPEG data. %zu bytes left in buffer", + __FUNCTION__, cinfo->dest->free_in_buffer); +} + +JpegCompressor::JpegListener::~JpegListener() { +} + +} // namespace android diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.h b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.h new file mode 100644 index 0000000..ff6f8a4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/JpegCompressor.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * This class simulates a hardware JPEG compressor. It receives image buffers + * in RGBA_8888 format, processes them in a worker thread, and then pushes them + * out to their destination stream. + */ + +#ifndef HW_EMULATOR_CAMERA2_JPEG_H +#define HW_EMULATOR_CAMERA2_JPEG_H + +#include "utils/Thread.h" +#include "utils/Mutex.h" +#include "utils/Timers.h" + +#include "Base.h" + +#include + +extern "C" { +#include +} + +namespace android { + +class JpegCompressor: private Thread, public virtual RefBase { + public: + + JpegCompressor(); + ~JpegCompressor(); + + struct JpegListener { + // Called when JPEG compression has finished, or encountered an error + virtual void onJpegDone(const StreamBuffer &jpegBuffer, + bool success) = 0; + // Called when the input buffer for JPEG is not needed any more, + // if the buffer came from the framework. + virtual void onJpegInputDone(const StreamBuffer &inputBuffer) = 0; + virtual ~JpegListener(); + }; + + // Start compressing COMPRESSED format buffers; JpegCompressor takes + // ownership of the Buffers vector. + status_t start(Buffers *buffers, JpegListener *listener); + + // Compress and block until buffer is complete. + status_t compressSynchronous(Buffers *buffers); + + status_t cancel(); + + bool isBusy(); + bool isStreamInUse(uint32_t id); + + bool waitForDone(nsecs_t timeout); + + // TODO: Measure this + static const size_t kMaxJpegSize = 300000; + + private: + Mutex mBusyMutex; + bool mIsBusy; + Condition mDone; + bool mSynchronous; + + Mutex mMutex; + + Buffers *mBuffers; + JpegListener *mListener; + + StreamBuffer mJpegBuffer, mAuxBuffer; + bool mFoundJpeg, mFoundAux; + + jpeg_compress_struct mCInfo; + + struct JpegError : public jpeg_error_mgr { + JpegCompressor *parent; + }; + j_common_ptr mJpegErrorInfo; + + struct JpegDestination : public jpeg_destination_mgr { + JpegCompressor *parent; + }; + + static void jpegErrorHandler(j_common_ptr cinfo); + + static void jpegInitDestination(j_compress_ptr cinfo); + static boolean jpegEmptyOutputBuffer(j_compress_ptr cinfo); + static void jpegTermDestination(j_compress_ptr cinfo); + + bool checkError(const char *msg); + status_t compress(); + + void cleanUp(); + + /** + * Inherited Thread virtual overrides + */ + private: + virtual status_t readyToRun(); + virtual bool threadLoop(); +}; + +} // namespace android + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.cpp new file mode 100644 index 0000000..48296d2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.cpp @@ -0,0 +1,478 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//#define LOG_NDEBUG 0 +#define LOG_TAG "EmulatedCamera_Scene" +#include +#include +#include +#include "Scene.h" + +// TODO: This should probably be done host-side in OpenGL for speed and better +// quality + +namespace android { + +// Define single-letter shortcuts for scene definition, for directly indexing +// mCurrentColors +#define G (Scene::GRASS * Scene::NUM_CHANNELS) +#define S (Scene::GRASS_SHADOW * Scene::NUM_CHANNELS) +#define H (Scene::HILL * Scene::NUM_CHANNELS) +#define W (Scene::WALL * Scene::NUM_CHANNELS) +#define R (Scene::ROOF * Scene::NUM_CHANNELS) +#define D (Scene::DOOR * Scene::NUM_CHANNELS) +#define C (Scene::CHIMNEY * Scene::NUM_CHANNELS) +#define I (Scene::WINDOW * Scene::NUM_CHANNELS) +#define U (Scene::SUN * Scene::NUM_CHANNELS) +#define K (Scene::SKY * Scene::NUM_CHANNELS) +#define M (Scene::MOON * Scene::NUM_CHANNELS) + +const int Scene::kSceneWidth = 20; +const int Scene::kSceneHeight = 20; + +const uint8_t Scene::kScene[Scene::kSceneWidth * Scene::kSceneHeight] = { + // 5 10 15 20 + K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K, + K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K, + K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K, + K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K, + K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K, // 5 + K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K, + K,K,K,K,K,K,K,K,H,H,H,H,H,H,H,H,H,H,H,H, + K,K,K,K,K,K,K,K,H,H,H,H,H,H,H,C,C,H,H,H, + K,K,K,K,K,K,H,H,H,H,H,H,H,H,H,C,C,H,H,H, + H,K,K,K,K,K,H,R,R,R,R,R,R,R,R,R,R,R,R,H, // 10 + H,K,K,K,K,H,H,R,R,R,R,R,R,R,R,R,R,R,R,H, + H,H,H,K,K,H,H,R,R,R,R,R,R,R,R,R,R,R,R,H, + H,H,H,K,K,H,H,H,W,W,W,W,W,W,W,W,W,W,H,H, + S,S,S,G,G,S,S,S,W,W,W,W,W,W,W,W,W,W,S,S, + S,G,G,G,G,S,S,S,W,I,I,W,D,D,W,I,I,W,S,S, // 15 + G,G,G,G,G,G,S,S,W,I,I,W,D,D,W,I,I,W,S,S, + G,G,G,G,G,G,G,G,W,W,W,W,D,D,W,W,W,W,G,G, + G,G,G,G,G,G,G,G,W,W,W,W,D,D,W,W,W,W,G,G, + G,G,G,G,G,G,G,G,S,S,S,S,S,S,S,S,S,S,G,G, + G,G,G,G,G,G,G,G,S,S,S,S,S,S,S,S,S,S,G,G, // 20 + // 5 10 15 20 +}; + +#undef G +#undef S +#undef H +#undef W +#undef R +#undef D +#undef C +#undef I +#undef U +#undef K +#undef M + +Scene::Scene( + int sensorWidthPx, + int sensorHeightPx, + float sensorSensitivity): + mSensorWidth(sensorWidthPx), + mSensorHeight(sensorHeightPx), + mHour(12), + mExposureDuration(0.033f), + mSensorSensitivity(sensorSensitivity) +{ + // Map scene to sensor pixels + if (mSensorWidth > mSensorHeight) { + mMapDiv = (mSensorWidth / (kSceneWidth + 1) ) + 1; + } else { + mMapDiv = (mSensorHeight / (kSceneHeight + 1) ) + 1; + } + mOffsetX = (kSceneWidth * mMapDiv - mSensorWidth) / 2; + mOffsetY = (kSceneHeight * mMapDiv - mSensorHeight) / 2; + + // Assume that sensor filters are sRGB primaries to start + mFilterR[0] = 3.2406f; mFilterR[1] = -1.5372f; mFilterR[2] = -0.4986f; + mFilterGr[0] = -0.9689f; mFilterGr[1] = 1.8758f; mFilterGr[2] = 0.0415f; + mFilterGb[0] = -0.9689f; mFilterGb[1] = 1.8758f; mFilterGb[2] = 0.0415f; + mFilterB[0] = 0.0557f; mFilterB[1] = -0.2040f; mFilterB[2] = 1.0570f; + + +} + +Scene::~Scene() { +} + +void Scene::setColorFilterXYZ( + float rX, float rY, float rZ, + float grX, float grY, float grZ, + float gbX, float gbY, float gbZ, + float bX, float bY, float bZ) { + mFilterR[0] = rX; mFilterR[1] = rY; mFilterR[2] = rZ; + mFilterGr[0] = grX; mFilterGr[1] = grY; mFilterGr[2] = grZ; + mFilterGb[0] = gbX; mFilterGb[1] = gbY; mFilterGb[2] = gbZ; + mFilterB[0] = bX; mFilterB[1] = bY; mFilterB[2] = bZ; +} + +void Scene::setHour(int hour) { + ALOGV("Hour set to: %d", hour); + mHour = hour % 24; +} + +int Scene::getHour() { + return mHour; +} + +void Scene::setExposureDuration(float seconds) { + mExposureDuration = seconds; +} + +void Scene::calculateScene(nsecs_t time) { + // Calculate time fractions for interpolation + int timeIdx = mHour / kTimeStep; + int nextTimeIdx = (timeIdx + 1) % (24 / kTimeStep); + const nsecs_t kOneHourInNsec = 1e9 * 60 * 60; + nsecs_t timeSinceIdx = (mHour - timeIdx * kTimeStep) * kOneHourInNsec + time; + float timeFrac = timeSinceIdx / (float)(kOneHourInNsec * kTimeStep); + + // Determine overall sunlight levels + float sunLux = + kSunlight[timeIdx] * (1 - timeFrac) + + kSunlight[nextTimeIdx] * timeFrac; + ALOGV("Sun lux: %f", sunLux); + + float sunShadeLux = sunLux * (kDaylightShadeIllum / kDirectSunIllum); + + // Determine sun/shade illumination chromaticity + float currentSunXY[2]; + float currentShadeXY[2]; + + const float *prevSunXY, *nextSunXY; + const float *prevShadeXY, *nextShadeXY; + if (kSunlight[timeIdx] == kSunsetIllum || + kSunlight[timeIdx] == kTwilightIllum) { + prevSunXY = kSunsetXY; + prevShadeXY = kSunsetXY; + } else { + prevSunXY = kDirectSunlightXY; + prevShadeXY = kDaylightXY; + } + if (kSunlight[nextTimeIdx] == kSunsetIllum || + kSunlight[nextTimeIdx] == kTwilightIllum) { + nextSunXY = kSunsetXY; + nextShadeXY = kSunsetXY; + } else { + nextSunXY = kDirectSunlightXY; + nextShadeXY = kDaylightXY; + } + currentSunXY[0] = prevSunXY[0] * (1 - timeFrac) + + nextSunXY[0] * timeFrac; + currentSunXY[1] = prevSunXY[1] * (1 - timeFrac) + + nextSunXY[1] * timeFrac; + + currentShadeXY[0] = prevShadeXY[0] * (1 - timeFrac) + + nextShadeXY[0] * timeFrac; + currentShadeXY[1] = prevShadeXY[1] * (1 - timeFrac) + + nextShadeXY[1] * timeFrac; + + ALOGV("Sun XY: %f, %f, Shade XY: %f, %f", + currentSunXY[0], currentSunXY[1], + currentShadeXY[0], currentShadeXY[1]); + + // Converting for xyY to XYZ: + // X = Y / y * x + // Y = Y + // Z = Y / y * (1 - x - y); + float sunXYZ[3] = { + sunLux / currentSunXY[1] * currentSunXY[0], + sunLux, + sunLux / currentSunXY[1] * + (1 - currentSunXY[0] - currentSunXY[1]) + }; + float sunShadeXYZ[3] = { + sunShadeLux / currentShadeXY[1] * currentShadeXY[0], + sunShadeLux, + sunShadeLux / currentShadeXY[1] * + (1 - currentShadeXY[0] - currentShadeXY[1]) + }; + ALOGV("Sun XYZ: %f, %f, %f", + sunXYZ[0], sunXYZ[1], sunXYZ[2]); + ALOGV("Sun shade XYZ: %f, %f, %f", + sunShadeXYZ[0], sunShadeXYZ[1], sunShadeXYZ[2]); + + // Determine moonlight levels + float moonLux = + kMoonlight[timeIdx] * (1 - timeFrac) + + kMoonlight[nextTimeIdx] * timeFrac; + float moonShadeLux = moonLux * (kDaylightShadeIllum / kDirectSunIllum); + + float moonXYZ[3] = { + moonLux / kMoonlightXY[1] * kMoonlightXY[0], + moonLux, + moonLux / kMoonlightXY[1] * + (1 - kMoonlightXY[0] - kMoonlightXY[1]) + }; + float moonShadeXYZ[3] = { + moonShadeLux / kMoonlightXY[1] * kMoonlightXY[0], + moonShadeLux, + moonShadeLux / kMoonlightXY[1] * + (1 - kMoonlightXY[0] - kMoonlightXY[1]) + }; + + // Determine starlight level + const float kClearNightXYZ[3] = { + kClearNightIllum / kMoonlightXY[1] * kMoonlightXY[0], + kClearNightIllum, + kClearNightIllum / kMoonlightXY[1] * + (1 - kMoonlightXY[0] - kMoonlightXY[1]) + }; + + // Calculate direct and shaded light + float directIllumXYZ[3] = { + sunXYZ[0] + moonXYZ[0] + kClearNightXYZ[0], + sunXYZ[1] + moonXYZ[1] + kClearNightXYZ[1], + sunXYZ[2] + moonXYZ[2] + kClearNightXYZ[2], + }; + + float shadeIllumXYZ[3] = { + kClearNightXYZ[0], + kClearNightXYZ[1], + kClearNightXYZ[2] + }; + + shadeIllumXYZ[0] += (mHour < kSunOverhead) ? sunXYZ[0] : sunShadeXYZ[0]; + shadeIllumXYZ[1] += (mHour < kSunOverhead) ? sunXYZ[1] : sunShadeXYZ[1]; + shadeIllumXYZ[2] += (mHour < kSunOverhead) ? sunXYZ[2] : sunShadeXYZ[2]; + + // Moon up period covers 23->0 transition, shift for simplicity + int adjHour = (mHour + 12) % 24; + int adjMoonOverhead = (kMoonOverhead + 12 ) % 24; + shadeIllumXYZ[0] += (adjHour < adjMoonOverhead) ? + moonXYZ[0] : moonShadeXYZ[0]; + shadeIllumXYZ[1] += (adjHour < adjMoonOverhead) ? + moonXYZ[1] : moonShadeXYZ[1]; + shadeIllumXYZ[2] += (adjHour < adjMoonOverhead) ? + moonXYZ[2] : moonShadeXYZ[2]; + + ALOGV("Direct XYZ: %f, %f, %f", + directIllumXYZ[0],directIllumXYZ[1],directIllumXYZ[2]); + ALOGV("Shade XYZ: %f, %f, %f", + shadeIllumXYZ[0], shadeIllumXYZ[1], shadeIllumXYZ[2]); + + for (int i = 0; i < NUM_MATERIALS; i++) { + // Converting for xyY to XYZ: + // X = Y / y * x + // Y = Y + // Z = Y / y * (1 - x - y); + float matXYZ[3] = { + kMaterials_xyY[i][2] / kMaterials_xyY[i][1] * + kMaterials_xyY[i][0], + kMaterials_xyY[i][2], + kMaterials_xyY[i][2] / kMaterials_xyY[i][1] * + (1 - kMaterials_xyY[i][0] - kMaterials_xyY[i][1]) + }; + + if (kMaterialsFlags[i] == 0 || kMaterialsFlags[i] & kSky) { + matXYZ[0] *= directIllumXYZ[0]; + matXYZ[1] *= directIllumXYZ[1]; + matXYZ[2] *= directIllumXYZ[2]; + } else if (kMaterialsFlags[i] & kShadowed) { + matXYZ[0] *= shadeIllumXYZ[0]; + matXYZ[1] *= shadeIllumXYZ[1]; + matXYZ[2] *= shadeIllumXYZ[2]; + } // else if (kMaterialsFlags[i] * kSelfLit), do nothing + + ALOGV("Mat %d XYZ: %f, %f, %f", i, matXYZ[0], matXYZ[1], matXYZ[2]); + float luxToElectrons = mSensorSensitivity * mExposureDuration / + (kAperture * kAperture); + mCurrentColors[i*NUM_CHANNELS + 0] = + (mFilterR[0] * matXYZ[0] + + mFilterR[1] * matXYZ[1] + + mFilterR[2] * matXYZ[2]) + * luxToElectrons; + mCurrentColors[i*NUM_CHANNELS + 1] = + (mFilterGr[0] * matXYZ[0] + + mFilterGr[1] * matXYZ[1] + + mFilterGr[2] * matXYZ[2]) + * luxToElectrons; + mCurrentColors[i*NUM_CHANNELS + 2] = + (mFilterGb[0] * matXYZ[0] + + mFilterGb[1] * matXYZ[1] + + mFilterGb[2] * matXYZ[2]) + * luxToElectrons; + mCurrentColors[i*NUM_CHANNELS + 3] = + (mFilterB[0] * matXYZ[0] + + mFilterB[1] * matXYZ[1] + + mFilterB[2] * matXYZ[2]) + * luxToElectrons; + + ALOGV("Color %d RGGB: %d, %d, %d, %d", i, + mCurrentColors[i*NUM_CHANNELS + 0], + mCurrentColors[i*NUM_CHANNELS + 1], + mCurrentColors[i*NUM_CHANNELS + 2], + mCurrentColors[i*NUM_CHANNELS + 3]); + } + // Shake viewpoint; horizontal and vertical sinusoids at roughly + // human handshake frequencies + mHandshakeX = + ( kFreq1Magnitude * std::sin(kHorizShakeFreq1 * timeSinceIdx) + + kFreq2Magnitude * std::sin(kHorizShakeFreq2 * timeSinceIdx) ) * + mMapDiv * kShakeFraction; + + mHandshakeY = + ( kFreq1Magnitude * std::sin(kVertShakeFreq1 * timeSinceIdx) + + kFreq2Magnitude * std::sin(kVertShakeFreq2 * timeSinceIdx) ) * + mMapDiv * kShakeFraction; + + // Set starting pixel + setReadoutPixel(0,0); +} + +void Scene::setReadoutPixel(int x, int y) { + mCurrentX = x; + mCurrentY = y; + mSubX = (x + mOffsetX + mHandshakeX) % mMapDiv; + mSubY = (y + mOffsetY + mHandshakeY) % mMapDiv; + mSceneX = (x + mOffsetX + mHandshakeX) / mMapDiv; + mSceneY = (y + mOffsetY + mHandshakeY) / mMapDiv; + mSceneIdx = mSceneY * kSceneWidth + mSceneX; + mCurrentSceneMaterial = &(mCurrentColors[kScene[mSceneIdx]]); +} + +const uint32_t* Scene::getPixelElectrons() { + const uint32_t *pixel = mCurrentSceneMaterial; + mCurrentX++; + mSubX++; + if (mCurrentX >= mSensorWidth) { + mCurrentX = 0; + mCurrentY++; + if (mCurrentY >= mSensorHeight) mCurrentY = 0; + setReadoutPixel(mCurrentX, mCurrentY); + } else if (mSubX > mMapDiv) { + mSceneIdx++; + mSceneX++; + mCurrentSceneMaterial = &(mCurrentColors[kScene[mSceneIdx]]); + mSubX = 0; + } + return pixel; +} + +// Handshake model constants. +// Frequencies measured in a nanosecond timebase +const float Scene::kHorizShakeFreq1 = 2 * M_PI * 2 / 1e9; // 2 Hz +const float Scene::kHorizShakeFreq2 = 2 * M_PI * 13 / 1e9; // 13 Hz +const float Scene::kVertShakeFreq1 = 2 * M_PI * 3 / 1e9; // 3 Hz +const float Scene::kVertShakeFreq2 = 2 * M_PI * 11 / 1e9; // 1 Hz +const float Scene::kFreq1Magnitude = 5; +const float Scene::kFreq2Magnitude = 1; +const float Scene::kShakeFraction = 0.03; // As a fraction of a scene tile + +// RGB->YUV, Jpeg standard +const float Scene::kRgb2Yuv[12] = { + 0.299f, 0.587f, 0.114f, 0.f, + -0.16874f, -0.33126f, 0.5f, -128.f, + 0.5f, -0.41869f, -0.08131f, -128.f, +}; + +// Aperture of imaging lens +const float Scene::kAperture = 2.8; + +// Sun illumination levels through the day +const float Scene::kSunlight[24/kTimeStep] = +{ + 0, // 00:00 + 0, + 0, + kTwilightIllum, // 06:00 + kDirectSunIllum, + kDirectSunIllum, + kDirectSunIllum, // 12:00 + kDirectSunIllum, + kDirectSunIllum, + kSunsetIllum, // 18:00 + kTwilightIllum, + 0 +}; + +// Moon illumination levels through the day +const float Scene::kMoonlight[24/kTimeStep] = +{ + kFullMoonIllum, // 00:00 + kFullMoonIllum, + 0, + 0, // 06:00 + 0, + 0, + 0, // 12:00 + 0, + 0, + 0, // 18:00 + 0, + kFullMoonIllum +}; + +const int Scene::kSunOverhead = 12; +const int Scene::kMoonOverhead = 0; + +// Used for sun illumination levels +const float Scene::kDirectSunIllum = 100000; +const float Scene::kSunsetIllum = 400; +const float Scene::kTwilightIllum = 4; +// Used for moon illumination levels +const float Scene::kFullMoonIllum = 1; +// Other illumination levels +const float Scene::kDaylightShadeIllum = 20000; +const float Scene::kClearNightIllum = 2e-3; +const float Scene::kStarIllum = 2e-6; +const float Scene::kLivingRoomIllum = 50; + +const float Scene::kIncandescentXY[2] = { 0.44757f, 0.40745f}; +const float Scene::kDirectSunlightXY[2] = { 0.34842f, 0.35161f}; +const float Scene::kDaylightXY[2] = { 0.31271f, 0.32902f}; +const float Scene::kNoonSkyXY[2] = { 0.346f, 0.359f}; +const float Scene::kMoonlightXY[2] = { 0.34842f, 0.35161f}; +const float Scene::kSunsetXY[2] = { 0.527f, 0.413f}; + +const uint8_t Scene::kSelfLit = 0x01; +const uint8_t Scene::kShadowed = 0x02; +const uint8_t Scene::kSky = 0x04; + +// For non-self-lit materials, the Y component is normalized with 1=full +// reflectance; for self-lit materials, it's the constant illuminance in lux. +const float Scene::kMaterials_xyY[Scene::NUM_MATERIALS][3] = { + { 0.3688f, 0.4501f, .1329f }, // GRASS + { 0.3688f, 0.4501f, .1329f }, // GRASS_SHADOW + { 0.3986f, 0.5002f, .4440f }, // HILL + { 0.3262f, 0.5040f, .2297f }, // WALL + { 0.4336f, 0.3787f, .1029f }, // ROOF + { 0.3316f, 0.2544f, .0639f }, // DOOR + { 0.3425f, 0.3577f, .0887f }, // CHIMNEY + { kIncandescentXY[0], kIncandescentXY[1], kLivingRoomIllum }, // WINDOW + { kDirectSunlightXY[0], kDirectSunlightXY[1], kDirectSunIllum }, // SUN + { kNoonSkyXY[0], kNoonSkyXY[1], kDaylightShadeIllum / kDirectSunIllum }, // SKY + { kMoonlightXY[0], kMoonlightXY[1], kFullMoonIllum } // MOON +}; + +const uint8_t Scene::kMaterialsFlags[Scene::NUM_MATERIALS] = { + 0, + kShadowed, + kShadowed, + kShadowed, + kShadowed, + kShadowed, + kShadowed, + kSelfLit, + kSelfLit, + kSky, + kSelfLit, +}; + +} // namespace android diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.h b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.h new file mode 100644 index 0000000..66d1a69 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Scene.h @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The Scene class implements a simple physical simulation of a scene, using the + * CIE 1931 colorspace to represent light in physical units (lux). + * + * It's fairly approximate, but does provide a scene with realistic widely + * variable illumination levels and colors over time. + * + */ + +#ifndef HW_EMULATOR_CAMERA2_SCENE_H +#define HW_EMULATOR_CAMERA2_SCENE_H + +#include "utils/Timers.h" + +namespace android { + +class Scene { + public: + Scene(int sensorWidthPx, + int sensorHeightPx, + float sensorSensitivity); + ~Scene(); + + // Set the filter coefficients for the red, green, and blue filters on the + // sensor. Used as an optimization to pre-calculate various illuminance + // values. Two different green filters can be provided, to account for + // possible cross-talk on a Bayer sensor. Must be called before + // calculateScene. + void setColorFilterXYZ( + float rX, float rY, float rZ, + float grX, float grY, float grZ, + float gbX, float gbY, float gbZ, + float bX, float bY, float bZ); + + // Set time of day (24-hour clock). This controls the general light levels + // in the scene. Must be called before calculateScene + void setHour(int hour); + // Get current hour + int getHour(); + + // Set the duration of exposure for determining luminous exposure. + // Must be called before calculateScene + void setExposureDuration(float seconds); + + // Calculate scene information for current hour and the time offset since + // the hour. Must be called at least once before calling getLuminousExposure. + // Resets pixel readout location to 0,0 + void calculateScene(nsecs_t time); + + // Set sensor pixel readout location. + void setReadoutPixel(int x, int y); + + // Get sensor response in physical units (electrons) for light hitting the + // current readout pixel, after passing through color filters. The readout + // pixel will be auto-incremented. The returned array can be indexed with + // ColorChannels. + const uint32_t* getPixelElectrons(); + + enum ColorChannels { + R = 0, + Gr, + Gb, + B, + Y, + Cb, + Cr, + NUM_CHANNELS + }; + + private: + // Sensor color filtering coefficients in XYZ + float mFilterR[3]; + float mFilterGr[3]; + float mFilterGb[3]; + float mFilterB[3]; + + int mOffsetX, mOffsetY; + int mMapDiv; + + int mHandshakeX, mHandshakeY; + + int mSensorWidth; + int mSensorHeight; + int mCurrentX; + int mCurrentY; + int mSubX; + int mSubY; + int mSceneX; + int mSceneY; + int mSceneIdx; + uint32_t *mCurrentSceneMaterial; + + int mHour; + float mExposureDuration; + float mSensorSensitivity; + + enum Materials { + GRASS = 0, + GRASS_SHADOW, + HILL, + WALL, + ROOF, + DOOR, + CHIMNEY, + WINDOW, + SUN, + SKY, + MOON, + NUM_MATERIALS + }; + + uint32_t mCurrentColors[NUM_MATERIALS*NUM_CHANNELS]; + + /** + * Constants for scene definition. These are various degrees of approximate. + */ + + // Fake handshake parameters. Two shake frequencies per axis, plus magnitude + // as a fraction of a scene tile, and relative magnitudes for the frequencies + static const float kHorizShakeFreq1; + static const float kHorizShakeFreq2; + static const float kVertShakeFreq1; + static const float kVertShakeFreq2; + static const float kFreq1Magnitude; + static const float kFreq2Magnitude; + + static const float kShakeFraction; + + // RGB->YUV conversion + static const float kRgb2Yuv[12]; + + // Aperture of imaging lens + static const float kAperture; + + // Sun, moon illuminance levels in 2-hour increments. These don't match any + // real day anywhere. + static const uint32_t kTimeStep = 2; + static const float kSunlight[]; + static const float kMoonlight[]; + static const int kSunOverhead; + static const int kMoonOverhead; + + // Illumination levels for various conditions, in lux + static const float kDirectSunIllum; + static const float kDaylightShadeIllum; + static const float kSunsetIllum; + static const float kTwilightIllum; + static const float kFullMoonIllum; + static const float kClearNightIllum; + static const float kStarIllum; + static const float kLivingRoomIllum; + + // Chromaticity of various illumination sources + static const float kIncandescentXY[2]; + static const float kDirectSunlightXY[2]; + static const float kDaylightXY[2]; + static const float kNoonSkyXY[2]; + static const float kMoonlightXY[2]; + static const float kSunsetXY[2]; + + static const uint8_t kSelfLit; + static const uint8_t kShadowed; + static const uint8_t kSky; + + static const float kMaterials_xyY[NUM_MATERIALS][3]; + static const uint8_t kMaterialsFlags[NUM_MATERIALS]; + + static const int kSceneWidth; + static const int kSceneHeight; + static const uint8_t kScene[]; +}; + +} + +#endif // HW_EMULATOR_CAMERA2_SCENE_H diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.cpp b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.cpp new file mode 100644 index 0000000..61c7f28 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.cpp @@ -0,0 +1,610 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//#define LOG_NDEBUG 0 +//#define LOG_NNDEBUG 0 +#define LOG_TAG "EmulatedCamera2_Sensor" + +#ifdef LOG_NNDEBUG +#define ALOGVV(...) ALOGV(__VA_ARGS__) +#else +#define ALOGVV(...) ((void)0) +#endif + +#include + +#include "../EmulatedFakeCamera2.h" +#include "Sensor.h" +#include +#include +#include "system/camera_metadata.h" + +namespace android { + +const unsigned int Sensor::kResolution[2] = {640, 480}; +const unsigned int Sensor::kActiveArray[4] = {0, 0, 640, 480}; + +//const nsecs_t Sensor::kExposureTimeRange[2] = +// {1000L, 30000000000L} ; // 1 us - 30 sec +//const nsecs_t Sensor::kFrameDurationRange[2] = +// {33331760L, 30000000000L}; // ~1/30 s - 30 sec +const nsecs_t Sensor::kExposureTimeRange[2] = + {1000L, 300000000L} ; // 1 us - 0.3 sec +const nsecs_t Sensor::kFrameDurationRange[2] = + {33331760L, 300000000L}; // ~1/30 s - 0.3 sec + +const nsecs_t Sensor::kMinVerticalBlank = 10000L; + +const uint8_t Sensor::kColorFilterArrangement = + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGGB; + +// Output image data characteristics +const uint32_t Sensor::kMaxRawValue = 4000; +const uint32_t Sensor::kBlackLevel = 1000; + +// Sensor sensitivity +const float Sensor::kSaturationVoltage = 0.520f; +const uint32_t Sensor::kSaturationElectrons = 2000; +const float Sensor::kVoltsPerLuxSecond = 0.100f; + +const float Sensor::kElectronsPerLuxSecond = + Sensor::kSaturationElectrons / Sensor::kSaturationVoltage + * Sensor::kVoltsPerLuxSecond; + +const float Sensor::kBaseGainFactor = (float)Sensor::kMaxRawValue / + Sensor::kSaturationElectrons; + +const float Sensor::kReadNoiseStddevBeforeGain = 1.177; // in electrons +const float Sensor::kReadNoiseStddevAfterGain = 2.100; // in digital counts +const float Sensor::kReadNoiseVarBeforeGain = + Sensor::kReadNoiseStddevBeforeGain * + Sensor::kReadNoiseStddevBeforeGain; +const float Sensor::kReadNoiseVarAfterGain = + Sensor::kReadNoiseStddevAfterGain * + Sensor::kReadNoiseStddevAfterGain; + +// While each row has to read out, reset, and then expose, the (reset + +// expose) sequence can be overlapped by other row readouts, so the final +// minimum frame duration is purely a function of row readout time, at least +// if there's a reasonable number of rows. +const nsecs_t Sensor::kRowReadoutTime = + Sensor::kFrameDurationRange[0] / Sensor::kResolution[1]; + +const int32_t Sensor::kSensitivityRange[2] = {100, 1600}; +const uint32_t Sensor::kDefaultSensitivity = 100; + +/** A few utility functions for math, normal distributions */ + +// Take advantage of IEEE floating-point format to calculate an approximate +// square root. Accurate to within +-3.6% +float sqrtf_approx(float r) { + // Modifier is based on IEEE floating-point representation; the + // manipulations boil down to finding approximate log2, dividing by two, and + // then inverting the log2. A bias is added to make the relative error + // symmetric about the real answer. + const int32_t modifier = 0x1FBB4000; + + int32_t r_i = *(int32_t*)(&r); + r_i = (r_i >> 1) + modifier; + + return *(float*)(&r_i); +} + + + +Sensor::Sensor(): + Thread(false), + mGotVSync(false), + mExposureTime(kFrameDurationRange[0]-kMinVerticalBlank), + mFrameDuration(kFrameDurationRange[0]), + mGainFactor(kDefaultSensitivity), + mNextBuffers(NULL), + mFrameNumber(0), + mCapturedBuffers(NULL), + mListener(NULL), + mScene(kResolution[0], kResolution[1], kElectronsPerLuxSecond) +{ + +} + +Sensor::~Sensor() { + shutDown(); +} + +status_t Sensor::startUp() { + ALOGV("%s: E", __FUNCTION__); + + int res; + mCapturedBuffers = NULL; + res = run("EmulatedFakeCamera2::Sensor", + ANDROID_PRIORITY_URGENT_DISPLAY); + + if (res != OK) { + ALOGE("Unable to start up sensor capture thread: %d", res); + } + return res; +} + +status_t Sensor::shutDown() { + ALOGV("%s: E", __FUNCTION__); + + int res; + res = requestExitAndWait(); + if (res != OK) { + ALOGE("Unable to shut down sensor capture thread: %d", res); + } + return res; +} + +Scene &Sensor::getScene() { + return mScene; +} + +void Sensor::setExposureTime(uint64_t ns) { + Mutex::Autolock lock(mControlMutex); + ALOGVV("Exposure set to %f", ns/1000000.f); + mExposureTime = ns; +} + +void Sensor::setFrameDuration(uint64_t ns) { + Mutex::Autolock lock(mControlMutex); + ALOGVV("Frame duration set to %f", ns/1000000.f); + mFrameDuration = ns; +} + +void Sensor::setSensitivity(uint32_t gain) { + Mutex::Autolock lock(mControlMutex); + ALOGVV("Gain set to %d", gain); + mGainFactor = gain; +} + +void Sensor::setDestinationBuffers(Buffers *buffers) { + Mutex::Autolock lock(mControlMutex); + mNextBuffers = buffers; +} + +void Sensor::setFrameNumber(uint32_t frameNumber) { + Mutex::Autolock lock(mControlMutex); + mFrameNumber = frameNumber; +} + +bool Sensor::waitForVSync(nsecs_t reltime) { + int res; + Mutex::Autolock lock(mControlMutex); + + mGotVSync = false; + res = mVSync.waitRelative(mControlMutex, reltime); + if (res != OK && res != TIMED_OUT) { + ALOGE("%s: Error waiting for VSync signal: %d", __FUNCTION__, res); + return false; + } + return mGotVSync; +} + +bool Sensor::waitForNewFrame(nsecs_t reltime, + nsecs_t *captureTime) { + Mutex::Autolock lock(mReadoutMutex); + uint8_t *ret; + if (mCapturedBuffers == NULL) { + int res; + res = mReadoutAvailable.waitRelative(mReadoutMutex, reltime); + if (res == TIMED_OUT) { + return false; + } else if (res != OK || mCapturedBuffers == NULL) { + ALOGE("Error waiting for sensor readout signal: %d", res); + return false; + } + } else { + mReadoutComplete.signal(); + } + + *captureTime = mCaptureTime; + mCapturedBuffers = NULL; + return true; +} + +Sensor::SensorListener::~SensorListener() { +} + +void Sensor::setSensorListener(SensorListener *listener) { + Mutex::Autolock lock(mControlMutex); + mListener = listener; +} + +status_t Sensor::readyToRun() { + ALOGV("Starting up sensor thread"); + mStartupTime = systemTime(); + mNextCaptureTime = 0; + mNextCapturedBuffers = NULL; + return OK; +} + +bool Sensor::threadLoop() { + /** + * Sensor capture operation main loop. + * + * Stages are out-of-order relative to a single frame's processing, but + * in-order in time. + */ + + /** + * Stage 1: Read in latest control parameters + */ + uint64_t exposureDuration; + uint64_t frameDuration; + uint32_t gain; + Buffers *nextBuffers; + uint32_t frameNumber; + SensorListener *listener = NULL; + { + Mutex::Autolock lock(mControlMutex); + exposureDuration = mExposureTime; + frameDuration = mFrameDuration; + gain = mGainFactor; + nextBuffers = mNextBuffers; + frameNumber = mFrameNumber; + listener = mListener; + // Don't reuse a buffer set + mNextBuffers = NULL; + + // Signal VSync for start of readout + ALOGVV("Sensor VSync"); + mGotVSync = true; + mVSync.signal(); + } + + /** + * Stage 3: Read out latest captured image + */ + + Buffers *capturedBuffers = NULL; + nsecs_t captureTime = 0; + + nsecs_t startRealTime = systemTime(); + // Stagefright cares about system time for timestamps, so base simulated + // time on that. + nsecs_t simulatedTime = startRealTime; + nsecs_t frameEndRealTime = startRealTime + frameDuration; + nsecs_t frameReadoutEndRealTime = startRealTime + + kRowReadoutTime * kResolution[1]; + + if (mNextCapturedBuffers != NULL) { + ALOGVV("Sensor starting readout"); + // Pretend we're doing readout now; will signal once enough time has elapsed + capturedBuffers = mNextCapturedBuffers; + captureTime = mNextCaptureTime; + } + simulatedTime += kRowReadoutTime + kMinVerticalBlank; + + // TODO: Move this signal to another thread to simulate readout + // time properly + if (capturedBuffers != NULL) { + ALOGVV("Sensor readout complete"); + Mutex::Autolock lock(mReadoutMutex); + if (mCapturedBuffers != NULL) { + ALOGV("Waiting for readout thread to catch up!"); + mReadoutComplete.wait(mReadoutMutex); + } + + mCapturedBuffers = capturedBuffers; + mCaptureTime = captureTime; + mReadoutAvailable.signal(); + capturedBuffers = NULL; + } + + /** + * Stage 2: Capture new image + */ + mNextCaptureTime = simulatedTime; + mNextCapturedBuffers = nextBuffers; + + if (mNextCapturedBuffers != NULL) { + if (listener != NULL) { + listener->onSensorEvent(frameNumber, SensorListener::EXPOSURE_START, + mNextCaptureTime); + } + ALOGVV("Starting next capture: Exposure: %f ms, gain: %d", + (float)exposureDuration/1e6, gain); + mScene.setExposureDuration((float)exposureDuration/1e9); + mScene.calculateScene(mNextCaptureTime); + + // Might be adding more buffers, so size isn't constant + for (size_t i = 0; i < mNextCapturedBuffers->size(); i++) { + const StreamBuffer &b = (*mNextCapturedBuffers)[i]; + ALOGVV("Sensor capturing buffer %d: stream %d," + " %d x %d, format %x, stride %d, buf %p, img %p", + i, b.streamId, b.width, b.height, b.format, b.stride, + b.buffer, b.img); + switch(b.format) { + case HAL_PIXEL_FORMAT_RAW16: + captureRaw(b.img, gain, b.stride); + break; + case HAL_PIXEL_FORMAT_RGB_888: + captureRGB(b.img, gain, b.stride); + break; + case HAL_PIXEL_FORMAT_RGBA_8888: + captureRGBA(b.img, gain, b.stride); + break; + case HAL_PIXEL_FORMAT_BLOB: + if (b.dataSpace != HAL_DATASPACE_DEPTH) { + // Add auxillary buffer of the right size + // Assumes only one BLOB (JPEG) buffer in + // mNextCapturedBuffers + StreamBuffer bAux; + bAux.streamId = 0; + bAux.width = b.width; + bAux.height = b.height; + bAux.format = HAL_PIXEL_FORMAT_RGB_888; + bAux.stride = b.width; + bAux.buffer = NULL; + // TODO: Reuse these + bAux.img = new uint8_t[b.width * b.height * 3]; + mNextCapturedBuffers->push_back(bAux); + } else { + captureDepthCloud(b.img); + } + break; + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + captureNV21(b.img, gain, b.stride); + break; + case HAL_PIXEL_FORMAT_YV12: + // TODO: + ALOGE("%s: Format %x is TODO", __FUNCTION__, b.format); + break; + case HAL_PIXEL_FORMAT_Y16: + captureDepth(b.img, gain, b.stride); + break; + default: + ALOGE("%s: Unknown format %x, no output", __FUNCTION__, + b.format); + break; + } + } + } + + ALOGVV("Sensor vertical blanking interval"); + nsecs_t workDoneRealTime = systemTime(); + const nsecs_t timeAccuracy = 2e6; // 2 ms of imprecision is ok + if (workDoneRealTime < frameEndRealTime - timeAccuracy) { + timespec t; + t.tv_sec = (frameEndRealTime - workDoneRealTime) / 1000000000L; + t.tv_nsec = (frameEndRealTime - workDoneRealTime) % 1000000000L; + + int ret; + do { + ret = nanosleep(&t, &t); + } while (ret != 0); + } + nsecs_t endRealTime = systemTime(); + ALOGVV("Frame cycle took %d ms, target %d ms", + (int)((endRealTime - startRealTime)/1000000), + (int)(frameDuration / 1000000)); + return true; +}; + +void Sensor::captureRaw(uint8_t *img, uint32_t gain, uint32_t stride) { + float totalGain = gain/100.0 * kBaseGainFactor; + float noiseVarGain = totalGain * totalGain; + float readNoiseVar = kReadNoiseVarBeforeGain * noiseVarGain + + kReadNoiseVarAfterGain; + + int bayerSelect[4] = {Scene::R, Scene::Gr, Scene::Gb, Scene::B}; // RGGB + mScene.setReadoutPixel(0,0); + for (unsigned int y = 0; y < kResolution[1]; y++ ) { + int *bayerRow = bayerSelect + (y & 0x1) * 2; + uint16_t *px = (uint16_t*)img + y * stride; + for (unsigned int x = 0; x < kResolution[0]; x++) { + uint32_t electronCount; + electronCount = mScene.getPixelElectrons()[bayerRow[x & 0x1]]; + + // TODO: Better pixel saturation curve? + electronCount = (electronCount < kSaturationElectrons) ? + electronCount : kSaturationElectrons; + + // TODO: Better A/D saturation curve? + uint16_t rawCount = electronCount * totalGain; + rawCount = (rawCount < kMaxRawValue) ? rawCount : kMaxRawValue; + + // Calculate noise value + // TODO: Use more-correct Gaussian instead of uniform noise + float photonNoiseVar = electronCount * noiseVarGain; + float noiseStddev = sqrtf_approx(readNoiseVar + photonNoiseVar); + // Scaled to roughly match gaussian/uniform noise stddev + float noiseSample = std::rand() * (2.5 / (1.0 + RAND_MAX)) - 1.25; + + rawCount += kBlackLevel; + rawCount += noiseStddev * noiseSample; + + *px++ = rawCount; + } + // TODO: Handle this better + //simulatedTime += kRowReadoutTime; + } + ALOGVV("Raw sensor image captured"); +} + +void Sensor::captureRGBA(uint8_t *img, uint32_t gain, uint32_t stride) { + float totalGain = gain/100.0 * kBaseGainFactor; + // In fixed-point math, calculate total scaling from electrons to 8bpp + int scale64x = 64 * totalGain * 255 / kMaxRawValue; + uint32_t inc = kResolution[0] / stride; + + for (unsigned int y = 0, outY = 0; y < kResolution[1]; y+=inc, outY++ ) { + uint8_t *px = img + outY * stride * 4; + mScene.setReadoutPixel(0, y); + for (unsigned int x = 0; x < kResolution[0]; x+=inc) { + uint32_t rCount, gCount, bCount; + // TODO: Perfect demosaicing is a cheat + const uint32_t *pixel = mScene.getPixelElectrons(); + rCount = pixel[Scene::R] * scale64x; + gCount = pixel[Scene::Gr] * scale64x; + bCount = pixel[Scene::B] * scale64x; + + *px++ = rCount < 255*64 ? rCount / 64 : 255; + *px++ = gCount < 255*64 ? gCount / 64 : 255; + *px++ = bCount < 255*64 ? bCount / 64 : 255; + *px++ = 255; + for (unsigned int j = 1; j < inc; j++) + mScene.getPixelElectrons(); + } + // TODO: Handle this better + //simulatedTime += kRowReadoutTime; + } + ALOGVV("RGBA sensor image captured"); +} + +void Sensor::captureRGB(uint8_t *img, uint32_t gain, uint32_t stride) { + float totalGain = gain/100.0 * kBaseGainFactor; + // In fixed-point math, calculate total scaling from electrons to 8bpp + int scale64x = 64 * totalGain * 255 / kMaxRawValue; + uint32_t inc = kResolution[0] / stride; + + for (unsigned int y = 0, outY = 0; y < kResolution[1]; y += inc, outY++ ) { + mScene.setReadoutPixel(0, y); + uint8_t *px = img + outY * stride * 3; + for (unsigned int x = 0; x < kResolution[0]; x += inc) { + uint32_t rCount, gCount, bCount; + // TODO: Perfect demosaicing is a cheat + const uint32_t *pixel = mScene.getPixelElectrons(); + rCount = pixel[Scene::R] * scale64x; + gCount = pixel[Scene::Gr] * scale64x; + bCount = pixel[Scene::B] * scale64x; + + *px++ = rCount < 255*64 ? rCount / 64 : 255; + *px++ = gCount < 255*64 ? gCount / 64 : 255; + *px++ = bCount < 255*64 ? bCount / 64 : 255; + for (unsigned int j = 1; j < inc; j++) + mScene.getPixelElectrons(); + } + // TODO: Handle this better + //simulatedTime += kRowReadoutTime; + } + ALOGVV("RGB sensor image captured"); +} + +void Sensor::captureNV21(uint8_t *img, uint32_t gain, uint32_t stride) { + float totalGain = gain/100.0 * kBaseGainFactor; + // Using fixed-point math with 6 bits of fractional precision. + // In fixed-point math, calculate total scaling from electrons to 8bpp + const int scale64x = 64 * totalGain * 255 / kMaxRawValue; + // In fixed-point math, saturation point of sensor after gain + const int saturationPoint = 64 * 255; + // Fixed-point coefficients for RGB-YUV transform + // Based on JFIF RGB->YUV transform. + // Cb/Cr offset scaled by 64x twice since they're applied post-multiply + const int rgbToY[] = {19, 37, 7}; + const int rgbToCb[] = {-10,-21, 32, 524288}; + const int rgbToCr[] = {32,-26, -5, 524288}; + // Scale back to 8bpp non-fixed-point + const int scaleOut = 64; + const int scaleOutSq = scaleOut * scaleOut; // after multiplies + + uint32_t inc = kResolution[0] / stride; + uint32_t outH = kResolution[1] / inc; + for (unsigned int y = 0, outY = 0; + y < kResolution[1]; y+=inc, outY++) { + uint8_t *pxY = img + outY * stride; + uint8_t *pxVU = img + (outH + outY / 2) * stride; + mScene.setReadoutPixel(0,y); + for (unsigned int outX = 0; outX < stride; outX++) { + int32_t rCount, gCount, bCount; + // TODO: Perfect demosaicing is a cheat + const uint32_t *pixel = mScene.getPixelElectrons(); + rCount = pixel[Scene::R] * scale64x; + rCount = rCount < saturationPoint ? rCount : saturationPoint; + gCount = pixel[Scene::Gr] * scale64x; + gCount = gCount < saturationPoint ? gCount : saturationPoint; + bCount = pixel[Scene::B] * scale64x; + bCount = bCount < saturationPoint ? bCount : saturationPoint; + + *pxY++ = (rgbToY[0] * rCount + + rgbToY[1] * gCount + + rgbToY[2] * bCount) / scaleOutSq; + if (outY % 2 == 0 && outX % 2 == 0) { + *pxVU++ = (rgbToCr[0] * rCount + + rgbToCr[1] * gCount + + rgbToCr[2] * bCount + + rgbToCr[3]) / scaleOutSq; + *pxVU++ = (rgbToCb[0] * rCount + + rgbToCb[1] * gCount + + rgbToCb[2] * bCount + + rgbToCb[3]) / scaleOutSq; + } + for (unsigned int j = 1; j < inc; j++) + mScene.getPixelElectrons(); + } + } + ALOGVV("NV21 sensor image captured"); +} + +void Sensor::captureDepth(uint8_t *img, uint32_t gain, uint32_t stride) { + float totalGain = gain/100.0 * kBaseGainFactor; + // In fixed-point math, calculate scaling factor to 13bpp millimeters + int scale64x = 64 * totalGain * 8191 / kMaxRawValue; + uint32_t inc = kResolution[0] / stride; + + for (unsigned int y = 0, outY = 0; y < kResolution[1]; y += inc, outY++ ) { + mScene.setReadoutPixel(0, y); + uint16_t *px = ((uint16_t*)img) + outY * stride; + for (unsigned int x = 0; x < kResolution[0]; x += inc) { + uint32_t depthCount; + // TODO: Make up real depth scene instead of using green channel + // as depth + const uint32_t *pixel = mScene.getPixelElectrons(); + depthCount = pixel[Scene::Gr] * scale64x; + + *px++ = depthCount < 8191*64 ? depthCount / 64 : 0; + for (unsigned int j = 1; j < inc; j++) + mScene.getPixelElectrons(); + } + // TODO: Handle this better + //simulatedTime += kRowReadoutTime; + } + ALOGVV("Depth sensor image captured"); +} + +void Sensor::captureDepthCloud(uint8_t *img) { + + android_depth_points *cloud = reinterpret_cast(img); + + cloud->num_points = 16; + + // TODO: Create point cloud values that match RGB scene + const int FLOATS_PER_POINT = 4; + const float JITTER_STDDEV = 0.1f; + for (size_t y = 0, i = 0; y < 4; y++) { + for (size_t x = 0; x < 4; x++, i++) { + float randSampleX = std::rand() * (2.5f / (1.0f + RAND_MAX)) - 1.25f; + randSampleX *= JITTER_STDDEV; + + float randSampleY = std::rand() * (2.5f / (1.0f + RAND_MAX)) - 1.25f; + randSampleY *= JITTER_STDDEV; + + float randSampleZ = std::rand() * (2.5f / (1.0f + RAND_MAX)) - 1.25f; + randSampleZ *= JITTER_STDDEV; + + cloud->xyzc_points[i * FLOATS_PER_POINT + 0] = x - 1.5f + randSampleX; + cloud->xyzc_points[i * FLOATS_PER_POINT + 1] = y - 1.5f + randSampleY; + cloud->xyzc_points[i * FLOATS_PER_POINT + 2] = 3.f + randSampleZ; + cloud->xyzc_points[i * FLOATS_PER_POINT + 3] = 0.8f; + } + } + + ALOGVV("Depth point cloud captured"); + +} + +} // namespace android diff --git a/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.h b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.h new file mode 100644 index 0000000..720fbc2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/camera/fake-pipeline2/Sensor.h @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This class is a simple simulation of a typical CMOS cellphone imager chip, + * which outputs 12-bit Bayer-mosaic raw images. + * + * Unlike most real image sensors, this one's native color space is linear sRGB. + * + * The sensor is abstracted as operating as a pipeline 3 stages deep; + * conceptually, each frame to be captured goes through these three stages. The + * processing step for the sensor is marked off by vertical sync signals, which + * indicate the start of readout of the oldest frame. The interval between + * processing steps depends on the frame duration of the frame currently being + * captured. The stages are 1) configure, 2) capture, and 3) readout. During + * configuration, the sensor's registers for settings such as exposure time, + * frame duration, and gain are set for the next frame to be captured. In stage + * 2, the image data for the frame is actually captured by the sensor. Finally, + * in stage 3, the just-captured data is read out and sent to the rest of the + * system. + * + * The sensor is assumed to be rolling-shutter, so low-numbered rows of the + * sensor are exposed earlier in time than larger-numbered rows, with the time + * offset between each row being equal to the row readout time. + * + * The characteristics of this sensor don't correspond to any actual sensor, + * but are not far off typical sensors. + * + * Example timing diagram, with three frames: + * Frame 0-1: Frame duration 50 ms, exposure time 20 ms. + * Frame 2: Frame duration 75 ms, exposure time 65 ms. + * Legend: + * C = update sensor registers for frame + * v = row in reset (vertical blanking interval) + * E = row capturing image data + * R = row being read out + * | = vertical sync signal + *time(ms)| 0 55 105 155 230 270 + * Frame 0| :configure : capture : readout : : : + * Row # | ..|CCCC______|_________|_________| : : + * 0 | :\ \vvvvvEEEER \ : : + * 500 | : \ \vvvvvEEEER \ : : + * 1000 | : \ \vvvvvEEEER \ : : + * 1500 | : \ \vvvvvEEEER \ : : + * 2000 | : \__________\vvvvvEEEER_________\ : : + * Frame 1| : configure capture readout : : + * Row # | : |CCCC_____|_________|______________| : + * 0 | : :\ \vvvvvEEEER \ : + * 500 | : : \ \vvvvvEEEER \ : + * 1000 | : : \ \vvvvvEEEER \ : + * 1500 | : : \ \vvvvvEEEER \ : + * 2000 | : : \_________\vvvvvEEEER______________\ : + * Frame 2| : : configure capture readout: + * Row # | : : |CCCC_____|______________|_______|... + * 0 | : : :\ \vEEEEEEEEEEEEER \ + * 500 | : : : \ \vEEEEEEEEEEEEER \ + * 1000 | : : : \ \vEEEEEEEEEEEEER \ + * 1500 | : : : \ \vEEEEEEEEEEEEER \ + * 2000 | : : : \_________\vEEEEEEEEEEEEER_______\ + */ + +#ifndef HW_EMULATOR_CAMERA2_SENSOR_H +#define HW_EMULATOR_CAMERA2_SENSOR_H + +#include "utils/Thread.h" +#include "utils/Mutex.h" +#include "utils/Timers.h" + +#include "Scene.h" +#include "Base.h" + +namespace android { + +class EmulatedFakeCamera2; + +class Sensor: private Thread, public virtual RefBase { + public: + + Sensor(); + ~Sensor(); + + /* + * Power control + */ + + status_t startUp(); + status_t shutDown(); + + /* + * Access to scene + */ + Scene &getScene(); + + /* + * Controls that can be updated every frame + */ + + void setExposureTime(uint64_t ns); + void setFrameDuration(uint64_t ns); + void setSensitivity(uint32_t gain); + // Buffer must be at least stride*height*2 bytes in size + void setDestinationBuffers(Buffers *buffers); + // To simplify tracking sensor's current frame + void setFrameNumber(uint32_t frameNumber); + + /* + * Controls that cause reconfiguration delay + */ + + void setBinning(int horizontalFactor, int verticalFactor); + + /* + * Synchronizing with sensor operation (vertical sync) + */ + + // Wait until the sensor outputs its next vertical sync signal, meaning it + // is starting readout of its latest frame of data. Returns true if vertical + // sync is signaled, false if the wait timed out. + bool waitForVSync(nsecs_t reltime); + + // Wait until a new frame has been read out, and then return the time + // capture started. May return immediately if a new frame has been pushed + // since the last wait for a new frame. Returns true if new frame is + // returned, false if timed out. + bool waitForNewFrame(nsecs_t reltime, + nsecs_t *captureTime); + + /* + * Interrupt event servicing from the sensor. Only triggers for sensor + * cycles that have valid buffers to write to. + */ + struct SensorListener { + enum Event { + EXPOSURE_START, // Start of exposure + }; + + virtual void onSensorEvent(uint32_t frameNumber, Event e, + nsecs_t timestamp) = 0; + virtual ~SensorListener(); + }; + + void setSensorListener(SensorListener *listener); + + /** + * Static sensor characteristics + */ + static const unsigned int kResolution[2]; + static const unsigned int kActiveArray[4]; + + static const nsecs_t kExposureTimeRange[2]; + static const nsecs_t kFrameDurationRange[2]; + static const nsecs_t kMinVerticalBlank; + + static const uint8_t kColorFilterArrangement; + + // Output image data characteristics + static const uint32_t kMaxRawValue; + static const uint32_t kBlackLevel; + // Sensor sensitivity, approximate + + static const float kSaturationVoltage; + static const uint32_t kSaturationElectrons; + static const float kVoltsPerLuxSecond; + static const float kElectronsPerLuxSecond; + + static const float kBaseGainFactor; + + static const float kReadNoiseStddevBeforeGain; // In electrons + static const float kReadNoiseStddevAfterGain; // In raw digital units + static const float kReadNoiseVarBeforeGain; + static const float kReadNoiseVarAfterGain; + + // While each row has to read out, reset, and then expose, the (reset + + // expose) sequence can be overlapped by other row readouts, so the final + // minimum frame duration is purely a function of row readout time, at least + // if there's a reasonable number of rows. + static const nsecs_t kRowReadoutTime; + + static const int32_t kSensitivityRange[2]; + static const uint32_t kDefaultSensitivity; + + private: + Mutex mControlMutex; // Lock before accessing control parameters + // Start of control parameters + Condition mVSync; + bool mGotVSync; + uint64_t mExposureTime; + uint64_t mFrameDuration; + uint32_t mGainFactor; + Buffers *mNextBuffers; + uint32_t mFrameNumber; + + // End of control parameters + + Mutex mReadoutMutex; // Lock before accessing readout variables + // Start of readout variables + Condition mReadoutAvailable; + Condition mReadoutComplete; + Buffers *mCapturedBuffers; + nsecs_t mCaptureTime; + SensorListener *mListener; + // End of readout variables + + // Time of sensor startup, used for simulation zero-time point + nsecs_t mStartupTime; + + /** + * Inherited Thread virtual overrides, and members only used by the + * processing thread + */ + private: + virtual status_t readyToRun(); + + virtual bool threadLoop(); + + nsecs_t mNextCaptureTime; + Buffers *mNextCapturedBuffers; + + Scene mScene; + + void captureRaw(uint8_t *img, uint32_t gain, uint32_t stride); + void captureRGBA(uint8_t *img, uint32_t gain, uint32_t stride); + void captureRGB(uint8_t *img, uint32_t gain, uint32_t stride); + void captureNV21(uint8_t *img, uint32_t gain, uint32_t stride); + void captureDepth(uint8_t *img, uint32_t gain, uint32_t stride); + void captureDepthCloud(uint8_t *img); + +}; + +} + +#endif // HW_EMULATOR_CAMERA2_SENSOR_H diff --git a/src/type3_AndroidCloud/anbox-master/android/data/etc/apns-conf.xml b/src/type3_AndroidCloud/anbox-master/android/data/etc/apns-conf.xml new file mode 100644 index 0000000..4d85cfc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/data/etc/apns-conf.xml @@ -0,0 +1,265 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/fingerprint/Android.mk b/src/type3_AndroidCloud/anbox-master/android/fingerprint/Android.mk new file mode 100644 index 0000000..f4b76c9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/fingerprint/Android.mk @@ -0,0 +1,33 @@ +# Copyright (C) 2013 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := fingerprint.goldfish +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := fingerprint.c +LOCAL_SHARED_LIBRARIES := liblog + +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_MODULE := fingerprint.ranchu +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := fingerprint.c +LOCAL_SHARED_LIBRARIES := liblog + +include $(BUILD_SHARED_LIBRARY) diff --git a/src/type3_AndroidCloud/anbox-master/android/fingerprint/fingerprint.c b/src/type3_AndroidCloud/anbox-master/android/fingerprint/fingerprint.c new file mode 100644 index 0000000..6405e26 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/fingerprint/fingerprint.c @@ -0,0 +1,857 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is a very basic implementation of fingerprint to allow testing on the emulator. It + * is *not* meant to be the final implementation on real devices. For example, it does *not* + * implement all of the required features, such as secure template storage and recognition + * inside a Trusted Execution Environment (TEE). However, this file is a reasonable starting + * point as developers add fingerprint support to their platform. See inline comments and + * recommendations for details. + * + * Please see the Android Compatibility Definition Document (CDD) for a full list of requirements + * and suggestions. + */ +#define LOG_TAG "FingerprintHal" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define FINGERPRINT_LISTEN_SERVICE_NAME "fingerprintlisten" +#define FINGERPRINT_FILENAME "emufp.bin" +#define AUTHENTICATOR_ID_FILENAME "emuauthid.bin" +#define MAX_COMM_CHARS 128 +#define MAX_COMM_ERRORS 8 +// Typical devices will allow up to 5 fingerprints per user to maintain performance of +// t < 500ms for recognition. This is the total number of fingerprints we'll store. +#define MAX_NUM_FINGERS 20 +#define MAX_FID_VALUE 0x7FFFFFFF // Arbitrary limit + +/** + * Most devices will have an internal state machine resembling this. There are 3 basic states, as + * shown below. When device is not authenticating or enrolling, it is expected to be in + * the idle state. + * + * Note that this is completely independent of device wake state. If the hardware device was in + * the "scan" state when the device drops into power collapse, it should resume scanning when power + * is restored. This is to facilitate rapid touch-to-unlock from keyguard. + */ +typedef enum worker_state_t { + STATE_IDLE = 0, + STATE_ENROLL, + STATE_SCAN, + STATE_EXIT +} worker_state_t; + +typedef struct worker_thread_t { + pthread_t thread; + worker_state_t state; + uint64_t secureid[MAX_NUM_FINGERS]; + uint64_t fingerid[MAX_NUM_FINGERS]; + char fp_filename[PATH_MAX]; + char authid_filename[PATH_MAX]; +} worker_thread_t; + +typedef struct qemu_fingerprint_device_t { + fingerprint_device_t device; // "inheritance" + worker_thread_t listener; + uint64_t op_id; + uint64_t challenge; + uint64_t user_id; + uint64_t group_id; + uint64_t secure_user_id; + uint64_t authenticator_id; + int qchanfd; + pthread_mutex_t lock; +} qemu_fingerprint_device_t; + +/******************************************************************************/ + +static FILE* openForWrite(const char* filename); + +static void saveFingerprint(worker_thread_t* listener, int idx) { + ALOGD("----------------> %s -----------------> idx %d", __FUNCTION__, idx); + + // Save fingerprints to file + FILE* fp = openForWrite(listener->fp_filename); + if (fp == NULL) { + ALOGE("Could not open fingerprints storage at %s; " + "fingerprints won't be saved", + listener->fp_filename); + perror("Failed to open file"); + return; + } + + ALOGD("Write fingerprint[%d] (0x%" PRIx64 ",0x%" PRIx64 ")", idx, + listener->secureid[idx], listener->fingerid[idx]); + + if (fseek(fp, (idx) * sizeof(uint64_t), SEEK_SET) < 0) { + ALOGE("Failed while seeking for fingerprint[%d] in emulator storage", + idx); + fclose(fp); + return; + } + int ns = fwrite(&listener->secureid[idx], sizeof(uint64_t), 1, fp); + + if (fseek(fp, (MAX_NUM_FINGERS + idx) * sizeof(uint64_t), SEEK_SET) < 0) { + ALOGE("Failed while seeking for fingerprint[%d] in emulator storage", + idx); + fclose(fp); + return; + } + int nf = fwrite(&listener->fingerid[idx], sizeof(uint64_t), 1, fp); + if (ns != 1 || ns !=1) + ALOGW("Corrupt emulator fingerprints storage; could not save " + "fingerprints"); + + fclose(fp); + + return; +} + +static FILE* openForWrite(const char* filename) { + + if (!filename) return NULL; + + FILE* fp = fopen(filename, "r+"); // write but don't truncate + if (fp == NULL) { + fp = fopen(filename, "w"); + if (fp) { + uint64_t zero = 0; + int i = 0; + for (i = 0; i < 2*MAX_NUM_FINGERS; ++i) { + fwrite(&zero, sizeof(uint64_t), 1, fp); + } + + //the last one is for authenticator id + fwrite(&zero, sizeof(uint64_t), 1, fp); + } + } + return fp; +} + +static void saveAuthenticatorId(const char* filename, uint64_t authenid) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + FILE* fp = openForWrite(filename); + if (!fp) { + ALOGE("Failed to open emulator storage file to save authenticator id"); + return; + } + + rewind(fp); + + int na = fwrite(&authenid, sizeof(authenid), 1, fp); + if (na != 1) { + ALOGE("Failed while writing authenticator id in emulator storage"); + } + + ALOGD("Save authenticator id (0x%" PRIx64 ")", authenid); + + fclose(fp); +} + +static void loadAuthenticatorId(const char* authid_filename, uint64_t* pauthenid) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + FILE* fp = fopen(authid_filename, "r"); + if (fp == NULL) { + ALOGE("Could not load authenticator id from storage at %s; " + "it has not yet been created.", + authid_filename); + perror("Failed to open/create file"); + return; + } + + rewind(fp); + + int na = fread(pauthenid, sizeof(*pauthenid), 1, fp); + if (na != 1) + ALOGW("Corrupt emulator authenticator id storage (read %d)", na); + + ALOGD("Read authenticator id (0x%" PRIx64 ")", *pauthenid); + + fclose(fp); + + return; +} + +static void loadFingerprints(worker_thread_t* listener) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + FILE* fp = fopen(listener->fp_filename, "r"); + if (fp == NULL) { + ALOGE("Could not load fingerprints from storage at %s; " + "it has not yet been created.", + listener->fp_filename); + perror("Failed to open/create file"); + return; + } + + int ns = fread(listener->secureid, MAX_NUM_FINGERS * sizeof(uint64_t), 1, + fp); + int nf = fread(listener->fingerid, MAX_NUM_FINGERS * sizeof(uint64_t), 1, + fp); + if (ns != 1 || nf != 1) + ALOGW("Corrupt emulator fingerprints storage (read %d+%db)", ns, nf); + + int i = 0; + for (i = 0; i < MAX_NUM_FINGERS; i++) + ALOGD("Read fingerprint %d (0x%" PRIx64 ",0x%" PRIx64 ")", i, + listener->secureid[i], listener->fingerid[i]); + + fclose(fp); + + return; +} + +/******************************************************************************/ + +static uint64_t get_64bit_rand() { + // This should use a cryptographically-secure random number generator like arc4random(). + // It should be generated inside of the TEE where possible. Here we just use something + // very simple. + ALOGD("----------------> %s ----------------->", __FUNCTION__); + uint64_t r = (((uint64_t)rand()) << 32) | ((uint64_t)rand()); + return r != 0 ? r : 1; +} + +static uint64_t fingerprint_get_auth_id(struct fingerprint_device* device) { + // This should return the authentication_id generated when the fingerprint template database + // was created. Though this isn't expected to be secret, it is reasonable to expect it to be + // cryptographically generated to avoid replay attacks. + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + ALOGD("----------------> %s ----------------->", __FUNCTION__); + uint64_t authenticator_id = 0; + pthread_mutex_lock(&qdev->lock); + authenticator_id = qdev->authenticator_id; + pthread_mutex_unlock(&qdev->lock); + + ALOGD("----------------> %s auth id %" PRIx64 "----------------->", __FUNCTION__, authenticator_id); + return authenticator_id; +} + +static int fingerprint_set_active_group(struct fingerprint_device *device, uint32_t gid, + const char *path) { + ALOGD("----------------> %s -----------------> path %s", __FUNCTION__, path); + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + pthread_mutex_lock(&qdev->lock); + qdev->group_id = gid; + snprintf(qdev->listener.fp_filename, sizeof(qdev->listener.fp_filename), + "%s/%s", path, FINGERPRINT_FILENAME); + snprintf(qdev->listener.authid_filename, sizeof(qdev->listener.authid_filename), + "%s/%s", path, AUTHENTICATOR_ID_FILENAME); + uint64_t authenticator_id = 0; + loadFingerprints(&qdev->listener); + loadAuthenticatorId(qdev->listener.authid_filename, &authenticator_id); + if (authenticator_id == 0) { + // firs time, create an authenticator id + authenticator_id = get_64bit_rand(); + // save it to disk + saveAuthenticatorId(qdev->listener.authid_filename, authenticator_id); + } + + qdev->authenticator_id = authenticator_id; + pthread_mutex_unlock(&qdev->lock); + + return 0; +} + +/** + * If fingerprints are enrolled, then this function is expected to put the sensor into a + * "scanning" state where it's actively scanning and recognizing fingerprint features. + * Actual authentication must happen in TEE and should be monitored in a separate thread + * since this function is expected to return immediately. + */ +static int fingerprint_authenticate(struct fingerprint_device *device, + uint64_t operation_id, __unused uint32_t gid) +{ + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + + pthread_mutex_lock(&qdev->lock); + qdev->op_id = operation_id; + qdev->listener.state = STATE_SCAN; + pthread_mutex_unlock(&qdev->lock); + + return 0; +} + +/** + * This is expected to put the sensor into an "enroll" state where it's actively scanning and + * working towards a finished fingerprint database entry. Authentication must happen in + * a separate thread since this function is expected to return immediately. + * + * Note: This method should always generate a new random authenticator_id. + * + * Note: As with fingerprint_authenticate(), this would run in TEE on a real device. + */ +static int fingerprint_enroll(struct fingerprint_device *device, + const hw_auth_token_t *hat, + uint32_t __unused gid, + uint32_t __unused timeout_sec) { + ALOGD("fingerprint_enroll"); + qemu_fingerprint_device_t* dev = (qemu_fingerprint_device_t*)device; + if (!hat) { + ALOGW("%s: null auth token", __func__); + return -EPROTONOSUPPORT; + } + if (hat->challenge == dev->challenge) { + // The secure_user_id retrieved from the auth token should be stored + // with the enrolled fingerprint template and returned in the auth result + // for a successful authentication with that finger. + dev->secure_user_id = hat->user_id; + } else { + ALOGW("%s: invalid auth token", __func__); + } + + if (hat->version != HW_AUTH_TOKEN_VERSION) { + return -EPROTONOSUPPORT; + } + if (hat->challenge != dev->challenge && !(hat->authenticator_type & HW_AUTH_FINGERPRINT)) { + return -EPERM; + } + + dev->user_id = hat->user_id; + + pthread_mutex_lock(&dev->lock); + dev->listener.state = STATE_ENROLL; + pthread_mutex_unlock(&dev->lock); + + // fingerprint id, authenticator id, and secure_user_id + // will be stored by worked thread + + return 0; + +} + +/** + * The pre-enrollment step is simply to get an authentication token that can be wrapped and + * verified at a later step. The primary purpose is to return a token that protects against + * spoofing and replay attacks. It is passed to password authentication where it is wrapped and + * propagated to the enroll step. + */ +static uint64_t fingerprint_pre_enroll(struct fingerprint_device *device) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + uint64_t challenge = 0; + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + + // The challenge will typically be a cryptographically-secure key + // coming from the TEE so it can be verified at a later step. For now we just generate a + // random value. + challenge = get_64bit_rand(); + + pthread_mutex_lock(&qdev->lock); + qdev->challenge = challenge; + pthread_mutex_unlock(&qdev->lock); + + return challenge; +} + +static int fingerprint_post_enroll(struct fingerprint_device* device) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + + pthread_mutex_lock(&qdev->lock); + qdev->challenge = 0; + pthread_mutex_unlock(&qdev->lock); + + return 0; +} + +/** + * Cancel is called by the framework to cancel an outstanding event. This should *not* be called + * by the driver since it will cause the framework to stop listening for fingerprints. + */ +static int fingerprint_cancel(struct fingerprint_device *device) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + + pthread_mutex_lock(&qdev->lock); + qdev->listener.state = STATE_IDLE; + pthread_mutex_unlock(&qdev->lock); + + fingerprint_msg_t msg = {0, {0}}; + msg.type = FINGERPRINT_ERROR; + msg.data.error = FINGERPRINT_ERROR_CANCELED; + qdev->device.notify(&msg); + + return 0; +} + +static int fingerprint_enumerate(struct fingerprint_device *device) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + if (device == NULL) { + ALOGE("Cannot enumerate saved fingerprints with uninitialized params"); + return -1; + } + + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + int template_count = 0; + for (int i = 0; i < MAX_NUM_FINGERS; i++) { + if (qdev->listener.secureid[i] != 0 || + qdev->listener.fingerid[i] != 0) { + ALOGD("ENUM: Fingerprint [%d] = 0x%" PRIx64 ",%" PRIx64, i, + qdev->listener.secureid[i], qdev->listener.fingerid[i]); + template_count++; + } + } + fingerprint_msg_t message = {0, {0}}; + message.type = FINGERPRINT_TEMPLATE_ENUMERATING; + message.data.enumerated.finger.gid = qdev->group_id; + for (int i = 0; i < MAX_NUM_FINGERS; i++) { + if (qdev->listener.secureid[i] != 0 || + qdev->listener.fingerid[i] != 0) { + template_count--; + message.data.enumerated.remaining_templates = template_count; + message.data.enumerated.finger.fid = qdev->listener.fingerid[i]; + qdev->device.notify(&message); + } + } + + return 0; +} + +static int fingerprint_remove(struct fingerprint_device *device, + uint32_t __unused gid, uint32_t fid) { + int idx = 0; + fingerprint_msg_t msg = {0, {0}}; + ALOGD("----------------> %s -----------------> fid %d", __FUNCTION__, fid); + if (device == NULL) { + ALOGE("Can't remove fingerprint (gid=%d, fid=%d); " + "device not initialized properly", + gid, fid); + return -1; + } + + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + + if (fid == 0) { + // Delete all fingerprints + // I'll do this one at a time, so I am not + // holding the mutext during the notification + bool listIsEmpty; + do { + pthread_mutex_lock(&qdev->lock); + listIsEmpty = true; // Haven't seen a valid entry yet + for (idx = 0; idx < MAX_NUM_FINGERS; idx++) { + uint32_t theFid = qdev->listener.fingerid[idx]; + if (theFid != 0) { + // Delete this entry + qdev->listener.secureid[idx] = 0; + qdev->listener.fingerid[idx] = 0; + saveFingerprint(&qdev->listener, idx); + + // Send a notification that we deleted this one + pthread_mutex_unlock(&qdev->lock); + msg.type = FINGERPRINT_TEMPLATE_REMOVED; + msg.data.removed.finger.fid = theFid; + device->notify(&msg); + + // Because we released the mutex, the list + // may have changed. Restart the 'for' loop + // after reacquiring the mutex. + listIsEmpty = false; + break; + } + } // end for (idx < MAX_NUM_FINGERS) + } while (!listIsEmpty); + msg.type = FINGERPRINT_TEMPLATE_REMOVED; + msg.data.removed.finger.fid = 0; + device->notify(&msg); + qdev->listener.state = STATE_IDLE; + pthread_mutex_unlock(&qdev->lock); + } else { + // Delete one fingerprint + // Look for this finger ID in our table. + pthread_mutex_lock(&qdev->lock); + for (idx = 0; idx < MAX_NUM_FINGERS; idx++) { + if (qdev->listener.fingerid[idx] == fid && + qdev->listener.secureid[idx] != 0) { + // Found it! + break; + } + } + if (idx >= MAX_NUM_FINGERS) { + qdev->listener.state = STATE_IDLE; + pthread_mutex_unlock(&qdev->lock); + ALOGE("Fingerprint ID %d not found", fid); + return FINGERPRINT_ERROR; + } + + qdev->listener.secureid[idx] = 0; + qdev->listener.fingerid[idx] = 0; + saveFingerprint(&qdev->listener, idx); + + qdev->listener.state = STATE_IDLE; + pthread_mutex_unlock(&qdev->lock); + + msg.type = FINGERPRINT_TEMPLATE_REMOVED; + msg.data.removed.finger.fid = fid; + device->notify(&msg); + } + + return 0; +} + +static int set_notify_callback(struct fingerprint_device *device, + fingerprint_notify_t notify) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + if (device == NULL || notify == NULL) { + ALOGE("Failed to set notify callback @ %p for fingerprint device %p", + device, notify); + return -1; + } + + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + pthread_mutex_lock(&qdev->lock); + qdev->listener.state = STATE_IDLE; + device->notify = notify; + pthread_mutex_unlock(&qdev->lock); + ALOGD("fingerprint callback notification set"); + + return 0; +} + +static bool is_valid_fid(qemu_fingerprint_device_t* qdev, uint64_t fid) { + int idx = 0; + if (0 == fid) { return false; } + for (idx = 0; idx < MAX_NUM_FINGERS; idx++) { + if (qdev->listener.fingerid[idx] == fid) { + return true; + } + } + return false; +} + +static void send_scan_notice(qemu_fingerprint_device_t* qdev, int fid) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + + // acquired message + fingerprint_msg_t acqu_msg = {0, {0}}; + acqu_msg.type = FINGERPRINT_ACQUIRED; + acqu_msg.data.acquired.acquired_info = FINGERPRINT_ACQUIRED_GOOD; + + // authenticated message + fingerprint_msg_t auth_msg = {0, {0}}; + auth_msg.type = FINGERPRINT_AUTHENTICATED; + auth_msg.data.authenticated.finger.fid = is_valid_fid(qdev, fid) ? fid : 0; + auth_msg.data.authenticated.finger.gid = 0; // unused + auth_msg.data.authenticated.hat.version = HW_AUTH_TOKEN_VERSION; + auth_msg.data.authenticated.hat.authenticator_type = + htobe32(HW_AUTH_FINGERPRINT); + auth_msg.data.authenticated.hat.challenge = qdev->op_id; + auth_msg.data.authenticated.hat.authenticator_id = qdev->authenticator_id; + auth_msg.data.authenticated.hat.user_id = qdev->secure_user_id; + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + auth_msg.data.authenticated.hat.timestamp = + htobe64((uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000); + + // pthread_mutex_lock(&qdev->lock); + qdev->device.notify(&acqu_msg); + qdev->device.notify(&auth_msg); + // pthread_mutex_unlock(&qdev->lock); + + return; +} + +static void send_enroll_notice(qemu_fingerprint_device_t* qdev, int fid) { + ALOGD("----------------> %s -----------------> fid %d", __FUNCTION__, fid); + + if (fid == 0) { + ALOGD("Fingerprint ID is zero (invalid)"); + return; + } + if (qdev->secure_user_id == 0) { + ALOGD("Secure user ID is zero (invalid)"); + return; + } + + // Find an available entry in the table + pthread_mutex_lock(&qdev->lock); + int idx = 0; + for (idx = 0; idx < MAX_NUM_FINGERS; idx++) { + if (qdev->listener.secureid[idx] == 0 || + qdev->listener.fingerid[idx] == 0) { + // This entry is available + break; + } + } + if (idx >= MAX_NUM_FINGERS) { + qdev->listener.state = STATE_SCAN; + pthread_mutex_unlock(&qdev->lock); + ALOGD("Fingerprint ID table is full"); + return; + } + + qdev->listener.secureid[idx] = qdev->secure_user_id; + qdev->listener.fingerid[idx] = fid; + saveFingerprint(&qdev->listener, idx); + + qdev->listener.state = STATE_SCAN; + pthread_mutex_unlock(&qdev->lock); + + // LOCKED notification? + fingerprint_msg_t msg = {0, {0}}; + msg.type = FINGERPRINT_TEMPLATE_ENROLLING; + msg.data.enroll.finger.fid = fid; + msg.data.enroll.samples_remaining = 0; + qdev->device.notify(&msg); + + return; +} + +static worker_state_t getListenerState(qemu_fingerprint_device_t* dev) { + ALOGV("----------------> %s ----------------->", __FUNCTION__); + worker_state_t state = STATE_IDLE; + + pthread_mutex_lock(&dev->lock); + state = dev->listener.state; + pthread_mutex_unlock(&dev->lock); + + return state; +} + +/** + * This a very simple event loop for the fingerprint sensor. For a given state (enroll, scan), + * this would receive events from the sensor and forward them to fingerprintd using the + * notify() method. + * + * In this simple example, we open a qemu channel (a pipe) where the developer can inject events to + * exercise the API and test application code. + * + * The scanner should remain in the scanning state until either an error occurs or the operation + * completes. + * + * Recoverable errors such as EINTR should be handled locally; they should not + * be propagated unless there's something the user can do about it (e.g. "clean sensor"). Such + * messages should go through the onAcquired() interface. + * + * If an unrecoverable error occurs, an acquired message (e.g. ACQUIRED_PARTIAL) should be sent, + * followed by an error message (e.g. FINGERPRINT_ERROR_UNABLE_TO_PROCESS). + * + * Note that this event loop would typically run in TEE since it must interact with the sensor + * hardware and handle raw fingerprint data and encrypted templates. It is expected that + * this code monitors the TEE for resulting events, such as enrollment and authentication status. + * Here we just have a very simple event loop that monitors a qemu channel for pseudo events. + */ +static void* listenerFunction(void* data) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)data; + + pthread_mutex_lock(&qdev->lock); + qdev->qchanfd = qemud_channel_open(FINGERPRINT_LISTEN_SERVICE_NAME); + if (qdev->qchanfd < 0) { + ALOGE("listener cannot open fingerprint listener service exit"); + pthread_mutex_unlock(&qdev->lock); + return NULL; + } + qdev->listener.state = STATE_IDLE; + pthread_mutex_unlock(&qdev->lock); + + const char* cmd = "listen"; + if (qemud_channel_send(qdev->qchanfd, cmd, strlen(cmd)) < 0) { + ALOGE("cannot write fingerprint 'listen' to host"); + goto done_quiet; + } + + int comm_errors = 0; + struct pollfd pfd = { + .fd = qdev->qchanfd, + .events = POLLIN, + }; + while (1) { + int size = 0; + int fid = 0; + char buffer[MAX_COMM_CHARS] = {0}; + bool disconnected = false; + while (1) { + if (getListenerState(qdev) == STATE_EXIT) { + ALOGD("Received request to exit listener thread"); + goto done; + } + + // Reset revents before poll() (just to be safe) + pfd.revents = 0; + + // Poll qemud channel for 5 seconds + // TODO: Eliminate the timeout so that polling can be interrupted + // instantly. One possible solution is to follow the example of + // android::Looper ($AOSP/system/core/include/utils/Looper.h and + // $AOSP/system/core/libutils/Looper.cpp), which makes use of an + // additional file descriptor ("wake event fd"). + int nfds = poll(&pfd, 1, 5000); + if (nfds < 0) { + ALOGE("Could not poll qemud channel: %s", strerror(errno)); + goto done; + } + + if (!nfds) { + // poll() timed out - try again + continue; + } + + // assert(nfds == 1) + if (pfd.revents & POLLIN) { + // Input data being available doesn't rule out a disconnection + disconnected = pfd.revents & (POLLERR | POLLHUP); + break; // Exit inner while loop + } else { + // Some event(s) other than "input data available" occurred, + // i.e. POLLERR or POLLHUP, indicating a disconnection + ALOGW("Lost connection to qemud channel"); + goto done; + } + } + + // Shouldn't block since we were just notified of a POLLIN event + if ((size = qemud_channel_recv(qdev->qchanfd, buffer, + sizeof(buffer) - 1)) > 0) { + buffer[size] = '\0'; + if (sscanf(buffer, "on:%d", &fid) == 1) { + if (fid > 0 && fid <= MAX_FID_VALUE) { + switch (qdev->listener.state) { + case STATE_ENROLL: + send_enroll_notice(qdev, fid); + break; + case STATE_SCAN: + send_scan_notice(qdev, fid); + break; + default: + ALOGE("fingerprint event listener at unexpected " + "state 0%x", + qdev->listener.state); + } + } else { + ALOGE("fingerprintid %d not in valid range [%d, %d] and " + "will be " + "ignored", + fid, 1, MAX_FID_VALUE); + continue; + } + } else if (strncmp("off", buffer, 3) == 0) { + // TODO: Nothing to do here ? Looks valid + ALOGD("fingerprint ID %d off", fid); + } else { + ALOGE("Invalid command '%s' to fingerprint listener", buffer); + } + + if (disconnected) { + ALOGW("Connection to qemud channel has been lost"); + break; + } + } else { + ALOGE("fingerprint listener receive failure"); + if (comm_errors > MAX_COMM_ERRORS) + break; + } + } + +done: + ALOGD("Listener exit with %d receive errors", comm_errors); +done_quiet: + close(qdev->qchanfd); + return NULL; +} + +static int fingerprint_close(hw_device_t* device) { + ALOGD("----------------> %s ----------------->", __FUNCTION__); + if (device == NULL) { + ALOGE("fingerprint hw device is NULL"); + return -1; + } + + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)device; + pthread_mutex_lock(&qdev->lock); + // Ask listener thread to exit + qdev->listener.state = STATE_EXIT; + pthread_mutex_unlock(&qdev->lock); + + pthread_join(qdev->listener.thread, NULL); + pthread_mutex_destroy(&qdev->lock); + free(qdev); + + return 0; +} + +static int fingerprint_open(const hw_module_t* module, const char __unused *id, + hw_device_t** device) +{ + + ALOGD("----------------> %s ----------------->", __FUNCTION__); + if (device == NULL) { + ALOGE("NULL device on open"); + return -EINVAL; + } + + qemu_fingerprint_device_t* qdev = (qemu_fingerprint_device_t*)calloc( + 1, sizeof(qemu_fingerprint_device_t)); + if (qdev == NULL) { + ALOGE("Insufficient memory for virtual fingerprint device"); + return -ENOMEM; + } + + + qdev->device.common.tag = HARDWARE_DEVICE_TAG; + qdev->device.common.version = HARDWARE_MODULE_API_VERSION(2, 1); + qdev->device.common.module = (struct hw_module_t*)module; + qdev->device.common.close = fingerprint_close; + + qdev->device.pre_enroll = fingerprint_pre_enroll; + qdev->device.enroll = fingerprint_enroll; + qdev->device.post_enroll = fingerprint_post_enroll; + qdev->device.get_authenticator_id = fingerprint_get_auth_id; + qdev->device.set_active_group = fingerprint_set_active_group; + qdev->device.authenticate = fingerprint_authenticate; + qdev->device.cancel = fingerprint_cancel; + qdev->device.enumerate = fingerprint_enumerate; + qdev->device.remove = fingerprint_remove; + qdev->device.set_notify = set_notify_callback; + qdev->device.notify = NULL; + + // init and create listener thread + pthread_mutex_init(&qdev->lock, NULL); + if (pthread_create(&qdev->listener.thread, NULL, listenerFunction, qdev) != + 0) + return -1; + + // "Inheritance" / casting + *device = &qdev->device.common; + + return 0; +} + +static struct hw_module_methods_t fingerprint_module_methods = { + .open = fingerprint_open, +}; + +fingerprint_module_t HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = FINGERPRINT_MODULE_API_VERSION_2_1, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = FINGERPRINT_HARDWARE_MODULE_ID, + .name = "Emulator Fingerprint HAL", + .author = "The Android Open Source Project", + .methods = &fingerprint_module_methods, + }, +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/fstab.goldfish b/src/type3_AndroidCloud/anbox-master/android/fstab.goldfish new file mode 100644 index 0000000..9558aa7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/fstab.goldfish @@ -0,0 +1 @@ +# Android fstab file. diff --git a/src/type3_AndroidCloud/anbox-master/android/gps/Android.mk b/src/type3_AndroidCloud/anbox-master/android/gps/Android.mk new file mode 100644 index 0000000..0abf1fb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/gps/Android.mk @@ -0,0 +1,47 @@ +# Copyright (C) 2010 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# We're moving the emulator-specific platform libs to +# development.git/tools/emulator/. The following test is to ensure +# smooth builds even if the tree contains both versions. +# + +LOCAL_PATH := $(call my-dir) + +# HAL module implemenation stored in +# hw/..so +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_CFLAGS += -DQEMU_HARDWARE +LOCAL_SHARED_LIBRARIES := liblog libcutils libhardware +LOCAL_SRC_FILES := gps_qemu.c +ifeq ($(TARGET_PRODUCT),vbox_x86) +LOCAL_MODULE := gps.vbox_x86 +else +LOCAL_MODULE := gps.goldfish +endif +include $(BUILD_SHARED_LIBRARY) + + +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_CFLAGS += -DQEMU_HARDWARE +LOCAL_SHARED_LIBRARIES := liblog libcutils libhardware +LOCAL_SRC_FILES := gps_qemu.c +LOCAL_MODULE := gps.ranchu + +include $(BUILD_SHARED_LIBRARY) diff --git a/src/type3_AndroidCloud/anbox-master/android/gps/gps_qemu.c b/src/type3_AndroidCloud/anbox-master/android/gps/gps_qemu.c new file mode 100644 index 0000000..133cbe4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/gps/gps_qemu.c @@ -0,0 +1,953 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* this implements a GPS hardware library for the Android emulator. + * the following code should be built as a shared library that will be + * placed into /system/lib/hw/gps.goldfish.so + * + * it will be loaded by the code in hardware/libhardware/hardware.c + * which is itself called from android_location_GpsLocationProvider.cpp + */ + + +#include +#include +#include +#include +#include +#include + +#define LOG_TAG "gps_qemu" +#include +#include +#include +#include + +/* the name of the qemud-controlled socket */ +#define QEMU_CHANNEL_NAME "gps" + +#define GPS_DEBUG 0 + +#if GPS_DEBUG +# define D(...) ALOGD(__VA_ARGS__) +#else +# define D(...) ((void)0) +#endif + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** N M E A T O K E N I Z E R *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ + +typedef struct { + const char* p; + const char* end; +} Token; + +#define MAX_NMEA_TOKENS 16 + +typedef struct { + int count; + Token tokens[ MAX_NMEA_TOKENS ]; +} NmeaTokenizer; + +static int +nmea_tokenizer_init( NmeaTokenizer* t, const char* p, const char* end ) +{ + int count = 0; + char* q; + + // the initial '$' is optional + if (p < end && p[0] == '$') + p += 1; + + // remove trailing newline + if (end > p && end[-1] == '\n') { + end -= 1; + if (end > p && end[-1] == '\r') + end -= 1; + } + + // get rid of checksum at the end of the sentecne + if (end >= p+3 && end[-3] == '*') { + end -= 3; + } + + while (p < end) { + const char* q = p; + + q = memchr(p, ',', end-p); + if (q == NULL) + q = end; + + if (count < MAX_NMEA_TOKENS) { + t->tokens[count].p = p; + t->tokens[count].end = q; + count += 1; + } + if (q < end) + q += 1; + + p = q; + } + + t->count = count; + return count; +} + +static Token +nmea_tokenizer_get( NmeaTokenizer* t, int index ) +{ + Token tok; + static const char* dummy = ""; + + if (index < 0 || index >= t->count) { + tok.p = tok.end = dummy; + } else + tok = t->tokens[index]; + + return tok; +} + + +static int +str2int( const char* p, const char* end ) +{ + int result = 0; + int len = end - p; + + for ( ; len > 0; len--, p++ ) + { + int c; + + if (p >= end) + goto Fail; + + c = *p - '0'; + if ((unsigned)c >= 10) + goto Fail; + + result = result*10 + c; + } + return result; + +Fail: + return -1; +} + +static double +str2float( const char* p, const char* end ) +{ + int result = 0; + int len = end - p; + char temp[16]; + + if (len >= (int)sizeof(temp)) + return 0.; + + memcpy( temp, p, len ); + temp[len] = 0; + return strtod( temp, NULL ); +} + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** N M E A P A R S E R *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ + +#define NMEA_MAX_SIZE 83 + +typedef struct { + int pos; + int overflow; + int utc_year; + int utc_mon; + int utc_day; + int utc_diff; + GpsLocation fix; + gps_location_callback callback; + char in[ NMEA_MAX_SIZE+1 ]; +} NmeaReader; + + +static void +nmea_reader_update_utc_diff( NmeaReader* r ) +{ + time_t now = time(NULL); + struct tm tm_local; + struct tm tm_utc; + long time_local, time_utc; + + gmtime_r( &now, &tm_utc ); + localtime_r( &now, &tm_local ); + + time_local = tm_local.tm_sec + + 60*(tm_local.tm_min + + 60*(tm_local.tm_hour + + 24*(tm_local.tm_yday + + 365*tm_local.tm_year))); + + time_utc = tm_utc.tm_sec + + 60*(tm_utc.tm_min + + 60*(tm_utc.tm_hour + + 24*(tm_utc.tm_yday + + 365*tm_utc.tm_year))); + + r->utc_diff = time_utc - time_local; +} + + +static void +nmea_reader_init( NmeaReader* r ) +{ + memset( r, 0, sizeof(*r) ); + + r->pos = 0; + r->overflow = 0; + r->utc_year = -1; + r->utc_mon = -1; + r->utc_day = -1; + r->callback = NULL; + r->fix.size = sizeof(r->fix); + + nmea_reader_update_utc_diff( r ); +} + + +static void +nmea_reader_set_callback( NmeaReader* r, gps_location_callback cb ) +{ + r->callback = cb; + if (cb != NULL && r->fix.flags != 0) { + D("%s: sending latest fix to new callback", __FUNCTION__); + r->callback( &r->fix ); + r->fix.flags = 0; + } +} + + +static int +nmea_reader_update_time( NmeaReader* r, Token tok ) +{ + int hour, minute; + double seconds; + struct tm tm; + time_t fix_time; + + if (tok.p + 6 > tok.end) + return -1; + + if (r->utc_year < 0) { + // no date yet, get current one + time_t now = time(NULL); + gmtime_r( &now, &tm ); + r->utc_year = tm.tm_year + 1900; + r->utc_mon = tm.tm_mon + 1; + r->utc_day = tm.tm_mday; + } + + hour = str2int(tok.p, tok.p+2); + minute = str2int(tok.p+2, tok.p+4); + seconds = str2float(tok.p+4, tok.end); + + tm.tm_hour = hour; + tm.tm_min = minute; + tm.tm_sec = (int) seconds; + tm.tm_year = r->utc_year - 1900; + tm.tm_mon = r->utc_mon - 1; + tm.tm_mday = r->utc_day; + tm.tm_isdst = -1; + + fix_time = mktime( &tm ) + r->utc_diff; + r->fix.timestamp = (long long)fix_time * 1000; + return 0; +} + +static int +nmea_reader_update_date( NmeaReader* r, Token date, Token time ) +{ + Token tok = date; + int day, mon, year; + + if (tok.p + 6 != tok.end) { + D("date not properly formatted: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + day = str2int(tok.p, tok.p+2); + mon = str2int(tok.p+2, tok.p+4); + year = str2int(tok.p+4, tok.p+6) + 2000; + + if ((day|mon|year) < 0) { + D("date not properly formatted: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + + r->utc_year = year; + r->utc_mon = mon; + r->utc_day = day; + + return nmea_reader_update_time( r, time ); +} + + +static double +convert_from_hhmm( Token tok ) +{ + double val = str2float(tok.p, tok.end); + int degrees = (int)(floor(val) / 100); + double minutes = val - degrees*100.; + double dcoord = degrees + minutes / 60.0; + return dcoord; +} + + +static int +nmea_reader_update_latlong( NmeaReader* r, + Token latitude, + char latitudeHemi, + Token longitude, + char longitudeHemi ) +{ + double lat, lon; + Token tok; + + tok = latitude; + if (tok.p + 6 > tok.end) { + D("latitude is too short: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + lat = convert_from_hhmm(tok); + if (latitudeHemi == 'S') + lat = -lat; + + tok = longitude; + if (tok.p + 6 > tok.end) { + D("longitude is too short: '%.*s'", tok.end-tok.p, tok.p); + return -1; + } + lon = convert_from_hhmm(tok); + if (longitudeHemi == 'W') + lon = -lon; + + r->fix.flags |= GPS_LOCATION_HAS_LAT_LONG; + r->fix.latitude = lat; + r->fix.longitude = lon; + return 0; +} + + +static int +nmea_reader_update_altitude( NmeaReader* r, + Token altitude, + Token units ) +{ + double alt; + Token tok = altitude; + + if (tok.p >= tok.end) + return -1; + + r->fix.flags |= GPS_LOCATION_HAS_ALTITUDE; + r->fix.altitude = str2float(tok.p, tok.end); + return 0; +} + + +static int +nmea_reader_update_bearing( NmeaReader* r, + Token bearing ) +{ + double alt; + Token tok = bearing; + + if (tok.p >= tok.end) + return -1; + + r->fix.flags |= GPS_LOCATION_HAS_BEARING; + r->fix.bearing = str2float(tok.p, tok.end); + return 0; +} + + +static int +nmea_reader_update_speed( NmeaReader* r, + Token speed ) +{ + double alt; + Token tok = speed; + + if (tok.p >= tok.end) + return -1; + + r->fix.flags |= GPS_LOCATION_HAS_SPEED; + r->fix.speed = str2float(tok.p, tok.end); + return 0; +} + +static int +nmea_reader_update_accuracy( NmeaReader* r ) +{ + // Always return 20m accuracy. + // Possibly parse it from the NMEA sentence in the future. + r->fix.flags |= GPS_LOCATION_HAS_ACCURACY; + r->fix.accuracy = 20; + return 0; +} + + +static void +nmea_reader_parse( NmeaReader* r ) +{ + /* we received a complete sentence, now parse it to generate + * a new GPS fix... + */ + NmeaTokenizer tzer[1]; + Token tok; + + D("Received: '%.*s'", r->pos, r->in); + if (r->pos < 9) { + D("Too short. discarded."); + return; + } + + nmea_tokenizer_init(tzer, r->in, r->in + r->pos); +#if GPS_DEBUG + { + int n; + D("Found %d tokens", tzer->count); + for (n = 0; n < tzer->count; n++) { + Token tok = nmea_tokenizer_get(tzer,n); + D("%2d: '%.*s'", n, tok.end-tok.p, tok.p); + } + } +#endif + + tok = nmea_tokenizer_get(tzer, 0); + if (tok.p + 5 > tok.end) { + D("sentence id '%.*s' too short, ignored.", tok.end-tok.p, tok.p); + return; + } + + // ignore first two characters. + tok.p += 2; + if ( !memcmp(tok.p, "GGA", 3) ) { + // GPS fix + Token tok_time = nmea_tokenizer_get(tzer,1); + Token tok_latitude = nmea_tokenizer_get(tzer,2); + Token tok_latitudeHemi = nmea_tokenizer_get(tzer,3); + Token tok_longitude = nmea_tokenizer_get(tzer,4); + Token tok_longitudeHemi = nmea_tokenizer_get(tzer,5); + Token tok_altitude = nmea_tokenizer_get(tzer,9); + Token tok_altitudeUnits = nmea_tokenizer_get(tzer,10); + + nmea_reader_update_time(r, tok_time); + nmea_reader_update_latlong(r, tok_latitude, + tok_latitudeHemi.p[0], + tok_longitude, + tok_longitudeHemi.p[0]); + nmea_reader_update_altitude(r, tok_altitude, tok_altitudeUnits); + + } else if ( !memcmp(tok.p, "GSA", 3) ) { + // do something ? + } else if ( !memcmp(tok.p, "RMC", 3) ) { + Token tok_time = nmea_tokenizer_get(tzer,1); + Token tok_fixStatus = nmea_tokenizer_get(tzer,2); + Token tok_latitude = nmea_tokenizer_get(tzer,3); + Token tok_latitudeHemi = nmea_tokenizer_get(tzer,4); + Token tok_longitude = nmea_tokenizer_get(tzer,5); + Token tok_longitudeHemi = nmea_tokenizer_get(tzer,6); + Token tok_speed = nmea_tokenizer_get(tzer,7); + Token tok_bearing = nmea_tokenizer_get(tzer,8); + Token tok_date = nmea_tokenizer_get(tzer,9); + + D("in RMC, fixStatus=%c", tok_fixStatus.p[0]); + if (tok_fixStatus.p[0] == 'A') + { + nmea_reader_update_date( r, tok_date, tok_time ); + + nmea_reader_update_latlong( r, tok_latitude, + tok_latitudeHemi.p[0], + tok_longitude, + tok_longitudeHemi.p[0] ); + + nmea_reader_update_bearing( r, tok_bearing ); + nmea_reader_update_speed ( r, tok_speed ); + } + } else { + tok.p -= 2; + D("unknown sentence '%.*s", tok.end-tok.p, tok.p); + } + + // Always update accuracy + nmea_reader_update_accuracy( r ); + + if (r->fix.flags != 0) { +#if GPS_DEBUG + char temp[256]; + char* p = temp; + char* end = p + sizeof(temp); + struct tm utc; + + p += snprintf( p, end-p, "sending fix" ); + if (r->fix.flags & GPS_LOCATION_HAS_LAT_LONG) { + p += snprintf(p, end-p, " lat=%g lon=%g", r->fix.latitude, r->fix.longitude); + } + if (r->fix.flags & GPS_LOCATION_HAS_ALTITUDE) { + p += snprintf(p, end-p, " altitude=%g", r->fix.altitude); + } + if (r->fix.flags & GPS_LOCATION_HAS_SPEED) { + p += snprintf(p, end-p, " speed=%g", r->fix.speed); + } + if (r->fix.flags & GPS_LOCATION_HAS_BEARING) { + p += snprintf(p, end-p, " bearing=%g", r->fix.bearing); + } + if (r->fix.flags & GPS_LOCATION_HAS_ACCURACY) { + p += snprintf(p,end-p, " accuracy=%g", r->fix.accuracy); + } + gmtime_r( (time_t*) &r->fix.timestamp, &utc ); + p += snprintf(p, end-p, " time=%s", asctime( &utc ) ); + D(temp); +#endif + if (r->callback) { + r->callback( &r->fix ); + r->fix.flags = 0; + } + else { + D("no callback, keeping data until needed !"); + } + } +} + + +static void +nmea_reader_addc( NmeaReader* r, int c ) +{ + if (r->overflow) { + r->overflow = (c != '\n'); + return; + } + + if (r->pos >= (int) sizeof(r->in)-1 ) { + r->overflow = 1; + r->pos = 0; + return; + } + + r->in[r->pos] = (char)c; + r->pos += 1; + + if (c == '\n') { + nmea_reader_parse( r ); + r->pos = 0; + } +} + + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** C O N N E C T I O N S T A T E *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ + +/* commands sent to the gps thread */ +enum { + CMD_QUIT = 0, + CMD_START = 1, + CMD_STOP = 2 +}; + + +/* this is the state of our connection to the qemu_gpsd daemon */ +typedef struct { + int init; + int fd; + GpsCallbacks callbacks; + pthread_t thread; + int control[2]; +} GpsState; + +static GpsState _gps_state[1]; + + +static void +gps_state_done( GpsState* s ) +{ + // tell the thread to quit, and wait for it + char cmd = CMD_QUIT; + void* dummy; + write( s->control[0], &cmd, 1 ); + pthread_join(s->thread, &dummy); + + // close the control socket pair + close( s->control[0] ); s->control[0] = -1; + close( s->control[1] ); s->control[1] = -1; + + // close connection to the QEMU GPS daemon + close( s->fd ); s->fd = -1; + s->init = 0; +} + + +static void +gps_state_start( GpsState* s ) +{ + char cmd = CMD_START; + int ret; + + do { ret=write( s->control[0], &cmd, 1 ); } + while (ret < 0 && errno == EINTR); + + if (ret != 1) + D("%s: could not send CMD_START command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} + + +static void +gps_state_stop( GpsState* s ) +{ + char cmd = CMD_STOP; + int ret; + + do { ret=write( s->control[0], &cmd, 1 ); } + while (ret < 0 && errno == EINTR); + + if (ret != 1) + D("%s: could not send CMD_STOP command: ret=%d: %s", + __FUNCTION__, ret, strerror(errno)); +} + + +static int +epoll_register( int epoll_fd, int fd ) +{ + struct epoll_event ev; + int ret, flags; + + /* important: make the fd non-blocking */ + flags = fcntl(fd, F_GETFL); + fcntl(fd, F_SETFL, flags | O_NONBLOCK); + + ev.events = EPOLLIN; + ev.data.fd = fd; + do { + ret = epoll_ctl( epoll_fd, EPOLL_CTL_ADD, fd, &ev ); + } while (ret < 0 && errno == EINTR); + return ret; +} + + +static int +epoll_deregister( int epoll_fd, int fd ) +{ + int ret; + do { + ret = epoll_ctl( epoll_fd, EPOLL_CTL_DEL, fd, NULL ); + } while (ret < 0 && errno == EINTR); + return ret; +} + +/* this is the main thread, it waits for commands from gps_state_start/stop and, + * when started, messages from the QEMU GPS daemon. these are simple NMEA sentences + * that must be parsed to be converted into GPS fixes sent to the framework + */ +static void +gps_state_thread( void* arg ) +{ + GpsState* state = (GpsState*) arg; + NmeaReader reader[1]; + int epoll_fd = epoll_create(2); + int started = 0; + int gps_fd = state->fd; + int control_fd = state->control[1]; + + nmea_reader_init( reader ); + + // register control file descriptors for polling + epoll_register( epoll_fd, control_fd ); + epoll_register( epoll_fd, gps_fd ); + + D("gps thread running"); + + // now loop + for (;;) { + struct epoll_event events[2]; + int ne, nevents; + + nevents = epoll_wait( epoll_fd, events, 2, -1 ); + if (nevents < 0) { + if (errno != EINTR) + ALOGE("epoll_wait() unexpected error: %s", strerror(errno)); + continue; + } + D("gps thread received %d events", nevents); + for (ne = 0; ne < nevents; ne++) { + if ((events[ne].events & (EPOLLERR|EPOLLHUP)) != 0) { + ALOGE("EPOLLERR or EPOLLHUP after epoll_wait() !?"); + return; + } + if ((events[ne].events & EPOLLIN) != 0) { + int fd = events[ne].data.fd; + + if (fd == control_fd) + { + char cmd = 255; + int ret; + D("gps control fd event"); + do { + ret = read( fd, &cmd, 1 ); + } while (ret < 0 && errno == EINTR); + + if (cmd == CMD_QUIT) { + D("gps thread quitting on demand"); + return; + } + else if (cmd == CMD_START) { + if (!started) { + D("gps thread starting location_cb=%p", state->callbacks.location_cb); + started = 1; + nmea_reader_set_callback( reader, state->callbacks.location_cb ); + } + } + else if (cmd == CMD_STOP) { + if (started) { + D("gps thread stopping"); + started = 0; + nmea_reader_set_callback( reader, NULL ); + } + } + } + else if (fd == gps_fd) + { + char buff[32]; + D("gps fd event"); + for (;;) { + int nn, ret; + + ret = read( fd, buff, sizeof(buff) ); + if (ret < 0) { + if (errno == EINTR) + continue; + if (errno != EWOULDBLOCK) + ALOGE("error while reading from gps daemon socket: %s:", strerror(errno)); + break; + } + D("received %d bytes: %.*s", ret, ret, buff); + for (nn = 0; nn < ret; nn++) + nmea_reader_addc( reader, buff[nn] ); + } + D("gps fd event end"); + } + else + { + ALOGE("epoll_wait() returned unkown fd %d ?", fd); + } + } + } + } +} + + +static void +gps_state_init( GpsState* state, GpsCallbacks* callbacks ) +{ + state->init = 1; + state->control[0] = -1; + state->control[1] = -1; + state->fd = -1; + + state->fd = qemud_channel_open(QEMU_CHANNEL_NAME); + + if (state->fd < 0) { + D("no gps emulation detected"); + return; + } + + D("gps emulation will read from '%s' qemud channel", QEMU_CHANNEL_NAME ); + + if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) { + ALOGE("could not create thread control socket pair: %s", strerror(errno)); + goto Fail; + } + + state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state ); + + if ( !state->thread ) { + ALOGE("could not create gps thread: %s", strerror(errno)); + goto Fail; + } + + state->callbacks = *callbacks; + + D("gps state initialized"); + return; + +Fail: + gps_state_done( state ); +} + + +/*****************************************************************/ +/*****************************************************************/ +/***** *****/ +/***** I N T E R F A C E *****/ +/***** *****/ +/*****************************************************************/ +/*****************************************************************/ + + +static int +qemu_gps_init(GpsCallbacks* callbacks) +{ + GpsState* s = _gps_state; + + if (!s->init) + gps_state_init(s, callbacks); + + if (s->fd < 0) + return -1; + + return 0; +} + +static void +qemu_gps_cleanup(void) +{ + GpsState* s = _gps_state; + + if (s->init) + gps_state_done(s); +} + + +static int +qemu_gps_start() +{ + GpsState* s = _gps_state; + + if (!s->init) { + D("%s: called with uninitialized state !!", __FUNCTION__); + return -1; + } + + D("%s: called", __FUNCTION__); + gps_state_start(s); + return 0; +} + + +static int +qemu_gps_stop() +{ + GpsState* s = _gps_state; + + if (!s->init) { + D("%s: called with uninitialized state !!", __FUNCTION__); + return -1; + } + + D("%s: called", __FUNCTION__); + gps_state_stop(s); + return 0; +} + + +static int +qemu_gps_inject_time(GpsUtcTime time, int64_t timeReference, int uncertainty) +{ + return 0; +} + +static int +qemu_gps_inject_location(double latitude, double longitude, float accuracy) +{ + return 0; +} + +static void +qemu_gps_delete_aiding_data(GpsAidingData flags) +{ +} + +static int qemu_gps_set_position_mode(GpsPositionMode mode, int fix_frequency) +{ + // FIXME - support fix_frequency + return 0; +} + +static const void* +qemu_gps_get_extension(const char* name) +{ + // no extensions supported + return NULL; +} + +static const GpsInterface qemuGpsInterface = { + sizeof(GpsInterface), + qemu_gps_init, + qemu_gps_start, + qemu_gps_stop, + qemu_gps_cleanup, + qemu_gps_inject_time, + qemu_gps_inject_location, + qemu_gps_delete_aiding_data, + qemu_gps_set_position_mode, + qemu_gps_get_extension, +}; + +const GpsInterface* gps__get_gps_interface(struct gps_device_t* dev) +{ + return &qemuGpsInterface; +} + +static int open_gps(const struct hw_module_t* module, char const* name, + struct hw_device_t** device) +{ + struct gps_device_t *dev = malloc(sizeof(struct gps_device_t)); + memset(dev, 0, sizeof(*dev)); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = (struct hw_module_t*)module; +// dev->common.close = (int (*)(struct hw_device_t*))close_lights; + dev->get_gps_interface = gps__get_gps_interface; + + *device = (struct hw_device_t*)dev; + return 0; +} + + +static struct hw_module_methods_t gps_module_methods = { + .open = open_gps +}; + +struct hw_module_t HAL_MODULE_INFO_SYM = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = GPS_HARDWARE_MODULE_ID, + .name = "Goldfish GPS Module", + .author = "The Android Open Source Project", + .methods = &gps_module_methods, +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/hwcomposer/hwcomposer.cpp b/src/type3_AndroidCloud/anbox-master/android/hwcomposer/hwcomposer.cpp new file mode 100644 index 0000000..530f948 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/hwcomposer/hwcomposer.cpp @@ -0,0 +1,333 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include +#include + +#define LOG_NDEBUG 1 +#include + +#include "HostConnection.h" +#include "gralloc_cb.h" + +#define DEFINE_HOST_CONNECTION() \ + HostConnection *hostCon = HostConnection::get(); \ + renderControl_encoder_context_t *rcEnc = (hostCon ? hostCon->rcEncoder() : NULL) + +#define DEFINE_AND_VALIDATE_HOST_CONNECTION() \ + HostConnection *hostCon = HostConnection::get(); \ + if (!hostCon) { \ + ALOGE("hwcomposer.anbox: Failed to get host connection\n"); \ + return -EIO; \ + } \ + renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \ + if (!rcEnc) { \ + ALOGE("hwcomposer.anbox: Failed to get renderControl encoder context\n"); \ + return -EIO; \ + } + +struct HwcContext { + hwc_composer_device_1_t device; + + // These 3 variables could be reduced to first_overlay only, however it makes + // the conditions in the code more complicated. In order to keep things as + // simple as possible, there are 3 major ways to display a frame. + // 1. Show only the framebuffer. + // 2. Show the framebuffer with some overlays above it. + // 3. Show all overlays and hide the framebuffer. + // + // Since the framebuffer has no alpha channel and is opaque, it can only ever + // be the rearmost layer that we end up putting on screen, otherwise it will + // cover up all layers behind it, since its display frame is the whole window. + // + // Without framebuffer_visible, the condition of whether to display the + // frambuffer becomes more complex and possibly if (numHwLayers == 0 || + // hwLayers[0]->compositionType != HWC_OVERLAY) but that might not be correct. + // + // The range [first_overlay, first_overlay+num_overlay) is a natural way to + // structure the loop and prevents requiring state and iterating through all + // the non-OVERLAY layers in hwc_set. + bool framebuffer_visible; + size_t first_overlay; + size_t num_overlays; +}; + +static void dump_layer(hwc_layer_1_t const* l) { + ALOGD("\tname='%s', type=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}", + l->name, l->compositionType, l->flags, l->handle, l->transform, l->blending, + l->sourceCrop.left, + l->sourceCrop.top, + l->sourceCrop.right, + l->sourceCrop.bottom, + l->displayFrame.left, + l->displayFrame.top, + l->displayFrame.right, + l->displayFrame.bottom); +} + +static int hwc_prepare(hwc_composer_device_1_t* dev, size_t numDisplays, + hwc_display_contents_1_t** displays) { + auto context = reinterpret_cast(dev); + + if (displays == NULL || displays[0] == NULL) + return -EINVAL; + + // Anbox only supports the primary display. + if (displays[0]->flags & HWC_GEOMETRY_CHANGED) { + const size_t& num_hw_layers = displays[0]->numHwLayers; + size_t i = 1; + bool visible = (num_hw_layers == 1); + + // Iterate backwards and skip the first (end) layer, which is the + // framebuffer target layer. According to the SurfaceFlinger folks, the + // actual location of this layer is up to the HWC implementation to + // decide, but is in the well know last slot of the list. This does not + // imply that the framebuffer target layer must be topmost. + for (; i < num_hw_layers; i++) { + hwc_layer_1_t* layer = &displays[0]->hwLayers[num_hw_layers - 1 - i]; + +#if 0 + dump_layer(layer); +#endif + + if (layer->flags & HWC_SKIP_LAYER) { + // All layers below and including this one will be drawn into the + // framebuffer. Stop marking further layers as HWC_OVERLAY. + visible = true; + break; + } + + switch (layer->compositionType) { + case HWC_OVERLAY: + case HWC_FRAMEBUFFER: + layer->compositionType = HWC_OVERLAY; + break; + case HWC_BACKGROUND: + break; + default: + ALOGE("hwcomposor: Invalid compositionType %d", + layer->compositionType); + break; + } + } + context->first_overlay = num_hw_layers - i; + context->num_overlays = i - 1; + context->framebuffer_visible = visible; + } + + return 0; +} + +/* + * We're using "implicit" synchronization, so make sure we aren't passing any + * sync object descriptors around. + */ +static void check_sync_fds(size_t numDisplays, hwc_display_contents_1_t** displays) +{ + unsigned int i, j; + for (i = 0; i < numDisplays; i++) { + hwc_display_contents_1_t* list = displays[i]; + if (list->retireFenceFd >= 0) { + ALOGW("retireFenceFd[%u] was %d", i, list->retireFenceFd); + list->retireFenceFd = -1; + } + + for (j = 0; j < list->numHwLayers; j++) { + hwc_layer_1_t* layer = &list->hwLayers[j]; + if (layer->acquireFenceFd >= 0) { + ALOGW("acquireFenceFd[%u][%u] was %d, closing", i, j, layer->acquireFenceFd); + close(layer->acquireFenceFd); + layer->acquireFenceFd = -1; + } + if (layer->releaseFenceFd >= 0) { + ALOGW("releaseFenceFd[%u][%u] was %d", i, j, layer->releaseFenceFd); + layer->releaseFenceFd = -1; + } + } + } +} + +static int hwc_set(hwc_composer_device_1_t* dev, size_t numDisplays, + hwc_display_contents_1_t** displays) { + auto context = reinterpret_cast(dev); + + if (displays == NULL || displays[0] == NULL) + return -EFAULT; + + DEFINE_AND_VALIDATE_HOST_CONNECTION(); + + for (size_t i = 0 ; i < displays[0]->numHwLayers ; i++) { + const auto layer = &displays[0]->hwLayers[i]; + + if (layer->flags & HWC_SKIP_LAYER || + layer->flags & HWC_IS_CURSOR_LAYER) + continue; + +#if 0 + dump_layer(layer); +#endif + + // FIXME this is just dirty ... but layer->handle is a const native_handle_t and canBePosted + // can't be called with a const. + auto cb = const_cast(reinterpret_cast(layer->handle)); + if (!cb_handle_t::validate(cb)) { + ALOGE("Buffer handle is invalid\n"); + return -EINVAL; + } + + rcEnc->rcPostLayer(rcEnc, + layer->name, + cb->hostHandle, + layer->planeAlpha / 255, + layer->sourceCrop.left, + layer->sourceCrop.top, + layer->sourceCrop.right, + layer->sourceCrop.bottom, + layer->displayFrame.left, + layer->displayFrame.top, + layer->displayFrame.right, + layer->displayFrame.bottom); + hostCon->flush(); + } + + rcEnc->rcPostAllLayersDone(rcEnc); + + check_sync_fds(numDisplays, displays); + + return 0; +} + +static int hwc_event_control(hwc_composer_device_1* dev, int disp, + int event, int enabled) { + return -EFAULT; +} + +static void hwc_register_procs(hwc_composer_device_1* dev, + hwc_procs_t const* procs) { +} + +static int hwc_blank(hwc_composer_device_1* dev, int disp, int blank) { + return 0; +} + +static int hwc_query(hwc_composer_device_1* dev, int what, int* value) { + return 0; +} + +static int hwc_device_close(hw_device_t* dev) { + auto context = reinterpret_cast(dev); + delete context; + return 0; +} + +static int hwc_get_display_configs(hwc_composer_device_1* dev, int disp, + uint32_t* configs, size_t* numConfigs) { + if (disp != 0) { + return -EINVAL; + } + + if (*numConfigs > 0) { + // Config[0] will be passed in to getDisplayAttributes as the disp + // parameter. The ARC display supports only 1 configuration. + configs[0] = 0; + *numConfigs = 1; + } + return 0; +} + +static int hwc_get_display_attributes(hwc_composer_device_1* dev, + int disp, uint32_t config, + const uint32_t* attributes, + int32_t* values) { + if (disp != 0 || config != 0) { + return -EINVAL; + } + + DEFINE_AND_VALIDATE_HOST_CONNECTION(); + + while (*attributes != HWC_DISPLAY_NO_ATTRIBUTE) { + switch (*attributes) { + case HWC_DISPLAY_VSYNC_PERIOD: + *values = rcEnc->rcGetDisplayVsyncPeriod(rcEnc, disp); + break; + case HWC_DISPLAY_WIDTH: + *values = rcEnc->rcGetDisplayWidth(rcEnc, disp); + break; + case HWC_DISPLAY_HEIGHT: + *values = rcEnc->rcGetDisplayHeight(rcEnc, disp); + break; + case HWC_DISPLAY_DPI_X: + *values = 1000 * rcEnc->rcGetDisplayDpiX(rcEnc, disp); + break; + case HWC_DISPLAY_DPI_Y: + *values = 1000 * rcEnc->rcGetDisplayDpiY(rcEnc, disp); + break; + default: + ALOGE("Unknown attribute value 0x%02x", *attributes); + } + ++attributes; + ++values; + } + return 0; +} + +static int hwc_device_open(const hw_module_t* module, const char* name, hw_device_t** device) { + ALOGD("%s", __PRETTY_FUNCTION__); + + if (strcmp(name, HWC_HARDWARE_COMPOSER) != 0) + return -EINVAL; + + auto dev = new HwcContext; + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = HWC_DEVICE_API_VERSION_1_0; + dev->device.common.module = const_cast(module); + dev->device.common.close = hwc_device_close; + dev->device.prepare = hwc_prepare; + dev->device.set = hwc_set; + dev->device.eventControl = hwc_event_control; + dev->device.blank = hwc_blank; + dev->device.query = hwc_query; + dev->device.getDisplayConfigs = hwc_get_display_configs; + dev->device.getDisplayAttributes = hwc_get_display_attributes; + dev->device.registerProcs = hwc_register_procs; + dev->device.dump = nullptr; + + *device = &dev->device.common; + + return 0; +} + +static hw_module_methods_t hwc_module_methods = { + .open = hwc_device_open +}; + +hwc_module_t HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = HWC_HARDWARE_MODULE_ID, + .name = "Hardware Composer Module", + .author = "Anbox Developers", + .methods = &hwc_module_methods, + } +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/init.goldfish.rc b/src/type3_AndroidCloud/anbox-master/android/init.goldfish.rc new file mode 100644 index 0000000..6db19e4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/init.goldfish.rc @@ -0,0 +1,100 @@ + +on early-init + mount debugfs debugfs /sys/kernel/debug + +on init + +on boot + setprop ARGH ARGH + setprop net.eth0.gw 10.0.2.2 + setprop net.eth0.dns1 10.0.2.3 + setprop net.dns1 10.0.2.3 + setprop net.gprs.local-ip 10.0.2.15 + setprop ro.radio.use-ppp no + setprop ro.build.product generic + setprop ro.product.device generic + +# fake some battery state + setprop status.battery.state Slow + setprop status.battery.level 5 + setprop status.battery.level_raw 50 + setprop status.battery.level_scale 9 + +# set up the GPU caching + setprop ro.hwui.texture_cache_size 72 + setprop ro.hwui.layer_cache_size 48 + setprop ro.hwui.r_buffer_cache_size 8 + setprop ro.hwui.path_cache_size 32 + setprop ro.hwui.gradient_cache_size 1 + setprop ro.hwui.drop_shadow_cache_size 6 + setprop ro.hwui.texture_cache_flushrate 0.4 + setprop ro.hwui.text_small_cache_width 1024 + setprop ro.hwui.text_small_cache_height 1024 + setprop ro.hwui.text_large_cache_width 2048 + setprop ro.hwui.text_large_cache_height 1024 + +# disable some daemons the emulator doesn't want + stop dund + stop akmd + +# start essential services + start qemud + start goldfish-logcat + start goldfish-setup + + setprop ro.setupwizard.mode EMULATOR + +# enable Google-specific location features, +# like NetworkLocationProvider and LocationCollector + setprop ro.com.google.locationfeatures 1 + +# For the emulator, which bypasses Setup Wizard, you can specify +# account info for the device via these two properties. Google +# Login Service will insert these accounts into the database when +# it is created (ie, after a data wipe). +# +# setprop ro.config.hosted_account username@hosteddomain.org:password +# setprop ro.config.google_account username@gmail.com:password +# +# You MUST have a Google account on the device, and you MAY +# additionally have a hosted account. No other configuration is +# supported, and arbitrary breakage may result if you specify +# something else. + +on fs + mount_all /fstab.goldfish + +service goldfish-setup /system/etc/init.goldfish.sh + user root + group root + oneshot + +# The qemu-props program is used to set various system +# properties on boot. It must be run early during the boot +# process to avoid race conditions with other daemons that +# might read them (e.g. surface flinger), so define it in +# class 'core' +# +service qemu-props /system/bin/qemu-props + class core + user root + group root + oneshot + +service qemud /system/bin/qemud + socket qemud stream 666 + oneshot + +# -Q is a special logcat option that forces the +# program to check wether it runs on the emulator +# if it does, it redirects its output to the device +# named by the androidboot.console kernel option +# if not, is simply exits immediately + +service goldfish-logcat /system/bin/logcat + console + oneshot + +service fingerprintd /system/bin/fingerprintd + class late_start + user system diff --git a/src/type3_AndroidCloud/anbox-master/android/init.goldfish.sh b/src/type3_AndroidCloud/anbox-master/android/init.goldfish.sh new file mode 100644 index 0000000..ece75b4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/init.goldfish.sh @@ -0,0 +1,68 @@ +#!/system/bin/sh + +# Setup networking when boot starts +ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up +route add default gw 10.0.2.2 dev eth0 + +# ro.kernel.android.qemud is normally set when we +# want the RIL (radio interface layer) to talk to +# the emulated modem through qemud. +# +# However, this will be undefined in two cases: +# +# - When we want the RIL to talk directly to a guest +# serial device that is connected to a host serial +# device by the emulator. +# +# - We don't want to use the RIL but the VM-based +# modem emulation that runs inside the guest system +# instead. +# +# The following detects the latter case and sets up the +# system for it. +# +qemud=`getprop ro.kernel.android.qemud` +case "$qemud" in + "") + radio_ril=`getprop ro.kernel.android.ril` + case "$radio_ril" in + "") + # no need for the radio interface daemon + # telephony is entirely emulated in Java + setprop ro.radio.noril yes + stop ril-daemon + ;; + esac + ;; +esac + +# Setup additionnal DNS servers if needed +num_dns=`getprop ro.kernel.ndns` +case "$num_dns" in + 2) setprop net.eth0.dns2 10.0.2.4 + ;; + 3) setprop net.eth0.dns2 10.0.2.4 + setprop net.eth0.dns3 10.0.2.5 + ;; + 4) setprop net.eth0.dns2 10.0.2.4 + setprop net.eth0.dns3 10.0.2.5 + setprop net.eth0.dns4 10.0.2.6 + ;; +esac + +# disable boot animation for a faster boot sequence when needed +boot_anim=`getprop ro.kernel.android.bootanim` +case "$boot_anim" in + 0) setprop debug.sf.nobootanimation 1 + ;; +esac + +# set up the second interface (for inter-emulator connections) +# if required +my_ip=`getprop net.shared_net_ip` +case "$my_ip" in + "") + ;; + *) ifconfig eth1 "$my_ip" netmask 255.255.255.0 up + ;; +esac diff --git a/src/type3_AndroidCloud/anbox-master/android/lights/Android.mk b/src/type3_AndroidCloud/anbox-master/android/lights/Android.mk new file mode 100644 index 0000000..fa783a9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/lights/Android.mk @@ -0,0 +1,25 @@ +# Copyright (C) 2011 The Android Open Source Project. +# +# Original code licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this software except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +# HAL module implemenation, not prelinked and stored in +# hw/..so +include $(CLEAR_VARS) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_SRC_FILES := lights_qemu.c +LOCAL_MODULE := lights.goldfish +LOCAL_CFLAGS += -DLIGHT_BACKLIGHT +include $(BUILD_SHARED_LIBRARY) diff --git a/src/type3_AndroidCloud/anbox-master/android/lights/lights_qemu.c b/src/type3_AndroidCloud/anbox-master/android/lights/lights_qemu.c new file mode 100644 index 0000000..94fe8cc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/lights/lights_qemu.c @@ -0,0 +1,213 @@ +/* Copyright (C) 2011 The Android Open Source Project + * + * Original code licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This implements a lights hardware library for the Android emulator. + * the following code should be built as a shared library that will be + * placed into /system/lib/hw/lights.goldfish.so + * + * It will be loaded by the code in hardware/libhardware/hardware.c + * which is itself called from + * ./frameworks/base/services/jni/com_android_server_HardwareService.cpp + */ + +#ifdef LOG_TAG +#undef LOG_TAG +#define LOG_TAG "Lights" +#endif + +/* we connect with the emulator through the "hw-control" qemud service */ +#define LIGHTS_SERVICE_NAME "hw-control" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Set to 1 to enable debug messages to the log */ +#define DEBUG 0 +#if DEBUG +# define D(...) ALOGD(__VA_ARGS__) +#else +# define D(...) do{}while(0) +#endif + +#define E(...) ALOGE(__VA_ARGS__) + +/* Get brightness(0~255) from state. */ +static int +rgb_to_brightness( struct light_state_t const* state ) +{ + int color = state->color & 0x00ffffff; + return ((77 * ((color >> 16) & 0x00ff)) + + (150 * ((color >> 8) & 0x00ff)) + (29 * (color & 0x00ff))) >> 8; +} + +/* set backlight brightness by LIGHTS_SERVICE_NAME service. */ +static int +set_light_backlight( struct light_device_t* dev, struct light_state_t const* state ) +{ + /* Get Lights service. */ + int fd = qemud_channel_open( LIGHTS_SERVICE_NAME ); + + if (fd < 0) { + E( "%s: no qemud connection", __FUNCTION__ ); + return -1; + } + + D( "%s: On/Off %d/%d flashMode %d brightnessMode %d" + " RGB = 0x%08x", __func__, + state->flashOnMS, + state->flashOffMS, + state->flashMode, + state->brightnessMode, + state->color ); + + int brightness = rgb_to_brightness( state ); + + char buffer[64]; + snprintf( buffer, sizeof(buffer), "power:light:brightness:lcd_backlight:%d", brightness ); + D( "%s: lcd_backlight command: %s", __FUNCTION__, buffer ); + + /* send backlight command to perform the backlight setting. */ + if (qemud_channel_send( fd, buffer, -1 ) < 0) { + E( "%s: could not query lcd_backlight: %s", __FUNCTION__, strerror(errno) ); + close( fd ); + return -1; + } + + close( fd ); + return 0; +} + +static int +set_light_buttons( struct light_device_t* dev, struct light_state_t const* state ) +{ + /* @Waiting for later implementation. */ + D( "%s: Not implemented.", __FUNCTION__ ); + + return 0; +} + +static int +set_light_battery( struct light_device_t* dev, struct light_state_t const* state ) +{ + /* @Waiting for later implementation. */ + D( "%s: Not implemented.", __FUNCTION__ ); + + return 0; +} + +static int +set_light_keyboard( struct light_device_t* dev, struct light_state_t const* state ) +{ + /* @Waiting for later implementation. */ + D( "%s: Not implemented.", __FUNCTION__ ); + + return 0; +} + +static int +set_light_notifications( struct light_device_t* dev, struct light_state_t const* state ) +{ + /* @Waiting for later implementation. */ + D( "%s: Not implemented.", __FUNCTION__ ); + + return 0; +} + +static int +set_light_attention( struct light_device_t* dev, struct light_state_t const* state ) +{ + /* @Waiting for later implementation. */ + D( "%s: Not implemented.", __FUNCTION__ ); + + return 0; +} + +/** Close the lights device */ +static int +close_lights( struct light_device_t *dev ) +{ + free( dev ); + + return 0; +} + +/** + * module methods + */ + +/** Open a new instance of a lights device using name */ +static int +open_lights( const struct hw_module_t* module, char const *name, + struct hw_device_t **device ) +{ + void* set_light; + + if (0 == strcmp( LIGHT_ID_BACKLIGHT, name )) { + set_light = set_light_backlight; + } else if (0 == strcmp( LIGHT_ID_KEYBOARD, name )) { + set_light = set_light_keyboard; + } else if (0 == strcmp( LIGHT_ID_BUTTONS, name )) { + set_light = set_light_buttons; + } else if (0 == strcmp( LIGHT_ID_BATTERY, name )) { + set_light = set_light_battery; + } else if (0 == strcmp( LIGHT_ID_NOTIFICATIONS, name )) { + set_light = set_light_notifications; + } else if (0 == strcmp( LIGHT_ID_ATTENTION, name )) { + set_light = set_light_attention; + } else { + D( "%s: %s light isn't supported yet.", __FUNCTION__, name ); + return -EINVAL; + } + + struct light_device_t *dev = malloc( sizeof(struct light_device_t) ); + if (dev == NULL) { + return -EINVAL; + } + memset( dev, 0, sizeof(*dev) ); + + dev->common.tag = HARDWARE_DEVICE_TAG; + dev->common.version = 0; + dev->common.module = (struct hw_module_t*)module; + dev->common.close = (int (*)(struct hw_device_t*))close_lights; + dev->set_light = set_light; + + *device = (struct hw_device_t*)dev; + return 0; +} + +static struct hw_module_methods_t lights_module_methods = { + .open = open_lights, +}; + +/* + * The emulator lights Module + */ +struct hw_module_t HAL_MODULE_INFO_SYM = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = LIGHTS_HARDWARE_MODULE_ID, + .name = "Goldfish lights Module", + .author = "The Android Open Source Project", + .methods = &lights_module_methods, +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/media/media_codecs.xml b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs.xml new file mode 100644 index 0000000..ee846da --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_audio.xml b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_audio.xml new file mode 100644 index 0000000..632088a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_audio.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_telephony.xml b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_telephony.xml new file mode 100644 index 0000000..5ad90d9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_telephony.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_tv.xml b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_tv.xml new file mode 100644 index 0000000..330c6fb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_tv.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_video.xml b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_video.xml new file mode 100644 index 0000000..829f403 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/media/media_codecs_google_video.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/media/media_profiles.xml b/src/type3_AndroidCloud/anbox-master/android/media/media_profiles.xml new file mode 100644 index 0000000..cd99857 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/media/media_profiles.xml @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/Android.mk new file mode 100644 index 0000000..2e9e473 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/Android.mk @@ -0,0 +1,65 @@ +# This is the top-level build file for the Android HW OpenGL ES emulation +# in Android. +# +# You must define BUILD_EMULATOR_OPENGL to 'true' in your environment to +# build the following files. +# +# Also define BUILD_EMULATOR_OPENGL_DRIVER to 'true' to build the gralloc +# stuff as well. +# +ifeq (true,$(BUILD_EMULATOR_OPENGL)) + +# Top-level for all modules +EMUGL_PATH := $(call my-dir) + +# Directory containing common headers used by several modules +# This is always set to a module's LOCAL_C_INCLUDES +# See the definition of emugl-begin-module in common.mk +# +EMUGL_COMMON_INCLUDES := $(EMUGL_PATH)/host/include/libOpenglRender + +# common cflags used by several modules +# This is always set to a module's LOCAL_CFLAGS +# See the definition of emugl-begin-module in common.mk +# +EMUGL_COMMON_CFLAGS := -DWITH_GLES2 + +# Uncomment the following line if you want to enable debug traces +# in the GLES emulation libraries. +# EMUGL_COMMON_CFLAGS += -DEMUGL_DEBUG=1 + +# Include common definitions used by all the modules included later +# in this build file. This contains the definition of all useful +# emugl-xxxx functions. +# +include $(EMUGL_PATH)/common.mk + +# IMPORTANT: ORDER IS CRUCIAL HERE +# +# For the import/export feature to work properly, you must include +# modules below in correct order. That is, if module B depends on +# module A, then it must be included after module A below. +# +# This ensures that anything exported by module A will be correctly +# be imported by module B when it is declared. +# +# Note that the build system will complain if you try to import a +# module that hasn't been declared yet anyway. +# + +include $(EMUGL_PATH)/shared/OpenglCodecCommon/Android.mk + +# System static libraries +include $(EMUGL_PATH)/system/GLESv1_enc/Android.mk +include $(EMUGL_PATH)/system/GLESv2_enc/Android.mk +include $(EMUGL_PATH)/system/renderControl_enc/Android.mk +include $(EMUGL_PATH)/system/OpenglSystemCommon/Android.mk + +# System shared libraries +include $(EMUGL_PATH)/system/GLESv1/Android.mk +include $(EMUGL_PATH)/system/GLESv2/Android.mk + +include $(EMUGL_PATH)/system/gralloc/Android.mk +include $(EMUGL_PATH)/system/egl/Android.mk + +endif # BUILD_EMULATOR_OPENGL == true diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/README b/src/type3_AndroidCloud/anbox-master/android/opengl/README new file mode 100644 index 0000000..3303d4b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/README @@ -0,0 +1,19 @@ +This directory contains Android-side modules related to hardware OpenGL ES +emulation. The host-side modules and documentation are in +$ANDROID_BUILD_TOP/sdk/emulator/opengl. + +Note that this directory contains encoder sources that are auto-generated +with the 'emugen' host tool (see sdk/emulator/opengl/host/tools/emugen). + +To regenerate them, run external/qemu/distrib/update-emugl-sources.sh, +after building the emulator from sources, this will populate the content +here with the appropriate updated source files. + +You should do this whenever you update one of the *.types, *.in and *.attrib +files located under one of: + + $AOSP/sdk/emulator/opengl/libs/GLESv1_dec/ + $AOSP/sdk/emulator/opengl/libs/GLESv2_dec/ + $AOSP/sdk/emulator/opengl/libs/renderControl_dec/ + +or when the 'emugen' tool itself is modified. diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/common.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/common.mk new file mode 100644 index 0000000..a1e5522 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/common.mk @@ -0,0 +1,237 @@ +# This top-level build file is included by all modules that implement +# the hardware OpenGL ES emulation for Android. +# +# We use it to ensure that all sub-Makefiles are included in the right +# order for various variable definitions and usage to happen in the correct +# order. +# + +# The following macros are used to start a new GLES emulation module. +# +# This will define LOCAL_MODULE as $1, plus a few other variables +# needed by the build system (e.g. LOCAL_MODULE_TAGS, LOCAL_MODULE_CLASS...) +# +# NOTE: You still need to define LOCAL_PATH before this +# +# Usage example: +# +# $(call emugl-begin-static-library,) +# LOCAL_SRC_FILES := .... +# LOCAL_C_INCLUDES += .... +# $(call emugl-end-module) +# +emugl-begin-static-library = $(call emugl-begin-module,$1,STATIC_LIBRARY) +emugl-begin-shared-library = $(call emugl-begin-module,$1,SHARED_LIBRARY) + +# Internal list of all declared modules (used for sanity checking) +_emugl_modules := +_emugl_HOST_modules := + +# do not use directly, see functions above instead +emugl-begin-module = \ + $(eval include $(CLEAR_VARS)) \ + $(eval LOCAL_MODULE := $1) \ + $(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \ + $(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\ + $(eval LOCAL_C_INCLUDES := $(EMUGL_COMMON_INCLUDES)) \ + $(eval LOCAL_CFLAGS := $(EMUGL_COMMON_CFLAGS)) \ + $(eval _EMUGL_INCLUDE_TYPE := $(BUILD_$2)) \ + $(call _emugl-init-module,$1,$2,$3) + +# Used to end a module definition, see function definitions above +emugl-end-module = \ + $(eval include $(_EMUGL_INCLUDE_TYPE))\ + $(eval _EMUGL_INCLUDE_TYPE :=) \ + $(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\ + $(if $(EMUGL_DEBUG),$(call emugl-dump-module)) + +# Managing module exports and imports. +# +# A module can 'import' another module, by calling emugl-import. This will +# make the current LOCAL_MODULE inherit various definitions exported from +# the imported module. +# +# Module exports are defined by calling emugl-export. Here is an example: +# +# $(call emugl-begin-static-library,foo) +# LOCAL_SRC_FILES := foo.c +# $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +# $(call emugl-export,SHARED_LIBRARIES,libcutils) +# $(call emugl-end-module) +# +# $(call emugl-begin-shared-library,bar) +# LOCAL_SRC_FILES := bar.cpp +# $(call emugl-import,foo) +# $(call emugl-end-module) +# +# Here, we define a static library named 'foo' which exports an include +# path and a shared library requirement, and a shared library 'bar' which +# imports it. +# +# What this means is that: +# +# - 'bar' will automatically inherit foo's LOCAL_PATH in its LOCAL_C_INCLUDES +# - 'bar' will automatically inherit libcutils in its own LOCAL_SHARED_LIBRARIES +# +# Note that order of declaration matters. If 'foo' is defined after 'bar' in +# the example above, nothing will work correctly because dependencies are +# computed at import time. +# +# +# IMPORTANT: Imports are transitive, i.e. when module A imports B, +# it automatically imports anything imported by B too. + +# This is the list of recognized export types we support for now. +EMUGL_EXPORT_TYPES := \ + CFLAGS \ + LDLIBS \ + LDFLAGS \ + C_INCLUDES \ + SHARED_LIBRARIES \ + STATIC_LIBRARIES \ + ADDITIONAL_DEPENDENCIES + +# Initialize a module in our database +# $1: Module name +# $2: Module type +# $3: "HOST" for a host module, empty for a target one. +_emugl-init-module = \ + $(eval _emugl_HOST := $(if $3,HOST_,))\ + $(eval _emugl_MODULE := $(_emugl_HOST)$1)\ + $(if $(filter $(_emugl_$(_emugl_HOST)modules),$(_emugl_MODULE)),\ + $(error There is already a $(if $3,host,) module named $1!)\ + )\ + $(eval _mod = $(_emugl_MODULE)) \ + $(eval _emugl.$(_mod).type := $(patsubst HOST_%,%,$2))\ + $(eval _emugl.$(_mod).imports :=) \ + $(eval _emugl,$(_mod).moved :=) \ + $(foreach _type,$(EMUGL_EXPORT_TYPES),\ + $(eval _emugl.$(_mod).export.$(_type) :=)\ + ) + +# Called to indicate that a module exports a given local variable for its +# users. This also adds this to LOCAL_$1 +# $1: Local variable type (e.g. CFLAGS, LDLIBS, etc...) +# $2: Value(s) to append to the export +emugl-export = \ + $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)\ + $(eval LOCAL_$1 := $2 $(LOCAL_$1)) + +emugl-export-outer = \ + $(eval _emugl.$(_emugl_MODULE).export.$1 += $2) + +# Called to indicate that a module imports the exports of another module +# $1: list of modules to import +# +emugl-import = \ + $(foreach _imod,$1,\ + $(call _emugl-module-import,$(_emugl_HOST)$(_imod))\ + ) + +_emugl-module-import = \ + $(eval _mod := $(_emugl_MODULE))\ + $(if $(filter-out $(_emugl_$(_emugl_HOST)modules),$1),\ + $(info Unknown imported emugles module: $1)\ + $(if $(_emugl_HOST),\ + $(eval _names := $(patsubst HOST_%,%,$(_emugl_HOST_modules))),\ + $(eval _names := $(_emugl_modules))\ + )\ + $(info Please one of the following names: $(_names))\ + $(error Aborting)\ + )\ + $(if $(filter-out $(_emugl.$(_mod).imports),$1),\ + $(eval _emugl.$(_mod).imports += $1)\ + $(foreach _sub,$(_emugl.$1.imports),\ + $(call _emugl-module-import,$(_sub))\ + )\ + $(foreach _type,$(EMUGL_EXPORT_TYPES),\ + $(eval LOCAL_$(_type) := $(_emugl.$1.export.$(_type)) $(LOCAL_$(_type)))\ + )\ + $(if $(filter EXECUTABLE SHARED_LIBRARY,$(_emugl.$(_emugl_MODULE).type)),\ + $(if $(filter STATIC_LIBRARY,$(_emugl.$1.type)),\ + $(eval LOCAL_STATIC_LIBRARIES := $(1:HOST_%=%) $(LOCAL_STATIC_LIBRARIES))\ + )\ + $(if $(filter SHARED_LIBRARY,$(_emugl.$1.type)),\ + $(if $(_emugl.$1.moved),,\ + $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\ + )\ + )\ + )\ + ) + +_emugl-dump-list = \ + $(foreach _list_item,$(strip $1),$(info . $(_list_item))) + +emugl-dump-module = \ + $(info MODULE=$(_emugl_MODULE))\ + $(info . HOST=$(_emugl_HOST))\ + $(info . TYPE=$(_emugl.$(_emugl_MODULE).type))\ + $(info . IMPORTS=$(_emugl.$(_emugl_MODULE).imports))\ + $(foreach _type,$(EMUGL_EXPORT_TYPES),\ + $(if $(filter C_INCLUDES ADDITIONAL_DEPENDENCIES,$(_type)),\ + $(info . EXPORT.$(_type) :=)\ + $(call _emugl-dump-list,$(_emugl.$(_emugl_MODULE).export.$(_type)))\ + $(info . LOCAL_$(_type) :=)\ + $(call _emugl-dump-list,$(LOCAL_$(_type)))\ + ,\ + $(info . EXPORT.$(_type) := $(strip $(_emugl.$(_emugl_MODULE).export.$(_type))))\ + $(info . LOCAL_$(_type) := $(strip $(LOCAL_$(_type))))\ + )\ + )\ + $(info . LOCAL_SRC_FILES := $(LOCAL_SRC_FILES))\ + +# This function can be called to generate the wrapper source files. +# LOCAL_MODULE and LOCAL_MODULE_CLASS must be defined or the build will abort. +# Source files will be stored in the local intermediates directory that will +# be automatically added to your LOCAL_C_INCLUDES. +# Usage: +# $(call emugl-gen-wrapper,,) +# +emugl-gen-wrapper = \ + $(eval _emugl_out := $(call local-intermediates-dir)) \ + $(call emugl-gen-wrapper-generic,$(_emugl_out),$1,$2) \ + $(call emugl-export,C_INCLUDES,$(_emugl_out)) + +# DO NOT CALL DIRECTLY, USE emugl-gen-wrapper instead. +# +# The following function can be called to generate GL library wrapper +# Usage is: +# +# $(call emugl-gen-wrapper-generic,,,) +# +# is the destination directory where the generated sources are stored +# is the source directory where to find .attrib, etc.. +# is the emugen basename (see host/tools/emugen/README) +# +emugl-gen-wrapper-generic = $(eval $(emugl-gen-wrapper-generic-ev)) + +define emugl-gen-wrapper-generic-ev +_emugl_wrap := $$1/$$3 +_emugl_src := $$2/$$3 +GEN := $$(_emugl_wrap)_wrapper_entry.cpp \ + $$(_emugl_wrap)_wrapper_context.cpp \ + $$(_emugl_wrap)_wrapper_context.h \ + $$(_emugl_wrap)_wrapper_proc.h + +$$(GEN): PRIVATE_PATH := $$(LOCAL_PATH) +$$(GEN): PRIVATE_CUSTOM_TOOL := $$(EMUGL_EMUGEN) -W $$1 -i $$2 $$3 +$$(GEN): $$(EMUGL_EMUGEN) $$(_emugl_src).attrib $$(_emugl_src).in $$(_emugl_src).types + $$(transform-generated-source) + +$$(call emugl-export,ADDITIONAL_DEPENDENCIES,$$(GEN)) +LOCAL_GENERATED_SOURCES += $$(GEN) +LOCAL_C_INCLUDES += $$1 + +#ifneq ($$(HOST_OS),windows) +$$(call emugl-export,LDFLAGS,-ldl) +#endif + +endef + +# Call this function when your shared library must be placed in a non-standard +# library path (i.e. not under /system/lib +# $1: library sub-path,relative to /system/lib +# For example: $(call emugl-set-shared-library-subpath,egl) +emugl-set-shared-library-subpath = \ + $(eval LOCAL_MODULE_RELATIVE_PATH := $1)\ + $(eval _emugl.$(LOCAL_MODULE).moved := true) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/host/include/libOpenglRender/IOStream.h b/src/type3_AndroidCloud/anbox-master/android/opengl/host/include/libOpenglRender/IOStream.h new file mode 100644 index 0000000..445ec17 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/host/include/libOpenglRender/IOStream.h @@ -0,0 +1,102 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __IO_STREAM_H__ +#define __IO_STREAM_H__ + +#include +#include + +#include "ErrorLog.h" + +class IOStream { +public: + + IOStream(size_t bufSize) { + m_buf = NULL; + m_bufsize = bufSize; + m_free = 0; + } + + virtual void *allocBuffer(size_t minSize) = 0; + virtual int commitBuffer(size_t size) = 0; + virtual const unsigned char *readFully( void *buf, size_t len) = 0; + virtual const unsigned char *read( void *buf, size_t *inout_len) = 0; + virtual int writeFully(const void* buf, size_t len) = 0; + + virtual ~IOStream() { + + // NOTE: m_buf is 'owned' by the child class thus we expect it to be released by it + } + + unsigned char *alloc(size_t len) { + + if (m_buf && len > m_free) { + if (flush() < 0) { + ERR("Failed to flush in alloc\n"); + return NULL; // we failed to flush so something is wrong + } + } + + if (!m_buf || len > m_bufsize) { + int allocLen = m_bufsize < len ? len : m_bufsize; + m_buf = (unsigned char *)allocBuffer(allocLen); + if (!m_buf) { + ERR("Alloc (%u bytes) failed\n", allocLen); + return NULL; + } + m_bufsize = m_free = allocLen; + } + + unsigned char *ptr; + + ptr = m_buf + (m_bufsize - m_free); + m_free -= len; + + return ptr; + } + + int flush() { + + if (!m_buf || m_free == m_bufsize) return 0; + + int stat = commitBuffer(m_bufsize - m_free); + m_buf = NULL; + m_free = 0; + return stat; + } + + const unsigned char *readback(void *buf, size_t len) { + flush(); + return readFully(buf, len); + } + + +private: + unsigned char *m_buf; + size_t m_bufsize; + size_t m_free; +}; + +// +// When a client opens a connection to the renderer, it should +// send unsigned int value indicating the "clientFlags". +// The following are the bitmask of the clientFlags. +// currently only one bit is used which flags the server +// it should exit. +// +#define IOSTREAM_CLIENT_EXIT_SERVER 1 + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Android.mk new file mode 100644 index 0000000..2104398 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Android.mk @@ -0,0 +1,23 @@ +# This build script corresponds to a library containing many definitions +# common to both the guest and the host. They relate to +# +LOCAL_PATH := $(call my-dir) + +commonSources := \ + GLClientState.cpp \ + ChecksumCalculator.cpp \ + GLSharedGroup.cpp \ + glUtils.cpp \ + SocketStream.cpp \ + TcpStream.cpp \ + +### CodecCommon guest ############################################## +$(call emugl-begin-static-library,libOpenglCodecCommon) + +LOCAL_SRC_FILES := $(commonSources) + +LOCAL_CFLAGS += -DLOG_TAG=\"eglCodecCommon\" + +$(call emugl-export,SHARED_LIBRARIES,libcutils libutils liblog) +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +$(call emugl-end-module) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.cpp new file mode 100644 index 0000000..60940b8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.cpp @@ -0,0 +1,154 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "ChecksumCalculator.h" + +#include +#include +#include + +// Checklist when implementing new protocol: +// 1. update CHECKSUMHELPER_MAX_VERSION +// 2. update maxChecksumSize() +// 3. update checksumByteSize() +// 4. update addBuffer, writeChecksum, resetChecksum, validate + +// change CHECKSUMHELPER_MAX_VERSION when you want to update the protocol version +#define CHECKSUMHELPER_MAX_VERSION 1 + +// checksum buffer size +// Please add a new checksum buffer size when implementing a new protocol, +// as well as modifying the maxChecksumSize function. +static const size_t kV1ChecksumSize = 8; + +static constexpr size_t maxChecksumSize() { + return 0 > kV1ChecksumSize ? 0 : kV1ChecksumSize; +} + +static const size_t kMaxChecksumSize = maxChecksumSize(); + +// utility macros to create checksum string at compilation time +#define CHECKSUMHELPER_VERSION_STR_PREFIX "ANDROID_EMU_CHECKSUM_HELPER_v" +#define CHECKSUMHELPER_MACRO_TO_STR(x) #x +#define CHECKSUMHELPER_MACRO_VAL_TO_STR(x) CHECKSUMHELPER_MACRO_TO_STR(x) + +static const uint32_t kMaxVersion = CHECKSUMHELPER_MAX_VERSION; +static const char* kMaxVersionStrPrefix = CHECKSUMHELPER_VERSION_STR_PREFIX; +static const char* kMaxVersionStr = CHECKSUMHELPER_VERSION_STR_PREFIX CHECKSUMHELPER_MACRO_VAL_TO_STR(CHECKSUMHELPER_MAX_VERSION); + +#undef CHECKSUMHELPER_MAX_VERSION +#undef CHECKSUMHELPER_VERSION_STR_PREFIX +#undef CHECKSUMHELPER_MACRO_TO_STR +#undef CHECKSUMHELPER_MACRO_VAL_TO_STR + +uint32_t ChecksumCalculator::getMaxVersion() {return kMaxVersion;} +const char* ChecksumCalculator::getMaxVersionStr() {return kMaxVersionStr;} +const char* ChecksumCalculator::getMaxVersionStrPrefix() {return kMaxVersionStrPrefix;} + +bool ChecksumCalculator::setVersion(uint32_t version) { + if (version > kMaxVersion) { // unsupported version + LOG_CHECKSUMHELPER("%s: ChecksumCalculator Set Unsupported version Version %d\n", + __FUNCTION__, m_version); + return false; + } + if (m_isEncodingChecksum) { // setVersion is called in the middle of encoding checksums + LOG_CHECKSUMHELPER("%s: called between addBuffer and writeChecksum\n", + __FUNCTION__); + return false; + } + m_version = version; + LOG_CHECKSUMHELPER("%s: ChecksumCalculator Set Version %d\n", __FUNCTION__, + m_version); + return true; +} + +size_t ChecksumCalculator::checksumByteSize() const { + switch (m_version) { + case 0: + return 0; + case 1: + return sizeof(uint32_t) + sizeof(m_numWrite); + default: + return 0; + } +} + +void ChecksumCalculator::addBuffer(const void* buf, size_t packetLen) { + m_isEncodingChecksum = true; + switch (m_version) { + case 1: + m_v1BufferTotalLength += packetLen; + break; + } +} + +bool ChecksumCalculator::writeChecksum(void* outputChecksum, size_t outputChecksumLen) { + if (outputChecksumLen < checksumByteSize()) return false; + char *checksumPtr = (char *)outputChecksum; + switch (m_version) { + case 1: { // protocol v1 is to reverse the packetLen and write it at the end + uint32_t val = computeV1Checksum(); + memcpy(checksumPtr, &val, sizeof(val)); + memcpy(checksumPtr+sizeof(val), &m_numWrite, sizeof(m_numWrite)); + break; + } + } + resetChecksum(); + m_numWrite++; + return true; +} + +void ChecksumCalculator::resetChecksum() { + switch (m_version) { + case 1: + m_v1BufferTotalLength = 0; + break; + } + m_isEncodingChecksum = false; +} + +bool ChecksumCalculator::validate(const void* expectedChecksum, size_t expectedChecksumLen) { + size_t checksumSize = checksumByteSize(); + if (expectedChecksumLen != checksumSize) { + m_numRead++; + resetChecksum(); + return false; + } + // buffers for computing the checksum + unsigned char sChecksumBuffer[kMaxChecksumSize]; + switch (m_version) { + case 1: { + uint32_t val = computeV1Checksum(); + memcpy(sChecksumBuffer, &val, sizeof(val)); + memcpy(sChecksumBuffer+sizeof(val), &m_numRead, sizeof(m_numRead)); + break; + } + } + bool isValid = !memcmp(sChecksumBuffer, expectedChecksum, checksumSize); + m_numRead++; + resetChecksum(); + return isValid; +} + +uint32_t ChecksumCalculator::computeV1Checksum() { + uint32_t revLen = m_v1BufferTotalLength; + revLen = (revLen & 0xffff0000) >> 16 | (revLen & 0x0000ffff) << 16; + revLen = (revLen & 0xff00ff00) >> 8 | (revLen & 0x00ff00ff) << 8; + revLen = (revLen & 0xf0f0f0f0) >> 4 | (revLen & 0x0f0f0f0f) << 4; + revLen = (revLen & 0xcccccccc) >> 2 | (revLen & 0x33333333) << 2; + revLen = (revLen & 0xaaaaaaaa) >> 1 | (revLen & 0x55555555) << 1; + return revLen; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.h new file mode 100644 index 0000000..4cc231a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ChecksumCalculator.h @@ -0,0 +1,181 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include +#include + +// Set TRACE_CHECKSUMHELPER to 1 to debug creation/destruction of GLprotocol +// instances. +#define TRACE_CHECKSUMHELPER 0 + +#if TRACE_CHECKSUMHELPER +#define LOG_CHECKSUMHELPER(x...) fprintf(stderr, x) +#else +#define LOG_CHECKSUMHELPER(x...) +#endif + +// ChecksumCalculator adds checksum as an array of bytes to GL pipe communication, which +// size depends on the protocol version. Each pipe should use one ChecksumCalculator. +// It can: +// (1) take a list of buffers one by one and compute their checksum string, +// in this case the checksum should be as the data in those buffers are +// concatenated; +// (2) compute the checksum of the buffer list, then either write them into +// a buffer provided by user, or compare it against a checksum provided +// by user +// (3) support different checksum version in future. +// +// For backward compatibility, checksum version 0 behaves the same as there is +// no checksum (i.e., checksumByteSize returns 0, validate always returns true, +// addBuffer and writeCheckSum does nothing). +// +// Notice that to detect package lost, ChecksumCalculator also keeps track of how +// many times it generates/validates checksums, and might use it as part of the +// checksum. +// +// To evaluate checksums from a list of data buffers buf1, buf2... Please call +// addBuffer(buf1, buf1len), addBuffer(buf2, buf2len) ... in order. +// Then if the checksum needs to be encoded into a buffer, one needs to allocate +// a checksum buffer with size checksumByteSize(), and call +// writeChecksum(checksumBuffer) to write the checksum to the buffer. +// If the checksum needs to be validated against an existing one, one needs to +// call validate(existChecksum, existChecksumLen). +// +// The checksum generator and validator must be set to the same version, and +// the validator must check ALL checksums in the order they are generated, +// otherwise the validation function will return false. +// +// It is allowed to change the checksum version between calculating two +// checksums. This is designed for backward compatibility reason. +// +// Example 1, encoding and decoding: +// +// bool testChecksum(void* buf, size_t bufLen) { +// // encoding message +// ChecksumCalculator encoder; +// encoder.setVersion(1); +// encoder.addBuffer(buf, bufLen); +// std::vector message(bufLen + encoder.checksumByteSize()); +// memcpy(&message[0], buf, bufLen); +// encoder.writeChecksum(&message[0] + bufLen, encoder.checksumByteSize()); +// +// // decoding message +// ChecksumCalculator decoder; +// decoder.setVersion(1); +// decoder.addBuffer(&message[0], bufLen); +// return decoder.validate(&message[0] + bufLen, decoder.checksumByteSize()); +// } +// The return value is true. +// +// Example 2, decoding will fail if the order of messages is wrong: +// +// bool testChecksumOrder(void* buf1, size_t bufLen1, +// void* buf2, size_t bufLen2) { +// // encoding messages +// ChecksumCalculator encoder; +// encoder.setVersion(1); +// +// std::vector message1(bufLen1 + encoder.checksumByteSize()); +// std::vector message2(bufLen2 + encoder.checksumByteSize()); +// +// encoder.addBuffer(buf1, bufLen1); +// std::vector message1(bufLen1 + encoder.checksumByteSize()); +// memcpy(&message1[0], buf1, bufLen1); +// encoder.writeChecksum(&message1[0] + bufLen1, encoder.checksumByteSize()); +// +// encoder.addBuffer(buf2, bufLen2); +// std::vector message2(bufLen2 + encoder.checksumByteSize()); +// memcpy(&message2[0], buf2, bufLen2); +// encoder.writeChecksum(&message2[0] + bufLen2, encoder.checksumByteSize()); +// +// // decoding messages +// ChecksumCalculator decoder; +// decoder.setVersion(1); +// decoder.addBuffer(&message2[0], bufLen2); +// // returns false because the decoding order is not consistent with +// // encoding order +// if (!decoder.validate(&message2[0]+bufLen2, decoder.checksumByteSize())) { +// return false; +// } +// +// decoder.addBuffer(&message1[0], bufLen1); +// if (!decoder.validate(&message1[0]+bufLen1, decoder.checksumByteSize())) { +// return false; +// } +// +// return false; +// } + +class ChecksumCalculator { +public: + // Get and set current checksum version + uint32_t getVersion() const { return m_version; } + // Call setVersion to set a checksum version. It should be called before + // addBuffer(), writeChecksum() and validate(). And it should be called + // exact once per rendering thread if both host and guest support checksum. + // It won't be called if either host or guest does not support checksum. + bool setVersion(uint32_t version); + + // Maximum supported checksum version + static uint32_t getMaxVersion(); + // A version string that looks like "ANDROID_EMU_CHECKSUM_HELPER_v1" + // Used multiple times when the guest queries the maximum supported version + // from the host. + // The library owns the returned pointer. The returned pointer will be + // deconstructed when unloading library. + static const char* getMaxVersionStr(); + static const char* getMaxVersionStrPrefix(); + + // Size of checksum in the current version + size_t checksumByteSize() const; + + // Update the current checksum value from the data + // at |buf| of |bufLen| bytes. Once all buffers + // have been added, call writeChecksum() to store + // the final checksum value and reset its state. + void addBuffer(const void* buf, size_t bufLen); + // Write the checksum from the list of buffers to outputChecksum + // Will reset the list of buffers by calling resetChecksum. + // Return false if the buffer is not long enough + // Please query buffer size from checksumByteSize() + bool writeChecksum(void* outputChecksum, size_t outputChecksumLen); + // Restore the states for computing checksums. + // Automatically called at the end of writeChecksum and validate. + // Can also be used to abandon the current checksum being calculated. + // Notes: it doesn't update the internal read / write counter + void resetChecksum(); + + // Calculate the checksum from the list of buffers and + // compare it with the checksum encoded in expectedChecksum + // Will reset the list of buffers by calling resetChecksum. + bool validate(const void* expectedChecksum, size_t expectedChecksumLen); +protected: + uint32_t m_version = 0; + // A temporary state used to compute the total length of a list of buffers, + // if addBuffer is called. + uint32_t m_numRead = 0; + uint32_t m_numWrite = 0; + // m_isEncodingChecksum is true when between addBuffer and writeChecksum + bool m_isEncodingChecksum = false; +private: + // Compute a 32bit checksum + // Used in protocol v1 + uint32_t computeV1Checksum(); + // The buffer used in protocol version 1 to compute checksum. + uint32_t m_v1BufferTotalLength = 0; +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ErrorLog.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ErrorLog.h new file mode 100644 index 0000000..d2388e6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/ErrorLog.h @@ -0,0 +1,37 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _ERROR_LOG_H_ +#define _ERROR_LOG_H_ + +#if defined(__ANDROID__) +# include +# define ERR(...) ALOGE(__VA_ARGS__) +# ifdef EMUGL_DEBUG +# define DBG(...) ALOGD(__VA_ARGS__) +# else +# define DBG(...) ((void)0) +# endif +#else +# include +# define ERR(...) fprintf(stderr, __VA_ARGS__) +# ifdef EMUGL_DEBUG +# define DBG(...) fprintf(stderr, __VA_ARGS__) +# else +# define DBG(...) ((void)0) +# endif +#endif + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/FixedBuffer.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/FixedBuffer.h new file mode 100644 index 0000000..7026396 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/FixedBuffer.h @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _FIXED_BUFFER_H +#define _FIXED_BUFFER_H + +class FixedBuffer { +public: + FixedBuffer(size_t initialSize = 0) { + m_buffer = NULL; + m_bufferLen = initialSize; + alloc(m_bufferLen); + } + + ~FixedBuffer() { + delete [] m_buffer; + m_bufferLen = 0; + } + + void * alloc(size_t size) { + if (m_bufferLen >= size) + return (void *)(m_buffer); + + if (m_buffer != NULL) + delete[] m_buffer; + + m_bufferLen = size; + m_buffer = new unsigned char[m_bufferLen]; + if (m_buffer == NULL) + m_bufferLen = 0; + + return m_buffer; + } + void *ptr() { return m_buffer; } + size_t len() { return m_bufferLen; } +private: + unsigned char *m_buffer; + size_t m_bufferLen; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.cpp new file mode 100644 index 0000000..638eb4c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.cpp @@ -0,0 +1,422 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "GLClientState.h" +#include "ErrorLog.h" +#include +#include +#include +#include "glUtils.h" +#include + +#ifndef MAX +#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#endif + +GLClientState::GLClientState(int nLocations) +{ + if (nLocations < LAST_LOCATION) { + nLocations = LAST_LOCATION; + } + m_nLocations = nLocations; + m_states = new VertexAttribState[m_nLocations]; + for (int i = 0; i < m_nLocations; i++) { + m_states[i].enabled = 0; + m_states[i].enableDirty = false; + m_states[i].data = 0; + } + m_currentArrayVbo = 0; + m_currentIndexVbo = 0; + // init gl constans; + m_states[VERTEX_LOCATION].glConst = GL_VERTEX_ARRAY; + m_states[NORMAL_LOCATION].glConst = GL_NORMAL_ARRAY; + m_states[COLOR_LOCATION].glConst = GL_COLOR_ARRAY; + m_states[POINTSIZE_LOCATION].glConst = GL_POINT_SIZE_ARRAY_OES; + m_states[TEXCOORD0_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[TEXCOORD1_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[TEXCOORD2_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[TEXCOORD3_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[TEXCOORD4_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[TEXCOORD5_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[TEXCOORD6_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[TEXCOORD7_LOCATION].glConst = GL_TEXTURE_COORD_ARRAY; + m_states[MATRIXINDEX_LOCATION].glConst = GL_MATRIX_INDEX_ARRAY_OES; + m_states[WEIGHT_LOCATION].glConst = GL_WEIGHT_ARRAY_OES; + m_activeTexture = 0; + m_currentProgram = 0; + + m_pixelStore.unpack_alignment = 4; + m_pixelStore.pack_alignment = 4; + + memset(m_tex.unit, 0, sizeof(m_tex.unit)); + m_tex.activeUnit = &m_tex.unit[0]; + m_tex.textures = NULL; + m_tex.numTextures = 0; + m_tex.allocTextures = 0; + + m_maxVertexAttribsDirty = true; +} + +GLClientState::~GLClientState() +{ + delete m_states; +} + +void GLClientState::enable(int location, int state) +{ + if (!validLocation(location)) { + return; + } + + m_states[location].enableDirty |= (state != m_states[location].enabled); + m_states[location].enabled = state; +} + +void GLClientState::setState(int location, int size, GLenum type, GLboolean normalized, GLsizei stride, const void *data) +{ + if (!validLocation(location)) { + return; + } + m_states[location].size = size; + m_states[location].type = type; + m_states[location].stride = stride; + m_states[location].data = (void*)data; + m_states[location].bufferObject = m_currentArrayVbo; + m_states[location].elementSize = size ? (glSizeof(type) * size) : 0; + m_states[location].normalized = normalized; +} + +void GLClientState::setBufferObject(int location, GLuint id) +{ + if (!validLocation(location)) { + return; + } + + m_states[location].bufferObject = id; +} + +const GLClientState::VertexAttribState * GLClientState::getState(int location) +{ + if (!validLocation(location)) { + return NULL; + } + return & m_states[location]; +} + +const GLClientState::VertexAttribState * GLClientState::getStateAndEnableDirty(int location, bool *enableChanged) +{ + if (!validLocation(location)) { + return NULL; + } + + if (enableChanged) { + *enableChanged = m_states[location].enableDirty; + } + + m_states[location].enableDirty = false; + return & m_states[location]; +} + +int GLClientState::getLocation(GLenum loc) +{ + int retval; + + switch(loc) { + case GL_VERTEX_ARRAY: + retval = int(VERTEX_LOCATION); + break; + case GL_NORMAL_ARRAY: + retval = int(NORMAL_LOCATION); + break; + case GL_COLOR_ARRAY: + retval = int(COLOR_LOCATION); + break; + case GL_POINT_SIZE_ARRAY_OES: + retval = int(POINTSIZE_LOCATION); + break; + case GL_TEXTURE_COORD_ARRAY: + retval = int (TEXCOORD0_LOCATION + m_activeTexture); + break; + case GL_MATRIX_INDEX_ARRAY_OES: + retval = int (MATRIXINDEX_LOCATION); + break; + case GL_WEIGHT_ARRAY_OES: + retval = int (WEIGHT_LOCATION); + break; + default: + retval = loc; + } + return retval; +} + +void GLClientState::getClientStatePointer(GLenum pname, GLvoid** params) +{ + const GLClientState::VertexAttribState *state = NULL; + switch (pname) { + case GL_VERTEX_ARRAY_POINTER: { + state = getState(GLClientState::VERTEX_LOCATION); + break; + } + case GL_NORMAL_ARRAY_POINTER: { + state = getState(GLClientState::NORMAL_LOCATION); + break; + } + case GL_COLOR_ARRAY_POINTER: { + state = getState(GLClientState::COLOR_LOCATION); + break; + } + case GL_TEXTURE_COORD_ARRAY_POINTER: { + state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); + break; + } + case GL_POINT_SIZE_ARRAY_POINTER_OES: { + state = getState(GLClientState::POINTSIZE_LOCATION); + break; + } + case GL_MATRIX_INDEX_ARRAY_POINTER_OES: { + state = getState(GLClientState::MATRIXINDEX_LOCATION); + break; + } + case GL_WEIGHT_ARRAY_POINTER_OES: { + state = getState(GLClientState::WEIGHT_LOCATION); + break; + } + } + if (state && params) + *params = state->data; +} + +int GLClientState::setPixelStore(GLenum param, GLint value) +{ + int retval = 0; + switch(param) { + case GL_UNPACK_ALIGNMENT: + if (value == 1 || value == 2 || value == 4 || value == 8) { + m_pixelStore.unpack_alignment = value; + } else { + retval = GL_INVALID_VALUE; + } + break; + case GL_PACK_ALIGNMENT: + if (value == 1 || value == 2 || value == 4 || value == 8) { + m_pixelStore.pack_alignment = value; + } else { + retval = GL_INVALID_VALUE; + } + break; + default: + retval = GL_INVALID_ENUM; + } + return retval; +} + + + + +size_t GLClientState::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const +{ + if (width <= 0 || height <= 0) return 0; + + int pixelsize = glUtilsPixelBitSize(format, type) >> 3; + + int alignment = pack ? m_pixelStore.pack_alignment : m_pixelStore.unpack_alignment; + + if (pixelsize == 0 ) { + ERR("unknown pixel size: width: %d height: %d format: %d type: %d pack: %d align: %d\n", + width, height, format, type, pack, alignment); + } + size_t linesize = pixelsize * width; + size_t aligned_linesize = int(linesize / alignment) * alignment; + if (aligned_linesize < linesize) { + aligned_linesize += alignment; + } + return aligned_linesize * height; +} + +GLenum GLClientState::setActiveTextureUnit(GLenum texture) +{ + GLuint unit = texture - GL_TEXTURE0; + if (unit >= MAX_TEXTURE_UNITS) { + return GL_INVALID_ENUM; + } + m_tex.activeUnit = &m_tex.unit[unit]; + return GL_NO_ERROR; +} + +GLenum GLClientState::getActiveTextureUnit() const +{ + return GL_TEXTURE0 + (m_tex.activeUnit - &m_tex.unit[0]); +} + +void GLClientState::enableTextureTarget(GLenum target) +{ + switch (target) { + case GL_TEXTURE_2D: + m_tex.activeUnit->enables |= (1u << TEXTURE_2D); + break; + case GL_TEXTURE_EXTERNAL_OES: + m_tex.activeUnit->enables |= (1u << TEXTURE_EXTERNAL); + break; + } +} + +void GLClientState::disableTextureTarget(GLenum target) +{ + switch (target) { + case GL_TEXTURE_2D: + m_tex.activeUnit->enables &= ~(1u << TEXTURE_2D); + break; + case GL_TEXTURE_EXTERNAL_OES: + m_tex.activeUnit->enables &= ~(1u << TEXTURE_EXTERNAL); + break; + } +} + +GLenum GLClientState::getPriorityEnabledTarget(GLenum allDisabled) const +{ + unsigned int enables = m_tex.activeUnit->enables; + if (enables & (1u << TEXTURE_EXTERNAL)) { + return GL_TEXTURE_EXTERNAL_OES; + } else if (enables & (1u << TEXTURE_2D)) { + return GL_TEXTURE_2D; + } else { + return allDisabled; + } +} + +int GLClientState::compareTexId(const void* pid, const void* prec) +{ + const GLuint* id = (const GLuint*)pid; + const TextureRec* rec = (const TextureRec*)prec; + return (GLint)(*id) - (GLint)rec->id; +} + +GLenum GLClientState::bindTexture(GLenum target, GLuint texture, + GLboolean* firstUse) +{ + GLboolean first = GL_FALSE; + TextureRec* texrec = NULL; + if (texture != 0) { + if (m_tex.textures) { + texrec = (TextureRec*)bsearch(&texture, m_tex.textures, + m_tex.numTextures, sizeof(TextureRec), compareTexId); + } + if (!texrec) { + if (!(texrec = addTextureRec(texture, target))) { + return GL_OUT_OF_MEMORY; + } + first = GL_TRUE; + } + if (target != texrec->target) { + return GL_INVALID_OPERATION; + } + } + + switch (target) { + case GL_TEXTURE_2D: + m_tex.activeUnit->texture[TEXTURE_2D] = texture; + break; + case GL_TEXTURE_EXTERNAL_OES: + m_tex.activeUnit->texture[TEXTURE_EXTERNAL] = texture; + break; + } + + if (firstUse) { + *firstUse = first; + } + + return GL_NO_ERROR; +} + +GLClientState::TextureRec* GLClientState::addTextureRec(GLuint id, + GLenum target) +{ + if (m_tex.numTextures == m_tex.allocTextures) { + const GLuint MAX_TEXTURES = 0xFFFFFFFFu; + + GLuint newAlloc; + if (MAX_TEXTURES - m_tex.allocTextures >= m_tex.allocTextures) { + newAlloc = MAX(4, 2 * m_tex.allocTextures); + } else { + if (m_tex.allocTextures == MAX_TEXTURES) { + return NULL; + } + newAlloc = MAX_TEXTURES; + } + + TextureRec* newTextures = (TextureRec*)realloc(m_tex.textures, + newAlloc * sizeof(TextureRec)); + if (!newTextures) { + return NULL; + } + + m_tex.textures = newTextures; + m_tex.allocTextures = newAlloc; + } + + TextureRec* tex = m_tex.textures + m_tex.numTextures; + TextureRec* prev = tex - 1; + while (tex != m_tex.textures && id < prev->id) { + *tex-- = *prev--; + } + tex->id = id; + tex->target = target; + m_tex.numTextures++; + + return tex; +} + +GLuint GLClientState::getBoundTexture(GLenum target) const +{ + switch (target) { + case GL_TEXTURE_2D: + return m_tex.activeUnit->texture[TEXTURE_2D]; + case GL_TEXTURE_EXTERNAL_OES: + return m_tex.activeUnit->texture[TEXTURE_EXTERNAL]; + default: + return 0; + } +} + +void GLClientState::deleteTextures(GLsizei n, const GLuint* textures) +{ + // Updating the textures array could be made more efficient when deleting + // several textures: + // - compacting the array could be done in a single pass once the deleted + // textures are marked, or + // - could swap deleted textures to the end and re-sort. + TextureRec* texrec; + for (const GLuint* texture = textures; texture != textures + n; texture++) { + texrec = (TextureRec*)bsearch(texture, m_tex.textures, + m_tex.numTextures, sizeof(TextureRec), compareTexId); + if (texrec) { + const TextureRec* end = m_tex.textures + m_tex.numTextures; + memmove(texrec, texrec + 1, + (end - texrec - 1) * sizeof(TextureRec)); + m_tex.numTextures--; + + for (TextureUnit* unit = m_tex.unit; + unit != m_tex.unit + MAX_TEXTURE_UNITS; + unit++) + { + if (unit->texture[TEXTURE_2D] == *texture) { + unit->texture[TEXTURE_2D] = 0; + } else if (unit->texture[TEXTURE_EXTERNAL] == *texture) { + unit->texture[TEXTURE_EXTERNAL] = 0; + } + } + } + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.h new file mode 100644 index 0000000..8e95c37 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLClientState.h @@ -0,0 +1,462 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GL_CLIENT_STATE_H_ +#define _GL_CLIENT_STATE_H_ + +#define GL_API +#ifndef ANDROID +#define GL_APIENTRY +#define GL_APIENTRYP +#endif + +#include +#include +#include +#include + +#include +#include +#include "ErrorLog.h" +#include "codec_defs.h" + +class GLClientState { +public: + typedef enum { + VERTEX_LOCATION = 0, + NORMAL_LOCATION = 1, + COLOR_LOCATION = 2, + POINTSIZE_LOCATION = 3, + TEXCOORD0_LOCATION = 4, + TEXCOORD1_LOCATION = 5, + TEXCOORD2_LOCATION = 6, + TEXCOORD3_LOCATION = 7, + TEXCOORD4_LOCATION = 8, + TEXCOORD5_LOCATION = 9, + TEXCOORD6_LOCATION = 10, + TEXCOORD7_LOCATION = 11, + MATRIXINDEX_LOCATION = 12, + WEIGHT_LOCATION = 13, + LAST_LOCATION = 14 + } StateLocation; + + typedef struct { + GLint enabled; + GLint size; + GLenum type; + GLsizei stride; + void *data; + GLuint bufferObject; + GLenum glConst; + unsigned int elementSize; + bool enableDirty; // true if any enable state has changed since last draw + bool normalized; + } VertexAttribState; + + typedef struct { + int unpack_alignment; + int pack_alignment; + } PixelStoreState; + + enum { + MAX_TEXTURE_UNITS = 32, + }; + +public: + GLClientState(int nLocations = CODEC_MAX_VERTEX_ATTRIBUTES); + ~GLClientState(); + int nLocations() { return m_nLocations; } + const PixelStoreState *pixelStoreState() { return &m_pixelStore; } + int setPixelStore(GLenum param, GLint value); + GLuint currentArrayVbo() { return m_currentArrayVbo; } + GLuint currentIndexVbo() { return m_currentIndexVbo; } + void enable(int location, int state); + void setState(int location, int size, GLenum type, GLboolean normalized, GLsizei stride, const void *data); + void setBufferObject(int location, GLuint id); + const VertexAttribState *getState(int location); + const VertexAttribState *getStateAndEnableDirty(int location, bool *enableChanged); + int getLocation(GLenum loc); + void setActiveTexture(int texUnit) {m_activeTexture = texUnit; }; + int getActiveTexture() const { return m_activeTexture; } + void setMaxVertexAttribs(int val) { + m_maxVertexAttribs = val; + m_maxVertexAttribsDirty = false; + } + + void unBindBuffer(GLuint id) + { + if (m_currentArrayVbo == id) m_currentArrayVbo = 0; + else if (m_currentIndexVbo == id) m_currentIndexVbo = 0; + } + + int bindBuffer(GLenum target, GLuint id) + { + int err = 0; + switch(target) { + case GL_ARRAY_BUFFER: + m_currentArrayVbo = id; + break; + case GL_ELEMENT_ARRAY_BUFFER: + m_currentIndexVbo = id; + break; + default: + err = -1; + } + return err; + } + + int getBuffer(GLenum target) + { + int ret=0; + switch (target) { + case GL_ARRAY_BUFFER: + ret = m_currentArrayVbo; + break; + case GL_ELEMENT_ARRAY_BUFFER: + ret = m_currentIndexVbo; + break; + default: + ret = -1; + } + return ret; + } + size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const; + + void setCurrentProgram(GLint program) { m_currentProgram = program; } + GLint currentProgram() const { return m_currentProgram; } + + /* OES_EGL_image_external + * + * These functions manipulate GL state which interacts with the + * OES_EGL_image_external extension, to support client-side emulation on + * top of host implementations that don't have it. + * + * Most of these calls should only be used with TEXTURE_2D or + * TEXTURE_EXTERNAL_OES texture targets; TEXTURE_CUBE_MAP or other extension + * targets should bypass this. An exception is bindTexture(), which should + * see all glBindTexture() calls for any target. + */ + + // glActiveTexture(GL_TEXTURE0 + i) + // Sets the active texture unit. Up to MAX_TEXTURE_UNITS are supported. + GLenum setActiveTextureUnit(GLenum texture); + GLenum getActiveTextureUnit() const; + + // glEnable(GL_TEXTURE_(2D|EXTERNAL_OES)) + void enableTextureTarget(GLenum target); + + // glDisable(GL_TEXTURE_(2D|EXTERNAL_OES)) + void disableTextureTarget(GLenum target); + + // Implements the target priority logic: + // * Return GL_TEXTURE_EXTERNAL_OES if enabled, else + // * Return GL_TEXTURE_2D if enabled, else + // * Return the allDisabled value. + // For some cases passing GL_TEXTURE_2D for allDisabled makes callee code + // simpler; for other cases passing a recognizable enum like GL_ZERO or + // GL_INVALID_ENUM is appropriate. + GLenum getPriorityEnabledTarget(GLenum allDisabled) const; + + // glBindTexture(GL_TEXTURE_*, ...) + // Set the target binding of the active texture unit to texture. Returns + // GL_NO_ERROR on success or GL_INVALID_OPERATION if the texture has + // previously been bound to a different target. If firstUse is not NULL, + // it is set to indicate whether this is the first use of the texture. + // For accurate error detection, bindTexture should be called for *all* + // targets, not just 2D and EXTERNAL_OES. + GLenum bindTexture(GLenum target, GLuint texture, GLboolean* firstUse); + + // Return the texture currently bound to GL_TEXTURE_(2D|EXTERNAL_OES). + GLuint getBoundTexture(GLenum target) const; + + // glDeleteTextures(...) + // Remove references to the to-be-deleted textures. + void deleteTextures(GLsizei n, const GLuint* textures); + +private: + PixelStoreState m_pixelStore; + VertexAttribState *m_states; + int m_maxVertexAttribs; + bool m_maxVertexAttribsDirty; + int m_nLocations; + GLuint m_currentArrayVbo; + GLuint m_currentIndexVbo; + int m_activeTexture; + GLint m_currentProgram; + + bool validLocation(int location) { return (location >= 0 && location < m_nLocations); } + + enum TextureTarget { + TEXTURE_2D = 0, + TEXTURE_EXTERNAL = 1, + TEXTURE_TARGET_COUNT + }; + struct TextureUnit { + unsigned int enables; + GLuint texture[TEXTURE_TARGET_COUNT]; + }; + struct TextureRec { + GLuint id; + GLenum target; + }; + struct TextureState { + TextureUnit unit[MAX_TEXTURE_UNITS]; + TextureUnit* activeUnit; + TextureRec* textures; + GLuint numTextures; + GLuint allocTextures; + }; + TextureState m_tex; + + static int compareTexId(const void* pid, const void* prec); + TextureRec* addTextureRec(GLuint id, GLenum target); + +public: + void getClientStatePointer(GLenum pname, GLvoid** params); + + template + int getVertexAttribParameter(GLuint index, GLenum param, T *ptr) + { + bool handled = true; + const VertexAttribState *vertexAttrib = getState(index); + if (vertexAttrib == NULL) { + ERR("getVeterxAttriParameter for non existant index %d\n", index); + // set gl error; + return handled; + } + + switch(param) { + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + *ptr = (T)(vertexAttrib->bufferObject); + break; + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: + *ptr = (T)(vertexAttrib->enabled); + break; + case GL_VERTEX_ATTRIB_ARRAY_SIZE: + *ptr = (T)(vertexAttrib->size); + break; + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: + *ptr = (T)(vertexAttrib->stride); + break; + case GL_VERTEX_ATTRIB_ARRAY_TYPE: + *ptr = (T)(vertexAttrib->type); + break; + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: + *ptr = (T)(vertexAttrib->normalized); + break; + case GL_CURRENT_VERTEX_ATTRIB: + handled = false; + break; + default: + handled = false; + ERR("unknown vertex-attrib parameter param %d\n", param); + } + return handled; + } + + template + bool getClientStateParameter(GLenum param, T* ptr) + { + bool isClientStateParam = false; + switch (param) { + case GL_CLIENT_ACTIVE_TEXTURE: { + GLint tex = getActiveTexture() + GL_TEXTURE0; + *ptr = tex; + isClientStateParam = true; + break; + } + case GL_VERTEX_ARRAY_SIZE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); + *ptr = state->size; + isClientStateParam = true; + break; + } + case GL_VERTEX_ARRAY_TYPE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); + *ptr = state->type; + isClientStateParam = true; + break; + } + case GL_VERTEX_ARRAY_STRIDE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); + *ptr = state->stride; + isClientStateParam = true; + break; + } + case GL_COLOR_ARRAY_SIZE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); + *ptr = state->size; + isClientStateParam = true; + break; + } + case GL_COLOR_ARRAY_TYPE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); + *ptr = state->type; + isClientStateParam = true; + break; + } + case GL_COLOR_ARRAY_STRIDE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); + *ptr = state->stride; + isClientStateParam = true; + break; + } + case GL_NORMAL_ARRAY_TYPE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION); + *ptr = state->type; + isClientStateParam = true; + break; + } + case GL_NORMAL_ARRAY_STRIDE: { + const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION); + *ptr = state->stride; + isClientStateParam = true; + break; + } + case GL_TEXTURE_COORD_ARRAY_SIZE: { + const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); + *ptr = state->size; + isClientStateParam = true; + break; + } + case GL_TEXTURE_COORD_ARRAY_TYPE: { + const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); + *ptr = state->type; + isClientStateParam = true; + break; + } + case GL_TEXTURE_COORD_ARRAY_STRIDE: { + const GLClientState::VertexAttribState *state = getState(getActiveTexture() + GLClientState::TEXCOORD0_LOCATION); + *ptr = state->stride; + isClientStateParam = true; + break; + } + case GL_POINT_SIZE_ARRAY_TYPE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION); + *ptr = state->type; + isClientStateParam = true; + break; + } + case GL_POINT_SIZE_ARRAY_STRIDE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION); + *ptr = state->stride; + isClientStateParam = true; + break; + } + case GL_MATRIX_INDEX_ARRAY_SIZE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); + *ptr = state->size; + isClientStateParam = true; + break; + } + case GL_MATRIX_INDEX_ARRAY_TYPE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); + *ptr = state->type; + isClientStateParam = true; + break; + } + case GL_MATRIX_INDEX_ARRAY_STRIDE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); + *ptr = state->stride; + isClientStateParam = true; + break; + } + case GL_WEIGHT_ARRAY_SIZE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); + *ptr = state->size; + isClientStateParam = true; + break; + } + case GL_WEIGHT_ARRAY_TYPE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); + *ptr = state->type; + isClientStateParam = true; + break; + } + case GL_WEIGHT_ARRAY_STRIDE_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); + *ptr = state->stride; + isClientStateParam = true; + break; + } + case GL_VERTEX_ARRAY_BUFFER_BINDING: { + const GLClientState::VertexAttribState *state = getState(GLClientState::VERTEX_LOCATION); + *ptr = state->bufferObject; + isClientStateParam = true; + break; + } + case GL_NORMAL_ARRAY_BUFFER_BINDING: { + const GLClientState::VertexAttribState *state = getState(GLClientState::NORMAL_LOCATION); + *ptr = state->bufferObject; + isClientStateParam = true; + break; + } + case GL_COLOR_ARRAY_BUFFER_BINDING: { + const GLClientState::VertexAttribState *state = getState(GLClientState::COLOR_LOCATION); + *ptr = state->bufferObject; + isClientStateParam = true; + break; + } + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: { + const GLClientState::VertexAttribState *state = getState(getActiveTexture()+GLClientState::TEXCOORD0_LOCATION); + *ptr = state->bufferObject; + isClientStateParam = true; + break; + } + case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::POINTSIZE_LOCATION); + *ptr = state->bufferObject; + isClientStateParam = true; + break; + } + case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::MATRIXINDEX_LOCATION); + *ptr = state->bufferObject; + isClientStateParam = true; + break; + } + case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES: { + const GLClientState::VertexAttribState *state = getState(GLClientState::WEIGHT_LOCATION); + *ptr = state->bufferObject; + isClientStateParam = true; + break; + } + case GL_ARRAY_BUFFER_BINDING: { + int buffer = getBuffer(GL_ARRAY_BUFFER); + *ptr = buffer; + isClientStateParam = true; + break; + } + case GL_ELEMENT_ARRAY_BUFFER_BINDING: { + int buffer = getBuffer(GL_ELEMENT_ARRAY_BUFFER); + *ptr = buffer; + isClientStateParam = true; + break; + } + case GL_MAX_VERTEX_ATTRIBS: { + if (m_maxVertexAttribsDirty) { + isClientStateParam = false; + } else { + *ptr = m_maxVertexAttribs; + isClientStateParam = true; + } + break; + } + } + return isClientStateParam; + } + +}; +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp new file mode 100644 index 0000000..b079b6d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp @@ -0,0 +1,497 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "GLSharedGroup.h" + +/**** KeyedVector utilities ****/ + +template +static void clearObjectMap(android::DefaultKeyedVector& v) { + for (size_t i = 0; i < v.size(); i++) + delete v.valueAt(i); + v.clear(); +} + +/**** BufferData ****/ + +BufferData::BufferData() : m_size(0) {}; +BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size) +{ + void * buffer = NULL; + if (size>0) buffer = m_fixedBuffer.alloc(size); + if (data) memcpy(buffer, data, size); +} + +/**** ProgramData ****/ +ProgramData::ProgramData() : m_numIndexes(0), + m_initialized(false), + m_locShiftWAR(false) +{ + m_Indexes = NULL; +} + +void ProgramData::initProgramData(GLuint numIndexes) +{ + m_initialized = true; + m_numIndexes = numIndexes; + delete[] m_Indexes; + m_Indexes = new IndexInfo[numIndexes]; + m_locShiftWAR = false; +} + +bool ProgramData::isInitialized() +{ + return m_initialized; +} + +ProgramData::~ProgramData() +{ + delete[] m_Indexes; + m_Indexes = NULL; +} + +void ProgramData::setIndexInfo(GLuint index, GLint base, GLint size, GLenum type) +{ + if (index>=m_numIndexes) + return; + m_Indexes[index].base = base; + m_Indexes[index].size = size; + m_Indexes[index].type = type; + if (index > 0) { + m_Indexes[index].appBase = m_Indexes[index-1].appBase + + m_Indexes[index-1].size; + } + else { + m_Indexes[index].appBase = 0; + } + m_Indexes[index].hostLocsPerElement = 1; + m_Indexes[index].flags = 0; + m_Indexes[index].samplerValue = 0; +} + +void ProgramData::setIndexFlags(GLuint index, GLuint flags) +{ + if (index >= m_numIndexes) + return; + m_Indexes[index].flags |= flags; +} + +GLuint ProgramData::getIndexForLocation(GLint location) +{ + GLuint index = m_numIndexes; + GLint minDist = -1; + for (GLuint i=0;i= 0 && + (minDist < 0 || dist < minDist)) { + index = i; + minDist = dist; + } + } + return index; +} + +GLenum ProgramData::getTypeForLocation(GLint location) +{ + GLuint index = getIndexForLocation(location); + if (index 1) { + m_locShiftWAR = true; + } +} + +GLint ProgramData::locationWARHostToApp(GLint hostLoc, GLint arrIndex) +{ + if (!m_locShiftWAR) return hostLoc; + + GLuint index = getIndexForLocation(hostLoc); + if (index 0) { + m_Indexes[index].hostLocsPerElement = + (hostLoc - m_Indexes[index].base) / arrIndex; + } + return m_Indexes[index].appBase + arrIndex; + } + return -1; +} + +GLint ProgramData::locationWARAppToHost(GLint appLoc) +{ + if (!m_locShiftWAR) return appLoc; + + for(GLuint i=0; i= 0 && elemIndex < m_Indexes[i].size) { + return m_Indexes[i].base + + elemIndex * m_Indexes[i].hostLocsPerElement; + } + } + return -1; +} + +GLint ProgramData::getNextSamplerUniform(GLint index, GLint* val, GLenum* target) +{ + for (GLint i = index + 1; i >= 0 && i < (GLint)m_numIndexes; i++) { + if (m_Indexes[i].type == GL_SAMPLER_2D) { + if (val) *val = m_Indexes[i].samplerValue; + if (target) { + if (m_Indexes[i].flags & INDEX_FLAG_SAMPLER_EXTERNAL) { + *target = GL_TEXTURE_EXTERNAL_OES; + } else { + *target = GL_TEXTURE_2D; + } + } + return i; + } + } + return -1; +} + +bool ProgramData::setSamplerUniform(GLint appLoc, GLint val, GLenum* target) +{ + for (GLuint i = 0; i < m_numIndexes; i++) { + GLint elemIndex = appLoc - m_Indexes[i].appBase; + if (elemIndex >= 0 && elemIndex < m_Indexes[i].size) { + if (m_Indexes[i].type == GL_TEXTURE_2D) { + m_Indexes[i].samplerValue = val; + if (target) { + if (m_Indexes[i].flags & INDEX_FLAG_SAMPLER_EXTERNAL) { + *target = GL_TEXTURE_EXTERNAL_OES; + } else { + *target = GL_TEXTURE_2D; + } + } + return true; + } + } + } + return false; +} + +bool ProgramData::attachShader(GLuint shader) +{ + size_t n = m_shaders.size(); + for (size_t i = 0; i < n; i++) { + if (m_shaders[i] == shader) { + return false; + } + } + // AKA m_shaders.push_back(), but that has an ambiguous call to insertAt() + // due to the default parameters. This is the desired insertAt() overload. + m_shaders.insertAt(shader, m_shaders.size(), 1); + return true; +} + +bool ProgramData::detachShader(GLuint shader) +{ + size_t n = m_shaders.size(); + for (size_t i = 0; i < n; i++) { + if (m_shaders[i] == shader) { + m_shaders.removeAt(i); + return true; + } + } + return false; +} + +/***** GLSharedGroup ****/ + +GLSharedGroup::GLSharedGroup() : + m_buffers(android::DefaultKeyedVector(NULL)), + m_programs(android::DefaultKeyedVector(NULL)), + m_shaders(android::DefaultKeyedVector(NULL)) +{ +} + +GLSharedGroup::~GLSharedGroup() +{ + m_buffers.clear(); + m_programs.clear(); + clearObjectMap(m_buffers); + clearObjectMap(m_programs); + clearObjectMap(m_shaders); +} + +bool GLSharedGroup::isObject(GLuint obj) +{ + android::AutoMutex _lock(m_lock); + return ((m_shaders.valueFor(obj)!=NULL) || (m_programs.valueFor(obj)!=NULL)); +} + +BufferData * GLSharedGroup::getBufferData(GLuint bufferId) +{ + android::AutoMutex _lock(m_lock); + return m_buffers.valueFor(bufferId); +} + +void GLSharedGroup::addBufferData(GLuint bufferId, GLsizeiptr size, void * data) +{ + android::AutoMutex _lock(m_lock); + m_buffers.add(bufferId, new BufferData(size, data)); +} + +void GLSharedGroup::updateBufferData(GLuint bufferId, GLsizeiptr size, void * data) +{ + android::AutoMutex _lock(m_lock); + ssize_t idx = m_buffers.indexOfKey(bufferId); + if (idx >= 0) { + delete m_buffers.valueAt(idx); + m_buffers.editValueAt(idx) = new BufferData(size, data); + } else { + m_buffers.add(bufferId, new BufferData(size, data)); + } +} + +GLenum GLSharedGroup::subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data) +{ + android::AutoMutex _lock(m_lock); + BufferData * buf = m_buffers.valueFor(bufferId); + if ((!buf) || (buf->m_size < offset+size) || (offset < 0) || (size<0)) return GL_INVALID_VALUE; + + //it's safe to update now + memcpy((char*)buf->m_fixedBuffer.ptr() + offset, data, size); + return GL_NO_ERROR; +} + +void GLSharedGroup::deleteBufferData(GLuint bufferId) +{ + android::AutoMutex _lock(m_lock); + ssize_t idx = m_buffers.indexOfKey(bufferId); + if (idx >= 0) { + delete m_buffers.valueAt(idx); + m_buffers.removeItemsAt(idx); + } +} + +void GLSharedGroup::addProgramData(GLuint program) +{ + android::AutoMutex _lock(m_lock); + ProgramData *pData = m_programs.valueFor(program); + if (pData) + { + m_programs.removeItem(program); + delete pData; + } + + m_programs.add(program,new ProgramData()); +} + +void GLSharedGroup::initProgramData(GLuint program, GLuint numIndexes) +{ + android::AutoMutex _lock(m_lock); + ProgramData *pData = m_programs.valueFor(program); + if (pData) + { + pData->initProgramData(numIndexes); + } +} + +bool GLSharedGroup::isProgramInitialized(GLuint program) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + if (pData) + { + return pData->isInitialized(); + } + return false; +} + +void GLSharedGroup::deleteProgramData(GLuint program) +{ + android::AutoMutex _lock(m_lock); + ProgramData *pData = m_programs.valueFor(program); + if (pData) + delete pData; + m_programs.removeItem(program); +} + +void GLSharedGroup::attachShader(GLuint program, GLuint shader) +{ + android::AutoMutex _lock(m_lock); + ProgramData* programData = m_programs.valueFor(program); + ssize_t idx = m_shaders.indexOfKey(shader); + if (programData && idx >= 0) { + if (programData->attachShader(shader)) { + refShaderDataLocked(idx); + } + } +} + +void GLSharedGroup::detachShader(GLuint program, GLuint shader) +{ + android::AutoMutex _lock(m_lock); + ProgramData* programData = m_programs.valueFor(program); + ssize_t idx = m_shaders.indexOfKey(shader); + if (programData && idx >= 0) { + if (programData->detachShader(shader)) { + unrefShaderDataLocked(idx); + } + } +} + +void GLSharedGroup::setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type, const char* name) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + if (pData) + { + pData->setIndexInfo(index,base,size,type); + + if (type == GL_SAMPLER_2D) { + size_t n = pData->getNumShaders(); + for (size_t i = 0; i < n; i++) { + GLuint shaderId = pData->getShader(i); + ShaderData* shader = m_shaders.valueFor(shaderId); + if (!shader) continue; + ShaderData::StringList::iterator nameIter = shader->samplerExternalNames.begin(); + ShaderData::StringList::iterator nameEnd = shader->samplerExternalNames.end(); + while (nameIter != nameEnd) { + if (*nameIter == name) { + pData->setIndexFlags(index, ProgramData::INDEX_FLAG_SAMPLER_EXTERNAL); + break; + } + ++nameIter; + } + } + } + } +} + +GLenum GLSharedGroup::getProgramUniformType(GLuint program, GLint location) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + GLenum type=0; + if (pData) + { + type = pData->getTypeForLocation(location); + } + return type; +} + +bool GLSharedGroup::isProgram(GLuint program) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + return (pData!=NULL); +} + +void GLSharedGroup::setupLocationShiftWAR(GLuint program) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + if (pData) pData->setupLocationShiftWAR(); +} + +GLint GLSharedGroup::locationWARHostToApp(GLuint program, GLint hostLoc, GLint arrIndex) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + if (pData) return pData->locationWARHostToApp(hostLoc, arrIndex); + else return hostLoc; +} + +GLint GLSharedGroup::locationWARAppToHost(GLuint program, GLint appLoc) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + if (pData) return pData->locationWARAppToHost(appLoc); + else return appLoc; +} + +bool GLSharedGroup::needUniformLocationWAR(GLuint program) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + if (pData) return pData->needUniformLocationWAR(); + return false; +} + +GLint GLSharedGroup::getNextSamplerUniform(GLuint program, GLint index, GLint* val, GLenum* target) const +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + return pData ? pData->getNextSamplerUniform(index, val, target) : -1; +} + +bool GLSharedGroup::setSamplerUniform(GLuint program, GLint appLoc, GLint val, GLenum* target) +{ + android::AutoMutex _lock(m_lock); + ProgramData* pData = m_programs.valueFor(program); + return pData ? pData->setSamplerUniform(appLoc, val, target) : false; +} + +bool GLSharedGroup::addShaderData(GLuint shader) +{ + android::AutoMutex _lock(m_lock); + ShaderData* data = new ShaderData; + if (data) { + if (m_shaders.add(shader, data) < 0) { + delete data; + data = NULL; + } + data->refcount = 1; + } + return data != NULL; +} + +ShaderData* GLSharedGroup::getShaderData(GLuint shader) +{ + android::AutoMutex _lock(m_lock); + return m_shaders.valueFor(shader); +} + +void GLSharedGroup::unrefShaderData(GLuint shader) +{ + android::AutoMutex _lock(m_lock); + ssize_t idx = m_shaders.indexOfKey(shader); + if (idx >= 0) { + unrefShaderDataLocked(idx); + } +} + +void GLSharedGroup::refShaderDataLocked(ssize_t shaderIdx) +{ + assert(shaderIdx >= 0 && shaderIdx <= m_shaders.size()); + ShaderData* data = m_shaders.valueAt(shaderIdx); + data->refcount++; +} + +void GLSharedGroup::unrefShaderDataLocked(ssize_t shaderIdx) +{ + assert(shaderIdx >= 0 && shaderIdx <= m_shaders.size()); + ShaderData* data = m_shaders.valueAt(shaderIdx); + if (--data->refcount == 0) { + delete data; + m_shaders.removeItemsAt(shaderIdx); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.h new file mode 100644 index 0000000..6dfcd8f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/GLSharedGroup.h @@ -0,0 +1,144 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GL_SHARED_GROUP_H_ +#define _GL_SHARED_GROUP_H_ + +#define GL_API +#ifndef ANDROID +#define GL_APIENTRY +#define GL_APIENTRYP +#endif + +#include +#include +#include +#include + +#include +#include +#include "ErrorLog.h" +#include +#include +#include +#include +#include "FixedBuffer.h" +#include "SmartPtr.h" + +struct BufferData { + BufferData(); + BufferData(GLsizeiptr size, void * data); + GLsizeiptr m_size; + FixedBuffer m_fixedBuffer; +}; + +class ProgramData { +private: + typedef struct _IndexInfo { + GLint base; + GLint size; + GLenum type; + GLint appBase; + GLint hostLocsPerElement; + GLuint flags; + GLint samplerValue; // only set for sampler uniforms + } IndexInfo; + + GLuint m_numIndexes; + IndexInfo* m_Indexes; + bool m_initialized; + bool m_locShiftWAR; + + android::Vector m_shaders; + +public: + enum { + INDEX_FLAG_SAMPLER_EXTERNAL = 0x00000001, + }; + + ProgramData(); + void initProgramData(GLuint numIndexes); + bool isInitialized(); + virtual ~ProgramData(); + void setIndexInfo(GLuint index, GLint base, GLint size, GLenum type); + void setIndexFlags(GLuint index, GLuint flags); + GLuint getIndexForLocation(GLint location); + GLenum getTypeForLocation(GLint location); + + bool needUniformLocationWAR() const { return m_locShiftWAR; } + void setupLocationShiftWAR(); + GLint locationWARHostToApp(GLint hostLoc, GLint arrIndex); + GLint locationWARAppToHost(GLint appLoc); + + GLint getNextSamplerUniform(GLint index, GLint* val, GLenum* target); + bool setSamplerUniform(GLint appLoc, GLint val, GLenum* target); + + bool attachShader(GLuint shader); + bool detachShader(GLuint shader); + size_t getNumShaders() const { return m_shaders.size(); } + GLuint getShader(size_t i) const { return m_shaders[i]; } +}; + +struct ShaderData { + typedef android::List StringList; + StringList samplerExternalNames; + int refcount; +}; + +class GLSharedGroup { +private: + android::DefaultKeyedVector m_buffers; + android::DefaultKeyedVector m_programs; + android::DefaultKeyedVector m_shaders; + mutable android::Mutex m_lock; + + void refShaderDataLocked(ssize_t shaderIdx); + void unrefShaderDataLocked(ssize_t shaderIdx); + +public: + GLSharedGroup(); + ~GLSharedGroup(); + bool isObject(GLuint obj); + BufferData * getBufferData(GLuint bufferId); + void addBufferData(GLuint bufferId, GLsizeiptr size, void * data); + void updateBufferData(GLuint bufferId, GLsizeiptr size, void * data); + GLenum subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data); + void deleteBufferData(GLuint); + + bool isProgram(GLuint program); + bool isProgramInitialized(GLuint program); + void addProgramData(GLuint program); + void initProgramData(GLuint program, GLuint numIndexes); + void attachShader(GLuint program, GLuint shader); + void detachShader(GLuint program, GLuint shader); + void deleteProgramData(GLuint program); + void setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type, const char* name); + GLenum getProgramUniformType(GLuint program, GLint location); + void setupLocationShiftWAR(GLuint program); + GLint locationWARHostToApp(GLuint program, GLint hostLoc, GLint arrIndex); + GLint locationWARAppToHost(GLuint program, GLint appLoc); + bool needUniformLocationWAR(GLuint program); + GLint getNextSamplerUniform(GLuint program, GLint index, GLint* val, GLenum* target) const; + bool setSamplerUniform(GLuint program, GLint appLoc, GLint val, GLenum* target); + + bool addShaderData(GLuint shader); + // caller must hold a reference to the shader as long as it holds the pointer + ShaderData* getShaderData(GLuint shader); + void unrefShaderData(GLuint shader); +}; + +typedef SmartPtr GLSharedGroupPtr; + +#endif //_GL_SHARED_GROUP_H_ diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Makefile b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Makefile new file mode 100644 index 0000000..e8bf431 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/Makefile @@ -0,0 +1,13 @@ + +ROOT=../.. + +include $(ROOT)/make/commondefs + +CXXFILES = TcpStream.cpp GLClientState.cpp glUtils.cpp +CXXINCS += -I$(ROOT)/libs/GLESv1 -I$(ROOT)/include + +LIBRARY_NAME = libcodecCommon.a + +include $(COMMONRULES) + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SmartPtr.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SmartPtr.h new file mode 100644 index 0000000..4bdfbe4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SmartPtr.h @@ -0,0 +1,167 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __SMART_PTR_H +#define __SMART_PTR_H + +#include +#include + +template +class SmartPtr +{ +public: + explicit SmartPtr(T* ptr = (T*)NULL) { + if (threadSafe) { + m_lock = new mutex_t; + mutex_init(m_lock); + } + else m_lock = NULL; + + m_ptr = ptr; + if (ptr) + m_pRefCount = new int32_t(1); + else + m_pRefCount = NULL; + } + + SmartPtr(const SmartPtr& rhs) { + if (threadSafe) { + m_lock = new mutex_t; + mutex_init(m_lock); + } + else m_lock = NULL; + + m_pRefCount = rhs.m_pRefCount; + m_ptr = rhs.m_ptr; + use(); + } + + SmartPtr(SmartPtr& rhs) { + if (threadSafe) { + m_lock = new mutex_t; + mutex_init(m_lock); + } + else m_lock = NULL; + + if (rhs.m_lock) mutex_lock(rhs.m_lock); + m_pRefCount = rhs.m_pRefCount; + m_ptr = rhs.m_ptr; + use(); + if (rhs.m_lock) mutex_unlock(rhs.m_lock); + } + + ~SmartPtr() { + if (m_lock) mutex_lock(m_lock); + release(); + if (m_lock) + { + mutex_unlock(m_lock); + mutex_destroy(m_lock); + delete m_lock; + } + } + + T* Ptr() const { + return m_ptr; + } + + const T* constPtr() const + { + return m_ptr; + } + + T* operator->() const { + return m_ptr; + } + + T& operator*() const { + return *m_ptr; + } + + operator void*() const { + return (void *)m_ptr; + } + + // This gives STL lists something to compare. + bool operator <(const SmartPtr& t1) const { + return m_ptr < t1.m_ptr; + } + + SmartPtr& operator=(const SmartPtr& rhs) + { + if (m_ptr == rhs.m_ptr) + return *this; + + if (m_lock) mutex_lock(m_lock); + release(); + m_pRefCount = rhs.m_pRefCount; + m_ptr = rhs.m_ptr; + use(); + if (m_lock) mutex_unlock(m_lock); + + return *this; + } + + SmartPtr& operator=(SmartPtr& rhs) + { + if (m_ptr == rhs.m_ptr) + return *this; + + if (m_lock) mutex_lock(m_lock); + release(); + if (rhs.m_lock) mutex_lock(rhs.m_lock); + m_pRefCount = rhs.m_pRefCount; + m_ptr = rhs.m_ptr; + use(); + if (rhs.m_lock) mutex_unlock(rhs.m_lock); + if (m_lock) mutex_unlock(m_lock); + + return *this; + } + +private: + int32_t *m_pRefCount; + mutex_t *m_lock; + T* m_ptr; + + // Increment the reference count on this pointer by 1. + int use() { + if (!m_pRefCount) return 0; + return android_atomic_inc(m_pRefCount) + 1; + } + + // Decrement the reference count on the pointer by 1. + // If the reference count goes to (or below) 0, the pointer is deleted. + int release() { + if (!m_pRefCount) return 0; + + int iVal = android_atomic_dec(m_pRefCount); + if (iVal > 1) + return iVal - 1; + + delete m_pRefCount; + m_pRefCount = NULL; + + if (m_ptr) { + delete m_ptr; + m_ptr = NULL; + } + return 0; + } + +}; + +#endif // of __SMART_PTR_H diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.cpp new file mode 100644 index 0000000..f7a2314 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.cpp @@ -0,0 +1,168 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "SocketStream.h" +#include +#include +#include +#include +#include +#include + +#ifndef _WIN32 +#include +#include +#include +#else +#include +#endif + +SocketStream::SocketStream(size_t bufSize) : + IOStream(bufSize), + m_sock(-1), + m_bufsize(bufSize), + m_buf(NULL) +{ +} + +SocketStream::SocketStream(int sock, size_t bufSize) : + IOStream(bufSize), + m_sock(sock), + m_bufsize(bufSize), + m_buf(NULL) +{ +} + +SocketStream::~SocketStream() +{ + if (m_sock >= 0) { +#ifdef _WIN32 + closesocket(m_sock); +#else + ::close(m_sock); +#endif + } + if (m_buf != NULL) { + free(m_buf); + m_buf = NULL; + } +} + + +void *SocketStream::allocBuffer(size_t minSize) +{ + size_t allocSize = (m_bufsize < minSize ? minSize : m_bufsize); + if (!m_buf) { + m_buf = (unsigned char *)malloc(allocSize); + } + else if (m_bufsize < allocSize) { + unsigned char *p = (unsigned char *)realloc(m_buf, allocSize); + if (p != NULL) { + m_buf = p; + m_bufsize = allocSize; + } else { + ERR("%s: realloc (%zu) failed\n", __FUNCTION__, allocSize); + free(m_buf); + m_buf = NULL; + m_bufsize = 0; + } + } + + return m_buf; +}; + +int SocketStream::commitBuffer(size_t size) +{ + return writeFully(m_buf, size); +} + +int SocketStream::writeFully(const void* buffer, size_t size) +{ + if (!valid()) return -1; + + size_t res = size; + int retval = 0; + + while (res > 0) { + ssize_t stat = ::send(m_sock, (const char *)buffer + (size - res), res, 0); + if (stat < 0) { + if (errno != EINTR) { + retval = stat; + ERR("%s: failed: %s\n", __FUNCTION__, strerror(errno)); + break; + } + } else { + res -= stat; + } + } + return retval; +} + +const unsigned char *SocketStream::readFully(void *buf, size_t len) +{ + const unsigned char* ret = NULL; + if (!valid()) return NULL; + if (!buf) { + return NULL; // do not allow NULL buf in that implementation + } + size_t res = len; + while (res > 0) { + ssize_t stat = ::recv(m_sock, (char *)(buf) + len - res, res, 0); + if (stat > 0) { + res -= stat; + continue; + } + if (stat == 0 || errno != EINTR) { // client shutdown or error + return NULL; + } + } + return (const unsigned char *)buf; +} + +const unsigned char *SocketStream::read( void *buf, size_t *inout_len) +{ + if (!valid()) return NULL; + if (!buf) { + return NULL; // do not allow NULL buf in that implementation + } + + int n; + do { + n = recv(buf, *inout_len); + } while( n < 0 && errno == EINTR ); + + if (n > 0) { + *inout_len = n; + return (const unsigned char *)buf; + } + + return NULL; +} + +int SocketStream::recv(void *buf, size_t len) +{ + if (!valid()) return int(ERR_INVALID_SOCKET); + int res = 0; + while(true) { + res = ::recv(m_sock, (char *)buf, len, 0); + if (res < 0) { + if (errno == EINTR) { + continue; + } + } + break; + } + return res; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.h new file mode 100644 index 0000000..3a501b4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/SocketStream.h @@ -0,0 +1,50 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __SOCKET_STREAM_H +#define __SOCKET_STREAM_H + +#include +#include "IOStream.h" + +class SocketStream : public IOStream { +public: + typedef enum { ERR_INVALID_SOCKET = -1000 } SocketStreamError; + + explicit SocketStream(size_t bufsize = 10000); + virtual ~SocketStream(); + + virtual int listen(unsigned short port) = 0; + virtual SocketStream *accept() = 0; + virtual int connect(unsigned short port) = 0; + + virtual void *allocBuffer(size_t minSize); + virtual int commitBuffer(size_t size); + virtual const unsigned char *readFully(void *buf, size_t len); + virtual const unsigned char *read(void *buf, size_t *inout_len); + + bool valid() { return m_sock >= 0; } + virtual int recv(void *buf, size_t len); + virtual int writeFully(const void *buf, size_t len); + +protected: + int m_sock; + size_t m_bufsize; + unsigned char *m_buf; + + SocketStream(int sock, size_t bufSize); +}; + +#endif /* __SOCKET_STREAM_H */ diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.cpp new file mode 100644 index 0000000..4da2cec --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.cpp @@ -0,0 +1,91 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "TcpStream.h" +#include +#include +#include +#include +#include +#include + +#ifndef _WIN32 +#include +#include +#else +#include +#endif + +TcpStream::TcpStream(size_t bufSize) : + SocketStream(bufSize) +{ +} + +TcpStream::TcpStream(int sock, size_t bufSize) : + SocketStream(sock, bufSize) +{ + // disable Nagle algorithm to improve bandwidth of small + // packets which are quite common in our implementation. +#ifdef _WIN32 + DWORD flag; +#else + int flag; +#endif + flag = 1; + setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(flag) ); +} + +int TcpStream::listen(unsigned short port) +{ + m_sock = socket_loopback_server(port, SOCK_STREAM); + if (!valid()) return int(ERR_INVALID_SOCKET); + + return 0; +} + +SocketStream * TcpStream::accept() +{ + int clientSock = -1; + + while (true) { + struct sockaddr_in addr; + socklen_t len = sizeof(addr); + clientSock = ::accept(m_sock, (sockaddr *)&addr, &len); + + if (clientSock < 0 && errno == EINTR) { + continue; + } + break; + } + + TcpStream *clientStream = NULL; + + if (clientSock >= 0) { + clientStream = new TcpStream(clientSock, m_bufsize); + } + return clientStream; +} + +int TcpStream::connect(unsigned short port) +{ + return connect("127.0.0.1",port); +} + +int TcpStream::connect(const char* hostname, unsigned short port) +{ + m_sock = socket_network_client(hostname, port, SOCK_STREAM); + if (!valid()) return -1; + return 0; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.h new file mode 100644 index 0000000..811a871 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/TcpStream.h @@ -0,0 +1,32 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __TCP_STREAM_H +#define __TCP_STREAM_H + +#include "SocketStream.h" + +class TcpStream : public SocketStream { +public: + explicit TcpStream(size_t bufsize = 10000); + virtual int listen(unsigned short port); + virtual SocketStream *accept(); + virtual int connect(unsigned short port); + int connect(const char* hostname, unsigned short port); +private: + TcpStream(int sock, size_t bufSize); +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/codec_defs.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/codec_defs.h new file mode 100644 index 0000000..f19f514 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/codec_defs.h @@ -0,0 +1,23 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _CODEC_DEFS_H +#define _CODEC_DEFS_H + +#define CODEC_SERVER_PORT 22468 + +#define CODEC_MAX_VERTEX_ATTRIBUTES 64 + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.cpp new file mode 100644 index 0000000..a61f76f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.cpp @@ -0,0 +1,475 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "glUtils.h" +#include +#include "ErrorLog.h" +#include + +size_t glSizeof(GLenum type) +{ + size_t retval = 0; + switch(type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + retval = 1; + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_HALF_FLOAT_OES: + retval = 2; + break; + case GL_UNSIGNED_INT: + case GL_INT: + case GL_FLOAT: + case GL_FIXED: + case GL_BOOL: + retval = 4; + break; +#ifdef GL_DOUBLE + case GL_DOUBLE: + retval = 8; + break; +#endif + case GL_FLOAT_VEC2: + case GL_INT_VEC2: + case GL_BOOL_VEC2: + retval = 8; + break; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + case GL_FLOAT_VEC3: + retval = 12; + break; + case GL_FLOAT_VEC4: + case GL_BOOL_VEC4: + case GL_INT_VEC4: + case GL_FLOAT_MAT2: + retval = 16; + break; + case GL_FLOAT_MAT3: + retval = 36; + break; + case GL_FLOAT_MAT4: + retval = 64; + break; + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + retval = 4; + break; + default: + ERR("**** ERROR unknown type 0x%x (%s,%d)\n", type, __FUNCTION__,__LINE__); + } + return retval; + +} + +size_t glUtilsParamSize(GLenum param) +{ + size_t s = 0; + + switch(param) + { + case GL_DEPTH_TEST: + case GL_DEPTH_FUNC: + case GL_DEPTH_BITS: + case GL_MAX_CLIP_PLANES: + case GL_GREEN_BITS: + case GL_MAX_MODELVIEW_STACK_DEPTH: + case GL_MAX_PROJECTION_STACK_DEPTH: + case GL_MAX_TEXTURE_STACK_DEPTH: + case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: + case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + case GL_MAX_TEXTURE_SIZE: + case GL_TEXTURE_GEN_MODE_OES: + case GL_TEXTURE_ENV_MODE: + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_SPOT_EXPONENT: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + case GL_SHININESS: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_POINT_SIZE: + case GL_POINT_SIZE_MIN: + case GL_POINT_SIZE_MAX: + case GL_POINT_FADE_THRESHOLD_SIZE: + case GL_CULL_FACE: + case GL_CULL_FACE_MODE: + case GL_FRONT_FACE: + case GL_SHADE_MODEL: + case GL_DEPTH_WRITEMASK: + case GL_DEPTH_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_WRITEMASK: + case GL_MATRIX_MODE: + case GL_MODELVIEW_STACK_DEPTH: + case GL_PROJECTION_STACK_DEPTH: + case GL_TEXTURE_STACK_DEPTH: + case GL_ALPHA_TEST_FUNC: + case GL_ALPHA_TEST_REF: + case GL_ALPHA_TEST: + case GL_DITHER: + case GL_BLEND_DST: + case GL_BLEND_SRC: + case GL_BLEND: + case GL_LOGIC_OP_MODE: + case GL_SCISSOR_TEST: + case GL_MAX_TEXTURE_UNITS: + case GL_ACTIVE_TEXTURE: + case GL_ALPHA_BITS: + case GL_ARRAY_BUFFER_BINDING: + case GL_BLUE_BITS: + case GL_CLIENT_ACTIVE_TEXTURE: + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + case GL_COLOR_ARRAY: + case GL_COLOR_ARRAY_BUFFER_BINDING: + case GL_COLOR_ARRAY_SIZE: + case GL_COLOR_ARRAY_STRIDE: + case GL_COLOR_ARRAY_TYPE: + case GL_COLOR_LOGIC_OP: + case GL_COLOR_MATERIAL: + case GL_PACK_ALIGNMENT: + case GL_PERSPECTIVE_CORRECTION_HINT: + case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: + case GL_POINT_SIZE_ARRAY_STRIDE_OES: + case GL_POINT_SIZE_ARRAY_TYPE_OES: + case GL_POINT_SMOOTH: + case GL_POINT_SMOOTH_HINT: + case GL_POINT_SPRITE_OES: + case GL_COORD_REPLACE_OES: + case GL_COMBINE_ALPHA: + case GL_SRC0_RGB: + case GL_SRC1_RGB: + case GL_SRC2_RGB: + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_SRC0_ALPHA: + case GL_SRC1_ALPHA: + case GL_SRC2_ALPHA: + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + case GL_COMBINE_RGB: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_RESCALE_NORMAL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_ALPHA_TO_ONE: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_MAX_SAMPLES_EXT: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FUNC: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_WRITEMASK: + case GL_TEXTURE_2D: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_TEXTURE_BINDING_EXTERNAL_OES: + case GL_TEXTURE_COORD_ARRAY: + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: + case GL_TEXTURE_COORD_ARRAY_SIZE: + case GL_TEXTURE_COORD_ARRAY_STRIDE: + case GL_TEXTURE_COORD_ARRAY_TYPE: + case GL_UNPACK_ALIGNMENT: + case GL_VERTEX_ARRAY: + case GL_VERTEX_ARRAY_BUFFER_BINDING: + case GL_VERTEX_ARRAY_SIZE: + case GL_VERTEX_ARRAY_STRIDE: + case GL_VERTEX_ARRAY_TYPE: + case GL_SPOT_CUTOFF: + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_GENERATE_MIPMAP: + case GL_GENERATE_MIPMAP_HINT: + case GL_RENDERBUFFER_WIDTH_OES: + case GL_RENDERBUFFER_HEIGHT_OES: + case GL_RENDERBUFFER_INTERNAL_FORMAT_OES: + case GL_RENDERBUFFER_RED_SIZE_OES: + case GL_RENDERBUFFER_GREEN_SIZE_OES: + case GL_RENDERBUFFER_BLUE_SIZE_OES: + case GL_RENDERBUFFER_ALPHA_SIZE_OES: + case GL_RENDERBUFFER_DEPTH_SIZE_OES: + case GL_RENDERBUFFER_STENCIL_SIZE_OES: + case GL_RENDERBUFFER_BINDING: + case GL_FRAMEBUFFER_BINDING: + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES: + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES: + case GL_FENCE_STATUS_NV: + case GL_FENCE_CONDITION_NV: + case GL_TEXTURE_WIDTH_QCOM: + case GL_TEXTURE_HEIGHT_QCOM: + case GL_TEXTURE_DEPTH_QCOM: + case GL_TEXTURE_INTERNAL_FORMAT_QCOM: + case GL_TEXTURE_FORMAT_QCOM: + case GL_TEXTURE_TYPE_QCOM: + case GL_TEXTURE_IMAGE_VALID_QCOM: + case GL_TEXTURE_NUM_LEVELS_QCOM: + case GL_TEXTURE_TARGET_QCOM: + case GL_TEXTURE_OBJECT_VALID_QCOM: + case GL_BLEND_EQUATION_RGB_OES: + case GL_BLEND_EQUATION_ALPHA_OES: + case GL_BLEND_DST_RGB_OES: + case GL_BLEND_SRC_RGB_OES: + case GL_BLEND_DST_ALPHA_OES: + case GL_BLEND_SRC_ALPHA_OES: + case GL_MAX_LIGHTS: + case GL_SHADER_TYPE: + case GL_DELETE_STATUS: + case GL_COMPILE_STATUS: + case GL_INFO_LOG_LENGTH: + case GL_SHADER_SOURCE_LENGTH: + case GL_CURRENT_PROGRAM: + case GL_LINK_STATUS: + case GL_VALIDATE_STATUS: + case GL_ATTACHED_SHADERS: + case GL_ACTIVE_UNIFORMS: + case GL_ACTIVE_ATTRIBUTES: + case GL_SUBPIXEL_BITS: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + case GL_NUM_SHADER_BINARY_FORMATS: + case GL_SHADER_COMPILER: + case GL_MAX_VERTEX_ATTRIBS: + case GL_MAX_VERTEX_UNIFORM_VECTORS: + case GL_MAX_VARYING_VECTORS: + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + case GL_MAX_RENDERBUFFER_SIZE: + case GL_MAX_TEXTURE_IMAGE_UNITS: + case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: + case GL_LINE_WIDTH: + s = 1; + break; + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_DEPTH_RANGE: + case GL_MAX_VIEWPORT_DIMS: + case GL_SMOOTH_POINT_SIZE_RANGE: + case GL_SMOOTH_LINE_WIDTH_RANGE: + s= 2; + break; + case GL_SPOT_DIRECTION: + case GL_POINT_DISTANCE_ATTENUATION: + case GL_CURRENT_NORMAL: + s = 3; + break; + case GL_CURRENT_VERTEX_ATTRIB: + case GL_CURRENT_TEXTURE_COORDS: + case GL_CURRENT_COLOR: + case GL_FOG_COLOR: + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + case GL_POSITION: + case GL_LIGHT_MODEL_AMBIENT: + case GL_TEXTURE_ENV_COLOR: + case GL_SCISSOR_BOX: + case GL_VIEWPORT: + case GL_TEXTURE_CROP_RECT_OES: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_AMBIENT_AND_DIFFUSE: + case GL_BLEND_COLOR: + s = 4; + break; + case GL_MODELVIEW_MATRIX: + case GL_PROJECTION_MATRIX: + case GL_TEXTURE_MATRIX: + s = 16; + break; + default: + ERR("glUtilsParamSize: unknow param 0x%08x\n", param); + s = 1; // assume 1 + } + return s; +} + +void glUtilsPackPointerData(unsigned char *dst, unsigned char *src, + int size, GLenum type, unsigned int stride, + unsigned int datalen) +{ + unsigned int vsize = size * glSizeof(type); + if (stride == 0) stride = vsize; + + if (stride == vsize) { + memcpy(dst, src, datalen); + } else { + for (unsigned int i = 0; i < datalen; i += vsize) { + memcpy(dst, src, vsize); + dst += vsize; + src += stride; + } + } +} + +void glUtilsWritePackPointerData(void* _stream, unsigned char *src, + int size, GLenum type, unsigned int stride, + unsigned int datalen) +{ + IOStream* stream = reinterpret_cast(_stream); + + unsigned int vsize = size * glSizeof(type); + if (stride == 0) stride = vsize; + + if (stride == vsize) { + stream->writeFully(src, datalen); + } else { + for (unsigned int i = 0; i < datalen; i += vsize) { + stream->writeFully(src, (size_t)vsize); + src += stride; + } + } +} + +int glUtilsPixelBitSize(GLenum format, GLenum type) +{ + int components = 0; + int componentsize = 0; + int pixelsize = 0; + switch(type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + componentsize = 8; + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_RGB565_OES: + case GL_RGB5_A1_OES: + case GL_RGBA4_OES: + pixelsize = 16; + break; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_FIXED: + case GL_UNSIGNED_INT_24_8_OES: + pixelsize = 32; + break; + default: + ERR("glUtilsPixelBitSize: unknown pixel type - assuming pixel data 0\n"); + componentsize = 0; + } + + if (pixelsize == 0) { + switch(format) { +#if 0 + case GL_RED: + case GL_GREEN: + case GL_BLUE: +#endif + case GL_ALPHA: + case GL_LUMINANCE: + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL_OES: + components = 1; + break; + case GL_LUMINANCE_ALPHA: + components = 2; + break; + case GL_RGB: +#if 0 + case GL_BGR: +#endif + components = 3; + break; + case GL_RGBA: + case GL_BGRA_EXT: + components = 4; + break; + default: + ERR("glUtilsPixelBitSize: unknown pixel format...\n"); + components = 0; + } + pixelsize = components * componentsize; + } + + return pixelsize; +} + +// pack a list of strings into one. +void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count) +{ + char *p = ptr; + *p = '\0'; + for (int i = 0; i < count; i++) { + int l=0; + if (strings[i]!=NULL) { + if (length == NULL || length[i] < 0) { + l = strlen(strings[i]); + strcat(p, strings[i]); + } else { + l = length[i]; + strncat(p, strings[i], l); + } + } + p += l; + } +} + +// claculate the length of a list of strings +int glUtilsCalcShaderSourceLen( char **strings, GLint *length, GLsizei count) +{ + int len = 0; + for (int i = 0; i < count; i++) { + int l; + if (length == NULL || length[i] < 0) { + l = strings[i]!=NULL ? strlen(strings[i]) : 0; + } else { + l = length[i]; + } + len += l; + } + return len; + +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.h new file mode 100644 index 0000000..f8857f1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/glUtils.h @@ -0,0 +1,95 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __GL_UTILS_H__ +#define __GL_UTILS_H__ + +#include +#include + +#ifdef GL_API + #undef GL_API +#endif +#define GL_API + +#ifdef GL_APIENTRY + #undef GL_APIENTRY +#endif + +#ifdef GL_APIENTRYP + #undef GL_APIENTRYP +#endif +#define GL_APIENTRYP + +#ifndef ANDROID +#define GL_APIENTRY +#endif + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + size_t glSizeof(GLenum type); + size_t glUtilsParamSize(GLenum param); + void glUtilsPackPointerData(unsigned char *dst, unsigned char *str, + int size, GLenum type, unsigned int stride, + unsigned int datalen); + void glUtilsWritePackPointerData(void* stream, unsigned char *src, + int size, GLenum type, unsigned int stride, + unsigned int datalen); + int glUtilsPixelBitSize(GLenum format, GLenum type); + void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count); + int glUtilsCalcShaderSourceLen(char **strings, GLint *length, GLsizei count); +#ifdef __cplusplus +}; +#endif + +namespace GLUtils { + + template void minmax(T *indices, int count, int *min, int *max) { + *min = -1; + *max = -1; + T *ptr = indices; + for (int i = 0; i < count; i++) { + if (*min == -1 || *ptr < *min) *min = *ptr; + if (*max == -1 || *ptr > *max) *max = *ptr; + ptr++; + } + } + + template void shiftIndices(T *indices, int count, int offset) { + T *ptr = indices; + for (int i = 0; i < count; i++) { + *ptr += offset; + ptr++; + } + } + + + template void shiftIndices(T *src, T *dst, int count, int offset) + { + for (int i = 0; i < count; i++) { + *dst = *src + offset; + dst++; + src++; + } + } +}; // namespace GLUtils +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/gl_base_types.h b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/gl_base_types.h new file mode 100644 index 0000000..d7ecf95 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/shared/OpenglCodecCommon/gl_base_types.h @@ -0,0 +1,63 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __GL_BASE_TYPES__H +#define __GL_BASE_TYPES__H + +#include + +#ifndef gl_APIENTRY +#define gl_APIENTRY KHRONOS_APIENTRY +#endif + +#ifndef gl2_APIENTRY +#define gl2_APIENTRY KHRONOS_APIENTRY +#endif + +typedef void GLvoid; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef char GLchar; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int32_t GLclampx; +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; +typedef char *GLstr; +/* JR XXX Treating this as an in handle - is this correct? */ +typedef void * GLeglImageOES; + +/* ErrorCode */ +#ifndef GL_INVALID_ENUM +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#endif + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/Android.mk new file mode 100644 index 0000000..8762c11 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH := $(call my-dir) + +### GLESv1 implementation ########################################### +$(call emugl-begin-shared-library,libGLESv1_CM_emulation) +$(call emugl-import,libOpenglSystemCommon libGLESv1_enc lib_renderControl_enc) + +LOCAL_CFLAGS += -DLOG_TAG=\"GLES_emulation\" -DGL_GLEXT_PROTOTYPES + +LOCAL_SRC_FILES := gl.cpp +LOCAL_MODULE_RELATIVE_PATH := egl + +$(call emugl-end-module) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/gl.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/gl.cpp new file mode 100644 index 0000000..8aaf347 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1/gl.cpp @@ -0,0 +1,165 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "EGLClientIface.h" +#include "HostConnection.h" +#include "GLEncoder.h" +#include "GLES/gl.h" +#include "GLES/glext.h" +#include "ErrorLog.h" +#include "gralloc_cb.h" +#include "ThreadInfo.h" +#include "EGLImage.h" + + +//XXX: fix this macro to get the context from fast tls path +#define GET_CONTEXT GLEncoder * ctx = getEGLThreadInfo()->hostConn->glEncoder(); + +#include "gl_entry.cpp" + +//The functions table +#include "gl_ftable.h" + +static EGLClient_eglInterface * s_egl = NULL; +static EGLClient_glesInterface * s_gl = NULL; + +#define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \ + HostConnection *hostCon = HostConnection::get(); \ + if (!hostCon) { \ + ALOGE("egl: Failed to get host connection\n"); \ + return ret; \ + } \ + renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \ + if (!rcEnc) { \ + ALOGE("egl: Failed to get renderControl encoder context\n"); \ + return ret; \ + } + +//GL extensions +void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES img) +{ + (void)self; + + DBG("glEGLImageTargetTexture2DOES v1 target=%#x img=%p", target, img); + + EGLImage_t *image = (EGLImage_t*)img; + + if (image->target == EGL_NATIVE_BUFFER_ANDROID) { + //TODO: check error - we don't have a way to set gl error + android_native_buffer_t* native_buffer = image->native_buffer; + + if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) { + return; + } + + if (native_buffer->common.version != sizeof(android_native_buffer_t)) { + return; + } + + GET_CONTEXT; + DEFINE_AND_VALIDATE_HOST_CONNECTION(); + + ctx->override2DTextureTarget(target); + rcEnc->rcBindTexture(rcEnc, + ((cb_handle_t *)(native_buffer->handle))->hostHandle); + ctx->restore2DTextureTarget(); + } + else if (image->target == EGL_GL_TEXTURE_2D_KHR) { + GET_CONTEXT; + ctx->override2DTextureTarget(target); + GLeglImageOES hostImage = reinterpret_cast((intptr_t)image->host_egl_image); + ctx->m_glEGLImageTargetTexture2DOES_enc(self, target, hostImage); + ctx->restore2DTextureTarget(); + } +} + +void glEGLImageTargetRenderbufferStorageOES(void *self, GLenum target, GLeglImageOES image) +{ + (void)self; + (void)target; + + DBG("glEGLImageTargetRenderbufferStorageOES v1 target=%#x image=%p", + target, image); + //TODO: check error - we don't have a way to set gl error + android_native_buffer_t* native_buffer = (android_native_buffer_t*)image; + + if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) { + return; + } + + if (native_buffer->common.version != sizeof(android_native_buffer_t)) { + return; + } + + DEFINE_AND_VALIDATE_HOST_CONNECTION(); + rcEnc->rcBindRenderbuffer(rcEnc, + ((cb_handle_t *)(native_buffer->handle))->hostHandle); + + return; +} + +void * getProcAddress(const char * procname) +{ + // search in GL function table + for (int i=0; igetGLString(name); + } + return NULL; +} + +void init() +{ + GET_CONTEXT; + ctx->m_glEGLImageTargetTexture2DOES_enc = ctx->glEGLImageTargetTexture2DOES; + ctx->glEGLImageTargetTexture2DOES = &glEGLImageTargetTexture2DOES; + ctx->glEGLImageTargetRenderbufferStorageOES = &glEGLImageTargetRenderbufferStorageOES; + ctx->glGetString = &my_glGetString; +} + +extern "C" { +EGLClient_glesInterface * init_emul_gles(EGLClient_eglInterface *eglIface) +{ + s_egl = eglIface; + + if (!s_gl) { + s_gl = new EGLClient_glesInterface(); + s_gl->getProcAddress = getProcAddress; + s_gl->finish = finish; + s_gl->init = init; + } + + return s_gl; +} +} //extern + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/Android.mk new file mode 100644 index 0000000..fd12395 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/Android.mk @@ -0,0 +1,19 @@ +LOCAL_PATH := $(call my-dir) + +### GLESv1_enc Encoder ########################################### +$(call emugl-begin-shared-library,libGLESv1_enc) + +LOCAL_CFLAGS += -DLOG_TAG=\"emuglGLESv1_enc\" + +LOCAL_SRC_FILES := \ + GLEncoder.cpp \ + GLEncoderUtils.cpp \ + gl_client_context.cpp \ + gl_enc.cpp \ + gl_entry.cpp + +$(call emugl-import,libOpenglCodecCommon) +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +$(call emugl-export,C_INCLUDES,$(intermediates)) + +$(call emugl-end-module) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.cpp new file mode 100644 index 0000000..8556c27 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.cpp @@ -0,0 +1,1029 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "GLEncoder.h" +#include "glUtils.h" +#include "FixedBuffer.h" +#include +#include + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +static GLubyte *gVendorString= (GLubyte *) "Android"; +static GLubyte *gRendererString= (GLubyte *) "Android HW-GLES 1.0"; +static GLubyte *gVersionString= (GLubyte *) "OpenGL ES-CM 1.0"; +static GLubyte *gExtensionsString= (GLubyte *) "GL_OES_EGL_image_external "; + +#define SET_ERROR_IF(condition,err) if((condition)) { \ + ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \ + ctx->setError(err); \ + return; \ + } + + +#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) { \ + ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \ + ctx->setError(err); \ + return ret; \ + } + +GLenum GLEncoder::s_glGetError(void * self) +{ + GLEncoder *ctx = (GLEncoder *)self; + GLenum err = ctx->getError(); + if(err != GL_NO_ERROR) { + ctx->setError(GL_NO_ERROR); + return err; + } + + return ctx->m_glGetError_enc(self); + +} + +GLint * GLEncoder::getCompressedTextureFormats() +{ + if (m_compressedTextureFormats == NULL) { + this->glGetIntegerv(this, GL_NUM_COMPRESSED_TEXTURE_FORMATS, + &m_num_compressedTextureFormats); + if (m_num_compressedTextureFormats > 0) { + // get number of texture formats; + m_compressedTextureFormats = new GLint[m_num_compressedTextureFormats]; + this->glGetCompressedTextureFormats(this, m_num_compressedTextureFormats, m_compressedTextureFormats); + } + } + return m_compressedTextureFormats; +} + +void GLEncoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + GLClientState* state = ctx->m_state; + + switch (param) { + case GL_COMPRESSED_TEXTURE_FORMATS: { + GLint * compressedTextureFormats = ctx->getCompressedTextureFormats(); + if (ctx->m_num_compressedTextureFormats > 0 && + compressedTextureFormats != NULL) { + memcpy(ptr, compressedTextureFormats, + ctx->m_num_compressedTextureFormats * sizeof(GLint)); + } + break; + } + + case GL_MAX_TEXTURE_UNITS: + ctx->m_glGetIntegerv_enc(self, param, ptr); + *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS); + break; + + case GL_TEXTURE_BINDING_2D: + *ptr = state->getBoundTexture(GL_TEXTURE_2D); + break; + + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES); + break; + + default: + if (!state->getClientStateParameter(param,ptr)) { + ctx->m_glGetIntegerv_enc(self, param, ptr); + } + break; + } +} + +void GLEncoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + GLClientState* state = ctx->m_state; + + switch (param) { + case GL_COMPRESSED_TEXTURE_FORMATS: { + GLint * compressedTextureFormats = ctx->getCompressedTextureFormats(); + if (ctx->m_num_compressedTextureFormats > 0 && + compressedTextureFormats != NULL) { + for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) { + ptr[i] = (GLfloat) compressedTextureFormats[i]; + } + } + break; + } + + case GL_MAX_TEXTURE_UNITS: + ctx->m_glGetFloatv_enc(self, param, ptr); + *ptr = MIN(*ptr, (GLfloat)GLClientState::MAX_TEXTURE_UNITS); + break; + + case GL_TEXTURE_BINDING_2D: + *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_2D); + break; + + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES); + break; + + default: + if (!state->getClientStateParameter(param,ptr)) { + ctx->m_glGetFloatv_enc(self, param, ptr); + } + break; + } +} + +void GLEncoder::s_glGetFixedv(void *self, GLenum param, GLfixed *ptr) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + GLClientState* state = ctx->m_state; + + switch (param) { + case GL_COMPRESSED_TEXTURE_FORMATS: { + GLint * compressedTextureFormats = ctx->getCompressedTextureFormats(); + if (ctx->m_num_compressedTextureFormats > 0 && + compressedTextureFormats != NULL) { + for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) { + ptr[i] = compressedTextureFormats[i] << 16; + } + } + break; + } + + case GL_MAX_TEXTURE_UNITS: + ctx->m_glGetFixedv_enc(self, param, ptr); + *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS << 16); + break; + + case GL_TEXTURE_BINDING_2D: + *ptr = state->getBoundTexture(GL_TEXTURE_2D) << 16; + break; + + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES) << 16; + break; + + default: + if (!state->getClientStateParameter(param,ptr)) { + ctx->m_glGetFixedv_enc(self, param, ptr); + } + break; + } +} + +void GLEncoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + GLClientState* state = ctx->m_state; + + switch (param) { + case GL_COMPRESSED_TEXTURE_FORMATS: { + GLint* compressedTextureFormats = ctx->getCompressedTextureFormats(); + if (ctx->m_num_compressedTextureFormats > 0 && + compressedTextureFormats != NULL) { + for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) { + ptr[i] = compressedTextureFormats[i] != 0 ? GL_TRUE : GL_FALSE; + } + } + break; + } + + case GL_TEXTURE_BINDING_2D: + *ptr = state->getBoundTexture(GL_TEXTURE_2D) != 0 ? GL_TRUE : GL_FALSE; + break; + + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES) != 0 + ? GL_TRUE : GL_FALSE; + break; + + default: + if (!state->getClientStateParameter(param,ptr)) { + ctx->m_glGetBooleanv_enc(self, param, ptr); + } + break; + } +} + +void GLEncoder::s_glGetPointerv(void * self, GLenum param, GLvoid **params) +{ + GLEncoder * ctx = (GLEncoder *) self; + assert(ctx->m_state != NULL); + ctx->m_state->getClientStatePointer(param,params); +} + +void GLEncoder::s_glFlush(void *self) +{ + GLEncoder *ctx = (GLEncoder *)self; + ctx->m_glFlush_enc(self); + ctx->m_stream->flush(); +} + +const GLubyte *GLEncoder::s_glGetString(void *self, GLenum name) +{ + (void)self; + + GLubyte *retval = (GLubyte *) ""; + switch(name) { + case GL_VENDOR: + retval = gVendorString; + break; + case GL_RENDERER: + retval = gRendererString; + break; + case GL_VERSION: + retval = gVersionString; + break; + case GL_EXTENSIONS: + retval = gExtensionsString; + break; + } + return retval; +} + +void GLEncoder::s_glPixelStorei(void *self, GLenum param, GLint value) +{ + GLEncoder *ctx = (GLEncoder *)self; + ctx->m_glPixelStorei_enc(ctx, param, value); + ALOG_ASSERT(ctx->m_state, "GLEncoder::s_glPixelStorei"); + ctx->m_state->setPixelStore(param, value); +} + +void GLEncoder::s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, const void *data) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + ctx->m_state->setState(GLClientState::VERTEX_LOCATION, size, type, false, stride, data); +} + +void GLEncoder::s_glNormalPointer(void *self, GLenum type, GLsizei stride, const void *data) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + ctx->m_state->setState(GLClientState::NORMAL_LOCATION, 3, type, false, stride, data); +} + +void GLEncoder::s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, const void *data) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + ctx->m_state->setState(GLClientState::COLOR_LOCATION, size, type, false, stride, data); +} + +void GLEncoder::s_glPointSizePointerOES(void *self, GLenum type, GLsizei stride, const void *data) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + ctx->m_state->setState(GLClientState::POINTSIZE_LOCATION, 1, type, false, stride, data); +} + +void GLEncoder::s_glClientActiveTexture(void *self, GLenum texture) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + ctx->m_state->setActiveTexture(texture - GL_TEXTURE0); +} + +void GLEncoder::s_glTexCoordPointer(void *self, int size, GLenum type, GLsizei stride, const void *data) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + int loc = ctx->m_state->getLocation(GL_TEXTURE_COORD_ARRAY); + ctx->m_state->setState(loc, size, type, false, stride, data); +} + +void GLEncoder::s_glMatrixIndexPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + int loc = ctx->m_state->getLocation(GL_MATRIX_INDEX_ARRAY_OES); + ctx->m_state->setState(loc, size, type, false, stride, data); +} + +void GLEncoder::s_glWeightPointerOES(void * self, int size, GLenum type, GLsizei stride, const void * data) +{ + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + int loc = ctx->m_state->getLocation(GL_WEIGHT_ARRAY_OES); + ctx->m_state->setState(loc, size, type, false, stride, data); +} + +void GLEncoder::s_glEnableClientState(void *self, GLenum state) +{ + GLEncoder *ctx = (GLEncoder *) self; + assert(ctx->m_state != NULL); + int loc = ctx->m_state->getLocation(state); + ctx->m_state->enable(loc, 1); +} + +void GLEncoder::s_glDisableClientState(void *self, GLenum state) +{ + GLEncoder *ctx = (GLEncoder *) self; + assert(ctx->m_state != NULL); + int loc = ctx->m_state->getLocation(state); + ctx->m_state->enable(loc, 0); +} + +GLboolean GLEncoder::s_glIsEnabled(void *self, GLenum cap) +{ + GLEncoder *ctx = (GLEncoder *) self; + assert(ctx->m_state != NULL); + int loc = ctx->m_state->getLocation(cap); + const GLClientState::VertexAttribState *state = ctx->m_state->getState(loc); + + if (state!=NULL) + return state->enabled; + + return ctx->m_glIsEnabled_enc(self,cap); +} + +void GLEncoder::s_glBindBuffer(void *self, GLenum target, GLuint id) +{ + GLEncoder *ctx = (GLEncoder *) self; + assert(ctx->m_state != NULL); + ctx->m_state->bindBuffer(target, id); + // TODO set error state if needed; + ctx->m_glBindBuffer_enc(self, target, id); +} + +void GLEncoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) +{ + GLEncoder *ctx = (GLEncoder *) self; + GLuint bufferId = ctx->m_state->getBuffer(target); + SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION); + SET_ERROR_IF(size<0, GL_INVALID_VALUE); + + ctx->m_shared->updateBufferData(bufferId, size, (void*)data); + ctx->m_glBufferData_enc(self, target, size, data, usage); +} + +void GLEncoder::s_glBufferSubData(void * self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) +{ + GLEncoder *ctx = (GLEncoder *) self; + GLuint bufferId = ctx->m_state->getBuffer(target); + SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION); + + GLenum res = ctx->m_shared->subUpdateBufferData(bufferId, offset, size, (void*)data); + SET_ERROR_IF(res, res); + + ctx->m_glBufferSubData_enc(self, target, offset, size, data); +} + +void GLEncoder::s_glDeleteBuffers(void * self, GLsizei n, const GLuint * buffers) +{ + GLEncoder *ctx = (GLEncoder *) self; + SET_ERROR_IF(n<0, GL_INVALID_VALUE); + for (int i=0; im_shared->deleteBufferData(buffers[i]); + ctx->m_glDeleteBuffers_enc(self,1,&buffers[i]); + } +} + +void GLEncoder::sendVertexData(unsigned int first, unsigned int count) +{ + assert(m_state != NULL); + for (int i = 0; i < GLClientState::LAST_LOCATION; i++) { + bool enableDirty; + const GLClientState::VertexAttribState *state = m_state->getStateAndEnableDirty(i, &enableDirty); + + // do not process if state not valid + if (!state) continue; + + // do not send disable state if state was already disabled + if (!enableDirty && !state->enabled) continue; + + if ( i >= GLClientState::TEXCOORD0_LOCATION && + i <= GLClientState::TEXCOORD7_LOCATION ) { + m_glClientActiveTexture_enc(this, GL_TEXTURE0 + i - GLClientState::TEXCOORD0_LOCATION); + } + + if (state->enabled) { + + if (enableDirty) + m_glEnableClientState_enc(this, state->glConst); + + unsigned int datalen = state->elementSize * count; + int stride = state->stride; + if (stride == 0) stride = state->elementSize; + int firstIndex = stride * first; + + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject); + if (state->bufferObject == 0) { + + switch(i) { + case GLClientState::VERTEX_LOCATION: + this->glVertexPointerData(this, state->size, state->type, state->stride, + (unsigned char *)state->data + firstIndex, datalen); + break; + case GLClientState::NORMAL_LOCATION: + this->glNormalPointerData(this, state->type, state->stride, + (unsigned char *)state->data + firstIndex, datalen); + break; + case GLClientState::COLOR_LOCATION: + this->glColorPointerData(this, state->size, state->type, state->stride, + (unsigned char *)state->data + firstIndex, datalen); + break; + case GLClientState::TEXCOORD0_LOCATION: + case GLClientState::TEXCOORD1_LOCATION: + case GLClientState::TEXCOORD2_LOCATION: + case GLClientState::TEXCOORD3_LOCATION: + case GLClientState::TEXCOORD4_LOCATION: + case GLClientState::TEXCOORD5_LOCATION: + case GLClientState::TEXCOORD6_LOCATION: + case GLClientState::TEXCOORD7_LOCATION: + this->glTexCoordPointerData(this, i - GLClientState::TEXCOORD0_LOCATION, state->size, state->type, state->stride, + (unsigned char *)state->data + firstIndex, datalen); + break; + case GLClientState::POINTSIZE_LOCATION: + this->glPointSizePointerData(this, state->type, state->stride, + (unsigned char *) state->data + firstIndex, datalen); + break; + case GLClientState::WEIGHT_LOCATION: + this->glWeightPointerData(this, state->size, state->type, state->stride, + (unsigned char * ) state->data + firstIndex, datalen); + break; + case GLClientState::MATRIXINDEX_LOCATION: + this->glMatrixIndexPointerData(this, state->size, state->type, state->stride, + (unsigned char *)state->data + firstIndex, datalen); + break; + } + } else { + + switch(i) { + case GLClientState::VERTEX_LOCATION: + this->glVertexPointerOffset(this, state->size, state->type, state->stride, + (uintptr_t)state->data + firstIndex); + break; + case GLClientState::NORMAL_LOCATION: + this->glNormalPointerOffset(this, state->type, state->stride, + (uintptr_t)state->data + firstIndex); + break; + case GLClientState::POINTSIZE_LOCATION: + this->glPointSizePointerOffset(this, state->type, state->stride, + (uintptr_t)state->data + firstIndex); + break; + case GLClientState::COLOR_LOCATION: + this->glColorPointerOffset(this, state->size, state->type, state->stride, + (uintptr_t)state->data + firstIndex); + break; + case GLClientState::TEXCOORD0_LOCATION: + case GLClientState::TEXCOORD1_LOCATION: + case GLClientState::TEXCOORD2_LOCATION: + case GLClientState::TEXCOORD3_LOCATION: + case GLClientState::TEXCOORD4_LOCATION: + case GLClientState::TEXCOORD5_LOCATION: + case GLClientState::TEXCOORD6_LOCATION: + case GLClientState::TEXCOORD7_LOCATION: + this->glTexCoordPointerOffset(this, state->size, state->type, state->stride, + (uintptr_t)state->data + firstIndex); + break; + case GLClientState::WEIGHT_LOCATION: + this->glWeightPointerOffset(this,state->size,state->type,state->stride, + (uintptr_t)state->data+firstIndex); + break; + case GLClientState::MATRIXINDEX_LOCATION: + this->glMatrixIndexPointerOffset(this,state->size,state->type,state->stride, + (uintptr_t)state->data+firstIndex); + break; + } + } + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); + } else { + this->m_glDisableClientState_enc(this, state->glConst); + } + } +} + +void GLEncoder::s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count) +{ + GLEncoder *ctx = (GLEncoder *)self; + + bool has_arrays = false; + for (int i = 0; i < GLClientState::LAST_LOCATION; i++) { + const GLClientState::VertexAttribState *state = ctx->m_state->getState(i); + if (state->enabled) { + if (state->bufferObject || state->data) { + has_arrays = true; + } else { + ALOGE("glDrawArrays: a vertex attribute array is enabled with no data bound\n"); + ctx->setError(GL_INVALID_OPERATION); + return; + } + } + } + if (!has_arrays) { + ALOGE("glDrawArrays: no data bound to the command - ignoring\n"); + return; + } + + ctx->sendVertexData(first, count); + ctx->m_glDrawArrays_enc(ctx, mode, /*first*/ 0, count); +} + +void GLEncoder::s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices) +{ + + GLEncoder *ctx = (GLEncoder *)self; + assert(ctx->m_state != NULL); + SET_ERROR_IF(count<0, GL_INVALID_VALUE); + + bool has_immediate_arrays = false; + bool has_indirect_arrays = false; + + for (int i = 0; i < GLClientState::LAST_LOCATION; i++) { + const GLClientState::VertexAttribState *state = ctx->m_state->getState(i); + if (state->enabled) { + if (state->bufferObject != 0) { + has_indirect_arrays = true; + } else if (state->data) { + has_immediate_arrays = true; + } else { + ALOGE("glDrawElements: a vertex attribute array is enabled with no data bound\n"); + ctx->setError(GL_INVALID_OPERATION); + return; + } + } + } + + if (!has_immediate_arrays && !has_indirect_arrays) { + ALOGE("glDrawElements: no data bound to the command - ignoring\n"); + return; + } + + bool adjustIndices = true; + if (ctx->m_state->currentIndexVbo() != 0) { + if (!has_immediate_arrays) { + ctx->sendVertexData(0, count); + ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, ctx->m_state->currentIndexVbo()); + ctx->glDrawElementsOffset(ctx, mode, count, type, (uintptr_t)indices); + adjustIndices = false; + } else { + BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo()); + ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, 0); + indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices); + } + } + if (adjustIndices) { + void *adjustedIndices = (void*)indices; + int minIndex = 0, maxIndex = 0; + + switch(type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + GLUtils::minmax((unsigned char *)indices, count, &minIndex, &maxIndex); + if (minIndex != 0) { + adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count); + GLUtils::shiftIndices((unsigned char *)indices, + (unsigned char *)adjustedIndices, + count, -minIndex); + } + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + GLUtils::minmax((unsigned short *)indices, count, &minIndex, &maxIndex); + if (minIndex != 0) { + adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count); + GLUtils::shiftIndices((unsigned short *)indices, + (unsigned short *)adjustedIndices, + count, -minIndex); + } + break; + case GL_INT: + case GL_UNSIGNED_INT: + GLUtils::minmax((unsigned int *)indices, count, &minIndex, &maxIndex); + if (minIndex != 0) { + adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count); + GLUtils::shiftIndices((unsigned int *)indices, + (unsigned int *)adjustedIndices, + count, -minIndex); + } + break; + default: + ALOGE("unsupported index buffer type %d\n", type); + } + if (has_indirect_arrays || 1) { + ctx->sendVertexData(minIndex, maxIndex - minIndex + 1); + ctx->glDrawElementsData(ctx, mode, count, type, adjustedIndices, + count * glSizeof(type)); + // XXX - OPTIMIZATION (see the other else branch) should be implemented + if(!has_indirect_arrays) { + //ALOGD("unoptimized drawelements !!!\n"); + } + } else { + // we are all direct arrays and immidate mode index array - + // rebuild the arrays and the index array; + ALOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n"); + } + } +} + +void GLEncoder::s_glActiveTexture(void* self, GLenum texture) +{ + GLEncoder* ctx = (GLEncoder*)self; + GLClientState* state = ctx->m_state; + GLenum err; + + if ((err = state->setActiveTextureUnit(texture)) != GL_NO_ERROR) { + ALOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err); + ctx->setError(err); + return; + } + + ctx->m_glActiveTexture_enc(ctx, texture); +} + +void GLEncoder::s_glBindTexture(void* self, GLenum target, GLuint texture) +{ + GLEncoder* ctx = (GLEncoder*)self; + GLClientState* state = ctx->m_state; + GLenum err; + + GLboolean firstUse; + if ((err = state->bindTexture(target, texture, &firstUse)) != GL_NO_ERROR) { + ALOGE("%s:%s:%d GL error %#x\n", __FILE__, __FUNCTION__, __LINE__, err); + ctx->setError(err); + return; + } + + if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) { + ctx->m_glBindTexture_enc(ctx, target, texture); + return; + } + + GLenum priorityTarget = state->getPriorityEnabledTarget(GL_TEXTURE_2D); + + if (target == GL_TEXTURE_EXTERNAL_OES && firstUse) { + // set TEXTURE_EXTERNAL_OES default states which differ from TEXTURE_2D + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, + GL_TEXTURE_MIN_FILTER, GL_LINEAR); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, + GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, + GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + if (target != priorityTarget) { + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, + state->getBoundTexture(GL_TEXTURE_2D)); + } + } + + if (target == priorityTarget) { + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture); + } +} + +void GLEncoder::s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures) +{ + GLEncoder* ctx = (GLEncoder*)self; + GLClientState* state = ctx->m_state; + + state->deleteTextures(n, textures); + ctx->m_glDeleteTextures_enc(ctx, n, textures); +} + +void GLEncoder::s_glDisable(void* self, GLenum cap) +{ + GLEncoder* ctx = (GLEncoder*)self; + GLClientState* state = ctx->m_state; + + if (cap == GL_TEXTURE_2D || cap == GL_TEXTURE_EXTERNAL_OES) { + GLenum prevTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM); + state->disableTextureTarget(cap); + GLenum currTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM); + + if (prevTarget != currTarget) { + if (currTarget == GL_INVALID_ENUM) { + ctx->m_glDisable_enc(ctx, GL_TEXTURE_2D); + currTarget = GL_TEXTURE_2D; + } + // maintain the invariant that when TEXTURE_EXTERNAL_OES is + // disabled, the TEXTURE_2D binding is active, even if + // TEXTURE_2D is also disabled. + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, + state->getBoundTexture(currTarget)); + } + + } else { + ctx->m_glDisable_enc(ctx, cap); + } +} + +void GLEncoder::s_glEnable(void* self, GLenum cap) +{ + GLEncoder* ctx = (GLEncoder*)self; + GLClientState* state = ctx->m_state; + + if (cap == GL_TEXTURE_2D || cap == GL_TEXTURE_EXTERNAL_OES) { + GLenum prevTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM); + state->enableTextureTarget(cap); + GLenum currTarget = state->getPriorityEnabledTarget(GL_INVALID_ENUM); + + if (prevTarget != currTarget) { + if (prevTarget == GL_INVALID_ENUM) { + ctx->m_glEnable_enc(ctx, GL_TEXTURE_2D); + } + if (currTarget == GL_TEXTURE_EXTERNAL_OES) { + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, + state->getBoundTexture(currTarget)); + } + } + + } else { + ctx->m_glEnable_enc(ctx, cap); + } +} + +void GLEncoder::s_glGetTexParameterfv(void* self, + GLenum target, GLenum pname, GLfloat* params) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glGetTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glGetTexParameterfv_enc(ctx, target, pname, params); + } +} + +void GLEncoder::s_glGetTexParameteriv(void* self, + GLenum target, GLenum pname, GLint* params) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + switch (pname) { + case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: + *params = 1; + break; + + default: + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glGetTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glGetTexParameteriv_enc(ctx, target, pname, params); + } + break; + } +} + +void GLEncoder::s_glGetTexParameterxv(void* self, + GLenum target, GLenum pname, GLfixed* params) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glGetTexParameterxv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glGetTexParameterxv_enc(ctx, target, pname, params); + } +} + +static bool isValidTextureExternalParam(GLenum pname, GLenum param) +{ + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + return param == GL_NEAREST || param == GL_LINEAR; + + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + return param == GL_CLAMP_TO_EDGE; + + case GL_GENERATE_MIPMAP: + return param == GL_FALSE; + + default: + return true; + } +} + +void GLEncoder::s_glTexParameterf(void* self, + GLenum target, GLenum pname, GLfloat param) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)param)), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameterf_enc(ctx, GL_TEXTURE_2D, pname, param); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameterf_enc(ctx, target, pname, param); + } +} + +void GLEncoder::s_glTexParameterfv(void* self, + GLenum target, GLenum pname, const GLfloat* params) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)params[0])), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameterfv_enc(ctx, target, pname, params); + } +} + +void GLEncoder::s_glTexParameteri(void* self, + GLenum target, GLenum pname, GLint param) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)param)), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, pname, param); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameteri_enc(ctx, target, pname, param); + } +} + +void GLEncoder::s_glTexParameterx(void* self, + GLenum target, GLenum pname, GLfixed param) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)param)), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameterx_enc(ctx, GL_TEXTURE_2D, pname, param); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameterx_enc(ctx, target, pname, param); + } +} + +void GLEncoder::s_glTexParameteriv(void* self, + GLenum target, GLenum pname, const GLint* params) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)params[0])), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameteriv_enc(ctx, target, pname, params); + } +} + +void GLEncoder::s_glTexParameterxv(void* self, + GLenum target, GLenum pname, const GLfixed* params) +{ + GLEncoder* ctx = (GLEncoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)params[0])), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameterxv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameterxv_enc(ctx, target, pname, params); + } +} + +void GLEncoder::override2DTextureTarget(GLenum target) +{ + if ((target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) && + target != m_state->getPriorityEnabledTarget(GL_TEXTURE_2D)) { + m_glBindTexture_enc(this, GL_TEXTURE_2D, + m_state->getBoundTexture(target)); + } +} + +void GLEncoder::restore2DTextureTarget() +{ + GLenum priorityTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D); + m_glBindTexture_enc(this, GL_TEXTURE_2D, + m_state->getBoundTexture(priorityTarget)); +} + +GLEncoder::GLEncoder(IOStream *stream, ChecksumCalculator *protocol) + : gl_encoder_context_t(stream, protocol) +{ + m_initialized = false; + m_state = NULL; + m_error = GL_NO_ERROR; + m_num_compressedTextureFormats = 0; + m_compressedTextureFormats = NULL; + + // overrides; +#define OVERRIDE(name) m_##name##_enc = this-> name ; this-> name = &s_##name + + OVERRIDE(glFlush); + OVERRIDE(glPixelStorei); + OVERRIDE(glVertexPointer); + OVERRIDE(glNormalPointer); + OVERRIDE(glColorPointer); + OVERRIDE(glPointSizePointerOES); + OVERRIDE(glClientActiveTexture); + OVERRIDE(glTexCoordPointer); + OVERRIDE(glMatrixIndexPointerOES); + OVERRIDE(glWeightPointerOES); + + OVERRIDE(glGetIntegerv); + OVERRIDE(glGetFloatv); + OVERRIDE(glGetBooleanv); + OVERRIDE(glGetFixedv); + OVERRIDE(glGetPointerv); + + OVERRIDE(glBindBuffer); + OVERRIDE(glBufferData); + OVERRIDE(glBufferSubData); + OVERRIDE(glDeleteBuffers); + + OVERRIDE(glEnableClientState); + OVERRIDE(glDisableClientState); + OVERRIDE(glIsEnabled); + OVERRIDE(glDrawArrays); + OVERRIDE(glDrawElements); + + this->glGetString = s_glGetString; + this->glFinish = s_glFinish; + + OVERRIDE(glGetError); + + OVERRIDE(glActiveTexture); + OVERRIDE(glBindTexture); + OVERRIDE(glDeleteTextures); + OVERRIDE(glDisable); + OVERRIDE(glEnable); + OVERRIDE(glGetTexParameterfv); + OVERRIDE(glGetTexParameteriv); + OVERRIDE(glGetTexParameterxv); + OVERRIDE(glTexParameterf); + OVERRIDE(glTexParameterfv); + OVERRIDE(glTexParameteri); + OVERRIDE(glTexParameterx); + OVERRIDE(glTexParameteriv); + OVERRIDE(glTexParameterxv); +} + +GLEncoder::~GLEncoder() +{ + delete [] m_compressedTextureFormats; +} + +size_t GLEncoder::pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) +{ + assert(m_state != NULL); + return m_state->pixelDataSize(width, height, format, type, pack); +} + +void GLEncoder::s_glFinish(void *self) +{ + GLEncoder *ctx = (GLEncoder *)self; + ctx->glFinishRoundTrip(self); +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.h new file mode 100644 index 0000000..f6d4b6a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoder.h @@ -0,0 +1,154 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GL_ENCODER_H_ +#define _GL_ENCODER_H_ + +#include "gl_enc.h" +#include "GLClientState.h" +#include "GLSharedGroup.h" +#include "FixedBuffer.h" +#include "ChecksumCalculator.h" + +class GLEncoder : public gl_encoder_context_t { + +public: + GLEncoder(IOStream *stream, ChecksumCalculator* protocol); + virtual ~GLEncoder(); + void setClientState(GLClientState *state) { + m_state = state; + } + void setSharedGroup(GLSharedGroupPtr shared) { m_shared = shared; } + void flush() { m_stream->flush(); } + size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack); + + void setInitialized(){ m_initialized = true; }; + bool isInitialized(){ return m_initialized; }; + + virtual void setError(GLenum error){ m_error = error; }; + virtual GLenum getError() { return m_error; }; + + void override2DTextureTarget(GLenum target); + void restore2DTextureTarget(); + +private: + + bool m_initialized; + GLClientState *m_state; + GLSharedGroupPtr m_shared; + GLenum m_error; + FixedBuffer m_fixedBuffer; + GLint *m_compressedTextureFormats; + GLint m_num_compressedTextureFormats; + + GLint *getCompressedTextureFormats(); + // original functions; + glGetError_client_proc_t m_glGetError_enc; + glGetIntegerv_client_proc_t m_glGetIntegerv_enc; + glGetFloatv_client_proc_t m_glGetFloatv_enc; + glGetFixedv_client_proc_t m_glGetFixedv_enc; + glGetBooleanv_client_proc_t m_glGetBooleanv_enc; + glGetPointerv_client_proc_t m_glGetPointerv_enc; + + glPixelStorei_client_proc_t m_glPixelStorei_enc; + glVertexPointer_client_proc_t m_glVertexPointer_enc; + glNormalPointer_client_proc_t m_glNormalPointer_enc; + glColorPointer_client_proc_t m_glColorPointer_enc; + glPointSizePointerOES_client_proc_t m_glPointSizePointerOES_enc; + glTexCoordPointer_client_proc_t m_glTexCoordPointer_enc; + glClientActiveTexture_client_proc_t m_glClientActiveTexture_enc; + glMatrixIndexPointerOES_client_proc_t m_glMatrixIndexPointerOES_enc; + glWeightPointerOES_client_proc_t m_glWeightPointerOES_enc; + + glBindBuffer_client_proc_t m_glBindBuffer_enc; + glBufferData_client_proc_t m_glBufferData_enc; + glBufferSubData_client_proc_t m_glBufferSubData_enc; + glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc; + + glEnableClientState_client_proc_t m_glEnableClientState_enc; + glDisableClientState_client_proc_t m_glDisableClientState_enc; + glIsEnabled_client_proc_t m_glIsEnabled_enc; + glDrawArrays_client_proc_t m_glDrawArrays_enc; + glDrawElements_client_proc_t m_glDrawElements_enc; + glFlush_client_proc_t m_glFlush_enc; + + glActiveTexture_client_proc_t m_glActiveTexture_enc; + glBindTexture_client_proc_t m_glBindTexture_enc; + glDeleteTextures_client_proc_t m_glDeleteTextures_enc; + glDisable_client_proc_t m_glDisable_enc; + glEnable_client_proc_t m_glEnable_enc; + glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc; + glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc; + glGetTexParameterxv_client_proc_t m_glGetTexParameterxv_enc; + glTexParameterf_client_proc_t m_glTexParameterf_enc; + glTexParameterfv_client_proc_t m_glTexParameterfv_enc; + glTexParameteri_client_proc_t m_glTexParameteri_enc; + glTexParameterx_client_proc_t m_glTexParameterx_enc; + glTexParameteriv_client_proc_t m_glTexParameteriv_enc; + glTexParameterxv_client_proc_t m_glTexParameterxv_enc; + + // statics + static GLenum s_glGetError(void * self); + static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr); + static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr); + static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr); + static void s_glGetFixedv(void *self, GLenum pname, GLfixed *ptr); + static void s_glGetPointerv(void *self, GLenum pname, GLvoid **params); + + static void s_glFlush(void * self); + static const GLubyte * s_glGetString(void *self, GLenum name); + static void s_glVertexPointer(void *self, int size, GLenum type, GLsizei stride, const void *data); + static void s_glNormalPointer(void *self, GLenum type, GLsizei stride, const void *data); + static void s_glColorPointer(void *self, int size, GLenum type, GLsizei stride, const void *data); + static void s_glPointSizePointerOES(void *self, GLenum type, GLsizei stride, const void *data); + static void s_glClientActiveTexture(void *self, GLenum texture); + static void s_glTexCoordPointer(void *self, int size, GLenum type, GLsizei stride, const void *data); + static void s_glMatrixIndexPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data); + static void s_glWeightPointerOES(void *self, int size, GLenum type, GLsizei stride, const void * data); + static void s_glDisableClientState(void *self, GLenum state); + static void s_glEnableClientState(void *self, GLenum state); + static GLboolean s_glIsEnabled(void *self, GLenum cap); + static void s_glBindBuffer(void *self, GLenum target, GLuint id); + static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); + static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers); + + static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count); + static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices); + static void s_glPixelStorei(void *self, GLenum param, GLint value); + + static void s_glFinish(void *self); + void sendVertexData(unsigned first, unsigned count); + + static void s_glActiveTexture(void* self, GLenum texture); + static void s_glBindTexture(void* self, GLenum target, GLuint texture); + static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures); + static void s_glDisable(void* self, GLenum cap); + static void s_glEnable(void* self, GLenum cap); + static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params); + static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params); + static void s_glGetTexParameterxv(void* self, GLenum target, GLenum pname, GLfixed* params); + static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param); + static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params); + static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param); + static void s_glTexParameterx(void* self, GLenum target, GLenum pname, GLfixed param); + static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params); + static void s_glTexParameterxv(void* self, GLenum target, GLenum pname, const GLfixed* params); + +public: + glEGLImageTargetTexture2DOES_client_proc_t m_glEGLImageTargetTexture2DOES_enc; + +}; +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.cpp new file mode 100644 index 0000000..4924392 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.cpp @@ -0,0 +1,28 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include "GLEncoder.h" + +namespace glesv1_enc { + +size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) +{ + GLEncoder *ctx = (GLEncoder *)self; + return ctx->pixelDataSize(width, height, format, type, pack); +} + +} // namespace glesv1_enc diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.h new file mode 100644 index 0000000..88d989f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/GLEncoderUtils.h @@ -0,0 +1,23 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef GL_ENCODER_UTILS_H +#define GL_ENCODER_UTILS_H + +namespace glesv1_enc { + size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack); +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.cpp new file mode 100644 index 0000000..cb504c8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.cpp @@ -0,0 +1,306 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include "gl_client_context.h" + + +#include + +int gl_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + glAlphaFunc = (glAlphaFunc_client_proc_t) getProc("glAlphaFunc", userData); + glClearColor = (glClearColor_client_proc_t) getProc("glClearColor", userData); + glClearDepthf = (glClearDepthf_client_proc_t) getProc("glClearDepthf", userData); + glClipPlanef = (glClipPlanef_client_proc_t) getProc("glClipPlanef", userData); + glColor4f = (glColor4f_client_proc_t) getProc("glColor4f", userData); + glDepthRangef = (glDepthRangef_client_proc_t) getProc("glDepthRangef", userData); + glFogf = (glFogf_client_proc_t) getProc("glFogf", userData); + glFogfv = (glFogfv_client_proc_t) getProc("glFogfv", userData); + glFrustumf = (glFrustumf_client_proc_t) getProc("glFrustumf", userData); + glGetClipPlanef = (glGetClipPlanef_client_proc_t) getProc("glGetClipPlanef", userData); + glGetFloatv = (glGetFloatv_client_proc_t) getProc("glGetFloatv", userData); + glGetLightfv = (glGetLightfv_client_proc_t) getProc("glGetLightfv", userData); + glGetMaterialfv = (glGetMaterialfv_client_proc_t) getProc("glGetMaterialfv", userData); + glGetTexEnvfv = (glGetTexEnvfv_client_proc_t) getProc("glGetTexEnvfv", userData); + glGetTexParameterfv = (glGetTexParameterfv_client_proc_t) getProc("glGetTexParameterfv", userData); + glLightModelf = (glLightModelf_client_proc_t) getProc("glLightModelf", userData); + glLightModelfv = (glLightModelfv_client_proc_t) getProc("glLightModelfv", userData); + glLightf = (glLightf_client_proc_t) getProc("glLightf", userData); + glLightfv = (glLightfv_client_proc_t) getProc("glLightfv", userData); + glLineWidth = (glLineWidth_client_proc_t) getProc("glLineWidth", userData); + glLoadMatrixf = (glLoadMatrixf_client_proc_t) getProc("glLoadMatrixf", userData); + glMaterialf = (glMaterialf_client_proc_t) getProc("glMaterialf", userData); + glMaterialfv = (glMaterialfv_client_proc_t) getProc("glMaterialfv", userData); + glMultMatrixf = (glMultMatrixf_client_proc_t) getProc("glMultMatrixf", userData); + glMultiTexCoord4f = (glMultiTexCoord4f_client_proc_t) getProc("glMultiTexCoord4f", userData); + glNormal3f = (glNormal3f_client_proc_t) getProc("glNormal3f", userData); + glOrthof = (glOrthof_client_proc_t) getProc("glOrthof", userData); + glPointParameterf = (glPointParameterf_client_proc_t) getProc("glPointParameterf", userData); + glPointParameterfv = (glPointParameterfv_client_proc_t) getProc("glPointParameterfv", userData); + glPointSize = (glPointSize_client_proc_t) getProc("glPointSize", userData); + glPolygonOffset = (glPolygonOffset_client_proc_t) getProc("glPolygonOffset", userData); + glRotatef = (glRotatef_client_proc_t) getProc("glRotatef", userData); + glScalef = (glScalef_client_proc_t) getProc("glScalef", userData); + glTexEnvf = (glTexEnvf_client_proc_t) getProc("glTexEnvf", userData); + glTexEnvfv = (glTexEnvfv_client_proc_t) getProc("glTexEnvfv", userData); + glTexParameterf = (glTexParameterf_client_proc_t) getProc("glTexParameterf", userData); + glTexParameterfv = (glTexParameterfv_client_proc_t) getProc("glTexParameterfv", userData); + glTranslatef = (glTranslatef_client_proc_t) getProc("glTranslatef", userData); + glActiveTexture = (glActiveTexture_client_proc_t) getProc("glActiveTexture", userData); + glAlphaFuncx = (glAlphaFuncx_client_proc_t) getProc("glAlphaFuncx", userData); + glBindBuffer = (glBindBuffer_client_proc_t) getProc("glBindBuffer", userData); + glBindTexture = (glBindTexture_client_proc_t) getProc("glBindTexture", userData); + glBlendFunc = (glBlendFunc_client_proc_t) getProc("glBlendFunc", userData); + glBufferData = (glBufferData_client_proc_t) getProc("glBufferData", userData); + glBufferSubData = (glBufferSubData_client_proc_t) getProc("glBufferSubData", userData); + glClear = (glClear_client_proc_t) getProc("glClear", userData); + glClearColorx = (glClearColorx_client_proc_t) getProc("glClearColorx", userData); + glClearDepthx = (glClearDepthx_client_proc_t) getProc("glClearDepthx", userData); + glClearStencil = (glClearStencil_client_proc_t) getProc("glClearStencil", userData); + glClientActiveTexture = (glClientActiveTexture_client_proc_t) getProc("glClientActiveTexture", userData); + glColor4ub = (glColor4ub_client_proc_t) getProc("glColor4ub", userData); + glColor4x = (glColor4x_client_proc_t) getProc("glColor4x", userData); + glColorMask = (glColorMask_client_proc_t) getProc("glColorMask", userData); + glColorPointer = (glColorPointer_client_proc_t) getProc("glColorPointer", userData); + glCompressedTexImage2D = (glCompressedTexImage2D_client_proc_t) getProc("glCompressedTexImage2D", userData); + glCompressedTexSubImage2D = (glCompressedTexSubImage2D_client_proc_t) getProc("glCompressedTexSubImage2D", userData); + glCopyTexImage2D = (glCopyTexImage2D_client_proc_t) getProc("glCopyTexImage2D", userData); + glCopyTexSubImage2D = (glCopyTexSubImage2D_client_proc_t) getProc("glCopyTexSubImage2D", userData); + glCullFace = (glCullFace_client_proc_t) getProc("glCullFace", userData); + glDeleteBuffers = (glDeleteBuffers_client_proc_t) getProc("glDeleteBuffers", userData); + glDeleteTextures = (glDeleteTextures_client_proc_t) getProc("glDeleteTextures", userData); + glDepthFunc = (glDepthFunc_client_proc_t) getProc("glDepthFunc", userData); + glDepthMask = (glDepthMask_client_proc_t) getProc("glDepthMask", userData); + glDepthRangex = (glDepthRangex_client_proc_t) getProc("glDepthRangex", userData); + glDisable = (glDisable_client_proc_t) getProc("glDisable", userData); + glDisableClientState = (glDisableClientState_client_proc_t) getProc("glDisableClientState", userData); + glDrawArrays = (glDrawArrays_client_proc_t) getProc("glDrawArrays", userData); + glDrawElements = (glDrawElements_client_proc_t) getProc("glDrawElements", userData); + glEnable = (glEnable_client_proc_t) getProc("glEnable", userData); + glEnableClientState = (glEnableClientState_client_proc_t) getProc("glEnableClientState", userData); + glFinish = (glFinish_client_proc_t) getProc("glFinish", userData); + glFlush = (glFlush_client_proc_t) getProc("glFlush", userData); + glFogx = (glFogx_client_proc_t) getProc("glFogx", userData); + glFogxv = (glFogxv_client_proc_t) getProc("glFogxv", userData); + glFrontFace = (glFrontFace_client_proc_t) getProc("glFrontFace", userData); + glFrustumx = (glFrustumx_client_proc_t) getProc("glFrustumx", userData); + glGetBooleanv = (glGetBooleanv_client_proc_t) getProc("glGetBooleanv", userData); + glGetBufferParameteriv = (glGetBufferParameteriv_client_proc_t) getProc("glGetBufferParameteriv", userData); + glClipPlanex = (glClipPlanex_client_proc_t) getProc("glClipPlanex", userData); + glGenBuffers = (glGenBuffers_client_proc_t) getProc("glGenBuffers", userData); + glGenTextures = (glGenTextures_client_proc_t) getProc("glGenTextures", userData); + glGetError = (glGetError_client_proc_t) getProc("glGetError", userData); + glGetFixedv = (glGetFixedv_client_proc_t) getProc("glGetFixedv", userData); + glGetIntegerv = (glGetIntegerv_client_proc_t) getProc("glGetIntegerv", userData); + glGetLightxv = (glGetLightxv_client_proc_t) getProc("glGetLightxv", userData); + glGetMaterialxv = (glGetMaterialxv_client_proc_t) getProc("glGetMaterialxv", userData); + glGetPointerv = (glGetPointerv_client_proc_t) getProc("glGetPointerv", userData); + glGetString = (glGetString_client_proc_t) getProc("glGetString", userData); + glGetTexEnviv = (glGetTexEnviv_client_proc_t) getProc("glGetTexEnviv", userData); + glGetTexEnvxv = (glGetTexEnvxv_client_proc_t) getProc("glGetTexEnvxv", userData); + glGetTexParameteriv = (glGetTexParameteriv_client_proc_t) getProc("glGetTexParameteriv", userData); + glGetTexParameterxv = (glGetTexParameterxv_client_proc_t) getProc("glGetTexParameterxv", userData); + glHint = (glHint_client_proc_t) getProc("glHint", userData); + glIsBuffer = (glIsBuffer_client_proc_t) getProc("glIsBuffer", userData); + glIsEnabled = (glIsEnabled_client_proc_t) getProc("glIsEnabled", userData); + glIsTexture = (glIsTexture_client_proc_t) getProc("glIsTexture", userData); + glLightModelx = (glLightModelx_client_proc_t) getProc("glLightModelx", userData); + glLightModelxv = (glLightModelxv_client_proc_t) getProc("glLightModelxv", userData); + glLightx = (glLightx_client_proc_t) getProc("glLightx", userData); + glLightxv = (glLightxv_client_proc_t) getProc("glLightxv", userData); + glLineWidthx = (glLineWidthx_client_proc_t) getProc("glLineWidthx", userData); + glLoadIdentity = (glLoadIdentity_client_proc_t) getProc("glLoadIdentity", userData); + glLoadMatrixx = (glLoadMatrixx_client_proc_t) getProc("glLoadMatrixx", userData); + glLogicOp = (glLogicOp_client_proc_t) getProc("glLogicOp", userData); + glMaterialx = (glMaterialx_client_proc_t) getProc("glMaterialx", userData); + glMaterialxv = (glMaterialxv_client_proc_t) getProc("glMaterialxv", userData); + glMatrixMode = (glMatrixMode_client_proc_t) getProc("glMatrixMode", userData); + glMultMatrixx = (glMultMatrixx_client_proc_t) getProc("glMultMatrixx", userData); + glMultiTexCoord4x = (glMultiTexCoord4x_client_proc_t) getProc("glMultiTexCoord4x", userData); + glNormal3x = (glNormal3x_client_proc_t) getProc("glNormal3x", userData); + glNormalPointer = (glNormalPointer_client_proc_t) getProc("glNormalPointer", userData); + glOrthox = (glOrthox_client_proc_t) getProc("glOrthox", userData); + glPixelStorei = (glPixelStorei_client_proc_t) getProc("glPixelStorei", userData); + glPointParameterx = (glPointParameterx_client_proc_t) getProc("glPointParameterx", userData); + glPointParameterxv = (glPointParameterxv_client_proc_t) getProc("glPointParameterxv", userData); + glPointSizex = (glPointSizex_client_proc_t) getProc("glPointSizex", userData); + glPolygonOffsetx = (glPolygonOffsetx_client_proc_t) getProc("glPolygonOffsetx", userData); + glPopMatrix = (glPopMatrix_client_proc_t) getProc("glPopMatrix", userData); + glPushMatrix = (glPushMatrix_client_proc_t) getProc("glPushMatrix", userData); + glReadPixels = (glReadPixels_client_proc_t) getProc("glReadPixels", userData); + glRotatex = (glRotatex_client_proc_t) getProc("glRotatex", userData); + glSampleCoverage = (glSampleCoverage_client_proc_t) getProc("glSampleCoverage", userData); + glSampleCoveragex = (glSampleCoveragex_client_proc_t) getProc("glSampleCoveragex", userData); + glScalex = (glScalex_client_proc_t) getProc("glScalex", userData); + glScissor = (glScissor_client_proc_t) getProc("glScissor", userData); + glShadeModel = (glShadeModel_client_proc_t) getProc("glShadeModel", userData); + glStencilFunc = (glStencilFunc_client_proc_t) getProc("glStencilFunc", userData); + glStencilMask = (glStencilMask_client_proc_t) getProc("glStencilMask", userData); + glStencilOp = (glStencilOp_client_proc_t) getProc("glStencilOp", userData); + glTexCoordPointer = (glTexCoordPointer_client_proc_t) getProc("glTexCoordPointer", userData); + glTexEnvi = (glTexEnvi_client_proc_t) getProc("glTexEnvi", userData); + glTexEnvx = (glTexEnvx_client_proc_t) getProc("glTexEnvx", userData); + glTexEnviv = (glTexEnviv_client_proc_t) getProc("glTexEnviv", userData); + glTexEnvxv = (glTexEnvxv_client_proc_t) getProc("glTexEnvxv", userData); + glTexImage2D = (glTexImage2D_client_proc_t) getProc("glTexImage2D", userData); + glTexParameteri = (glTexParameteri_client_proc_t) getProc("glTexParameteri", userData); + glTexParameterx = (glTexParameterx_client_proc_t) getProc("glTexParameterx", userData); + glTexParameteriv = (glTexParameteriv_client_proc_t) getProc("glTexParameteriv", userData); + glTexParameterxv = (glTexParameterxv_client_proc_t) getProc("glTexParameterxv", userData); + glTexSubImage2D = (glTexSubImage2D_client_proc_t) getProc("glTexSubImage2D", userData); + glTranslatex = (glTranslatex_client_proc_t) getProc("glTranslatex", userData); + glVertexPointer = (glVertexPointer_client_proc_t) getProc("glVertexPointer", userData); + glViewport = (glViewport_client_proc_t) getProc("glViewport", userData); + glPointSizePointerOES = (glPointSizePointerOES_client_proc_t) getProc("glPointSizePointerOES", userData); + glVertexPointerOffset = (glVertexPointerOffset_client_proc_t) getProc("glVertexPointerOffset", userData); + glColorPointerOffset = (glColorPointerOffset_client_proc_t) getProc("glColorPointerOffset", userData); + glNormalPointerOffset = (glNormalPointerOffset_client_proc_t) getProc("glNormalPointerOffset", userData); + glPointSizePointerOffset = (glPointSizePointerOffset_client_proc_t) getProc("glPointSizePointerOffset", userData); + glTexCoordPointerOffset = (glTexCoordPointerOffset_client_proc_t) getProc("glTexCoordPointerOffset", userData); + glWeightPointerOffset = (glWeightPointerOffset_client_proc_t) getProc("glWeightPointerOffset", userData); + glMatrixIndexPointerOffset = (glMatrixIndexPointerOffset_client_proc_t) getProc("glMatrixIndexPointerOffset", userData); + glVertexPointerData = (glVertexPointerData_client_proc_t) getProc("glVertexPointerData", userData); + glColorPointerData = (glColorPointerData_client_proc_t) getProc("glColorPointerData", userData); + glNormalPointerData = (glNormalPointerData_client_proc_t) getProc("glNormalPointerData", userData); + glTexCoordPointerData = (glTexCoordPointerData_client_proc_t) getProc("glTexCoordPointerData", userData); + glPointSizePointerData = (glPointSizePointerData_client_proc_t) getProc("glPointSizePointerData", userData); + glWeightPointerData = (glWeightPointerData_client_proc_t) getProc("glWeightPointerData", userData); + glMatrixIndexPointerData = (glMatrixIndexPointerData_client_proc_t) getProc("glMatrixIndexPointerData", userData); + glDrawElementsOffset = (glDrawElementsOffset_client_proc_t) getProc("glDrawElementsOffset", userData); + glDrawElementsData = (glDrawElementsData_client_proc_t) getProc("glDrawElementsData", userData); + glGetCompressedTextureFormats = (glGetCompressedTextureFormats_client_proc_t) getProc("glGetCompressedTextureFormats", userData); + glFinishRoundTrip = (glFinishRoundTrip_client_proc_t) getProc("glFinishRoundTrip", userData); + glBlendEquationSeparateOES = (glBlendEquationSeparateOES_client_proc_t) getProc("glBlendEquationSeparateOES", userData); + glBlendFuncSeparateOES = (glBlendFuncSeparateOES_client_proc_t) getProc("glBlendFuncSeparateOES", userData); + glBlendEquationOES = (glBlendEquationOES_client_proc_t) getProc("glBlendEquationOES", userData); + glDrawTexsOES = (glDrawTexsOES_client_proc_t) getProc("glDrawTexsOES", userData); + glDrawTexiOES = (glDrawTexiOES_client_proc_t) getProc("glDrawTexiOES", userData); + glDrawTexxOES = (glDrawTexxOES_client_proc_t) getProc("glDrawTexxOES", userData); + glDrawTexsvOES = (glDrawTexsvOES_client_proc_t) getProc("glDrawTexsvOES", userData); + glDrawTexivOES = (glDrawTexivOES_client_proc_t) getProc("glDrawTexivOES", userData); + glDrawTexxvOES = (glDrawTexxvOES_client_proc_t) getProc("glDrawTexxvOES", userData); + glDrawTexfOES = (glDrawTexfOES_client_proc_t) getProc("glDrawTexfOES", userData); + glDrawTexfvOES = (glDrawTexfvOES_client_proc_t) getProc("glDrawTexfvOES", userData); + glEGLImageTargetTexture2DOES = (glEGLImageTargetTexture2DOES_client_proc_t) getProc("glEGLImageTargetTexture2DOES", userData); + glEGLImageTargetRenderbufferStorageOES = (glEGLImageTargetRenderbufferStorageOES_client_proc_t) getProc("glEGLImageTargetRenderbufferStorageOES", userData); + glAlphaFuncxOES = (glAlphaFuncxOES_client_proc_t) getProc("glAlphaFuncxOES", userData); + glClearColorxOES = (glClearColorxOES_client_proc_t) getProc("glClearColorxOES", userData); + glClearDepthxOES = (glClearDepthxOES_client_proc_t) getProc("glClearDepthxOES", userData); + glClipPlanexOES = (glClipPlanexOES_client_proc_t) getProc("glClipPlanexOES", userData); + glClipPlanexIMG = (glClipPlanexIMG_client_proc_t) getProc("glClipPlanexIMG", userData); + glColor4xOES = (glColor4xOES_client_proc_t) getProc("glColor4xOES", userData); + glDepthRangexOES = (glDepthRangexOES_client_proc_t) getProc("glDepthRangexOES", userData); + glFogxOES = (glFogxOES_client_proc_t) getProc("glFogxOES", userData); + glFogxvOES = (glFogxvOES_client_proc_t) getProc("glFogxvOES", userData); + glFrustumxOES = (glFrustumxOES_client_proc_t) getProc("glFrustumxOES", userData); + glGetClipPlanexOES = (glGetClipPlanexOES_client_proc_t) getProc("glGetClipPlanexOES", userData); + glGetClipPlanex = (glGetClipPlanex_client_proc_t) getProc("glGetClipPlanex", userData); + glGetFixedvOES = (glGetFixedvOES_client_proc_t) getProc("glGetFixedvOES", userData); + glGetLightxvOES = (glGetLightxvOES_client_proc_t) getProc("glGetLightxvOES", userData); + glGetMaterialxvOES = (glGetMaterialxvOES_client_proc_t) getProc("glGetMaterialxvOES", userData); + glGetTexEnvxvOES = (glGetTexEnvxvOES_client_proc_t) getProc("glGetTexEnvxvOES", userData); + glGetTexParameterxvOES = (glGetTexParameterxvOES_client_proc_t) getProc("glGetTexParameterxvOES", userData); + glLightModelxOES = (glLightModelxOES_client_proc_t) getProc("glLightModelxOES", userData); + glLightModelxvOES = (glLightModelxvOES_client_proc_t) getProc("glLightModelxvOES", userData); + glLightxOES = (glLightxOES_client_proc_t) getProc("glLightxOES", userData); + glLightxvOES = (glLightxvOES_client_proc_t) getProc("glLightxvOES", userData); + glLineWidthxOES = (glLineWidthxOES_client_proc_t) getProc("glLineWidthxOES", userData); + glLoadMatrixxOES = (glLoadMatrixxOES_client_proc_t) getProc("glLoadMatrixxOES", userData); + glMaterialxOES = (glMaterialxOES_client_proc_t) getProc("glMaterialxOES", userData); + glMaterialxvOES = (glMaterialxvOES_client_proc_t) getProc("glMaterialxvOES", userData); + glMultMatrixxOES = (glMultMatrixxOES_client_proc_t) getProc("glMultMatrixxOES", userData); + glMultiTexCoord4xOES = (glMultiTexCoord4xOES_client_proc_t) getProc("glMultiTexCoord4xOES", userData); + glNormal3xOES = (glNormal3xOES_client_proc_t) getProc("glNormal3xOES", userData); + glOrthoxOES = (glOrthoxOES_client_proc_t) getProc("glOrthoxOES", userData); + glPointParameterxOES = (glPointParameterxOES_client_proc_t) getProc("glPointParameterxOES", userData); + glPointParameterxvOES = (glPointParameterxvOES_client_proc_t) getProc("glPointParameterxvOES", userData); + glPointSizexOES = (glPointSizexOES_client_proc_t) getProc("glPointSizexOES", userData); + glPolygonOffsetxOES = (glPolygonOffsetxOES_client_proc_t) getProc("glPolygonOffsetxOES", userData); + glRotatexOES = (glRotatexOES_client_proc_t) getProc("glRotatexOES", userData); + glSampleCoveragexOES = (glSampleCoveragexOES_client_proc_t) getProc("glSampleCoveragexOES", userData); + glScalexOES = (glScalexOES_client_proc_t) getProc("glScalexOES", userData); + glTexEnvxOES = (glTexEnvxOES_client_proc_t) getProc("glTexEnvxOES", userData); + glTexEnvxvOES = (glTexEnvxvOES_client_proc_t) getProc("glTexEnvxvOES", userData); + glTexParameterxOES = (glTexParameterxOES_client_proc_t) getProc("glTexParameterxOES", userData); + glTexParameterxvOES = (glTexParameterxvOES_client_proc_t) getProc("glTexParameterxvOES", userData); + glTranslatexOES = (glTranslatexOES_client_proc_t) getProc("glTranslatexOES", userData); + glIsRenderbufferOES = (glIsRenderbufferOES_client_proc_t) getProc("glIsRenderbufferOES", userData); + glBindRenderbufferOES = (glBindRenderbufferOES_client_proc_t) getProc("glBindRenderbufferOES", userData); + glDeleteRenderbuffersOES = (glDeleteRenderbuffersOES_client_proc_t) getProc("glDeleteRenderbuffersOES", userData); + glGenRenderbuffersOES = (glGenRenderbuffersOES_client_proc_t) getProc("glGenRenderbuffersOES", userData); + glRenderbufferStorageOES = (glRenderbufferStorageOES_client_proc_t) getProc("glRenderbufferStorageOES", userData); + glGetRenderbufferParameterivOES = (glGetRenderbufferParameterivOES_client_proc_t) getProc("glGetRenderbufferParameterivOES", userData); + glIsFramebufferOES = (glIsFramebufferOES_client_proc_t) getProc("glIsFramebufferOES", userData); + glBindFramebufferOES = (glBindFramebufferOES_client_proc_t) getProc("glBindFramebufferOES", userData); + glDeleteFramebuffersOES = (glDeleteFramebuffersOES_client_proc_t) getProc("glDeleteFramebuffersOES", userData); + glGenFramebuffersOES = (glGenFramebuffersOES_client_proc_t) getProc("glGenFramebuffersOES", userData); + glCheckFramebufferStatusOES = (glCheckFramebufferStatusOES_client_proc_t) getProc("glCheckFramebufferStatusOES", userData); + glFramebufferRenderbufferOES = (glFramebufferRenderbufferOES_client_proc_t) getProc("glFramebufferRenderbufferOES", userData); + glFramebufferTexture2DOES = (glFramebufferTexture2DOES_client_proc_t) getProc("glFramebufferTexture2DOES", userData); + glGetFramebufferAttachmentParameterivOES = (glGetFramebufferAttachmentParameterivOES_client_proc_t) getProc("glGetFramebufferAttachmentParameterivOES", userData); + glGenerateMipmapOES = (glGenerateMipmapOES_client_proc_t) getProc("glGenerateMipmapOES", userData); + glMapBufferOES = (glMapBufferOES_client_proc_t) getProc("glMapBufferOES", userData); + glUnmapBufferOES = (glUnmapBufferOES_client_proc_t) getProc("glUnmapBufferOES", userData); + glGetBufferPointervOES = (glGetBufferPointervOES_client_proc_t) getProc("glGetBufferPointervOES", userData); + glCurrentPaletteMatrixOES = (glCurrentPaletteMatrixOES_client_proc_t) getProc("glCurrentPaletteMatrixOES", userData); + glLoadPaletteFromModelViewMatrixOES = (glLoadPaletteFromModelViewMatrixOES_client_proc_t) getProc("glLoadPaletteFromModelViewMatrixOES", userData); + glMatrixIndexPointerOES = (glMatrixIndexPointerOES_client_proc_t) getProc("glMatrixIndexPointerOES", userData); + glWeightPointerOES = (glWeightPointerOES_client_proc_t) getProc("glWeightPointerOES", userData); + glQueryMatrixxOES = (glQueryMatrixxOES_client_proc_t) getProc("glQueryMatrixxOES", userData); + glDepthRangefOES = (glDepthRangefOES_client_proc_t) getProc("glDepthRangefOES", userData); + glFrustumfOES = (glFrustumfOES_client_proc_t) getProc("glFrustumfOES", userData); + glOrthofOES = (glOrthofOES_client_proc_t) getProc("glOrthofOES", userData); + glClipPlanefOES = (glClipPlanefOES_client_proc_t) getProc("glClipPlanefOES", userData); + glClipPlanefIMG = (glClipPlanefIMG_client_proc_t) getProc("glClipPlanefIMG", userData); + glGetClipPlanefOES = (glGetClipPlanefOES_client_proc_t) getProc("glGetClipPlanefOES", userData); + glClearDepthfOES = (glClearDepthfOES_client_proc_t) getProc("glClearDepthfOES", userData); + glTexGenfOES = (glTexGenfOES_client_proc_t) getProc("glTexGenfOES", userData); + glTexGenfvOES = (glTexGenfvOES_client_proc_t) getProc("glTexGenfvOES", userData); + glTexGeniOES = (glTexGeniOES_client_proc_t) getProc("glTexGeniOES", userData); + glTexGenivOES = (glTexGenivOES_client_proc_t) getProc("glTexGenivOES", userData); + glTexGenxOES = (glTexGenxOES_client_proc_t) getProc("glTexGenxOES", userData); + glTexGenxvOES = (glTexGenxvOES_client_proc_t) getProc("glTexGenxvOES", userData); + glGetTexGenfvOES = (glGetTexGenfvOES_client_proc_t) getProc("glGetTexGenfvOES", userData); + glGetTexGenivOES = (glGetTexGenivOES_client_proc_t) getProc("glGetTexGenivOES", userData); + glGetTexGenxvOES = (glGetTexGenxvOES_client_proc_t) getProc("glGetTexGenxvOES", userData); + glBindVertexArrayOES = (glBindVertexArrayOES_client_proc_t) getProc("glBindVertexArrayOES", userData); + glDeleteVertexArraysOES = (glDeleteVertexArraysOES_client_proc_t) getProc("glDeleteVertexArraysOES", userData); + glGenVertexArraysOES = (glGenVertexArraysOES_client_proc_t) getProc("glGenVertexArraysOES", userData); + glIsVertexArrayOES = (glIsVertexArrayOES_client_proc_t) getProc("glIsVertexArrayOES", userData); + glDiscardFramebufferEXT = (glDiscardFramebufferEXT_client_proc_t) getProc("glDiscardFramebufferEXT", userData); + glMultiDrawArraysEXT = (glMultiDrawArraysEXT_client_proc_t) getProc("glMultiDrawArraysEXT", userData); + glMultiDrawElementsEXT = (glMultiDrawElementsEXT_client_proc_t) getProc("glMultiDrawElementsEXT", userData); + glMultiDrawArraysSUN = (glMultiDrawArraysSUN_client_proc_t) getProc("glMultiDrawArraysSUN", userData); + glMultiDrawElementsSUN = (glMultiDrawElementsSUN_client_proc_t) getProc("glMultiDrawElementsSUN", userData); + glRenderbufferStorageMultisampleIMG = (glRenderbufferStorageMultisampleIMG_client_proc_t) getProc("glRenderbufferStorageMultisampleIMG", userData); + glFramebufferTexture2DMultisampleIMG = (glFramebufferTexture2DMultisampleIMG_client_proc_t) getProc("glFramebufferTexture2DMultisampleIMG", userData); + glDeleteFencesNV = (glDeleteFencesNV_client_proc_t) getProc("glDeleteFencesNV", userData); + glGenFencesNV = (glGenFencesNV_client_proc_t) getProc("glGenFencesNV", userData); + glIsFenceNV = (glIsFenceNV_client_proc_t) getProc("glIsFenceNV", userData); + glTestFenceNV = (glTestFenceNV_client_proc_t) getProc("glTestFenceNV", userData); + glGetFenceivNV = (glGetFenceivNV_client_proc_t) getProc("glGetFenceivNV", userData); + glFinishFenceNV = (glFinishFenceNV_client_proc_t) getProc("glFinishFenceNV", userData); + glSetFenceNV = (glSetFenceNV_client_proc_t) getProc("glSetFenceNV", userData); + glGetDriverControlsQCOM = (glGetDriverControlsQCOM_client_proc_t) getProc("glGetDriverControlsQCOM", userData); + glGetDriverControlStringQCOM = (glGetDriverControlStringQCOM_client_proc_t) getProc("glGetDriverControlStringQCOM", userData); + glEnableDriverControlQCOM = (glEnableDriverControlQCOM_client_proc_t) getProc("glEnableDriverControlQCOM", userData); + glDisableDriverControlQCOM = (glDisableDriverControlQCOM_client_proc_t) getProc("glDisableDriverControlQCOM", userData); + glExtGetTexturesQCOM = (glExtGetTexturesQCOM_client_proc_t) getProc("glExtGetTexturesQCOM", userData); + glExtGetBuffersQCOM = (glExtGetBuffersQCOM_client_proc_t) getProc("glExtGetBuffersQCOM", userData); + glExtGetRenderbuffersQCOM = (glExtGetRenderbuffersQCOM_client_proc_t) getProc("glExtGetRenderbuffersQCOM", userData); + glExtGetFramebuffersQCOM = (glExtGetFramebuffersQCOM_client_proc_t) getProc("glExtGetFramebuffersQCOM", userData); + glExtGetTexLevelParameterivQCOM = (glExtGetTexLevelParameterivQCOM_client_proc_t) getProc("glExtGetTexLevelParameterivQCOM", userData); + glExtTexObjectStateOverrideiQCOM = (glExtTexObjectStateOverrideiQCOM_client_proc_t) getProc("glExtTexObjectStateOverrideiQCOM", userData); + glExtGetTexSubImageQCOM = (glExtGetTexSubImageQCOM_client_proc_t) getProc("glExtGetTexSubImageQCOM", userData); + glExtGetBufferPointervQCOM = (glExtGetBufferPointervQCOM_client_proc_t) getProc("glExtGetBufferPointervQCOM", userData); + glExtGetShadersQCOM = (glExtGetShadersQCOM_client_proc_t) getProc("glExtGetShadersQCOM", userData); + glExtGetProgramsQCOM = (glExtGetProgramsQCOM_client_proc_t) getProc("glExtGetProgramsQCOM", userData); + glExtIsProgramBinaryQCOM = (glExtIsProgramBinaryQCOM_client_proc_t) getProc("glExtIsProgramBinaryQCOM", userData); + glExtGetProgramBinarySourceQCOM = (glExtGetProgramBinarySourceQCOM_client_proc_t) getProc("glExtGetProgramBinarySourceQCOM", userData); + glStartTilingQCOM = (glStartTilingQCOM_client_proc_t) getProc("glStartTilingQCOM", userData); + glEndTilingQCOM = (glEndTilingQCOM_client_proc_t) getProc("glEndTilingQCOM", userData); + return 0; +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.h new file mode 100644 index 0000000..8074095 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_context.h @@ -0,0 +1,313 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __gl_client_context_t_h +#define __gl_client_context_t_h + +#include "gl_client_proc.h" + +#include "gl_types.h" + + +struct gl_client_context_t { + + glAlphaFunc_client_proc_t glAlphaFunc; + glClearColor_client_proc_t glClearColor; + glClearDepthf_client_proc_t glClearDepthf; + glClipPlanef_client_proc_t glClipPlanef; + glColor4f_client_proc_t glColor4f; + glDepthRangef_client_proc_t glDepthRangef; + glFogf_client_proc_t glFogf; + glFogfv_client_proc_t glFogfv; + glFrustumf_client_proc_t glFrustumf; + glGetClipPlanef_client_proc_t glGetClipPlanef; + glGetFloatv_client_proc_t glGetFloatv; + glGetLightfv_client_proc_t glGetLightfv; + glGetMaterialfv_client_proc_t glGetMaterialfv; + glGetTexEnvfv_client_proc_t glGetTexEnvfv; + glGetTexParameterfv_client_proc_t glGetTexParameterfv; + glLightModelf_client_proc_t glLightModelf; + glLightModelfv_client_proc_t glLightModelfv; + glLightf_client_proc_t glLightf; + glLightfv_client_proc_t glLightfv; + glLineWidth_client_proc_t glLineWidth; + glLoadMatrixf_client_proc_t glLoadMatrixf; + glMaterialf_client_proc_t glMaterialf; + glMaterialfv_client_proc_t glMaterialfv; + glMultMatrixf_client_proc_t glMultMatrixf; + glMultiTexCoord4f_client_proc_t glMultiTexCoord4f; + glNormal3f_client_proc_t glNormal3f; + glOrthof_client_proc_t glOrthof; + glPointParameterf_client_proc_t glPointParameterf; + glPointParameterfv_client_proc_t glPointParameterfv; + glPointSize_client_proc_t glPointSize; + glPolygonOffset_client_proc_t glPolygonOffset; + glRotatef_client_proc_t glRotatef; + glScalef_client_proc_t glScalef; + glTexEnvf_client_proc_t glTexEnvf; + glTexEnvfv_client_proc_t glTexEnvfv; + glTexParameterf_client_proc_t glTexParameterf; + glTexParameterfv_client_proc_t glTexParameterfv; + glTranslatef_client_proc_t glTranslatef; + glActiveTexture_client_proc_t glActiveTexture; + glAlphaFuncx_client_proc_t glAlphaFuncx; + glBindBuffer_client_proc_t glBindBuffer; + glBindTexture_client_proc_t glBindTexture; + glBlendFunc_client_proc_t glBlendFunc; + glBufferData_client_proc_t glBufferData; + glBufferSubData_client_proc_t glBufferSubData; + glClear_client_proc_t glClear; + glClearColorx_client_proc_t glClearColorx; + glClearDepthx_client_proc_t glClearDepthx; + glClearStencil_client_proc_t glClearStencil; + glClientActiveTexture_client_proc_t glClientActiveTexture; + glColor4ub_client_proc_t glColor4ub; + glColor4x_client_proc_t glColor4x; + glColorMask_client_proc_t glColorMask; + glColorPointer_client_proc_t glColorPointer; + glCompressedTexImage2D_client_proc_t glCompressedTexImage2D; + glCompressedTexSubImage2D_client_proc_t glCompressedTexSubImage2D; + glCopyTexImage2D_client_proc_t glCopyTexImage2D; + glCopyTexSubImage2D_client_proc_t glCopyTexSubImage2D; + glCullFace_client_proc_t glCullFace; + glDeleteBuffers_client_proc_t glDeleteBuffers; + glDeleteTextures_client_proc_t glDeleteTextures; + glDepthFunc_client_proc_t glDepthFunc; + glDepthMask_client_proc_t glDepthMask; + glDepthRangex_client_proc_t glDepthRangex; + glDisable_client_proc_t glDisable; + glDisableClientState_client_proc_t glDisableClientState; + glDrawArrays_client_proc_t glDrawArrays; + glDrawElements_client_proc_t glDrawElements; + glEnable_client_proc_t glEnable; + glEnableClientState_client_proc_t glEnableClientState; + glFinish_client_proc_t glFinish; + glFlush_client_proc_t glFlush; + glFogx_client_proc_t glFogx; + glFogxv_client_proc_t glFogxv; + glFrontFace_client_proc_t glFrontFace; + glFrustumx_client_proc_t glFrustumx; + glGetBooleanv_client_proc_t glGetBooleanv; + glGetBufferParameteriv_client_proc_t glGetBufferParameteriv; + glClipPlanex_client_proc_t glClipPlanex; + glGenBuffers_client_proc_t glGenBuffers; + glGenTextures_client_proc_t glGenTextures; + glGetError_client_proc_t glGetError; + glGetFixedv_client_proc_t glGetFixedv; + glGetIntegerv_client_proc_t glGetIntegerv; + glGetLightxv_client_proc_t glGetLightxv; + glGetMaterialxv_client_proc_t glGetMaterialxv; + glGetPointerv_client_proc_t glGetPointerv; + glGetString_client_proc_t glGetString; + glGetTexEnviv_client_proc_t glGetTexEnviv; + glGetTexEnvxv_client_proc_t glGetTexEnvxv; + glGetTexParameteriv_client_proc_t glGetTexParameteriv; + glGetTexParameterxv_client_proc_t glGetTexParameterxv; + glHint_client_proc_t glHint; + glIsBuffer_client_proc_t glIsBuffer; + glIsEnabled_client_proc_t glIsEnabled; + glIsTexture_client_proc_t glIsTexture; + glLightModelx_client_proc_t glLightModelx; + glLightModelxv_client_proc_t glLightModelxv; + glLightx_client_proc_t glLightx; + glLightxv_client_proc_t glLightxv; + glLineWidthx_client_proc_t glLineWidthx; + glLoadIdentity_client_proc_t glLoadIdentity; + glLoadMatrixx_client_proc_t glLoadMatrixx; + glLogicOp_client_proc_t glLogicOp; + glMaterialx_client_proc_t glMaterialx; + glMaterialxv_client_proc_t glMaterialxv; + glMatrixMode_client_proc_t glMatrixMode; + glMultMatrixx_client_proc_t glMultMatrixx; + glMultiTexCoord4x_client_proc_t glMultiTexCoord4x; + glNormal3x_client_proc_t glNormal3x; + glNormalPointer_client_proc_t glNormalPointer; + glOrthox_client_proc_t glOrthox; + glPixelStorei_client_proc_t glPixelStorei; + glPointParameterx_client_proc_t glPointParameterx; + glPointParameterxv_client_proc_t glPointParameterxv; + glPointSizex_client_proc_t glPointSizex; + glPolygonOffsetx_client_proc_t glPolygonOffsetx; + glPopMatrix_client_proc_t glPopMatrix; + glPushMatrix_client_proc_t glPushMatrix; + glReadPixels_client_proc_t glReadPixels; + glRotatex_client_proc_t glRotatex; + glSampleCoverage_client_proc_t glSampleCoverage; + glSampleCoveragex_client_proc_t glSampleCoveragex; + glScalex_client_proc_t glScalex; + glScissor_client_proc_t glScissor; + glShadeModel_client_proc_t glShadeModel; + glStencilFunc_client_proc_t glStencilFunc; + glStencilMask_client_proc_t glStencilMask; + glStencilOp_client_proc_t glStencilOp; + glTexCoordPointer_client_proc_t glTexCoordPointer; + glTexEnvi_client_proc_t glTexEnvi; + glTexEnvx_client_proc_t glTexEnvx; + glTexEnviv_client_proc_t glTexEnviv; + glTexEnvxv_client_proc_t glTexEnvxv; + glTexImage2D_client_proc_t glTexImage2D; + glTexParameteri_client_proc_t glTexParameteri; + glTexParameterx_client_proc_t glTexParameterx; + glTexParameteriv_client_proc_t glTexParameteriv; + glTexParameterxv_client_proc_t glTexParameterxv; + glTexSubImage2D_client_proc_t glTexSubImage2D; + glTranslatex_client_proc_t glTranslatex; + glVertexPointer_client_proc_t glVertexPointer; + glViewport_client_proc_t glViewport; + glPointSizePointerOES_client_proc_t glPointSizePointerOES; + glVertexPointerOffset_client_proc_t glVertexPointerOffset; + glColorPointerOffset_client_proc_t glColorPointerOffset; + glNormalPointerOffset_client_proc_t glNormalPointerOffset; + glPointSizePointerOffset_client_proc_t glPointSizePointerOffset; + glTexCoordPointerOffset_client_proc_t glTexCoordPointerOffset; + glWeightPointerOffset_client_proc_t glWeightPointerOffset; + glMatrixIndexPointerOffset_client_proc_t glMatrixIndexPointerOffset; + glVertexPointerData_client_proc_t glVertexPointerData; + glColorPointerData_client_proc_t glColorPointerData; + glNormalPointerData_client_proc_t glNormalPointerData; + glTexCoordPointerData_client_proc_t glTexCoordPointerData; + glPointSizePointerData_client_proc_t glPointSizePointerData; + glWeightPointerData_client_proc_t glWeightPointerData; + glMatrixIndexPointerData_client_proc_t glMatrixIndexPointerData; + glDrawElementsOffset_client_proc_t glDrawElementsOffset; + glDrawElementsData_client_proc_t glDrawElementsData; + glGetCompressedTextureFormats_client_proc_t glGetCompressedTextureFormats; + glFinishRoundTrip_client_proc_t glFinishRoundTrip; + glBlendEquationSeparateOES_client_proc_t glBlendEquationSeparateOES; + glBlendFuncSeparateOES_client_proc_t glBlendFuncSeparateOES; + glBlendEquationOES_client_proc_t glBlendEquationOES; + glDrawTexsOES_client_proc_t glDrawTexsOES; + glDrawTexiOES_client_proc_t glDrawTexiOES; + glDrawTexxOES_client_proc_t glDrawTexxOES; + glDrawTexsvOES_client_proc_t glDrawTexsvOES; + glDrawTexivOES_client_proc_t glDrawTexivOES; + glDrawTexxvOES_client_proc_t glDrawTexxvOES; + glDrawTexfOES_client_proc_t glDrawTexfOES; + glDrawTexfvOES_client_proc_t glDrawTexfvOES; + glEGLImageTargetTexture2DOES_client_proc_t glEGLImageTargetTexture2DOES; + glEGLImageTargetRenderbufferStorageOES_client_proc_t glEGLImageTargetRenderbufferStorageOES; + glAlphaFuncxOES_client_proc_t glAlphaFuncxOES; + glClearColorxOES_client_proc_t glClearColorxOES; + glClearDepthxOES_client_proc_t glClearDepthxOES; + glClipPlanexOES_client_proc_t glClipPlanexOES; + glClipPlanexIMG_client_proc_t glClipPlanexIMG; + glColor4xOES_client_proc_t glColor4xOES; + glDepthRangexOES_client_proc_t glDepthRangexOES; + glFogxOES_client_proc_t glFogxOES; + glFogxvOES_client_proc_t glFogxvOES; + glFrustumxOES_client_proc_t glFrustumxOES; + glGetClipPlanexOES_client_proc_t glGetClipPlanexOES; + glGetClipPlanex_client_proc_t glGetClipPlanex; + glGetFixedvOES_client_proc_t glGetFixedvOES; + glGetLightxvOES_client_proc_t glGetLightxvOES; + glGetMaterialxvOES_client_proc_t glGetMaterialxvOES; + glGetTexEnvxvOES_client_proc_t glGetTexEnvxvOES; + glGetTexParameterxvOES_client_proc_t glGetTexParameterxvOES; + glLightModelxOES_client_proc_t glLightModelxOES; + glLightModelxvOES_client_proc_t glLightModelxvOES; + glLightxOES_client_proc_t glLightxOES; + glLightxvOES_client_proc_t glLightxvOES; + glLineWidthxOES_client_proc_t glLineWidthxOES; + glLoadMatrixxOES_client_proc_t glLoadMatrixxOES; + glMaterialxOES_client_proc_t glMaterialxOES; + glMaterialxvOES_client_proc_t glMaterialxvOES; + glMultMatrixxOES_client_proc_t glMultMatrixxOES; + glMultiTexCoord4xOES_client_proc_t glMultiTexCoord4xOES; + glNormal3xOES_client_proc_t glNormal3xOES; + glOrthoxOES_client_proc_t glOrthoxOES; + glPointParameterxOES_client_proc_t glPointParameterxOES; + glPointParameterxvOES_client_proc_t glPointParameterxvOES; + glPointSizexOES_client_proc_t glPointSizexOES; + glPolygonOffsetxOES_client_proc_t glPolygonOffsetxOES; + glRotatexOES_client_proc_t glRotatexOES; + glSampleCoveragexOES_client_proc_t glSampleCoveragexOES; + glScalexOES_client_proc_t glScalexOES; + glTexEnvxOES_client_proc_t glTexEnvxOES; + glTexEnvxvOES_client_proc_t glTexEnvxvOES; + glTexParameterxOES_client_proc_t glTexParameterxOES; + glTexParameterxvOES_client_proc_t glTexParameterxvOES; + glTranslatexOES_client_proc_t glTranslatexOES; + glIsRenderbufferOES_client_proc_t glIsRenderbufferOES; + glBindRenderbufferOES_client_proc_t glBindRenderbufferOES; + glDeleteRenderbuffersOES_client_proc_t glDeleteRenderbuffersOES; + glGenRenderbuffersOES_client_proc_t glGenRenderbuffersOES; + glRenderbufferStorageOES_client_proc_t glRenderbufferStorageOES; + glGetRenderbufferParameterivOES_client_proc_t glGetRenderbufferParameterivOES; + glIsFramebufferOES_client_proc_t glIsFramebufferOES; + glBindFramebufferOES_client_proc_t glBindFramebufferOES; + glDeleteFramebuffersOES_client_proc_t glDeleteFramebuffersOES; + glGenFramebuffersOES_client_proc_t glGenFramebuffersOES; + glCheckFramebufferStatusOES_client_proc_t glCheckFramebufferStatusOES; + glFramebufferRenderbufferOES_client_proc_t glFramebufferRenderbufferOES; + glFramebufferTexture2DOES_client_proc_t glFramebufferTexture2DOES; + glGetFramebufferAttachmentParameterivOES_client_proc_t glGetFramebufferAttachmentParameterivOES; + glGenerateMipmapOES_client_proc_t glGenerateMipmapOES; + glMapBufferOES_client_proc_t glMapBufferOES; + glUnmapBufferOES_client_proc_t glUnmapBufferOES; + glGetBufferPointervOES_client_proc_t glGetBufferPointervOES; + glCurrentPaletteMatrixOES_client_proc_t glCurrentPaletteMatrixOES; + glLoadPaletteFromModelViewMatrixOES_client_proc_t glLoadPaletteFromModelViewMatrixOES; + glMatrixIndexPointerOES_client_proc_t glMatrixIndexPointerOES; + glWeightPointerOES_client_proc_t glWeightPointerOES; + glQueryMatrixxOES_client_proc_t glQueryMatrixxOES; + glDepthRangefOES_client_proc_t glDepthRangefOES; + glFrustumfOES_client_proc_t glFrustumfOES; + glOrthofOES_client_proc_t glOrthofOES; + glClipPlanefOES_client_proc_t glClipPlanefOES; + glClipPlanefIMG_client_proc_t glClipPlanefIMG; + glGetClipPlanefOES_client_proc_t glGetClipPlanefOES; + glClearDepthfOES_client_proc_t glClearDepthfOES; + glTexGenfOES_client_proc_t glTexGenfOES; + glTexGenfvOES_client_proc_t glTexGenfvOES; + glTexGeniOES_client_proc_t glTexGeniOES; + glTexGenivOES_client_proc_t glTexGenivOES; + glTexGenxOES_client_proc_t glTexGenxOES; + glTexGenxvOES_client_proc_t glTexGenxvOES; + glGetTexGenfvOES_client_proc_t glGetTexGenfvOES; + glGetTexGenivOES_client_proc_t glGetTexGenivOES; + glGetTexGenxvOES_client_proc_t glGetTexGenxvOES; + glBindVertexArrayOES_client_proc_t glBindVertexArrayOES; + glDeleteVertexArraysOES_client_proc_t glDeleteVertexArraysOES; + glGenVertexArraysOES_client_proc_t glGenVertexArraysOES; + glIsVertexArrayOES_client_proc_t glIsVertexArrayOES; + glDiscardFramebufferEXT_client_proc_t glDiscardFramebufferEXT; + glMultiDrawArraysEXT_client_proc_t glMultiDrawArraysEXT; + glMultiDrawElementsEXT_client_proc_t glMultiDrawElementsEXT; + glMultiDrawArraysSUN_client_proc_t glMultiDrawArraysSUN; + glMultiDrawElementsSUN_client_proc_t glMultiDrawElementsSUN; + glRenderbufferStorageMultisampleIMG_client_proc_t glRenderbufferStorageMultisampleIMG; + glFramebufferTexture2DMultisampleIMG_client_proc_t glFramebufferTexture2DMultisampleIMG; + glDeleteFencesNV_client_proc_t glDeleteFencesNV; + glGenFencesNV_client_proc_t glGenFencesNV; + glIsFenceNV_client_proc_t glIsFenceNV; + glTestFenceNV_client_proc_t glTestFenceNV; + glGetFenceivNV_client_proc_t glGetFenceivNV; + glFinishFenceNV_client_proc_t glFinishFenceNV; + glSetFenceNV_client_proc_t glSetFenceNV; + glGetDriverControlsQCOM_client_proc_t glGetDriverControlsQCOM; + glGetDriverControlStringQCOM_client_proc_t glGetDriverControlStringQCOM; + glEnableDriverControlQCOM_client_proc_t glEnableDriverControlQCOM; + glDisableDriverControlQCOM_client_proc_t glDisableDriverControlQCOM; + glExtGetTexturesQCOM_client_proc_t glExtGetTexturesQCOM; + glExtGetBuffersQCOM_client_proc_t glExtGetBuffersQCOM; + glExtGetRenderbuffersQCOM_client_proc_t glExtGetRenderbuffersQCOM; + glExtGetFramebuffersQCOM_client_proc_t glExtGetFramebuffersQCOM; + glExtGetTexLevelParameterivQCOM_client_proc_t glExtGetTexLevelParameterivQCOM; + glExtTexObjectStateOverrideiQCOM_client_proc_t glExtTexObjectStateOverrideiQCOM; + glExtGetTexSubImageQCOM_client_proc_t glExtGetTexSubImageQCOM; + glExtGetBufferPointervQCOM_client_proc_t glExtGetBufferPointervQCOM; + glExtGetShadersQCOM_client_proc_t glExtGetShadersQCOM; + glExtGetProgramsQCOM_client_proc_t glExtGetProgramsQCOM; + glExtIsProgramBinaryQCOM_client_proc_t glExtIsProgramBinaryQCOM; + glExtGetProgramBinarySourceQCOM_client_proc_t glExtGetProgramBinarySourceQCOM; + glStartTilingQCOM_client_proc_t glStartTilingQCOM; + glEndTilingQCOM_client_proc_t glEndTilingQCOM; + virtual ~gl_client_context_t() {} + + typedef gl_client_context_t *CONTEXT_ACCESSOR_TYPE(void); + static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); + virtual void setError(unsigned int error){ (void)error; }; + virtual unsigned int getError(){ return 0; }; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_proc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_proc.h new file mode 100644 index 0000000..707c524 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_client_proc.h @@ -0,0 +1,305 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __gl_client_proc_t_h +#define __gl_client_proc_t_h + + + +#include "gl_types.h" +#ifndef gl_APIENTRY +#define gl_APIENTRY +#endif +typedef void (gl_APIENTRY *glAlphaFunc_client_proc_t) (void * ctx, GLenum, GLclampf); +typedef void (gl_APIENTRY *glClearColor_client_proc_t) (void * ctx, GLclampf, GLclampf, GLclampf, GLclampf); +typedef void (gl_APIENTRY *glClearDepthf_client_proc_t) (void * ctx, GLclampf); +typedef void (gl_APIENTRY *glClipPlanef_client_proc_t) (void * ctx, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glColor4f_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glDepthRangef_client_proc_t) (void * ctx, GLclampf, GLclampf); +typedef void (gl_APIENTRY *glFogf_client_proc_t) (void * ctx, GLenum, GLfloat); +typedef void (gl_APIENTRY *glFogfv_client_proc_t) (void * ctx, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glFrustumf_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glGetClipPlanef_client_proc_t) (void * ctx, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glGetFloatv_client_proc_t) (void * ctx, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glGetLightfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glGetMaterialfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glGetTexEnvfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glGetTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glLightModelf_client_proc_t) (void * ctx, GLenum, GLfloat); +typedef void (gl_APIENTRY *glLightModelfv_client_proc_t) (void * ctx, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glLightf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat); +typedef void (gl_APIENTRY *glLightfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glLineWidth_client_proc_t) (void * ctx, GLfloat); +typedef void (gl_APIENTRY *glLoadMatrixf_client_proc_t) (void * ctx, const GLfloat*); +typedef void (gl_APIENTRY *glMaterialf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat); +typedef void (gl_APIENTRY *glMaterialfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glMultMatrixf_client_proc_t) (void * ctx, const GLfloat*); +typedef void (gl_APIENTRY *glMultiTexCoord4f_client_proc_t) (void * ctx, GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glNormal3f_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glOrthof_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glPointParameterf_client_proc_t) (void * ctx, GLenum, GLfloat); +typedef void (gl_APIENTRY *glPointParameterfv_client_proc_t) (void * ctx, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glPointSize_client_proc_t) (void * ctx, GLfloat); +typedef void (gl_APIENTRY *glPolygonOffset_client_proc_t) (void * ctx, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glRotatef_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glScalef_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glTexEnvf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat); +typedef void (gl_APIENTRY *glTexEnvfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glTexParameterf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat); +typedef void (gl_APIENTRY *glTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glTranslatef_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glActiveTexture_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glAlphaFuncx_client_proc_t) (void * ctx, GLenum, GLclampx); +typedef void (gl_APIENTRY *glBindBuffer_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl_APIENTRY *glBindTexture_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl_APIENTRY *glBlendFunc_client_proc_t) (void * ctx, GLenum, GLenum); +typedef void (gl_APIENTRY *glBufferData_client_proc_t) (void * ctx, GLenum, GLsizeiptr, const GLvoid*, GLenum); +typedef void (gl_APIENTRY *glBufferSubData_client_proc_t) (void * ctx, GLenum, GLintptr, GLsizeiptr, const GLvoid*); +typedef void (gl_APIENTRY *glClear_client_proc_t) (void * ctx, GLbitfield); +typedef void (gl_APIENTRY *glClearColorx_client_proc_t) (void * ctx, GLclampx, GLclampx, GLclampx, GLclampx); +typedef void (gl_APIENTRY *glClearDepthx_client_proc_t) (void * ctx, GLclampx); +typedef void (gl_APIENTRY *glClearStencil_client_proc_t) (void * ctx, GLint); +typedef void (gl_APIENTRY *glClientActiveTexture_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glColor4ub_client_proc_t) (void * ctx, GLubyte, GLubyte, GLubyte, GLubyte); +typedef void (gl_APIENTRY *glColor4x_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glColorMask_client_proc_t) (void * ctx, GLboolean, GLboolean, GLboolean, GLboolean); +typedef void (gl_APIENTRY *glColorPointer_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glCompressedTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glCompressedTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glCopyTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +typedef void (gl_APIENTRY *glCopyTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +typedef void (gl_APIENTRY *glCullFace_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glDeleteBuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl_APIENTRY *glDeleteTextures_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl_APIENTRY *glDepthFunc_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glDepthMask_client_proc_t) (void * ctx, GLboolean); +typedef void (gl_APIENTRY *glDepthRangex_client_proc_t) (void * ctx, GLclampx, GLclampx); +typedef void (gl_APIENTRY *glDisable_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glDisableClientState_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glDrawArrays_client_proc_t) (void * ctx, GLenum, GLint, GLsizei); +typedef void (gl_APIENTRY *glDrawElements_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, const GLvoid*); +typedef void (gl_APIENTRY *glEnable_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glEnableClientState_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glFinish_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glFlush_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glFogx_client_proc_t) (void * ctx, GLenum, GLfixed); +typedef void (gl_APIENTRY *glFogxv_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glFrontFace_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glFrustumx_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glGetBooleanv_client_proc_t) (void * ctx, GLenum, GLboolean*); +typedef void (gl_APIENTRY *glGetBufferParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef void (gl_APIENTRY *glClipPlanex_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glGenBuffers_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl_APIENTRY *glGenTextures_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef GLenum (gl_APIENTRY *glGetError_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glGetFixedv_client_proc_t) (void * ctx, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetIntegerv_client_proc_t) (void * ctx, GLenum, GLint*); +typedef void (gl_APIENTRY *glGetLightxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetMaterialxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetPointerv_client_proc_t) (void * ctx, GLenum, GLvoid**); +typedef const GLubyte* (gl_APIENTRY *glGetString_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glGetTexEnviv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef void (gl_APIENTRY *glGetTexEnvxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef void (gl_APIENTRY *glGetTexParameterxv_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glHint_client_proc_t) (void * ctx, GLenum, GLenum); +typedef GLboolean (gl_APIENTRY *glIsBuffer_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl_APIENTRY *glIsEnabled_client_proc_t) (void * ctx, GLenum); +typedef GLboolean (gl_APIENTRY *glIsTexture_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glLightModelx_client_proc_t) (void * ctx, GLenum, GLfixed); +typedef void (gl_APIENTRY *glLightModelxv_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glLightx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glLightxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glLineWidthx_client_proc_t) (void * ctx, GLfixed); +typedef void (gl_APIENTRY *glLoadIdentity_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glLoadMatrixx_client_proc_t) (void * ctx, const GLfixed*); +typedef void (gl_APIENTRY *glLogicOp_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glMaterialx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glMaterialxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glMatrixMode_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glMultMatrixx_client_proc_t) (void * ctx, const GLfixed*); +typedef void (gl_APIENTRY *glMultiTexCoord4x_client_proc_t) (void * ctx, GLenum, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glNormal3x_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glNormalPointer_client_proc_t) (void * ctx, GLenum, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glOrthox_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glPixelStorei_client_proc_t) (void * ctx, GLenum, GLint); +typedef void (gl_APIENTRY *glPointParameterx_client_proc_t) (void * ctx, GLenum, GLfixed); +typedef void (gl_APIENTRY *glPointParameterxv_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glPointSizex_client_proc_t) (void * ctx, GLfixed); +typedef void (gl_APIENTRY *glPolygonOffsetx_client_proc_t) (void * ctx, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glPopMatrix_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glPushMatrix_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glReadPixels_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); +typedef void (gl_APIENTRY *glRotatex_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glSampleCoverage_client_proc_t) (void * ctx, GLclampf, GLboolean); +typedef void (gl_APIENTRY *glSampleCoveragex_client_proc_t) (void * ctx, GLclampx, GLboolean); +typedef void (gl_APIENTRY *glScalex_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glScissor_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei); +typedef void (gl_APIENTRY *glShadeModel_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glStencilFunc_client_proc_t) (void * ctx, GLenum, GLint, GLuint); +typedef void (gl_APIENTRY *glStencilMask_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glStencilOp_client_proc_t) (void * ctx, GLenum, GLenum, GLenum); +typedef void (gl_APIENTRY *glTexCoordPointer_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glTexEnvi_client_proc_t) (void * ctx, GLenum, GLenum, GLint); +typedef void (gl_APIENTRY *glTexEnvx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glTexEnviv_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*); +typedef void (gl_APIENTRY *glTexEnvxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); +typedef void (gl_APIENTRY *glTexParameteri_client_proc_t) (void * ctx, GLenum, GLenum, GLint); +typedef void (gl_APIENTRY *glTexParameterx_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*); +typedef void (gl_APIENTRY *glTexParameterxv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*); +typedef void (gl_APIENTRY *glTranslatex_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glVertexPointer_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glViewport_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei); +typedef void (gl_APIENTRY *glPointSizePointerOES_client_proc_t) (void * ctx, GLenum, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glVertexPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint); +typedef void (gl_APIENTRY *glColorPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint); +typedef void (gl_APIENTRY *glNormalPointerOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLuint); +typedef void (gl_APIENTRY *glPointSizePointerOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLuint); +typedef void (gl_APIENTRY *glTexCoordPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint); +typedef void (gl_APIENTRY *glWeightPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint); +typedef void (gl_APIENTRY *glMatrixIndexPointerOffset_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, GLuint); +typedef void (gl_APIENTRY *glVertexPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint); +typedef void (gl_APIENTRY *glColorPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint); +typedef void (gl_APIENTRY *glNormalPointerData_client_proc_t) (void * ctx, GLenum, GLsizei, void*, GLuint); +typedef void (gl_APIENTRY *glTexCoordPointerData_client_proc_t) (void * ctx, GLint, GLint, GLenum, GLsizei, void*, GLuint); +typedef void (gl_APIENTRY *glPointSizePointerData_client_proc_t) (void * ctx, GLenum, GLsizei, void*, GLuint); +typedef void (gl_APIENTRY *glWeightPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint); +typedef void (gl_APIENTRY *glMatrixIndexPointerData_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, void*, GLuint); +typedef void (gl_APIENTRY *glDrawElementsOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLuint); +typedef void (gl_APIENTRY *glDrawElementsData_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, void*, GLuint); +typedef void (gl_APIENTRY *glGetCompressedTextureFormats_client_proc_t) (void * ctx, int, GLint*); +typedef int (gl_APIENTRY *glFinishRoundTrip_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glBlendEquationSeparateOES_client_proc_t) (void * ctx, GLenum, GLenum); +typedef void (gl_APIENTRY *glBlendFuncSeparateOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLenum); +typedef void (gl_APIENTRY *glBlendEquationOES_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glDrawTexsOES_client_proc_t) (void * ctx, GLshort, GLshort, GLshort, GLshort, GLshort); +typedef void (gl_APIENTRY *glDrawTexiOES_client_proc_t) (void * ctx, GLint, GLint, GLint, GLint, GLint); +typedef void (gl_APIENTRY *glDrawTexxOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glDrawTexsvOES_client_proc_t) (void * ctx, const GLshort*); +typedef void (gl_APIENTRY *glDrawTexivOES_client_proc_t) (void * ctx, const GLint*); +typedef void (gl_APIENTRY *glDrawTexxvOES_client_proc_t) (void * ctx, const GLfixed*); +typedef void (gl_APIENTRY *glDrawTexfOES_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glDrawTexfvOES_client_proc_t) (void * ctx, const GLfloat*); +typedef void (gl_APIENTRY *glEGLImageTargetTexture2DOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES); +typedef void (gl_APIENTRY *glEGLImageTargetRenderbufferStorageOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES); +typedef void (gl_APIENTRY *glAlphaFuncxOES_client_proc_t) (void * ctx, GLenum, GLclampx); +typedef void (gl_APIENTRY *glClearColorxOES_client_proc_t) (void * ctx, GLclampx, GLclampx, GLclampx, GLclampx); +typedef void (gl_APIENTRY *glClearDepthxOES_client_proc_t) (void * ctx, GLclampx); +typedef void (gl_APIENTRY *glClipPlanexOES_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glClipPlanexIMG_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glColor4xOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glDepthRangexOES_client_proc_t) (void * ctx, GLclampx, GLclampx); +typedef void (gl_APIENTRY *glFogxOES_client_proc_t) (void * ctx, GLenum, GLfixed); +typedef void (gl_APIENTRY *glFogxvOES_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glFrustumxOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glGetClipPlanexOES_client_proc_t) (void * ctx, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetClipPlanex_client_proc_t) (void * ctx, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetFixedvOES_client_proc_t) (void * ctx, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetLightxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetMaterialxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetTexEnvxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glGetTexParameterxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glLightModelxOES_client_proc_t) (void * ctx, GLenum, GLfixed); +typedef void (gl_APIENTRY *glLightModelxvOES_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glLightxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glLightxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glLineWidthxOES_client_proc_t) (void * ctx, GLfixed); +typedef void (gl_APIENTRY *glLoadMatrixxOES_client_proc_t) (void * ctx, const GLfixed*); +typedef void (gl_APIENTRY *glMaterialxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glMaterialxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glMultMatrixxOES_client_proc_t) (void * ctx, const GLfixed*); +typedef void (gl_APIENTRY *glMultiTexCoord4xOES_client_proc_t) (void * ctx, GLenum, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glNormal3xOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glOrthoxOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glPointParameterxOES_client_proc_t) (void * ctx, GLenum, GLfixed); +typedef void (gl_APIENTRY *glPointParameterxvOES_client_proc_t) (void * ctx, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glPointSizexOES_client_proc_t) (void * ctx, GLfixed); +typedef void (gl_APIENTRY *glPolygonOffsetxOES_client_proc_t) (void * ctx, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glRotatexOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glSampleCoveragexOES_client_proc_t) (void * ctx, GLclampx, GLboolean); +typedef void (gl_APIENTRY *glScalexOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed); +typedef void (gl_APIENTRY *glTexEnvxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glTexEnvxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glTexParameterxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glTexParameterxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glTranslatexOES_client_proc_t) (void * ctx, GLfixed, GLfixed, GLfixed); +typedef GLboolean (gl_APIENTRY *glIsRenderbufferOES_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glBindRenderbufferOES_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl_APIENTRY *glDeleteRenderbuffersOES_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl_APIENTRY *glGenRenderbuffersOES_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl_APIENTRY *glRenderbufferStorageOES_client_proc_t) (void * ctx, GLenum, GLenum, GLsizei, GLsizei); +typedef void (gl_APIENTRY *glGetRenderbufferParameterivOES_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef GLboolean (gl_APIENTRY *glIsFramebufferOES_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glBindFramebufferOES_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl_APIENTRY *glDeleteFramebuffersOES_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl_APIENTRY *glGenFramebuffersOES_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef GLenum (gl_APIENTRY *glCheckFramebufferStatusOES_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glFramebufferRenderbufferOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint); +typedef void (gl_APIENTRY *glFramebufferTexture2DOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint); +typedef void (gl_APIENTRY *glGetFramebufferAttachmentParameterivOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLint*); +typedef void (gl_APIENTRY *glGenerateMipmapOES_client_proc_t) (void * ctx, GLenum); +typedef void* (gl_APIENTRY *glMapBufferOES_client_proc_t) (void * ctx, GLenum, GLenum); +typedef GLboolean (gl_APIENTRY *glUnmapBufferOES_client_proc_t) (void * ctx, GLenum); +typedef void (gl_APIENTRY *glGetBufferPointervOES_client_proc_t) (void * ctx, GLenum, GLenum, GLvoid**); +typedef void (gl_APIENTRY *glCurrentPaletteMatrixOES_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glLoadPaletteFromModelViewMatrixOES_client_proc_t) (void * ctx); +typedef void (gl_APIENTRY *glMatrixIndexPointerOES_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*); +typedef void (gl_APIENTRY *glWeightPointerOES_client_proc_t) (void * ctx, GLint, GLenum, GLsizei, const GLvoid*); +typedef GLbitfield (gl_APIENTRY *glQueryMatrixxOES_client_proc_t) (void * ctx, GLfixed*, GLint*); +typedef void (gl_APIENTRY *glDepthRangefOES_client_proc_t) (void * ctx, GLclampf, GLclampf); +typedef void (gl_APIENTRY *glFrustumfOES_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glOrthofOES_client_proc_t) (void * ctx, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl_APIENTRY *glClipPlanefOES_client_proc_t) (void * ctx, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glClipPlanefIMG_client_proc_t) (void * ctx, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glGetClipPlanefOES_client_proc_t) (void * ctx, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glClearDepthfOES_client_proc_t) (void * ctx, GLclampf); +typedef void (gl_APIENTRY *glTexGenfOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat); +typedef void (gl_APIENTRY *glTexGenfvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*); +typedef void (gl_APIENTRY *glTexGeniOES_client_proc_t) (void * ctx, GLenum, GLenum, GLint); +typedef void (gl_APIENTRY *glTexGenivOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*); +typedef void (gl_APIENTRY *glTexGenxOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed); +typedef void (gl_APIENTRY *glTexGenxvOES_client_proc_t) (void * ctx, GLenum, GLenum, const GLfixed*); +typedef void (gl_APIENTRY *glGetTexGenfvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*); +typedef void (gl_APIENTRY *glGetTexGenivOES_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef void (gl_APIENTRY *glGetTexGenxvOES_client_proc_t) (void * ctx, GLenum, GLenum, GLfixed*); +typedef void (gl_APIENTRY *glBindVertexArrayOES_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glDeleteVertexArraysOES_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl_APIENTRY *glGenVertexArraysOES_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef GLboolean (gl_APIENTRY *glIsVertexArrayOES_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glDiscardFramebufferEXT_client_proc_t) (void * ctx, GLenum, GLsizei, const GLenum*); +typedef void (gl_APIENTRY *glMultiDrawArraysEXT_client_proc_t) (void * ctx, GLenum, const GLint*, const GLsizei*, GLsizei); +typedef void (gl_APIENTRY *glMultiDrawElementsEXT_client_proc_t) (void * ctx, GLenum, const GLsizei*, GLenum, const GLvoid* const*, GLsizei); +typedef void (gl_APIENTRY *glMultiDrawArraysSUN_client_proc_t) (void * ctx, GLenum, GLint*, GLsizei*, GLsizei); +typedef void (gl_APIENTRY *glMultiDrawElementsSUN_client_proc_t) (void * ctx, GLenum, const GLsizei*, GLenum, const GLvoid**, GLsizei); +typedef void (gl_APIENTRY *glRenderbufferStorageMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLsizei, GLsizei); +typedef void (gl_APIENTRY *glFramebufferTexture2DMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); +typedef void (gl_APIENTRY *glDeleteFencesNV_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl_APIENTRY *glGenFencesNV_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef GLboolean (gl_APIENTRY *glIsFenceNV_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl_APIENTRY *glTestFenceNV_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glGetFenceivNV_client_proc_t) (void * ctx, GLuint, GLenum, GLint*); +typedef void (gl_APIENTRY *glFinishFenceNV_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glSetFenceNV_client_proc_t) (void * ctx, GLuint, GLenum); +typedef void (gl_APIENTRY *glGetDriverControlsQCOM_client_proc_t) (void * ctx, GLint*, GLsizei, GLuint*); +typedef void (gl_APIENTRY *glGetDriverControlStringQCOM_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*); +typedef void (gl_APIENTRY *glEnableDriverControlQCOM_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glDisableDriverControlQCOM_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glExtGetTexturesQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl_APIENTRY *glExtGetBuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl_APIENTRY *glExtGetRenderbuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl_APIENTRY *glExtGetFramebuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl_APIENTRY *glExtGetTexLevelParameterivQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLint, GLenum, GLint*); +typedef void (gl_APIENTRY *glExtTexObjectStateOverrideiQCOM_client_proc_t) (void * ctx, GLenum, GLenum, GLint); +typedef void (gl_APIENTRY *glExtGetTexSubImageQCOM_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); +typedef void (gl_APIENTRY *glExtGetBufferPointervQCOM_client_proc_t) (void * ctx, GLenum, GLvoid**); +typedef void (gl_APIENTRY *glExtGetShadersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl_APIENTRY *glExtGetProgramsQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef GLboolean (gl_APIENTRY *glExtIsProgramBinaryQCOM_client_proc_t) (void * ctx, GLuint); +typedef void (gl_APIENTRY *glExtGetProgramBinarySourceQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLchar*, GLint*); +typedef void (gl_APIENTRY *glStartTilingQCOM_client_proc_t) (void * ctx, GLuint, GLuint, GLuint, GLuint, GLbitfield); +typedef void (gl_APIENTRY *glEndTilingQCOM_client_proc_t) (void * ctx, GLbitfield); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.cpp new file mode 100644 index 0000000..6206cce --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.cpp @@ -0,0 +1,8463 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include +#include "gl_opcodes.h" + +#include "gl_enc.h" + + +#include + +namespace { + +void enc_unsupported() +{ + ALOGE("Function is unsupported\n"); +} + +void glAlphaFunc_enc(void *self , GLenum func, GLclampf ref) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearColor;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearDepthf_enc(void *self , GLclampf depth) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearDepthf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &depth, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClipPlanef_enc(void *self , GLenum plane, const GLfloat* equation) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_equation = (4 * sizeof(float)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_equation + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClipPlanef;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &plane, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_equation; ptr += 4; + memcpy(ptr, equation, __size_equation);ptr += __size_equation; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColor4f_enc(void *self , GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColor4f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthRangef_enc(void *self , GLclampf zNear, GLclampf zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthRangef;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFogf_enc(void *self , GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFogf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFogfv_enc(void *self , GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFogfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFrustumf_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFrustumf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetClipPlanef_enc(void *self , GLenum pname, GLfloat* eqn) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_eqn = (4 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_eqn + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetClipPlanef;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_eqn; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(eqn, __size_eqn); + if (useChecksum) checksumCalculator->addBuffer(eqn, __size_eqn); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetClipPlanef: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetFloatv_enc(void *self , GLenum pname, GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetFloatv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetFloatv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetLightfv_enc(void *self , GLenum light, GLenum pname, GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetLightfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetLightfv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetMaterialfv_enc(void *self , GLenum face, GLenum pname, GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetMaterialfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetMaterialfv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexEnvfv_enc(void *self , GLenum env, GLenum pname, GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexEnvfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &env, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexEnvfv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexParameterfv_enc(void *self , GLenum target, GLenum pname, GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexParameterfv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glLightModelf_enc(void *self , GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightModelf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightModelfv_enc(void *self , GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightModelfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightf_enc(void *self , GLenum light, GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightfv_enc(void *self , GLenum light, GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLineWidth_enc(void *self , GLfloat width) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLineWidth;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &width, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLoadMatrixf_enc(void *self , const GLfloat* m) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_m = (16 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_m + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLoadMatrixf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_m; ptr += 4; + memcpy(ptr, m, __size_m);ptr += __size_m; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMaterialf_enc(void *self , GLenum face, GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMaterialf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMaterialfv_enc(void *self , GLenum face, GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMaterialfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMultMatrixf_enc(void *self , const GLfloat* m) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_m = (16 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_m + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMultMatrixf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_m; ptr += 4; + memcpy(ptr, m, __size_m);ptr += __size_m; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMultiTexCoord4f_enc(void *self , GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMultiTexCoord4f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &s, 4); ptr += 4; + memcpy(ptr, &t, 4); ptr += 4; + memcpy(ptr, &r, 4); ptr += 4; + memcpy(ptr, &q, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glNormal3f_enc(void *self , GLfloat nx, GLfloat ny, GLfloat nz) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glNormal3f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &nx, 4); ptr += 4; + memcpy(ptr, &ny, 4); ptr += 4; + memcpy(ptr, &nz, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glOrthof_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glOrthof;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointParameterf_enc(void *self , GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointParameterf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointParameterfv_enc(void *self , GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointParameterfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointSize_enc(void *self , GLfloat size) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointSize;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPolygonOffset_enc(void *self , GLfloat factor, GLfloat units) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPolygonOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &factor, 4); ptr += 4; + memcpy(ptr, &units, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glRotatef_enc(void *self , GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glRotatef;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &angle, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glScalef_enc(void *self , GLfloat x, GLfloat y, GLfloat z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glScalef;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnvf_enc(void *self , GLenum target, GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnvf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnvfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnvfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameterf_enc(void *self , GLenum target, GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameterfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTranslatef_enc(void *self , GLfloat x, GLfloat y, GLfloat z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTranslatef;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glActiveTexture_enc(void *self , GLenum texture) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glActiveTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &texture, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glAlphaFuncx_enc(void *self , GLenum func, GLclampx ref) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glAlphaFuncx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindBuffer_enc(void *self , GLenum target, GLuint buffer) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &buffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindTexture_enc(void *self , GLenum target, GLuint texture) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &texture, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendFunc_enc(void *self , GLenum sfactor, GLenum dfactor) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &sfactor, 4); ptr += 4; + memcpy(ptr, &dfactor, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBufferData_enc(void *self , GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? size : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBufferData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + if (data != NULL) memcpy(ptr, data, __size_data);ptr += __size_data; + memcpy(ptr, &usage, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBufferSubData_enc(void *self , GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? size : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBufferSubData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + if (data != NULL) memcpy(ptr, data, __size_data);ptr += __size_data; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClear_enc(void *self , GLbitfield mask) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClear;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearColorx_enc(void *self , GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearColorx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearDepthx_enc(void *self , GLclampx depth) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearDepthx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &depth, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearStencil_enc(void *self , GLint s) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearStencil;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &s, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClientActiveTexture_enc(void *self , GLenum texture) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClientActiveTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &texture, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColor4ub_enc(void *self , GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 1 + 1 + 1 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColor4ub;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 1); ptr += 1; + memcpy(ptr, &green, 1); ptr += 1; + memcpy(ptr, &blue, 1); ptr += 1; + memcpy(ptr, &alpha, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColor4x_enc(void *self , GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColor4x;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColorMask_enc(void *self , GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 1 + 1 + 1 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColorMask;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 1); ptr += 1; + memcpy(ptr, &green, 1); ptr += 1; + memcpy(ptr, &blue, 1); ptr += 1; + memcpy(ptr, &alpha, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCompressedTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? imageSize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCompressedTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + memcpy(ptr, &imageSize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + if (data != NULL) memcpy(ptr, data, __size_data);ptr += __size_data; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCompressedTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? imageSize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCompressedTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &imageSize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + if (data != NULL) memcpy(ptr, data, __size_data);ptr += __size_data; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCopyTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCopyTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCopyTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCopyTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCullFace_enc(void *self , GLenum mode) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCullFace;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteBuffers_enc(void *self , GLsizei n, const GLuint* buffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_buffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteBuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_buffers; ptr += 4; + memcpy(ptr, buffers, __size_buffers);ptr += __size_buffers; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteTextures_enc(void *self , GLsizei n, const GLuint* textures) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_textures = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_textures + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteTextures;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_textures; ptr += 4; + memcpy(ptr, textures, __size_textures);ptr += __size_textures; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthFunc_enc(void *self , GLenum func) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthMask_enc(void *self , GLboolean flag) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthMask;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &flag, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthRangex_enc(void *self , GLclampx zNear, GLclampx zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthRangex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDisable_enc(void *self , GLenum cap) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDisable;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &cap, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDisableClientState_enc(void *self , GLenum array) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDisableClientState;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &array, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawArrays_enc(void *self , GLenum mode, GLint first, GLsizei count) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawArrays;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + memcpy(ptr, &first, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEnable_enc(void *self , GLenum cap) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEnable;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &cap, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEnableClientState_enc(void *self , GLenum array) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEnableClientState;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &array, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFinish_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFinish;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFlush_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFlush;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFogx_enc(void *self , GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFogx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFogxv_enc(void *self , GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFogxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFrontFace_enc(void *self , GLenum mode) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFrontFace;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFrustumx_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFrustumx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetBooleanv_enc(void *self , GLenum pname, GLboolean* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLboolean)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetBooleanv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetBooleanv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetBufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetBufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetBufferParameteriv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glClipPlanex_enc(void *self , GLenum pname, const GLfixed* eqn) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_eqn = (4 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_eqn + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClipPlanex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_eqn; ptr += 4; + memcpy(ptr, eqn, __size_eqn);ptr += __size_eqn; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenBuffers_enc(void *self , GLsizei n, GLuint* buffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_buffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenBuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_buffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(buffers, __size_buffers); + if (useChecksum) checksumCalculator->addBuffer(buffers, __size_buffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenBuffers: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGenTextures_enc(void *self , GLsizei n, GLuint* textures) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_textures = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_textures + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenTextures;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_textures; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(textures, __size_textures); + if (useChecksum) checksumCalculator->addBuffer(textures, __size_textures); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenTextures: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +GLenum glGetError_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetError;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLenum retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetError: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glGetFixedv_enc(void *self , GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetFixedv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetFixedv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetIntegerv_enc(void *self , GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetIntegerv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetIntegerv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetLightxv_enc(void *self , GLenum light, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetLightxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetLightxv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetMaterialxv_enc(void *self , GLenum face, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetMaterialxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetMaterialxv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexEnviv_enc(void *self , GLenum env, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexEnviv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &env, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexEnviv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexEnvxv_enc(void *self , GLenum env, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexEnvxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &env, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexEnvxv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexParameteriv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexParameterxv_enc(void *self , GLenum target, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexParameterxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexParameterxv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glHint_enc(void *self , GLenum target, GLenum mode) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glHint;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLboolean glIsBuffer_enc(void *self , GLuint buffer) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &buffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsEnabled_enc(void *self , GLenum cap) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsEnabled;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &cap, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsEnabled: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsTexture_enc(void *self , GLuint texture) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &texture, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsTexture: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glLightModelx_enc(void *self , GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightModelx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightModelxv_enc(void *self , GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightModelxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightx_enc(void *self , GLenum light, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightxv_enc(void *self , GLenum light, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLineWidthx_enc(void *self , GLfixed width) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLineWidthx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &width, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLoadIdentity_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLoadIdentity;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLoadMatrixx_enc(void *self , const GLfixed* m) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_m = (16 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_m + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLoadMatrixx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_m; ptr += 4; + memcpy(ptr, m, __size_m);ptr += __size_m; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLogicOp_enc(void *self , GLenum opcode) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLogicOp;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &opcode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMaterialx_enc(void *self , GLenum face, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMaterialx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMaterialxv_enc(void *self , GLenum face, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMaterialxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMatrixMode_enc(void *self , GLenum mode) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMatrixMode;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMultMatrixx_enc(void *self , const GLfixed* m) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_m = (16 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_m + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMultMatrixx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_m; ptr += 4; + memcpy(ptr, m, __size_m);ptr += __size_m; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMultiTexCoord4x_enc(void *self , GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMultiTexCoord4x;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &s, 4); ptr += 4; + memcpy(ptr, &t, 4); ptr += 4; + memcpy(ptr, &r, 4); ptr += 4; + memcpy(ptr, &q, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glNormal3x_enc(void *self , GLfixed nx, GLfixed ny, GLfixed nz) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glNormal3x;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &nx, 4); ptr += 4; + memcpy(ptr, &ny, 4); ptr += 4; + memcpy(ptr, &nz, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glOrthox_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glOrthox;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPixelStorei_enc(void *self , GLenum pname, GLint param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPixelStorei;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointParameterx_enc(void *self , GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointParameterx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointParameterxv_enc(void *self , GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointParameterxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointSizex_enc(void *self , GLfixed size) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointSizex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPolygonOffsetx_enc(void *self , GLfixed factor, GLfixed units) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPolygonOffsetx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &factor, 4); ptr += 4; + memcpy(ptr, &units, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPopMatrix_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPopMatrix;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPushMatrix_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPushMatrix;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = glesv1_enc::pixelDataSize(self, width, height, format, type, 1); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glReadPixels;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_pixels; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glReadPixels: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glRotatex_enc(void *self , GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glRotatex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &angle, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glSampleCoverage_enc(void *self , GLclampf value, GLboolean invert) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glSampleCoverage;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &value, 4); ptr += 4; + memcpy(ptr, &invert, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glSampleCoveragex_enc(void *self , GLclampx value, GLboolean invert) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glSampleCoveragex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &value, 4); ptr += 4; + memcpy(ptr, &invert, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glScalex_enc(void *self , GLfixed x, GLfixed y, GLfixed z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glScalex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glScissor_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glScissor;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glShadeModel_enc(void *self , GLenum mode) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glShadeModel;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilFunc_enc(void *self , GLenum func, GLint ref, GLuint mask) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilMask_enc(void *self , GLuint mask) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilMask;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilOp_enc(void *self , GLenum fail, GLenum zfail, GLenum zpass) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilOp;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &fail, 4); ptr += 4; + memcpy(ptr, &zfail, 4); ptr += 4; + memcpy(ptr, &zpass, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnvi_enc(void *self , GLenum target, GLenum pname, GLint param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnvi;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnvx_enc(void *self , GLenum target, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnvx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnviv_enc(void *self , GLenum target, GLenum pname, const GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnviv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnvxv_enc(void *self , GLenum target, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnvxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexImage2D_enc(void *self , GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = ((pixels != NULL) ? glesv1_enc::pixelDataSize(self, width, height, format, type, 0) : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_pixels,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4); + if (pixels != NULL) { + stream->writeFully(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glTexParameteri_enc(void *self , GLenum target, GLenum pname, GLint param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameteri;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameterx_enc(void *self , GLenum target, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterx;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameteriv_enc(void *self , GLenum target, GLenum pname, const GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameterxv_enc(void *self , GLenum target, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterxv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = ((pixels != NULL) ? glesv1_enc::pixelDataSize(self, width, height, format, type, 0) : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_pixels,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4); + if (pixels != NULL) { + stream->writeFully(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glTranslatex_enc(void *self , GLfixed x, GLfixed y, GLfixed z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTranslatex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glViewport_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glViewport;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColorPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColorPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glNormalPointerOffset_enc(void *self , GLenum type, GLsizei stride, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glNormalPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointSizePointerOffset_enc(void *self , GLenum type, GLsizei stride, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointSizePointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexCoordPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexCoordPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glWeightPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glWeightPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMatrixIndexPointerOffset_enc(void *self , GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMatrixIndexPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexPointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColorPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColorPointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glNormalPointerData_enc(void *self , GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glNormalPointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 3, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexCoordPointerData_enc(void *self , GLint unit, GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexCoordPointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &unit, 4); ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointSizePointerData_enc(void *self , GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointSizePointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 1, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glWeightPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glWeightPointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMatrixIndexPointerData_enc(void *self , GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMatrixIndexPointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawElementsOffset_enc(void *self , GLenum mode, GLsizei count, GLenum type, GLuint offset) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawElementsOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawElementsData_enc(void *self , GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawElementsData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + memcpy(ptr, data, __size_data);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetCompressedTextureFormats_enc(void *self , int count, GLint* formats) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_formats = (count * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_formats + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetCompressedTextureFormats;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_formats; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(formats, __size_formats); + if (useChecksum) checksumCalculator->addBuffer(formats, __size_formats); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetCompressedTextureFormats: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +int glFinishRoundTrip_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFinishRoundTrip;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glFinishRoundTrip: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glBlendEquationSeparateOES_enc(void *self , GLenum modeRGB, GLenum modeAlpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendEquationSeparateOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &modeRGB, 4); ptr += 4; + memcpy(ptr, &modeAlpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendFuncSeparateOES_enc(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendFuncSeparateOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &srcRGB, 4); ptr += 4; + memcpy(ptr, &dstRGB, 4); ptr += 4; + memcpy(ptr, &srcAlpha, 4); ptr += 4; + memcpy(ptr, &dstAlpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendEquationOES_enc(void *self , GLenum mode) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendEquationOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexsOES_enc(void *self , GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 2 + 2 + 2 + 2 + 2; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexsOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 2); ptr += 2; + memcpy(ptr, &y, 2); ptr += 2; + memcpy(ptr, &z, 2); ptr += 2; + memcpy(ptr, &width, 2); ptr += 2; + memcpy(ptr, &height, 2); ptr += 2; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexiOES_enc(void *self , GLint x, GLint y, GLint z, GLint width, GLint height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexiOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexxOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexsvOES_enc(void *self , const GLshort* coords) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_coords = (5 * sizeof(GLshort)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_coords + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexsvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_coords; ptr += 4; + memcpy(ptr, coords, __size_coords);ptr += __size_coords; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexivOES_enc(void *self , const GLint* coords) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_coords = (5 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_coords + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexivOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_coords; ptr += 4; + memcpy(ptr, coords, __size_coords);ptr += __size_coords; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexxvOES_enc(void *self , const GLfixed* coords) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_coords = (5 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_coords + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_coords; ptr += 4; + memcpy(ptr, coords, __size_coords);ptr += __size_coords; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexfOES_enc(void *self , GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexfOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawTexfvOES_enc(void *self , const GLfloat* coords) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_coords = (5 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_coords + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawTexfvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_coords; ptr += 4; + memcpy(ptr, coords, __size_coords);ptr += __size_coords; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEGLImageTargetTexture2DOES_enc(void *self , GLenum target, GLeglImageOES image) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEGLImageTargetTexture2DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &image, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEGLImageTargetRenderbufferStorageOES_enc(void *self , GLenum target, GLeglImageOES image) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEGLImageTargetRenderbufferStorageOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &image, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glAlphaFuncxOES_enc(void *self , GLenum func, GLclampx ref) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glAlphaFuncxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearColorxOES_enc(void *self , GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearColorxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearDepthxOES_enc(void *self , GLclampx depth) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearDepthxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &depth, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClipPlanexOES_enc(void *self , GLenum plane, const GLfixed* equation) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_equation = (4 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_equation + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClipPlanexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &plane, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_equation; ptr += 4; + memcpy(ptr, equation, __size_equation);ptr += __size_equation; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClipPlanexIMG_enc(void *self , GLenum plane, const GLfixed* equation) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_equation = (4 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_equation + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClipPlanexIMG;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &plane, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_equation; ptr += 4; + memcpy(ptr, equation, __size_equation);ptr += __size_equation; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColor4xOES_enc(void *self , GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColor4xOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthRangexOES_enc(void *self , GLclampx zNear, GLclampx zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthRangexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFogxOES_enc(void *self , GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFogxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFogxvOES_enc(void *self , GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFogxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFrustumxOES_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFrustumxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetClipPlanexOES_enc(void *self , GLenum pname, GLfixed* eqn) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_eqn = (4 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_eqn + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetClipPlanexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_eqn; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(eqn, __size_eqn); + if (useChecksum) checksumCalculator->addBuffer(eqn, __size_eqn); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetClipPlanexOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetClipPlanex_enc(void *self , GLenum pname, GLfixed* eqn) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_eqn = (4 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_eqn + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetClipPlanex;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_eqn; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(eqn, __size_eqn); + if (useChecksum) checksumCalculator->addBuffer(eqn, __size_eqn); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetClipPlanex: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetFixedvOES_enc(void *self , GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetFixedvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetFixedvOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetLightxvOES_enc(void *self , GLenum light, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetLightxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetLightxvOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetMaterialxvOES_enc(void *self , GLenum face, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetMaterialxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetMaterialxvOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexEnvxvOES_enc(void *self , GLenum env, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexEnvxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &env, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexEnvxvOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexParameterxvOES_enc(void *self , GLenum target, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexParameterxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexParameterxvOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glLightModelxOES_enc(void *self , GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightModelxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightModelxvOES_enc(void *self , GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightModelxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightxOES_enc(void *self , GLenum light, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLightxvOES_enc(void *self , GLenum light, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLightxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &light, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLineWidthxOES_enc(void *self , GLfixed width) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLineWidthxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &width, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLoadMatrixxOES_enc(void *self , const GLfixed* m) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_m = (16 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_m + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLoadMatrixxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_m; ptr += 4; + memcpy(ptr, m, __size_m);ptr += __size_m; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMaterialxOES_enc(void *self , GLenum face, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMaterialxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMaterialxvOES_enc(void *self , GLenum face, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMaterialxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMultMatrixxOES_enc(void *self , const GLfixed* m) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_m = (16 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_m + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMultMatrixxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_m; ptr += 4; + memcpy(ptr, m, __size_m);ptr += __size_m; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glMultiTexCoord4xOES_enc(void *self , GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glMultiTexCoord4xOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &s, 4); ptr += 4; + memcpy(ptr, &t, 4); ptr += 4; + memcpy(ptr, &r, 4); ptr += 4; + memcpy(ptr, &q, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glNormal3xOES_enc(void *self , GLfixed nx, GLfixed ny, GLfixed nz) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glNormal3xOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &nx, 4); ptr += 4; + memcpy(ptr, &ny, 4); ptr += 4; + memcpy(ptr, &nz, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glOrthoxOES_enc(void *self , GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glOrthoxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointParameterxOES_enc(void *self , GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointParameterxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointParameterxvOES_enc(void *self , GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointParameterxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPointSizexOES_enc(void *self , GLfixed size) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPointSizexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &size, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPolygonOffsetxOES_enc(void *self , GLfixed factor, GLfixed units) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPolygonOffsetxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &factor, 4); ptr += 4; + memcpy(ptr, &units, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glRotatexOES_enc(void *self , GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glRotatexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &angle, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glSampleCoveragexOES_enc(void *self , GLclampx value, GLboolean invert) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glSampleCoveragexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &value, 4); ptr += 4; + memcpy(ptr, &invert, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glScalexOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glScalexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnvxOES_enc(void *self , GLenum target, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnvxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexEnvxvOES_enc(void *self , GLenum target, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexEnvxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameterxOES_enc(void *self , GLenum target, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameterxvOES_enc(void *self , GLenum target, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTranslatexOES_enc(void *self , GLfixed x, GLfixed y, GLfixed z) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTranslatexOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLboolean glIsRenderbufferOES_enc(void *self , GLuint renderbuffer) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsRenderbufferOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &renderbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsRenderbufferOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glBindRenderbufferOES_enc(void *self , GLenum target, GLuint renderbuffer) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindRenderbufferOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &renderbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteRenderbuffersOES_enc(void *self , GLsizei n, const GLuint* renderbuffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_renderbuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_renderbuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteRenderbuffersOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4; + memcpy(ptr, renderbuffers, __size_renderbuffers);ptr += __size_renderbuffers; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenRenderbuffersOES_enc(void *self , GLsizei n, GLuint* renderbuffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_renderbuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_renderbuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenRenderbuffersOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(renderbuffers, __size_renderbuffers); + if (useChecksum) checksumCalculator->addBuffer(renderbuffers, __size_renderbuffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenRenderbuffersOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glRenderbufferStorageOES_enc(void *self , GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glRenderbufferStorageOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetRenderbufferParameterivOES_enc(void *self , GLenum target, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetRenderbufferParameterivOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetRenderbufferParameterivOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +GLboolean glIsFramebufferOES_enc(void *self , GLuint framebuffer) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsFramebufferOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &framebuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsFramebufferOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glBindFramebufferOES_enc(void *self , GLenum target, GLuint framebuffer) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindFramebufferOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &framebuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteFramebuffersOES_enc(void *self , GLsizei n, const GLuint* framebuffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_framebuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_framebuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteFramebuffersOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_framebuffers; ptr += 4; + memcpy(ptr, framebuffers, __size_framebuffers);ptr += __size_framebuffers; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenFramebuffersOES_enc(void *self , GLsizei n, GLuint* framebuffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_framebuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_framebuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenFramebuffersOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_framebuffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(framebuffers, __size_framebuffers); + if (useChecksum) checksumCalculator->addBuffer(framebuffers, __size_framebuffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenFramebuffersOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +GLenum glCheckFramebufferStatusOES_enc(void *self , GLenum target) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCheckFramebufferStatusOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLenum retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glCheckFramebufferStatusOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glFramebufferRenderbufferOES_enc(void *self , GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFramebufferRenderbufferOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &renderbuffertarget, 4); ptr += 4; + memcpy(ptr, &renderbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFramebufferTexture2DOES_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFramebufferTexture2DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &textarget, 4); ptr += 4; + memcpy(ptr, &texture, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetFramebufferAttachmentParameterivOES_enc(void *self , GLenum target, GLenum attachment, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetFramebufferAttachmentParameterivOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetFramebufferAttachmentParameterivOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGenerateMipmapOES_enc(void *self , GLenum target) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenerateMipmapOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLboolean glUnmapBufferOES_enc(void *self , GLenum target) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUnmapBufferOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glUnmapBufferOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glCurrentPaletteMatrixOES_enc(void *self , GLuint matrixpaletteindex) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCurrentPaletteMatrixOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &matrixpaletteindex, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLoadPaletteFromModelViewMatrixOES_enc(void *self ) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLoadPaletteFromModelViewMatrixOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLbitfield glQueryMatrixxOES_enc(void *self , GLfixed* mantissa, GLint* exponent) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_mantissa = (16 * sizeof(GLfixed)); + const unsigned int __size_exponent = (16 * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_mantissa + __size_exponent + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glQueryMatrixxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_mantissa; ptr += 4; + *(unsigned int *)(ptr) = __size_exponent; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(mantissa, __size_mantissa); + if (useChecksum) checksumCalculator->addBuffer(mantissa, __size_mantissa); + stream->readback(exponent, __size_exponent); + if (useChecksum) checksumCalculator->addBuffer(exponent, __size_exponent); + + GLbitfield retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glQueryMatrixxOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glDepthRangefOES_enc(void *self , GLclampf zNear, GLclampf zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthRangefOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFrustumfOES_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFrustumfOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glOrthofOES_enc(void *self , GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glOrthofOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &left, 4); ptr += 4; + memcpy(ptr, &right, 4); ptr += 4; + memcpy(ptr, &bottom, 4); ptr += 4; + memcpy(ptr, &top, 4); ptr += 4; + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClipPlanefOES_enc(void *self , GLenum plane, const GLfloat* equation) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_equation = (4 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_equation + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClipPlanefOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &plane, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_equation; ptr += 4; + memcpy(ptr, equation, __size_equation);ptr += __size_equation; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClipPlanefIMG_enc(void *self , GLenum plane, const GLfloat* equation) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_equation = (4 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_equation + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClipPlanefIMG;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &plane, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_equation; ptr += 4; + memcpy(ptr, equation, __size_equation);ptr += __size_equation; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetClipPlanefOES_enc(void *self , GLenum pname, GLfloat* eqn) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_eqn = (4 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_eqn + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetClipPlanefOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_eqn; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(eqn, __size_eqn); + if (useChecksum) checksumCalculator->addBuffer(eqn, __size_eqn); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetClipPlanefOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glClearDepthfOES_enc(void *self , GLclampf depth) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearDepthfOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &depth, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexGenfOES_enc(void *self , GLenum coord, GLenum pname, GLfloat param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexGenfOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexGenfvOES_enc(void *self , GLenum coord, GLenum pname, const GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexGenfvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexGeniOES_enc(void *self , GLenum coord, GLenum pname, GLint param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexGeniOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexGenivOES_enc(void *self , GLenum coord, GLenum pname, const GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexGenivOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexGenxOES_enc(void *self , GLenum coord, GLenum pname, GLfixed param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexGenxOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexGenxvOES_enc(void *self , GLenum coord, GLenum pname, const GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexGenxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetTexGenfvOES_enc(void *self , GLenum coord, GLenum pname, GLfloat* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexGenfvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetTexGenivOES_enc(void *self , GLenum coord, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexGenivOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetTexGenxvOES_enc(void *self , GLenum coord, GLenum pname, GLfixed* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfixed)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexGenxvOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &coord, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindVertexArrayOES_enc(void *self , GLuint array) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &array, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteVertexArraysOES_enc(void *self , GLsizei n, const GLuint* arrays) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_arrays = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_arrays + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_arrays; ptr += 4; + memcpy(ptr, arrays, __size_arrays);ptr += __size_arrays; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenVertexArraysOES_enc(void *self , GLsizei n, GLuint* arrays) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_arrays = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_arrays + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_arrays; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(arrays, __size_arrays); + if (useChecksum) checksumCalculator->addBuffer(arrays, __size_arrays); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenVertexArraysOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +GLboolean glIsVertexArrayOES_enc(void *self , GLuint array) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &array, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsVertexArrayOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glDiscardFramebufferEXT_enc(void *self , GLenum target, GLsizei numAttachments, const GLenum* attachments) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_attachments = (numAttachments * sizeof(const GLenum)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_attachments + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDiscardFramebufferEXT;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &numAttachments, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_attachments; ptr += 4; + memcpy(ptr, attachments, __size_attachments);ptr += __size_attachments; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glRenderbufferStorageMultisampleIMG_enc(void *self , GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glRenderbufferStorageMultisampleIMG;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &samples, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFramebufferTexture2DMultisampleIMG_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFramebufferTexture2DMultisampleIMG;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &textarget, 4); ptr += 4; + memcpy(ptr, &texture, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &samples, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteFencesNV_enc(void *self , GLsizei n, const GLuint* fences) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_fences = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_fences + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteFencesNV;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_fences; ptr += 4; + memcpy(ptr, fences, __size_fences);ptr += __size_fences; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenFencesNV_enc(void *self , GLsizei n, GLuint* fences) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_fences = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_fences + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenFencesNV;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_fences; ptr += 4; + memcpy(ptr, fences, __size_fences);ptr += __size_fences; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLboolean glIsFenceNV_enc(void *self , GLuint fence) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsFenceNV;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &fence, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsFenceNV: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glTestFenceNV_enc(void *self , GLuint fence) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTestFenceNV;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &fence, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glTestFenceNV: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glGetFenceivNV_enc(void *self , GLuint fence, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetFenceivNV;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &fence, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetFenceivNV: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glFinishFenceNV_enc(void *self , GLuint fence) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFinishFenceNV;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &fence, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glSetFenceNV_enc(void *self , GLuint fence, GLenum condition) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glSetFenceNV;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &fence, 4); ptr += 4; + memcpy(ptr, &condition, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetDriverControlsQCOM_enc(void *self , GLint* num, GLsizei size, GLuint* driverControls) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_num = (1 * sizeof(GLint)); + const unsigned int __size_driverControls = (size * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_num + 4 + __size_driverControls + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetDriverControlsQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_num; ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_driverControls; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(num, __size_num); + if (useChecksum) checksumCalculator->addBuffer(num, __size_num); + stream->readback(driverControls, __size_driverControls); + if (useChecksum) checksumCalculator->addBuffer(driverControls, __size_driverControls); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetDriverControlsQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetDriverControlStringQCOM_enc(void *self , GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_length = (1 * sizeof(GLsizei)); + const unsigned int __size_driverControlString = (1 * sizeof(GLchar)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_length + __size_driverControlString + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetDriverControlStringQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &driverControl, 4); ptr += 4; + memcpy(ptr, &bufSize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_length; ptr += 4; + *(unsigned int *)(ptr) = __size_driverControlString; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(length, __size_length); + if (useChecksum) checksumCalculator->addBuffer(length, __size_length); + stream->readback(driverControlString, __size_driverControlString); + if (useChecksum) checksumCalculator->addBuffer(driverControlString, __size_driverControlString); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetDriverControlStringQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glEnableDriverControlQCOM_enc(void *self , GLuint driverControl) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEnableDriverControlQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &driverControl, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDisableDriverControlQCOM_enc(void *self , GLuint driverControl) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDisableDriverControlQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &driverControl, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glExtGetTexturesQCOM_enc(void *self , GLuint* textures, GLint maxTextures, GLint* numTextures) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_textures = (maxTextures * sizeof(GLuint)); + const unsigned int __size_numTextures = (1 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_textures + 4 + __size_numTextures + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetTexturesQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_textures; ptr += 4; + memcpy(ptr, &maxTextures, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_numTextures; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(textures, __size_textures); + if (useChecksum) checksumCalculator->addBuffer(textures, __size_textures); + stream->readback(numTextures, __size_numTextures); + if (useChecksum) checksumCalculator->addBuffer(numTextures, __size_numTextures); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetTexturesQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glExtGetBuffersQCOM_enc(void *self , GLuint* buffers, GLint maxBuffers, GLint* numBuffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffers = (maxBuffers * sizeof(GLuint)); + const unsigned int __size_numBuffers = (1 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_buffers + 4 + __size_numBuffers + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetBuffersQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_buffers; ptr += 4; + memcpy(ptr, &maxBuffers, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_numBuffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(buffers, __size_buffers); + if (useChecksum) checksumCalculator->addBuffer(buffers, __size_buffers); + stream->readback(numBuffers, __size_numBuffers); + if (useChecksum) checksumCalculator->addBuffer(numBuffers, __size_numBuffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetBuffersQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glExtGetRenderbuffersQCOM_enc(void *self , GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_renderbuffers = (maxRenderbuffers * sizeof(GLuint)); + const unsigned int __size_numRenderbuffers = (1 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_renderbuffers + 4 + __size_numRenderbuffers + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetRenderbuffersQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4; + memcpy(ptr, &maxRenderbuffers, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_numRenderbuffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(renderbuffers, __size_renderbuffers); + if (useChecksum) checksumCalculator->addBuffer(renderbuffers, __size_renderbuffers); + stream->readback(numRenderbuffers, __size_numRenderbuffers); + if (useChecksum) checksumCalculator->addBuffer(numRenderbuffers, __size_numRenderbuffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetRenderbuffersQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glExtGetFramebuffersQCOM_enc(void *self , GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_framebuffers = (maxFramebuffers * sizeof(GLuint)); + const unsigned int __size_numFramebuffers = (1 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_framebuffers + 4 + __size_numFramebuffers + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetFramebuffersQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_framebuffers; ptr += 4; + memcpy(ptr, &maxFramebuffers, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_numFramebuffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(framebuffers, __size_framebuffers); + if (useChecksum) checksumCalculator->addBuffer(framebuffers, __size_framebuffers); + stream->readback(numFramebuffers, __size_numFramebuffers); + if (useChecksum) checksumCalculator->addBuffer(numFramebuffers, __size_numFramebuffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetFramebuffersQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glExtGetTexLevelParameterivQCOM_enc(void *self , GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetTexLevelParameterivQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &texture, 4); ptr += 4; + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetTexLevelParameterivQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glExtTexObjectStateOverrideiQCOM_enc(void *self , GLenum target, GLenum pname, GLint param) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtTexObjectStateOverrideiQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glExtGetTexSubImageQCOM_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_texels = (depth * glesv1_enc::pixelDataSize(self, width, height, format, type, 0)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_texels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetTexSubImageQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &zoffset, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &depth, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_texels; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(texels, __size_texels); + if (useChecksum) checksumCalculator->addBuffer(texels, __size_texels); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetTexSubImageQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glExtGetShadersQCOM_enc(void *self , GLuint* shaders, GLint maxShaders, GLint* numShaders) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_shaders = (maxShaders * sizeof(GLuint)); + const unsigned int __size_numShaders = (1 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_shaders + 4 + __size_numShaders + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetShadersQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_shaders; ptr += 4; + memcpy(ptr, &maxShaders, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_numShaders; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(shaders, __size_shaders); + if (useChecksum) checksumCalculator->addBuffer(shaders, __size_shaders); + stream->readback(numShaders, __size_numShaders); + if (useChecksum) checksumCalculator->addBuffer(numShaders, __size_numShaders); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetShadersQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glExtGetProgramsQCOM_enc(void *self , GLuint* programs, GLint maxPrograms, GLint* numPrograms) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_programs = (maxPrograms * sizeof(GLuint)); + const unsigned int __size_numPrograms = (1 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_programs + 4 + __size_numPrograms + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtGetProgramsQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_programs; ptr += 4; + memcpy(ptr, &maxPrograms, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_numPrograms; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(programs, __size_programs); + if (useChecksum) checksumCalculator->addBuffer(programs, __size_programs); + stream->readback(numPrograms, __size_numPrograms); + if (useChecksum) checksumCalculator->addBuffer(numPrograms, __size_numPrograms); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtGetProgramsQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +GLboolean glExtIsProgramBinaryQCOM_enc(void *self , GLuint program) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glExtIsProgramBinaryQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glExtIsProgramBinaryQCOM: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glStartTilingQCOM_enc(void *self , GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStartTilingQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &preserveMask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEndTilingQCOM_enc(void *self , GLbitfield preserveMask) +{ + + gl_encoder_context_t *ctx = (gl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEndTilingQCOM;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &preserveMask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +} // namespace + +gl_encoder_context_t::gl_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator) +{ + m_stream = stream; + m_checksumCalculator = checksumCalculator; + + this->glAlphaFunc = &glAlphaFunc_enc; + this->glClearColor = &glClearColor_enc; + this->glClearDepthf = &glClearDepthf_enc; + this->glClipPlanef = &glClipPlanef_enc; + this->glColor4f = &glColor4f_enc; + this->glDepthRangef = &glDepthRangef_enc; + this->glFogf = &glFogf_enc; + this->glFogfv = &glFogfv_enc; + this->glFrustumf = &glFrustumf_enc; + this->glGetClipPlanef = &glGetClipPlanef_enc; + this->glGetFloatv = &glGetFloatv_enc; + this->glGetLightfv = &glGetLightfv_enc; + this->glGetMaterialfv = &glGetMaterialfv_enc; + this->glGetTexEnvfv = &glGetTexEnvfv_enc; + this->glGetTexParameterfv = &glGetTexParameterfv_enc; + this->glLightModelf = &glLightModelf_enc; + this->glLightModelfv = &glLightModelfv_enc; + this->glLightf = &glLightf_enc; + this->glLightfv = &glLightfv_enc; + this->glLineWidth = &glLineWidth_enc; + this->glLoadMatrixf = &glLoadMatrixf_enc; + this->glMaterialf = &glMaterialf_enc; + this->glMaterialfv = &glMaterialfv_enc; + this->glMultMatrixf = &glMultMatrixf_enc; + this->glMultiTexCoord4f = &glMultiTexCoord4f_enc; + this->glNormal3f = &glNormal3f_enc; + this->glOrthof = &glOrthof_enc; + this->glPointParameterf = &glPointParameterf_enc; + this->glPointParameterfv = &glPointParameterfv_enc; + this->glPointSize = &glPointSize_enc; + this->glPolygonOffset = &glPolygonOffset_enc; + this->glRotatef = &glRotatef_enc; + this->glScalef = &glScalef_enc; + this->glTexEnvf = &glTexEnvf_enc; + this->glTexEnvfv = &glTexEnvfv_enc; + this->glTexParameterf = &glTexParameterf_enc; + this->glTexParameterfv = &glTexParameterfv_enc; + this->glTranslatef = &glTranslatef_enc; + this->glActiveTexture = &glActiveTexture_enc; + this->glAlphaFuncx = &glAlphaFuncx_enc; + this->glBindBuffer = &glBindBuffer_enc; + this->glBindTexture = &glBindTexture_enc; + this->glBlendFunc = &glBlendFunc_enc; + this->glBufferData = &glBufferData_enc; + this->glBufferSubData = &glBufferSubData_enc; + this->glClear = &glClear_enc; + this->glClearColorx = &glClearColorx_enc; + this->glClearDepthx = &glClearDepthx_enc; + this->glClearStencil = &glClearStencil_enc; + this->glClientActiveTexture = &glClientActiveTexture_enc; + this->glColor4ub = &glColor4ub_enc; + this->glColor4x = &glColor4x_enc; + this->glColorMask = &glColorMask_enc; + this->glColorPointer = (glColorPointer_client_proc_t) &enc_unsupported; + this->glCompressedTexImage2D = &glCompressedTexImage2D_enc; + this->glCompressedTexSubImage2D = &glCompressedTexSubImage2D_enc; + this->glCopyTexImage2D = &glCopyTexImage2D_enc; + this->glCopyTexSubImage2D = &glCopyTexSubImage2D_enc; + this->glCullFace = &glCullFace_enc; + this->glDeleteBuffers = &glDeleteBuffers_enc; + this->glDeleteTextures = &glDeleteTextures_enc; + this->glDepthFunc = &glDepthFunc_enc; + this->glDepthMask = &glDepthMask_enc; + this->glDepthRangex = &glDepthRangex_enc; + this->glDisable = &glDisable_enc; + this->glDisableClientState = &glDisableClientState_enc; + this->glDrawArrays = &glDrawArrays_enc; + this->glDrawElements = (glDrawElements_client_proc_t) &enc_unsupported; + this->glEnable = &glEnable_enc; + this->glEnableClientState = &glEnableClientState_enc; + this->glFinish = &glFinish_enc; + this->glFlush = &glFlush_enc; + this->glFogx = &glFogx_enc; + this->glFogxv = &glFogxv_enc; + this->glFrontFace = &glFrontFace_enc; + this->glFrustumx = &glFrustumx_enc; + this->glGetBooleanv = &glGetBooleanv_enc; + this->glGetBufferParameteriv = &glGetBufferParameteriv_enc; + this->glClipPlanex = &glClipPlanex_enc; + this->glGenBuffers = &glGenBuffers_enc; + this->glGenTextures = &glGenTextures_enc; + this->glGetError = &glGetError_enc; + this->glGetFixedv = &glGetFixedv_enc; + this->glGetIntegerv = &glGetIntegerv_enc; + this->glGetLightxv = &glGetLightxv_enc; + this->glGetMaterialxv = &glGetMaterialxv_enc; + this->glGetPointerv = (glGetPointerv_client_proc_t) &enc_unsupported; + this->glGetString = (glGetString_client_proc_t) &enc_unsupported; + this->glGetTexEnviv = &glGetTexEnviv_enc; + this->glGetTexEnvxv = &glGetTexEnvxv_enc; + this->glGetTexParameteriv = &glGetTexParameteriv_enc; + this->glGetTexParameterxv = &glGetTexParameterxv_enc; + this->glHint = &glHint_enc; + this->glIsBuffer = &glIsBuffer_enc; + this->glIsEnabled = &glIsEnabled_enc; + this->glIsTexture = &glIsTexture_enc; + this->glLightModelx = &glLightModelx_enc; + this->glLightModelxv = &glLightModelxv_enc; + this->glLightx = &glLightx_enc; + this->glLightxv = &glLightxv_enc; + this->glLineWidthx = &glLineWidthx_enc; + this->glLoadIdentity = &glLoadIdentity_enc; + this->glLoadMatrixx = &glLoadMatrixx_enc; + this->glLogicOp = &glLogicOp_enc; + this->glMaterialx = &glMaterialx_enc; + this->glMaterialxv = &glMaterialxv_enc; + this->glMatrixMode = &glMatrixMode_enc; + this->glMultMatrixx = &glMultMatrixx_enc; + this->glMultiTexCoord4x = &glMultiTexCoord4x_enc; + this->glNormal3x = &glNormal3x_enc; + this->glNormalPointer = (glNormalPointer_client_proc_t) &enc_unsupported; + this->glOrthox = &glOrthox_enc; + this->glPixelStorei = &glPixelStorei_enc; + this->glPointParameterx = &glPointParameterx_enc; + this->glPointParameterxv = &glPointParameterxv_enc; + this->glPointSizex = &glPointSizex_enc; + this->glPolygonOffsetx = &glPolygonOffsetx_enc; + this->glPopMatrix = &glPopMatrix_enc; + this->glPushMatrix = &glPushMatrix_enc; + this->glReadPixels = &glReadPixels_enc; + this->glRotatex = &glRotatex_enc; + this->glSampleCoverage = &glSampleCoverage_enc; + this->glSampleCoveragex = &glSampleCoveragex_enc; + this->glScalex = &glScalex_enc; + this->glScissor = &glScissor_enc; + this->glShadeModel = &glShadeModel_enc; + this->glStencilFunc = &glStencilFunc_enc; + this->glStencilMask = &glStencilMask_enc; + this->glStencilOp = &glStencilOp_enc; + this->glTexCoordPointer = (glTexCoordPointer_client_proc_t) &enc_unsupported; + this->glTexEnvi = &glTexEnvi_enc; + this->glTexEnvx = &glTexEnvx_enc; + this->glTexEnviv = &glTexEnviv_enc; + this->glTexEnvxv = &glTexEnvxv_enc; + this->glTexImage2D = &glTexImage2D_enc; + this->glTexParameteri = &glTexParameteri_enc; + this->glTexParameterx = &glTexParameterx_enc; + this->glTexParameteriv = &glTexParameteriv_enc; + this->glTexParameterxv = &glTexParameterxv_enc; + this->glTexSubImage2D = &glTexSubImage2D_enc; + this->glTranslatex = &glTranslatex_enc; + this->glVertexPointer = (glVertexPointer_client_proc_t) &enc_unsupported; + this->glViewport = &glViewport_enc; + this->glPointSizePointerOES = (glPointSizePointerOES_client_proc_t) &enc_unsupported; + this->glVertexPointerOffset = &glVertexPointerOffset_enc; + this->glColorPointerOffset = &glColorPointerOffset_enc; + this->glNormalPointerOffset = &glNormalPointerOffset_enc; + this->glPointSizePointerOffset = &glPointSizePointerOffset_enc; + this->glTexCoordPointerOffset = &glTexCoordPointerOffset_enc; + this->glWeightPointerOffset = &glWeightPointerOffset_enc; + this->glMatrixIndexPointerOffset = &glMatrixIndexPointerOffset_enc; + this->glVertexPointerData = &glVertexPointerData_enc; + this->glColorPointerData = &glColorPointerData_enc; + this->glNormalPointerData = &glNormalPointerData_enc; + this->glTexCoordPointerData = &glTexCoordPointerData_enc; + this->glPointSizePointerData = &glPointSizePointerData_enc; + this->glWeightPointerData = &glWeightPointerData_enc; + this->glMatrixIndexPointerData = &glMatrixIndexPointerData_enc; + this->glDrawElementsOffset = &glDrawElementsOffset_enc; + this->glDrawElementsData = &glDrawElementsData_enc; + this->glGetCompressedTextureFormats = &glGetCompressedTextureFormats_enc; + this->glFinishRoundTrip = &glFinishRoundTrip_enc; + this->glBlendEquationSeparateOES = &glBlendEquationSeparateOES_enc; + this->glBlendFuncSeparateOES = &glBlendFuncSeparateOES_enc; + this->glBlendEquationOES = &glBlendEquationOES_enc; + this->glDrawTexsOES = &glDrawTexsOES_enc; + this->glDrawTexiOES = &glDrawTexiOES_enc; + this->glDrawTexxOES = &glDrawTexxOES_enc; + this->glDrawTexsvOES = &glDrawTexsvOES_enc; + this->glDrawTexivOES = &glDrawTexivOES_enc; + this->glDrawTexxvOES = &glDrawTexxvOES_enc; + this->glDrawTexfOES = &glDrawTexfOES_enc; + this->glDrawTexfvOES = &glDrawTexfvOES_enc; + this->glEGLImageTargetTexture2DOES = &glEGLImageTargetTexture2DOES_enc; + this->glEGLImageTargetRenderbufferStorageOES = &glEGLImageTargetRenderbufferStorageOES_enc; + this->glAlphaFuncxOES = &glAlphaFuncxOES_enc; + this->glClearColorxOES = &glClearColorxOES_enc; + this->glClearDepthxOES = &glClearDepthxOES_enc; + this->glClipPlanexOES = &glClipPlanexOES_enc; + this->glClipPlanexIMG = &glClipPlanexIMG_enc; + this->glColor4xOES = &glColor4xOES_enc; + this->glDepthRangexOES = &glDepthRangexOES_enc; + this->glFogxOES = &glFogxOES_enc; + this->glFogxvOES = &glFogxvOES_enc; + this->glFrustumxOES = &glFrustumxOES_enc; + this->glGetClipPlanexOES = &glGetClipPlanexOES_enc; + this->glGetClipPlanex = &glGetClipPlanex_enc; + this->glGetFixedvOES = &glGetFixedvOES_enc; + this->glGetLightxvOES = &glGetLightxvOES_enc; + this->glGetMaterialxvOES = &glGetMaterialxvOES_enc; + this->glGetTexEnvxvOES = &glGetTexEnvxvOES_enc; + this->glGetTexParameterxvOES = &glGetTexParameterxvOES_enc; + this->glLightModelxOES = &glLightModelxOES_enc; + this->glLightModelxvOES = &glLightModelxvOES_enc; + this->glLightxOES = &glLightxOES_enc; + this->glLightxvOES = &glLightxvOES_enc; + this->glLineWidthxOES = &glLineWidthxOES_enc; + this->glLoadMatrixxOES = &glLoadMatrixxOES_enc; + this->glMaterialxOES = &glMaterialxOES_enc; + this->glMaterialxvOES = &glMaterialxvOES_enc; + this->glMultMatrixxOES = &glMultMatrixxOES_enc; + this->glMultiTexCoord4xOES = &glMultiTexCoord4xOES_enc; + this->glNormal3xOES = &glNormal3xOES_enc; + this->glOrthoxOES = &glOrthoxOES_enc; + this->glPointParameterxOES = &glPointParameterxOES_enc; + this->glPointParameterxvOES = &glPointParameterxvOES_enc; + this->glPointSizexOES = &glPointSizexOES_enc; + this->glPolygonOffsetxOES = &glPolygonOffsetxOES_enc; + this->glRotatexOES = &glRotatexOES_enc; + this->glSampleCoveragexOES = &glSampleCoveragexOES_enc; + this->glScalexOES = &glScalexOES_enc; + this->glTexEnvxOES = &glTexEnvxOES_enc; + this->glTexEnvxvOES = &glTexEnvxvOES_enc; + this->glTexParameterxOES = &glTexParameterxOES_enc; + this->glTexParameterxvOES = &glTexParameterxvOES_enc; + this->glTranslatexOES = &glTranslatexOES_enc; + this->glIsRenderbufferOES = &glIsRenderbufferOES_enc; + this->glBindRenderbufferOES = &glBindRenderbufferOES_enc; + this->glDeleteRenderbuffersOES = &glDeleteRenderbuffersOES_enc; + this->glGenRenderbuffersOES = &glGenRenderbuffersOES_enc; + this->glRenderbufferStorageOES = &glRenderbufferStorageOES_enc; + this->glGetRenderbufferParameterivOES = &glGetRenderbufferParameterivOES_enc; + this->glIsFramebufferOES = &glIsFramebufferOES_enc; + this->glBindFramebufferOES = &glBindFramebufferOES_enc; + this->glDeleteFramebuffersOES = &glDeleteFramebuffersOES_enc; + this->glGenFramebuffersOES = &glGenFramebuffersOES_enc; + this->glCheckFramebufferStatusOES = &glCheckFramebufferStatusOES_enc; + this->glFramebufferRenderbufferOES = &glFramebufferRenderbufferOES_enc; + this->glFramebufferTexture2DOES = &glFramebufferTexture2DOES_enc; + this->glGetFramebufferAttachmentParameterivOES = &glGetFramebufferAttachmentParameterivOES_enc; + this->glGenerateMipmapOES = &glGenerateMipmapOES_enc; + this->glMapBufferOES = (glMapBufferOES_client_proc_t) &enc_unsupported; + this->glUnmapBufferOES = &glUnmapBufferOES_enc; + this->glGetBufferPointervOES = (glGetBufferPointervOES_client_proc_t) &enc_unsupported; + this->glCurrentPaletteMatrixOES = &glCurrentPaletteMatrixOES_enc; + this->glLoadPaletteFromModelViewMatrixOES = &glLoadPaletteFromModelViewMatrixOES_enc; + this->glMatrixIndexPointerOES = (glMatrixIndexPointerOES_client_proc_t) &enc_unsupported; + this->glWeightPointerOES = (glWeightPointerOES_client_proc_t) &enc_unsupported; + this->glQueryMatrixxOES = &glQueryMatrixxOES_enc; + this->glDepthRangefOES = &glDepthRangefOES_enc; + this->glFrustumfOES = &glFrustumfOES_enc; + this->glOrthofOES = &glOrthofOES_enc; + this->glClipPlanefOES = &glClipPlanefOES_enc; + this->glClipPlanefIMG = &glClipPlanefIMG_enc; + this->glGetClipPlanefOES = &glGetClipPlanefOES_enc; + this->glClearDepthfOES = &glClearDepthfOES_enc; + this->glTexGenfOES = &glTexGenfOES_enc; + this->glTexGenfvOES = &glTexGenfvOES_enc; + this->glTexGeniOES = &glTexGeniOES_enc; + this->glTexGenivOES = &glTexGenivOES_enc; + this->glTexGenxOES = &glTexGenxOES_enc; + this->glTexGenxvOES = &glTexGenxvOES_enc; + this->glGetTexGenfvOES = &glGetTexGenfvOES_enc; + this->glGetTexGenivOES = &glGetTexGenivOES_enc; + this->glGetTexGenxvOES = &glGetTexGenxvOES_enc; + this->glBindVertexArrayOES = &glBindVertexArrayOES_enc; + this->glDeleteVertexArraysOES = &glDeleteVertexArraysOES_enc; + this->glGenVertexArraysOES = &glGenVertexArraysOES_enc; + this->glIsVertexArrayOES = &glIsVertexArrayOES_enc; + this->glDiscardFramebufferEXT = &glDiscardFramebufferEXT_enc; + this->glMultiDrawArraysEXT = (glMultiDrawArraysEXT_client_proc_t) &enc_unsupported; + this->glMultiDrawElementsEXT = (glMultiDrawElementsEXT_client_proc_t) &enc_unsupported; + this->glMultiDrawArraysSUN = (glMultiDrawArraysSUN_client_proc_t) &enc_unsupported; + this->glMultiDrawElementsSUN = (glMultiDrawElementsSUN_client_proc_t) &enc_unsupported; + this->glRenderbufferStorageMultisampleIMG = &glRenderbufferStorageMultisampleIMG_enc; + this->glFramebufferTexture2DMultisampleIMG = &glFramebufferTexture2DMultisampleIMG_enc; + this->glDeleteFencesNV = &glDeleteFencesNV_enc; + this->glGenFencesNV = &glGenFencesNV_enc; + this->glIsFenceNV = &glIsFenceNV_enc; + this->glTestFenceNV = &glTestFenceNV_enc; + this->glGetFenceivNV = &glGetFenceivNV_enc; + this->glFinishFenceNV = &glFinishFenceNV_enc; + this->glSetFenceNV = &glSetFenceNV_enc; + this->glGetDriverControlsQCOM = &glGetDriverControlsQCOM_enc; + this->glGetDriverControlStringQCOM = &glGetDriverControlStringQCOM_enc; + this->glEnableDriverControlQCOM = &glEnableDriverControlQCOM_enc; + this->glDisableDriverControlQCOM = &glDisableDriverControlQCOM_enc; + this->glExtGetTexturesQCOM = &glExtGetTexturesQCOM_enc; + this->glExtGetBuffersQCOM = &glExtGetBuffersQCOM_enc; + this->glExtGetRenderbuffersQCOM = &glExtGetRenderbuffersQCOM_enc; + this->glExtGetFramebuffersQCOM = &glExtGetFramebuffersQCOM_enc; + this->glExtGetTexLevelParameterivQCOM = &glExtGetTexLevelParameterivQCOM_enc; + this->glExtTexObjectStateOverrideiQCOM = &glExtTexObjectStateOverrideiQCOM_enc; + this->glExtGetTexSubImageQCOM = &glExtGetTexSubImageQCOM_enc; + this->glExtGetBufferPointervQCOM = (glExtGetBufferPointervQCOM_client_proc_t) &enc_unsupported; + this->glExtGetShadersQCOM = &glExtGetShadersQCOM_enc; + this->glExtGetProgramsQCOM = &glExtGetProgramsQCOM_enc; + this->glExtIsProgramBinaryQCOM = &glExtIsProgramBinaryQCOM_enc; + this->glExtGetProgramBinarySourceQCOM = (glExtGetProgramBinarySourceQCOM_client_proc_t) &enc_unsupported; + this->glStartTilingQCOM = &glStartTilingQCOM_enc; + this->glEndTilingQCOM = &glEndTilingQCOM_enc; +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.h new file mode 100644 index 0000000..37de4c4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_enc.h @@ -0,0 +1,23 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + +#ifndef GUARD_gl_encoder_context_t +#define GUARD_gl_encoder_context_t + +#include "IOStream.h" +#include "ChecksumCalculator.h" +#include "gl_client_context.h" + + +#include "glUtils.h" +#include "GLEncoderUtils.h" + +struct gl_encoder_context_t : public gl_client_context_t { + + IOStream *m_stream; + ChecksumCalculator *m_checksumCalculator; + + gl_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator); +}; + +#endif // GUARD_gl_encoder_context_t \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_entry.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_entry.cpp new file mode 100644 index 0000000..2b7fa9f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_entry.cpp @@ -0,0 +1,2066 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#include +#include +#include "gl_client_context.h" + +#ifndef GL_TRUE +extern "C" { + void glAlphaFunc(GLenum func, GLclampf ref); + void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void glClearDepthf(GLclampf depth); + void glClipPlanef(GLenum plane, const GLfloat* equation); + void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + void glDepthRangef(GLclampf zNear, GLclampf zFar); + void glFogf(GLenum pname, GLfloat param); + void glFogfv(GLenum pname, const GLfloat* params); + void glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); + void glGetClipPlanef(GLenum pname, GLfloat* eqn); + void glGetFloatv(GLenum pname, GLfloat* params); + void glGetLightfv(GLenum light, GLenum pname, GLfloat* params); + void glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params); + void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat* params); + void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); + void glLightModelf(GLenum pname, GLfloat param); + void glLightModelfv(GLenum pname, const GLfloat* params); + void glLightf(GLenum light, GLenum pname, GLfloat param); + void glLightfv(GLenum light, GLenum pname, const GLfloat* params); + void glLineWidth(GLfloat width); + void glLoadMatrixf(const GLfloat* m); + void glMaterialf(GLenum face, GLenum pname, GLfloat param); + void glMaterialfv(GLenum face, GLenum pname, const GLfloat* params); + void glMultMatrixf(const GLfloat* m); + void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); + void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); + void glPointParameterf(GLenum pname, GLfloat param); + void glPointParameterfv(GLenum pname, const GLfloat* params); + void glPointSize(GLfloat size); + void glPolygonOffset(GLfloat factor, GLfloat units); + void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + void glScalef(GLfloat x, GLfloat y, GLfloat z); + void glTexEnvf(GLenum target, GLenum pname, GLfloat param); + void glTexEnvfv(GLenum target, GLenum pname, const GLfloat* params); + void glTexParameterf(GLenum target, GLenum pname, GLfloat param); + void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); + void glTranslatef(GLfloat x, GLfloat y, GLfloat z); + void glActiveTexture(GLenum texture); + void glAlphaFuncx(GLenum func, GLclampx ref); + void glBindBuffer(GLenum target, GLuint buffer); + void glBindTexture(GLenum target, GLuint texture); + void glBlendFunc(GLenum sfactor, GLenum dfactor); + void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); + void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); + void glClear(GLbitfield mask); + void glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); + void glClearDepthx(GLclampx depth); + void glClearStencil(GLint s); + void glClientActiveTexture(GLenum texture); + void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); + void glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); + void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); + void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); + void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + void glCullFace(GLenum mode); + void glDeleteBuffers(GLsizei n, const GLuint* buffers); + void glDeleteTextures(GLsizei n, const GLuint* textures); + void glDepthFunc(GLenum func); + void glDepthMask(GLboolean flag); + void glDepthRangex(GLclampx zNear, GLclampx zFar); + void glDisable(GLenum cap); + void glDisableClientState(GLenum array); + void glDrawArrays(GLenum mode, GLint first, GLsizei count); + void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); + void glEnable(GLenum cap); + void glEnableClientState(GLenum array); + void glFinish(); + void glFlush(); + void glFogx(GLenum pname, GLfixed param); + void glFogxv(GLenum pname, const GLfixed* params); + void glFrontFace(GLenum mode); + void glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); + void glGetBooleanv(GLenum pname, GLboolean* params); + void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params); + void glClipPlanex(GLenum pname, const GLfixed* eqn); + void glGenBuffers(GLsizei n, GLuint* buffers); + void glGenTextures(GLsizei n, GLuint* textures); + GLenum glGetError(); + void glGetFixedv(GLenum pname, GLfixed* params); + void glGetIntegerv(GLenum pname, GLint* params); + void glGetLightxv(GLenum light, GLenum pname, GLfixed* params); + void glGetMaterialxv(GLenum face, GLenum pname, GLfixed* params); + void glGetPointerv(GLenum pname, GLvoid** params); + const GLubyte* glGetString(GLenum name); + void glGetTexEnviv(GLenum env, GLenum pname, GLint* params); + void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed* params); + void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params); + void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed* params); + void glHint(GLenum target, GLenum mode); + GLboolean glIsBuffer(GLuint buffer); + GLboolean glIsEnabled(GLenum cap); + GLboolean glIsTexture(GLuint texture); + void glLightModelx(GLenum pname, GLfixed param); + void glLightModelxv(GLenum pname, const GLfixed* params); + void glLightx(GLenum light, GLenum pname, GLfixed param); + void glLightxv(GLenum light, GLenum pname, const GLfixed* params); + void glLineWidthx(GLfixed width); + void glLoadIdentity(); + void glLoadMatrixx(const GLfixed* m); + void glLogicOp(GLenum opcode); + void glMaterialx(GLenum face, GLenum pname, GLfixed param); + void glMaterialxv(GLenum face, GLenum pname, const GLfixed* params); + void glMatrixMode(GLenum mode); + void glMultMatrixx(const GLfixed* m); + void glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); + void glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz); + void glNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer); + void glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); + void glPixelStorei(GLenum pname, GLint param); + void glPointParameterx(GLenum pname, GLfixed param); + void glPointParameterxv(GLenum pname, const GLfixed* params); + void glPointSizex(GLfixed size); + void glPolygonOffsetx(GLfixed factor, GLfixed units); + void glPopMatrix(); + void glPushMatrix(); + void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); + void glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z); + void glSampleCoverage(GLclampf value, GLboolean invert); + void glSampleCoveragex(GLclampx value, GLboolean invert); + void glScalex(GLfixed x, GLfixed y, GLfixed z); + void glScissor(GLint x, GLint y, GLsizei width, GLsizei height); + void glShadeModel(GLenum mode); + void glStencilFunc(GLenum func, GLint ref, GLuint mask); + void glStencilMask(GLuint mask); + void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); + void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); + void glTexEnvi(GLenum target, GLenum pname, GLint param); + void glTexEnvx(GLenum target, GLenum pname, GLfixed param); + void glTexEnviv(GLenum target, GLenum pname, const GLint* params); + void glTexEnvxv(GLenum target, GLenum pname, const GLfixed* params); + void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); + void glTexParameteri(GLenum target, GLenum pname, GLint param); + void glTexParameterx(GLenum target, GLenum pname, GLfixed param); + void glTexParameteriv(GLenum target, GLenum pname, const GLint* params); + void glTexParameterxv(GLenum target, GLenum pname, const GLfixed* params); + void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); + void glTranslatex(GLfixed x, GLfixed y, GLfixed z); + void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); + void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); + void glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid* pointer); + void glVertexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset); + void glColorPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset); + void glNormalPointerOffset(GLenum type, GLsizei stride, GLuint offset); + void glPointSizePointerOffset(GLenum type, GLsizei stride, GLuint offset); + void glTexCoordPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset); + void glWeightPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset); + void glMatrixIndexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset); + void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen); + void glColorPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen); + void glNormalPointerData(GLenum type, GLsizei stride, void* data, GLuint datalen); + void glTexCoordPointerData(GLint unit, GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen); + void glPointSizePointerData(GLenum type, GLsizei stride, void* data, GLuint datalen); + void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen); + void glMatrixIndexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen); + void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset); + void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen); + void glGetCompressedTextureFormats(int count, GLint* formats); + int glFinishRoundTrip(); + void glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha); + void glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + void glBlendEquationOES(GLenum mode); + void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); + void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height); + void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); + void glDrawTexsvOES(const GLshort* coords); + void glDrawTexivOES(const GLint* coords); + void glDrawTexxvOES(const GLfixed* coords); + void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); + void glDrawTexfvOES(const GLfloat* coords); + void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); + void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); + void glAlphaFuncxOES(GLenum func, GLclampx ref); + void glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); + void glClearDepthxOES(GLclampx depth); + void glClipPlanexOES(GLenum plane, const GLfixed* equation); + void glClipPlanexIMG(GLenum plane, const GLfixed* equation); + void glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); + void glDepthRangexOES(GLclampx zNear, GLclampx zFar); + void glFogxOES(GLenum pname, GLfixed param); + void glFogxvOES(GLenum pname, const GLfixed* params); + void glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); + void glGetClipPlanexOES(GLenum pname, GLfixed* eqn); + void glGetClipPlanex(GLenum pname, GLfixed* eqn); + void glGetFixedvOES(GLenum pname, GLfixed* params); + void glGetLightxvOES(GLenum light, GLenum pname, GLfixed* params); + void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed* params); + void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed* params); + void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed* params); + void glLightModelxOES(GLenum pname, GLfixed param); + void glLightModelxvOES(GLenum pname, const GLfixed* params); + void glLightxOES(GLenum light, GLenum pname, GLfixed param); + void glLightxvOES(GLenum light, GLenum pname, const GLfixed* params); + void glLineWidthxOES(GLfixed width); + void glLoadMatrixxOES(const GLfixed* m); + void glMaterialxOES(GLenum face, GLenum pname, GLfixed param); + void glMaterialxvOES(GLenum face, GLenum pname, const GLfixed* params); + void glMultMatrixxOES(const GLfixed* m); + void glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); + void glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz); + void glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); + void glPointParameterxOES(GLenum pname, GLfixed param); + void glPointParameterxvOES(GLenum pname, const GLfixed* params); + void glPointSizexOES(GLfixed size); + void glPolygonOffsetxOES(GLfixed factor, GLfixed units); + void glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z); + void glSampleCoveragexOES(GLclampx value, GLboolean invert); + void glScalexOES(GLfixed x, GLfixed y, GLfixed z); + void glTexEnvxOES(GLenum target, GLenum pname, GLfixed param); + void glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed* params); + void glTexParameterxOES(GLenum target, GLenum pname, GLfixed param); + void glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed* params); + void glTranslatexOES(GLfixed x, GLfixed y, GLfixed z); + GLboolean glIsRenderbufferOES(GLuint renderbuffer); + void glBindRenderbufferOES(GLenum target, GLuint renderbuffer); + void glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers); + void glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers); + void glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params); + GLboolean glIsFramebufferOES(GLuint framebuffer); + void glBindFramebufferOES(GLenum target, GLuint framebuffer); + void glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers); + void glGenFramebuffersOES(GLsizei n, GLuint* framebuffers); + GLenum glCheckFramebufferStatusOES(GLenum target); + void glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + void glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params); + void glGenerateMipmapOES(GLenum target); + void* glMapBufferOES(GLenum target, GLenum access); + GLboolean glUnmapBufferOES(GLenum target); + void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid** params); + void glCurrentPaletteMatrixOES(GLuint matrixpaletteindex); + void glLoadPaletteFromModelViewMatrixOES(); + void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); + void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); + GLbitfield glQueryMatrixxOES(GLfixed* mantissa, GLint* exponent); + void glDepthRangefOES(GLclampf zNear, GLclampf zFar); + void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); + void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); + void glClipPlanefOES(GLenum plane, const GLfloat* equation); + void glClipPlanefIMG(GLenum plane, const GLfloat* equation); + void glGetClipPlanefOES(GLenum pname, GLfloat* eqn); + void glClearDepthfOES(GLclampf depth); + void glTexGenfOES(GLenum coord, GLenum pname, GLfloat param); + void glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat* params); + void glTexGeniOES(GLenum coord, GLenum pname, GLint param); + void glTexGenivOES(GLenum coord, GLenum pname, const GLint* params); + void glTexGenxOES(GLenum coord, GLenum pname, GLfixed param); + void glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed* params); + void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat* params); + void glGetTexGenivOES(GLenum coord, GLenum pname, GLint* params); + void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed* params); + void glBindVertexArrayOES(GLuint array); + void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays); + void glGenVertexArraysOES(GLsizei n, GLuint* arrays); + GLboolean glIsVertexArrayOES(GLuint array); + void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments); + void glMultiDrawArraysEXT(GLenum mode, const GLint* first, const GLsizei* count, GLsizei primcount); + void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices, GLsizei primcount); + void glMultiDrawArraysSUN(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount); + void glMultiDrawElementsSUN(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount); + void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); + void glDeleteFencesNV(GLsizei n, const GLuint* fences); + void glGenFencesNV(GLsizei n, GLuint* fences); + GLboolean glIsFenceNV(GLuint fence); + GLboolean glTestFenceNV(GLuint fence); + void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params); + void glFinishFenceNV(GLuint fence); + void glSetFenceNV(GLuint fence, GLenum condition); + void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls); + void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString); + void glEnableDriverControlQCOM(GLuint driverControl); + void glDisableDriverControlQCOM(GLuint driverControl); + void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures); + void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers); + void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers); + void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers); + void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params); + void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param); + void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels); + void glExtGetBufferPointervQCOM(GLenum target, GLvoid** params); + void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders); + void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms); + GLboolean glExtIsProgramBinaryQCOM(GLuint program); + void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length); + void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); + void glEndTilingQCOM(GLbitfield preserveMask); +}; + +#endif +#ifndef GET_CONTEXT +static gl_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; +void gl_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } +#define GET_CONTEXT gl_client_context_t * ctx = getCurrentContext() +#endif + +void glAlphaFunc(GLenum func, GLclampf ref) +{ + GET_CONTEXT; + ctx->glAlphaFunc(ctx, func, ref); +} + +void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + GET_CONTEXT; + ctx->glClearColor(ctx, red, green, blue, alpha); +} + +void glClearDepthf(GLclampf depth) +{ + GET_CONTEXT; + ctx->glClearDepthf(ctx, depth); +} + +void glClipPlanef(GLenum plane, const GLfloat* equation) +{ + GET_CONTEXT; + ctx->glClipPlanef(ctx, plane, equation); +} + +void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + GET_CONTEXT; + ctx->glColor4f(ctx, red, green, blue, alpha); +} + +void glDepthRangef(GLclampf zNear, GLclampf zFar) +{ + GET_CONTEXT; + ctx->glDepthRangef(ctx, zNear, zFar); +} + +void glFogf(GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glFogf(ctx, pname, param); +} + +void glFogfv(GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glFogfv(ctx, pname, params); +} + +void glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + GET_CONTEXT; + ctx->glFrustumf(ctx, left, right, bottom, top, zNear, zFar); +} + +void glGetClipPlanef(GLenum pname, GLfloat* eqn) +{ + GET_CONTEXT; + ctx->glGetClipPlanef(ctx, pname, eqn); +} + +void glGetFloatv(GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetFloatv(ctx, pname, params); +} + +void glGetLightfv(GLenum light, GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetLightfv(ctx, light, pname, params); +} + +void glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetMaterialfv(ctx, face, pname, params); +} + +void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetTexEnvfv(ctx, env, pname, params); +} + +void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetTexParameterfv(ctx, target, pname, params); +} + +void glLightModelf(GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glLightModelf(ctx, pname, param); +} + +void glLightModelfv(GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glLightModelfv(ctx, pname, params); +} + +void glLightf(GLenum light, GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glLightf(ctx, light, pname, param); +} + +void glLightfv(GLenum light, GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glLightfv(ctx, light, pname, params); +} + +void glLineWidth(GLfloat width) +{ + GET_CONTEXT; + ctx->glLineWidth(ctx, width); +} + +void glLoadMatrixf(const GLfloat* m) +{ + GET_CONTEXT; + ctx->glLoadMatrixf(ctx, m); +} + +void glMaterialf(GLenum face, GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glMaterialf(ctx, face, pname, param); +} + +void glMaterialfv(GLenum face, GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glMaterialfv(ctx, face, pname, params); +} + +void glMultMatrixf(const GLfloat* m) +{ + GET_CONTEXT; + ctx->glMultMatrixf(ctx, m); +} + +void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + GET_CONTEXT; + ctx->glMultiTexCoord4f(ctx, target, s, t, r, q); +} + +void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) +{ + GET_CONTEXT; + ctx->glNormal3f(ctx, nx, ny, nz); +} + +void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + GET_CONTEXT; + ctx->glOrthof(ctx, left, right, bottom, top, zNear, zFar); +} + +void glPointParameterf(GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glPointParameterf(ctx, pname, param); +} + +void glPointParameterfv(GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glPointParameterfv(ctx, pname, params); +} + +void glPointSize(GLfloat size) +{ + GET_CONTEXT; + ctx->glPointSize(ctx, size); +} + +void glPolygonOffset(GLfloat factor, GLfloat units) +{ + GET_CONTEXT; + ctx->glPolygonOffset(ctx, factor, units); +} + +void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CONTEXT; + ctx->glRotatef(ctx, angle, x, y, z); +} + +void glScalef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CONTEXT; + ctx->glScalef(ctx, x, y, z); +} + +void glTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glTexEnvf(ctx, target, pname, param); +} + +void glTexEnvfv(GLenum target, GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glTexEnvfv(ctx, target, pname, params); +} + +void glTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glTexParameterf(ctx, target, pname, param); +} + +void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glTexParameterfv(ctx, target, pname, params); +} + +void glTranslatef(GLfloat x, GLfloat y, GLfloat z) +{ + GET_CONTEXT; + ctx->glTranslatef(ctx, x, y, z); +} + +void glActiveTexture(GLenum texture) +{ + GET_CONTEXT; + ctx->glActiveTexture(ctx, texture); +} + +void glAlphaFuncx(GLenum func, GLclampx ref) +{ + GET_CONTEXT; + ctx->glAlphaFuncx(ctx, func, ref); +} + +void glBindBuffer(GLenum target, GLuint buffer) +{ + GET_CONTEXT; + ctx->glBindBuffer(ctx, target, buffer); +} + +void glBindTexture(GLenum target, GLuint texture) +{ + GET_CONTEXT; + ctx->glBindTexture(ctx, target, texture); +} + +void glBlendFunc(GLenum sfactor, GLenum dfactor) +{ + GET_CONTEXT; + ctx->glBlendFunc(ctx, sfactor, dfactor); +} + +void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) +{ + GET_CONTEXT; + ctx->glBufferData(ctx, target, size, data, usage); +} + +void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glBufferSubData(ctx, target, offset, size, data); +} + +void glClear(GLbitfield mask) +{ + GET_CONTEXT; + ctx->glClear(ctx, mask); +} + +void glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + GET_CONTEXT; + ctx->glClearColorx(ctx, red, green, blue, alpha); +} + +void glClearDepthx(GLclampx depth) +{ + GET_CONTEXT; + ctx->glClearDepthx(ctx, depth); +} + +void glClearStencil(GLint s) +{ + GET_CONTEXT; + ctx->glClearStencil(ctx, s); +} + +void glClientActiveTexture(GLenum texture) +{ + GET_CONTEXT; + ctx->glClientActiveTexture(ctx, texture); +} + +void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + GET_CONTEXT; + ctx->glColor4ub(ctx, red, green, blue, alpha); +} + +void glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + GET_CONTEXT; + ctx->glColor4x(ctx, red, green, blue, alpha); +} + +void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + GET_CONTEXT; + ctx->glColorMask(ctx, red, green, blue, alpha); +} + +void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + GET_CONTEXT; + ctx->glColorPointer(ctx, size, type, stride, pointer); +} + +void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glCompressedTexImage2D(ctx, target, level, internalformat, width, height, border, imageSize, data); +} + +void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glCompressedTexSubImage2D(ctx, target, level, xoffset, yoffset, width, height, format, imageSize, data); +} + +void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + GET_CONTEXT; + ctx->glCopyTexImage2D(ctx, target, level, internalformat, x, y, width, height, border); +} + +void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glCopyTexSubImage2D(ctx, target, level, xoffset, yoffset, x, y, width, height); +} + +void glCullFace(GLenum mode) +{ + GET_CONTEXT; + ctx->glCullFace(ctx, mode); +} + +void glDeleteBuffers(GLsizei n, const GLuint* buffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteBuffers(ctx, n, buffers); +} + +void glDeleteTextures(GLsizei n, const GLuint* textures) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteTextures(ctx, n, textures); +} + +void glDepthFunc(GLenum func) +{ + GET_CONTEXT; + ctx->glDepthFunc(ctx, func); +} + +void glDepthMask(GLboolean flag) +{ + GET_CONTEXT; + ctx->glDepthMask(ctx, flag); +} + +void glDepthRangex(GLclampx zNear, GLclampx zFar) +{ + GET_CONTEXT; + ctx->glDepthRangex(ctx, zNear, zFar); +} + +void glDisable(GLenum cap) +{ + GET_CONTEXT; + ctx->glDisable(ctx, cap); +} + +void glDisableClientState(GLenum array) +{ + GET_CONTEXT; + ctx->glDisableClientState(ctx, array); +} + +void glDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + GET_CONTEXT; + ctx->glDrawArrays(ctx, mode, first, count); +} + +void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) +{ + GET_CONTEXT; + ctx->glDrawElements(ctx, mode, count, type, indices); +} + +void glEnable(GLenum cap) +{ + GET_CONTEXT; + ctx->glEnable(ctx, cap); +} + +void glEnableClientState(GLenum array) +{ + GET_CONTEXT; + ctx->glEnableClientState(ctx, array); +} + +void glFinish() +{ + GET_CONTEXT; + ctx->glFinish(ctx); +} + +void glFlush() +{ + GET_CONTEXT; + ctx->glFlush(ctx); +} + +void glFogx(GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glFogx(ctx, pname, param); +} + +void glFogxv(GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glFogxv(ctx, pname, params); +} + +void glFrontFace(GLenum mode) +{ + GET_CONTEXT; + ctx->glFrontFace(ctx, mode); +} + +void glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + GET_CONTEXT; + ctx->glFrustumx(ctx, left, right, bottom, top, zNear, zFar); +} + +void glGetBooleanv(GLenum pname, GLboolean* params) +{ + GET_CONTEXT; + ctx->glGetBooleanv(ctx, pname, params); +} + +void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetBufferParameteriv(ctx, target, pname, params); +} + +void glClipPlanex(GLenum pname, const GLfixed* eqn) +{ + GET_CONTEXT; + ctx->glClipPlanex(ctx, pname, eqn); +} + +void glGenBuffers(GLsizei n, GLuint* buffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenBuffers(ctx, n, buffers); +} + +void glGenTextures(GLsizei n, GLuint* textures) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenTextures(ctx, n, textures); +} + +GLenum glGetError() +{ + GET_CONTEXT; + return ctx->glGetError(ctx); +} + +void glGetFixedv(GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetFixedv(ctx, pname, params); +} + +void glGetIntegerv(GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetIntegerv(ctx, pname, params); +} + +void glGetLightxv(GLenum light, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetLightxv(ctx, light, pname, params); +} + +void glGetMaterialxv(GLenum face, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetMaterialxv(ctx, face, pname, params); +} + +void glGetPointerv(GLenum pname, GLvoid** params) +{ + GET_CONTEXT; + ctx->glGetPointerv(ctx, pname, params); +} + +const GLubyte* glGetString(GLenum name) +{ + GET_CONTEXT; + return ctx->glGetString(ctx, name); +} + +void glGetTexEnviv(GLenum env, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetTexEnviv(ctx, env, pname, params); +} + +void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetTexEnvxv(ctx, env, pname, params); +} + +void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetTexParameteriv(ctx, target, pname, params); +} + +void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetTexParameterxv(ctx, target, pname, params); +} + +void glHint(GLenum target, GLenum mode) +{ + GET_CONTEXT; + ctx->glHint(ctx, target, mode); +} + +GLboolean glIsBuffer(GLuint buffer) +{ + GET_CONTEXT; + return ctx->glIsBuffer(ctx, buffer); +} + +GLboolean glIsEnabled(GLenum cap) +{ + GET_CONTEXT; + return ctx->glIsEnabled(ctx, cap); +} + +GLboolean glIsTexture(GLuint texture) +{ + GET_CONTEXT; + return ctx->glIsTexture(ctx, texture); +} + +void glLightModelx(GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glLightModelx(ctx, pname, param); +} + +void glLightModelxv(GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glLightModelxv(ctx, pname, params); +} + +void glLightx(GLenum light, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glLightx(ctx, light, pname, param); +} + +void glLightxv(GLenum light, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glLightxv(ctx, light, pname, params); +} + +void glLineWidthx(GLfixed width) +{ + GET_CONTEXT; + ctx->glLineWidthx(ctx, width); +} + +void glLoadIdentity() +{ + GET_CONTEXT; + ctx->glLoadIdentity(ctx); +} + +void glLoadMatrixx(const GLfixed* m) +{ + GET_CONTEXT; + ctx->glLoadMatrixx(ctx, m); +} + +void glLogicOp(GLenum opcode) +{ + GET_CONTEXT; + ctx->glLogicOp(ctx, opcode); +} + +void glMaterialx(GLenum face, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glMaterialx(ctx, face, pname, param); +} + +void glMaterialxv(GLenum face, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glMaterialxv(ctx, face, pname, params); +} + +void glMatrixMode(GLenum mode) +{ + GET_CONTEXT; + ctx->glMatrixMode(ctx, mode); +} + +void glMultMatrixx(const GLfixed* m) +{ + GET_CONTEXT; + ctx->glMultMatrixx(ctx, m); +} + +void glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + GET_CONTEXT; + ctx->glMultiTexCoord4x(ctx, target, s, t, r, q); +} + +void glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz) +{ + GET_CONTEXT; + ctx->glNormal3x(ctx, nx, ny, nz); +} + +void glNormalPointer(GLenum type, GLsizei stride, const GLvoid* pointer) +{ + GET_CONTEXT; + ctx->glNormalPointer(ctx, type, stride, pointer); +} + +void glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + GET_CONTEXT; + ctx->glOrthox(ctx, left, right, bottom, top, zNear, zFar); +} + +void glPixelStorei(GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glPixelStorei(ctx, pname, param); +} + +void glPointParameterx(GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glPointParameterx(ctx, pname, param); +} + +void glPointParameterxv(GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glPointParameterxv(ctx, pname, params); +} + +void glPointSizex(GLfixed size) +{ + GET_CONTEXT; + ctx->glPointSizex(ctx, size); +} + +void glPolygonOffsetx(GLfixed factor, GLfixed units) +{ + GET_CONTEXT; + ctx->glPolygonOffsetx(ctx, factor, units); +} + +void glPopMatrix() +{ + GET_CONTEXT; + ctx->glPopMatrix(ctx); +} + +void glPushMatrix() +{ + GET_CONTEXT; + ctx->glPushMatrix(ctx); +} + +void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glReadPixels(ctx, x, y, width, height, format, type, pixels); +} + +void glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + GET_CONTEXT; + ctx->glRotatex(ctx, angle, x, y, z); +} + +void glSampleCoverage(GLclampf value, GLboolean invert) +{ + GET_CONTEXT; + ctx->glSampleCoverage(ctx, value, invert); +} + +void glSampleCoveragex(GLclampx value, GLboolean invert) +{ + GET_CONTEXT; + ctx->glSampleCoveragex(ctx, value, invert); +} + +void glScalex(GLfixed x, GLfixed y, GLfixed z) +{ + GET_CONTEXT; + ctx->glScalex(ctx, x, y, z); +} + +void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glScissor(ctx, x, y, width, height); +} + +void glShadeModel(GLenum mode) +{ + GET_CONTEXT; + ctx->glShadeModel(ctx, mode); +} + +void glStencilFunc(GLenum func, GLint ref, GLuint mask) +{ + GET_CONTEXT; + ctx->glStencilFunc(ctx, func, ref, mask); +} + +void glStencilMask(GLuint mask) +{ + GET_CONTEXT; + ctx->glStencilMask(ctx, mask); +} + +void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CONTEXT; + ctx->glStencilOp(ctx, fail, zfail, zpass); +} + +void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + GET_CONTEXT; + ctx->glTexCoordPointer(ctx, size, type, stride, pointer); +} + +void glTexEnvi(GLenum target, GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glTexEnvi(ctx, target, pname, param); +} + +void glTexEnvx(GLenum target, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glTexEnvx(ctx, target, pname, param); +} + +void glTexEnviv(GLenum target, GLenum pname, const GLint* params) +{ + GET_CONTEXT; + ctx->glTexEnviv(ctx, target, pname, params); +} + +void glTexEnvxv(GLenum target, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glTexEnvxv(ctx, target, pname, params); +} + +void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glTexImage2D(ctx, target, level, internalformat, width, height, border, format, type, pixels); +} + +void glTexParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glTexParameteri(ctx, target, pname, param); +} + +void glTexParameterx(GLenum target, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glTexParameterx(ctx, target, pname, param); +} + +void glTexParameteriv(GLenum target, GLenum pname, const GLint* params) +{ + GET_CONTEXT; + ctx->glTexParameteriv(ctx, target, pname, params); +} + +void glTexParameterxv(GLenum target, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glTexParameterxv(ctx, target, pname, params); +} + +void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glTexSubImage2D(ctx, target, level, xoffset, yoffset, width, height, format, type, pixels); +} + +void glTranslatex(GLfixed x, GLfixed y, GLfixed z) +{ + GET_CONTEXT; + ctx->glTranslatex(ctx, x, y, z); +} + +void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + GET_CONTEXT; + ctx->glVertexPointer(ctx, size, type, stride, pointer); +} + +void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glViewport(ctx, x, y, width, height); +} + +void glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid* pointer) +{ + GET_CONTEXT; + ctx->glPointSizePointerOES(ctx, type, stride, pointer); +} + +void glVertexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glVertexPointerOffset(ctx, size, type, stride, offset); +} + +void glColorPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glColorPointerOffset(ctx, size, type, stride, offset); +} + +void glNormalPointerOffset(GLenum type, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glNormalPointerOffset(ctx, type, stride, offset); +} + +void glPointSizePointerOffset(GLenum type, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glPointSizePointerOffset(ctx, type, stride, offset); +} + +void glTexCoordPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glTexCoordPointerOffset(ctx, size, type, stride, offset); +} + +void glWeightPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glWeightPointerOffset(ctx, size, type, stride, offset); +} + +void glMatrixIndexPointerOffset(GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glMatrixIndexPointerOffset(ctx, size, type, stride, offset); +} + +void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glVertexPointerData(ctx, size, type, stride, data, datalen); +} + +void glColorPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glColorPointerData(ctx, size, type, stride, data, datalen); +} + +void glNormalPointerData(GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glNormalPointerData(ctx, type, stride, data, datalen); +} + +void glTexCoordPointerData(GLint unit, GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glTexCoordPointerData(ctx, unit, size, type, stride, data, datalen); +} + +void glPointSizePointerData(GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glPointSizePointerData(ctx, type, stride, data, datalen); +} + +void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glWeightPointerData(ctx, size, type, stride, data, datalen); +} + +void glMatrixIndexPointerData(GLint size, GLenum type, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glMatrixIndexPointerData(ctx, size, type, stride, data, datalen); +} + +void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset) +{ + GET_CONTEXT; + ctx->glDrawElementsOffset(ctx, mode, count, type, offset); +} + +void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glDrawElementsData(ctx, mode, count, type, data, datalen); +} + +void glGetCompressedTextureFormats(int count, GLint* formats) +{ + GET_CONTEXT; + ctx->glGetCompressedTextureFormats(ctx, count, formats); +} + +int glFinishRoundTrip() +{ + GET_CONTEXT; + return ctx->glFinishRoundTrip(ctx); +} + +void glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha) +{ + GET_CONTEXT; + ctx->glBlendEquationSeparateOES(ctx, modeRGB, modeAlpha); +} + +void glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + GET_CONTEXT; + ctx->glBlendFuncSeparateOES(ctx, srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void glBlendEquationOES(GLenum mode) +{ + GET_CONTEXT; + ctx->glBlendEquationOES(ctx, mode); +} + +void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ + GET_CONTEXT; + ctx->glDrawTexsOES(ctx, x, y, z, width, height); +} + +void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + GET_CONTEXT; + ctx->glDrawTexiOES(ctx, x, y, z, width, height); +} + +void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ + GET_CONTEXT; + ctx->glDrawTexxOES(ctx, x, y, z, width, height); +} + +void glDrawTexsvOES(const GLshort* coords) +{ + GET_CONTEXT; + ctx->glDrawTexsvOES(ctx, coords); +} + +void glDrawTexivOES(const GLint* coords) +{ + GET_CONTEXT; + ctx->glDrawTexivOES(ctx, coords); +} + +void glDrawTexxvOES(const GLfixed* coords) +{ + GET_CONTEXT; + ctx->glDrawTexxvOES(ctx, coords); +} + +void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ + GET_CONTEXT; + ctx->glDrawTexfOES(ctx, x, y, z, width, height); +} + +void glDrawTexfvOES(const GLfloat* coords) +{ + GET_CONTEXT; + ctx->glDrawTexfvOES(ctx, coords); +} + +void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +{ + GET_CONTEXT; + ctx->glEGLImageTargetTexture2DOES(ctx, target, image); +} + +void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + GET_CONTEXT; + ctx->glEGLImageTargetRenderbufferStorageOES(ctx, target, image); +} + +void glAlphaFuncxOES(GLenum func, GLclampx ref) +{ + GET_CONTEXT; + ctx->glAlphaFuncxOES(ctx, func, ref); +} + +void glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + GET_CONTEXT; + ctx->glClearColorxOES(ctx, red, green, blue, alpha); +} + +void glClearDepthxOES(GLclampx depth) +{ + GET_CONTEXT; + ctx->glClearDepthxOES(ctx, depth); +} + +void glClipPlanexOES(GLenum plane, const GLfixed* equation) +{ + GET_CONTEXT; + ctx->glClipPlanexOES(ctx, plane, equation); +} + +void glClipPlanexIMG(GLenum plane, const GLfixed* equation) +{ + GET_CONTEXT; + ctx->glClipPlanexIMG(ctx, plane, equation); +} + +void glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + GET_CONTEXT; + ctx->glColor4xOES(ctx, red, green, blue, alpha); +} + +void glDepthRangexOES(GLclampx zNear, GLclampx zFar) +{ + GET_CONTEXT; + ctx->glDepthRangexOES(ctx, zNear, zFar); +} + +void glFogxOES(GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glFogxOES(ctx, pname, param); +} + +void glFogxvOES(GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glFogxvOES(ctx, pname, params); +} + +void glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + GET_CONTEXT; + ctx->glFrustumxOES(ctx, left, right, bottom, top, zNear, zFar); +} + +void glGetClipPlanexOES(GLenum pname, GLfixed* eqn) +{ + GET_CONTEXT; + ctx->glGetClipPlanexOES(ctx, pname, eqn); +} + +void glGetClipPlanex(GLenum pname, GLfixed* eqn) +{ + GET_CONTEXT; + ctx->glGetClipPlanex(ctx, pname, eqn); +} + +void glGetFixedvOES(GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetFixedvOES(ctx, pname, params); +} + +void glGetLightxvOES(GLenum light, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetLightxvOES(ctx, light, pname, params); +} + +void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetMaterialxvOES(ctx, face, pname, params); +} + +void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetTexEnvxvOES(ctx, env, pname, params); +} + +void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetTexParameterxvOES(ctx, target, pname, params); +} + +void glLightModelxOES(GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glLightModelxOES(ctx, pname, param); +} + +void glLightModelxvOES(GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glLightModelxvOES(ctx, pname, params); +} + +void glLightxOES(GLenum light, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glLightxOES(ctx, light, pname, param); +} + +void glLightxvOES(GLenum light, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glLightxvOES(ctx, light, pname, params); +} + +void glLineWidthxOES(GLfixed width) +{ + GET_CONTEXT; + ctx->glLineWidthxOES(ctx, width); +} + +void glLoadMatrixxOES(const GLfixed* m) +{ + GET_CONTEXT; + ctx->glLoadMatrixxOES(ctx, m); +} + +void glMaterialxOES(GLenum face, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glMaterialxOES(ctx, face, pname, param); +} + +void glMaterialxvOES(GLenum face, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glMaterialxvOES(ctx, face, pname, params); +} + +void glMultMatrixxOES(const GLfixed* m) +{ + GET_CONTEXT; + ctx->glMultMatrixxOES(ctx, m); +} + +void glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + GET_CONTEXT; + ctx->glMultiTexCoord4xOES(ctx, target, s, t, r, q); +} + +void glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz) +{ + GET_CONTEXT; + ctx->glNormal3xOES(ctx, nx, ny, nz); +} + +void glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + GET_CONTEXT; + ctx->glOrthoxOES(ctx, left, right, bottom, top, zNear, zFar); +} + +void glPointParameterxOES(GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glPointParameterxOES(ctx, pname, param); +} + +void glPointParameterxvOES(GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glPointParameterxvOES(ctx, pname, params); +} + +void glPointSizexOES(GLfixed size) +{ + GET_CONTEXT; + ctx->glPointSizexOES(ctx, size); +} + +void glPolygonOffsetxOES(GLfixed factor, GLfixed units) +{ + GET_CONTEXT; + ctx->glPolygonOffsetxOES(ctx, factor, units); +} + +void glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + GET_CONTEXT; + ctx->glRotatexOES(ctx, angle, x, y, z); +} + +void glSampleCoveragexOES(GLclampx value, GLboolean invert) +{ + GET_CONTEXT; + ctx->glSampleCoveragexOES(ctx, value, invert); +} + +void glScalexOES(GLfixed x, GLfixed y, GLfixed z) +{ + GET_CONTEXT; + ctx->glScalexOES(ctx, x, y, z); +} + +void glTexEnvxOES(GLenum target, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glTexEnvxOES(ctx, target, pname, param); +} + +void glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glTexEnvxvOES(ctx, target, pname, params); +} + +void glTexParameterxOES(GLenum target, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glTexParameterxOES(ctx, target, pname, param); +} + +void glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glTexParameterxvOES(ctx, target, pname, params); +} + +void glTranslatexOES(GLfixed x, GLfixed y, GLfixed z) +{ + GET_CONTEXT; + ctx->glTranslatexOES(ctx, x, y, z); +} + +GLboolean glIsRenderbufferOES(GLuint renderbuffer) +{ + GET_CONTEXT; + return ctx->glIsRenderbufferOES(ctx, renderbuffer); +} + +void glBindRenderbufferOES(GLenum target, GLuint renderbuffer) +{ + GET_CONTEXT; + ctx->glBindRenderbufferOES(ctx, target, renderbuffer); +} + +void glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteRenderbuffersOES(ctx, n, renderbuffers); +} + +void glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenRenderbuffersOES(ctx, n, renderbuffers); +} + +void glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glRenderbufferStorageOES(ctx, target, internalformat, width, height); +} + +void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetRenderbufferParameterivOES(ctx, target, pname, params); +} + +GLboolean glIsFramebufferOES(GLuint framebuffer) +{ + GET_CONTEXT; + return ctx->glIsFramebufferOES(ctx, framebuffer); +} + +void glBindFramebufferOES(GLenum target, GLuint framebuffer) +{ + GET_CONTEXT; + ctx->glBindFramebufferOES(ctx, target, framebuffer); +} + +void glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteFramebuffersOES(ctx, n, framebuffers); +} + +void glGenFramebuffersOES(GLsizei n, GLuint* framebuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenFramebuffersOES(ctx, n, framebuffers); +} + +GLenum glCheckFramebufferStatusOES(GLenum target) +{ + GET_CONTEXT; + return ctx->glCheckFramebufferStatusOES(ctx, target); +} + +void glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + GET_CONTEXT; + ctx->glFramebufferRenderbufferOES(ctx, target, attachment, renderbuffertarget, renderbuffer); +} + +void glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + GET_CONTEXT; + ctx->glFramebufferTexture2DOES(ctx, target, attachment, textarget, texture, level); +} + +void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetFramebufferAttachmentParameterivOES(ctx, target, attachment, pname, params); +} + +void glGenerateMipmapOES(GLenum target) +{ + GET_CONTEXT; + ctx->glGenerateMipmapOES(ctx, target); +} + +void* glMapBufferOES(GLenum target, GLenum access) +{ + GET_CONTEXT; + return ctx->glMapBufferOES(ctx, target, access); +} + +GLboolean glUnmapBufferOES(GLenum target) +{ + GET_CONTEXT; + return ctx->glUnmapBufferOES(ctx, target); +} + +void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid** params) +{ + GET_CONTEXT; + ctx->glGetBufferPointervOES(ctx, target, pname, params); +} + +void glCurrentPaletteMatrixOES(GLuint matrixpaletteindex) +{ + GET_CONTEXT; + ctx->glCurrentPaletteMatrixOES(ctx, matrixpaletteindex); +} + +void glLoadPaletteFromModelViewMatrixOES() +{ + GET_CONTEXT; + ctx->glLoadPaletteFromModelViewMatrixOES(ctx); +} + +void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + GET_CONTEXT; + ctx->glMatrixIndexPointerOES(ctx, size, type, stride, pointer); +} + +void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) +{ + GET_CONTEXT; + ctx->glWeightPointerOES(ctx, size, type, stride, pointer); +} + +GLbitfield glQueryMatrixxOES(GLfixed* mantissa, GLint* exponent) +{ + GET_CONTEXT; + return ctx->glQueryMatrixxOES(ctx, mantissa, exponent); +} + +void glDepthRangefOES(GLclampf zNear, GLclampf zFar) +{ + GET_CONTEXT; + ctx->glDepthRangefOES(ctx, zNear, zFar); +} + +void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + GET_CONTEXT; + ctx->glFrustumfOES(ctx, left, right, bottom, top, zNear, zFar); +} + +void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + GET_CONTEXT; + ctx->glOrthofOES(ctx, left, right, bottom, top, zNear, zFar); +} + +void glClipPlanefOES(GLenum plane, const GLfloat* equation) +{ + GET_CONTEXT; + ctx->glClipPlanefOES(ctx, plane, equation); +} + +void glClipPlanefIMG(GLenum plane, const GLfloat* equation) +{ + GET_CONTEXT; + ctx->glClipPlanefIMG(ctx, plane, equation); +} + +void glGetClipPlanefOES(GLenum pname, GLfloat* eqn) +{ + GET_CONTEXT; + ctx->glGetClipPlanefOES(ctx, pname, eqn); +} + +void glClearDepthfOES(GLclampf depth) +{ + GET_CONTEXT; + ctx->glClearDepthfOES(ctx, depth); +} + +void glTexGenfOES(GLenum coord, GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glTexGenfOES(ctx, coord, pname, param); +} + +void glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glTexGenfvOES(ctx, coord, pname, params); +} + +void glTexGeniOES(GLenum coord, GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glTexGeniOES(ctx, coord, pname, param); +} + +void glTexGenivOES(GLenum coord, GLenum pname, const GLint* params) +{ + GET_CONTEXT; + ctx->glTexGenivOES(ctx, coord, pname, params); +} + +void glTexGenxOES(GLenum coord, GLenum pname, GLfixed param) +{ + GET_CONTEXT; + ctx->glTexGenxOES(ctx, coord, pname, param); +} + +void glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed* params) +{ + GET_CONTEXT; + ctx->glTexGenxvOES(ctx, coord, pname, params); +} + +void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetTexGenfvOES(ctx, coord, pname, params); +} + +void glGetTexGenivOES(GLenum coord, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetTexGenivOES(ctx, coord, pname, params); +} + +void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed* params) +{ + GET_CONTEXT; + ctx->glGetTexGenxvOES(ctx, coord, pname, params); +} + +void glBindVertexArrayOES(GLuint array) +{ + GET_CONTEXT; + ctx->glBindVertexArrayOES(ctx, array); +} + +void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteVertexArraysOES(ctx, n, arrays); +} + +void glGenVertexArraysOES(GLsizei n, GLuint* arrays) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenVertexArraysOES(ctx, n, arrays); +} + +GLboolean glIsVertexArrayOES(GLuint array) +{ + GET_CONTEXT; + return ctx->glIsVertexArrayOES(ctx, array); +} + +void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments) +{ + GET_CONTEXT; + ctx->glDiscardFramebufferEXT(ctx, target, numAttachments, attachments); +} + +void glMultiDrawArraysEXT(GLenum mode, const GLint* first, const GLsizei* count, GLsizei primcount) +{ + GET_CONTEXT; + ctx->glMultiDrawArraysEXT(ctx, mode, first, count, primcount); +} + +void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices, GLsizei primcount) +{ + GET_CONTEXT; + ctx->glMultiDrawElementsEXT(ctx, mode, count, type, indices, primcount); +} + +void glMultiDrawArraysSUN(GLenum mode, GLint* first, GLsizei* count, GLsizei primcount) +{ + GET_CONTEXT; + ctx->glMultiDrawArraysSUN(ctx, mode, first, count, primcount); +} + +void glMultiDrawElementsSUN(GLenum mode, const GLsizei* count, GLenum type, const GLvoid** indices, GLsizei primcount) +{ + GET_CONTEXT; + ctx->glMultiDrawElementsSUN(ctx, mode, count, type, indices, primcount); +} + +void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glRenderbufferStorageMultisampleIMG(ctx, target, samples, internalformat, width, height); +} + +void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +{ + GET_CONTEXT; + ctx->glFramebufferTexture2DMultisampleIMG(ctx, target, attachment, textarget, texture, level, samples); +} + +void glDeleteFencesNV(GLsizei n, const GLuint* fences) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteFencesNV(ctx, n, fences); +} + +void glGenFencesNV(GLsizei n, GLuint* fences) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenFencesNV(ctx, n, fences); +} + +GLboolean glIsFenceNV(GLuint fence) +{ + GET_CONTEXT; + return ctx->glIsFenceNV(ctx, fence); +} + +GLboolean glTestFenceNV(GLuint fence) +{ + GET_CONTEXT; + return ctx->glTestFenceNV(ctx, fence); +} + +void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetFenceivNV(ctx, fence, pname, params); +} + +void glFinishFenceNV(GLuint fence) +{ + GET_CONTEXT; + ctx->glFinishFenceNV(ctx, fence); +} + +void glSetFenceNV(GLuint fence, GLenum condition) +{ + GET_CONTEXT; + ctx->glSetFenceNV(ctx, fence, condition); +} + +void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls) +{ + GET_CONTEXT; + ctx->glGetDriverControlsQCOM(ctx, num, size, driverControls); +} + +void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString) +{ + GET_CONTEXT; + ctx->glGetDriverControlStringQCOM(ctx, driverControl, bufSize, length, driverControlString); +} + +void glEnableDriverControlQCOM(GLuint driverControl) +{ + GET_CONTEXT; + ctx->glEnableDriverControlQCOM(ctx, driverControl); +} + +void glDisableDriverControlQCOM(GLuint driverControl) +{ + GET_CONTEXT; + ctx->glDisableDriverControlQCOM(ctx, driverControl); +} + +void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures) +{ + GET_CONTEXT; + ctx->glExtGetTexturesQCOM(ctx, textures, maxTextures, numTextures); +} + +void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers) +{ + GET_CONTEXT; + ctx->glExtGetBuffersQCOM(ctx, buffers, maxBuffers, numBuffers); +} + +void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers) +{ + GET_CONTEXT; + ctx->glExtGetRenderbuffersQCOM(ctx, renderbuffers, maxRenderbuffers, numRenderbuffers); +} + +void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers) +{ + GET_CONTEXT; + ctx->glExtGetFramebuffersQCOM(ctx, framebuffers, maxFramebuffers, numFramebuffers); +} + +void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glExtGetTexLevelParameterivQCOM(ctx, texture, face, level, pname, params); +} + +void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glExtTexObjectStateOverrideiQCOM(ctx, target, pname, param); +} + +void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels) +{ + GET_CONTEXT; + ctx->glExtGetTexSubImageQCOM(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels); +} + +void glExtGetBufferPointervQCOM(GLenum target, GLvoid** params) +{ + GET_CONTEXT; + ctx->glExtGetBufferPointervQCOM(ctx, target, params); +} + +void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders) +{ + GET_CONTEXT; + ctx->glExtGetShadersQCOM(ctx, shaders, maxShaders, numShaders); +} + +void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms) +{ + GET_CONTEXT; + ctx->glExtGetProgramsQCOM(ctx, programs, maxPrograms, numPrograms); +} + +GLboolean glExtIsProgramBinaryQCOM(GLuint program) +{ + GET_CONTEXT; + return ctx->glExtIsProgramBinaryQCOM(ctx, program); +} + +void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length) +{ + GET_CONTEXT; + ctx->glExtGetProgramBinarySourceQCOM(ctx, program, shadertype, source, length); +} + +void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) +{ + GET_CONTEXT; + ctx->glStartTilingQCOM(ctx, x, y, width, height, preserveMask); +} + +void glEndTilingQCOM(GLbitfield preserveMask) +{ + GET_CONTEXT; + ctx->glEndTilingQCOM(ctx, preserveMask); +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_ftable.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_ftable.h new file mode 100644 index 0000000..67ba6f4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_ftable.h @@ -0,0 +1,288 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __gl_client_ftable_t_h +#define __gl_client_ftable_t_h + + +static const struct _gl_funcs_by_name { + const char *name; + void *proc; +} gl_funcs_by_name[] = { + {"glAlphaFunc", (void*)glAlphaFunc}, + {"glClearColor", (void*)glClearColor}, + {"glClearDepthf", (void*)glClearDepthf}, + {"glClipPlanef", (void*)glClipPlanef}, + {"glColor4f", (void*)glColor4f}, + {"glDepthRangef", (void*)glDepthRangef}, + {"glFogf", (void*)glFogf}, + {"glFogfv", (void*)glFogfv}, + {"glFrustumf", (void*)glFrustumf}, + {"glGetClipPlanef", (void*)glGetClipPlanef}, + {"glGetFloatv", (void*)glGetFloatv}, + {"glGetLightfv", (void*)glGetLightfv}, + {"glGetMaterialfv", (void*)glGetMaterialfv}, + {"glGetTexEnvfv", (void*)glGetTexEnvfv}, + {"glGetTexParameterfv", (void*)glGetTexParameterfv}, + {"glLightModelf", (void*)glLightModelf}, + {"glLightModelfv", (void*)glLightModelfv}, + {"glLightf", (void*)glLightf}, + {"glLightfv", (void*)glLightfv}, + {"glLineWidth", (void*)glLineWidth}, + {"glLoadMatrixf", (void*)glLoadMatrixf}, + {"glMaterialf", (void*)glMaterialf}, + {"glMaterialfv", (void*)glMaterialfv}, + {"glMultMatrixf", (void*)glMultMatrixf}, + {"glMultiTexCoord4f", (void*)glMultiTexCoord4f}, + {"glNormal3f", (void*)glNormal3f}, + {"glOrthof", (void*)glOrthof}, + {"glPointParameterf", (void*)glPointParameterf}, + {"glPointParameterfv", (void*)glPointParameterfv}, + {"glPointSize", (void*)glPointSize}, + {"glPolygonOffset", (void*)glPolygonOffset}, + {"glRotatef", (void*)glRotatef}, + {"glScalef", (void*)glScalef}, + {"glTexEnvf", (void*)glTexEnvf}, + {"glTexEnvfv", (void*)glTexEnvfv}, + {"glTexParameterf", (void*)glTexParameterf}, + {"glTexParameterfv", (void*)glTexParameterfv}, + {"glTranslatef", (void*)glTranslatef}, + {"glActiveTexture", (void*)glActiveTexture}, + {"glAlphaFuncx", (void*)glAlphaFuncx}, + {"glBindBuffer", (void*)glBindBuffer}, + {"glBindTexture", (void*)glBindTexture}, + {"glBlendFunc", (void*)glBlendFunc}, + {"glBufferData", (void*)glBufferData}, + {"glBufferSubData", (void*)glBufferSubData}, + {"glClear", (void*)glClear}, + {"glClearColorx", (void*)glClearColorx}, + {"glClearDepthx", (void*)glClearDepthx}, + {"glClearStencil", (void*)glClearStencil}, + {"glClientActiveTexture", (void*)glClientActiveTexture}, + {"glColor4ub", (void*)glColor4ub}, + {"glColor4x", (void*)glColor4x}, + {"glColorMask", (void*)glColorMask}, + {"glColorPointer", (void*)glColorPointer}, + {"glCompressedTexImage2D", (void*)glCompressedTexImage2D}, + {"glCompressedTexSubImage2D", (void*)glCompressedTexSubImage2D}, + {"glCopyTexImage2D", (void*)glCopyTexImage2D}, + {"glCopyTexSubImage2D", (void*)glCopyTexSubImage2D}, + {"glCullFace", (void*)glCullFace}, + {"glDeleteBuffers", (void*)glDeleteBuffers}, + {"glDeleteTextures", (void*)glDeleteTextures}, + {"glDepthFunc", (void*)glDepthFunc}, + {"glDepthMask", (void*)glDepthMask}, + {"glDepthRangex", (void*)glDepthRangex}, + {"glDisable", (void*)glDisable}, + {"glDisableClientState", (void*)glDisableClientState}, + {"glDrawArrays", (void*)glDrawArrays}, + {"glDrawElements", (void*)glDrawElements}, + {"glEnable", (void*)glEnable}, + {"glEnableClientState", (void*)glEnableClientState}, + {"glFinish", (void*)glFinish}, + {"glFlush", (void*)glFlush}, + {"glFogx", (void*)glFogx}, + {"glFogxv", (void*)glFogxv}, + {"glFrontFace", (void*)glFrontFace}, + {"glFrustumx", (void*)glFrustumx}, + {"glGetBooleanv", (void*)glGetBooleanv}, + {"glGetBufferParameteriv", (void*)glGetBufferParameteriv}, + {"glClipPlanex", (void*)glClipPlanex}, + {"glGenBuffers", (void*)glGenBuffers}, + {"glGenTextures", (void*)glGenTextures}, + {"glGetError", (void*)glGetError}, + {"glGetFixedv", (void*)glGetFixedv}, + {"glGetIntegerv", (void*)glGetIntegerv}, + {"glGetLightxv", (void*)glGetLightxv}, + {"glGetMaterialxv", (void*)glGetMaterialxv}, + {"glGetPointerv", (void*)glGetPointerv}, + {"glGetString", (void*)glGetString}, + {"glGetTexEnviv", (void*)glGetTexEnviv}, + {"glGetTexEnvxv", (void*)glGetTexEnvxv}, + {"glGetTexParameteriv", (void*)glGetTexParameteriv}, + {"glGetTexParameterxv", (void*)glGetTexParameterxv}, + {"glHint", (void*)glHint}, + {"glIsBuffer", (void*)glIsBuffer}, + {"glIsEnabled", (void*)glIsEnabled}, + {"glIsTexture", (void*)glIsTexture}, + {"glLightModelx", (void*)glLightModelx}, + {"glLightModelxv", (void*)glLightModelxv}, + {"glLightx", (void*)glLightx}, + {"glLightxv", (void*)glLightxv}, + {"glLineWidthx", (void*)glLineWidthx}, + {"glLoadIdentity", (void*)glLoadIdentity}, + {"glLoadMatrixx", (void*)glLoadMatrixx}, + {"glLogicOp", (void*)glLogicOp}, + {"glMaterialx", (void*)glMaterialx}, + {"glMaterialxv", (void*)glMaterialxv}, + {"glMatrixMode", (void*)glMatrixMode}, + {"glMultMatrixx", (void*)glMultMatrixx}, + {"glMultiTexCoord4x", (void*)glMultiTexCoord4x}, + {"glNormal3x", (void*)glNormal3x}, + {"glNormalPointer", (void*)glNormalPointer}, + {"glOrthox", (void*)glOrthox}, + {"glPixelStorei", (void*)glPixelStorei}, + {"glPointParameterx", (void*)glPointParameterx}, + {"glPointParameterxv", (void*)glPointParameterxv}, + {"glPointSizex", (void*)glPointSizex}, + {"glPolygonOffsetx", (void*)glPolygonOffsetx}, + {"glPopMatrix", (void*)glPopMatrix}, + {"glPushMatrix", (void*)glPushMatrix}, + {"glReadPixels", (void*)glReadPixels}, + {"glRotatex", (void*)glRotatex}, + {"glSampleCoverage", (void*)glSampleCoverage}, + {"glSampleCoveragex", (void*)glSampleCoveragex}, + {"glScalex", (void*)glScalex}, + {"glScissor", (void*)glScissor}, + {"glShadeModel", (void*)glShadeModel}, + {"glStencilFunc", (void*)glStencilFunc}, + {"glStencilMask", (void*)glStencilMask}, + {"glStencilOp", (void*)glStencilOp}, + {"glTexCoordPointer", (void*)glTexCoordPointer}, + {"glTexEnvi", (void*)glTexEnvi}, + {"glTexEnvx", (void*)glTexEnvx}, + {"glTexEnviv", (void*)glTexEnviv}, + {"glTexEnvxv", (void*)glTexEnvxv}, + {"glTexImage2D", (void*)glTexImage2D}, + {"glTexParameteri", (void*)glTexParameteri}, + {"glTexParameterx", (void*)glTexParameterx}, + {"glTexParameteriv", (void*)glTexParameteriv}, + {"glTexParameterxv", (void*)glTexParameterxv}, + {"glTexSubImage2D", (void*)glTexSubImage2D}, + {"glTranslatex", (void*)glTranslatex}, + {"glVertexPointer", (void*)glVertexPointer}, + {"glViewport", (void*)glViewport}, + {"glPointSizePointerOES", (void*)glPointSizePointerOES}, + {"glBlendEquationSeparateOES", (void*)glBlendEquationSeparateOES}, + {"glBlendFuncSeparateOES", (void*)glBlendFuncSeparateOES}, + {"glBlendEquationOES", (void*)glBlendEquationOES}, + {"glDrawTexsOES", (void*)glDrawTexsOES}, + {"glDrawTexiOES", (void*)glDrawTexiOES}, + {"glDrawTexxOES", (void*)glDrawTexxOES}, + {"glDrawTexsvOES", (void*)glDrawTexsvOES}, + {"glDrawTexivOES", (void*)glDrawTexivOES}, + {"glDrawTexxvOES", (void*)glDrawTexxvOES}, + {"glDrawTexfOES", (void*)glDrawTexfOES}, + {"glDrawTexfvOES", (void*)glDrawTexfvOES}, + {"glEGLImageTargetTexture2DOES", (void*)glEGLImageTargetTexture2DOES}, + {"glEGLImageTargetRenderbufferStorageOES", (void*)glEGLImageTargetRenderbufferStorageOES}, + {"glAlphaFuncxOES", (void*)glAlphaFuncxOES}, + {"glClearColorxOES", (void*)glClearColorxOES}, + {"glClearDepthxOES", (void*)glClearDepthxOES}, + {"glClipPlanexOES", (void*)glClipPlanexOES}, + {"glClipPlanexIMG", (void*)glClipPlanexIMG}, + {"glColor4xOES", (void*)glColor4xOES}, + {"glDepthRangexOES", (void*)glDepthRangexOES}, + {"glFogxOES", (void*)glFogxOES}, + {"glFogxvOES", (void*)glFogxvOES}, + {"glFrustumxOES", (void*)glFrustumxOES}, + {"glGetClipPlanexOES", (void*)glGetClipPlanexOES}, + {"glGetClipPlanex", (void*)glGetClipPlanex}, + {"glGetFixedvOES", (void*)glGetFixedvOES}, + {"glGetLightxvOES", (void*)glGetLightxvOES}, + {"glGetMaterialxvOES", (void*)glGetMaterialxvOES}, + {"glGetTexEnvxvOES", (void*)glGetTexEnvxvOES}, + {"glGetTexParameterxvOES", (void*)glGetTexParameterxvOES}, + {"glLightModelxOES", (void*)glLightModelxOES}, + {"glLightModelxvOES", (void*)glLightModelxvOES}, + {"glLightxOES", (void*)glLightxOES}, + {"glLightxvOES", (void*)glLightxvOES}, + {"glLineWidthxOES", (void*)glLineWidthxOES}, + {"glLoadMatrixxOES", (void*)glLoadMatrixxOES}, + {"glMaterialxOES", (void*)glMaterialxOES}, + {"glMaterialxvOES", (void*)glMaterialxvOES}, + {"glMultMatrixxOES", (void*)glMultMatrixxOES}, + {"glMultiTexCoord4xOES", (void*)glMultiTexCoord4xOES}, + {"glNormal3xOES", (void*)glNormal3xOES}, + {"glOrthoxOES", (void*)glOrthoxOES}, + {"glPointParameterxOES", (void*)glPointParameterxOES}, + {"glPointParameterxvOES", (void*)glPointParameterxvOES}, + {"glPointSizexOES", (void*)glPointSizexOES}, + {"glPolygonOffsetxOES", (void*)glPolygonOffsetxOES}, + {"glRotatexOES", (void*)glRotatexOES}, + {"glSampleCoveragexOES", (void*)glSampleCoveragexOES}, + {"glScalexOES", (void*)glScalexOES}, + {"glTexEnvxOES", (void*)glTexEnvxOES}, + {"glTexEnvxvOES", (void*)glTexEnvxvOES}, + {"glTexParameterxOES", (void*)glTexParameterxOES}, + {"glTexParameterxvOES", (void*)glTexParameterxvOES}, + {"glTranslatexOES", (void*)glTranslatexOES}, + {"glIsRenderbufferOES", (void*)glIsRenderbufferOES}, + {"glBindRenderbufferOES", (void*)glBindRenderbufferOES}, + {"glDeleteRenderbuffersOES", (void*)glDeleteRenderbuffersOES}, + {"glGenRenderbuffersOES", (void*)glGenRenderbuffersOES}, + {"glRenderbufferStorageOES", (void*)glRenderbufferStorageOES}, + {"glGetRenderbufferParameterivOES", (void*)glGetRenderbufferParameterivOES}, + {"glIsFramebufferOES", (void*)glIsFramebufferOES}, + {"glBindFramebufferOES", (void*)glBindFramebufferOES}, + {"glDeleteFramebuffersOES", (void*)glDeleteFramebuffersOES}, + {"glGenFramebuffersOES", (void*)glGenFramebuffersOES}, + {"glCheckFramebufferStatusOES", (void*)glCheckFramebufferStatusOES}, + {"glFramebufferRenderbufferOES", (void*)glFramebufferRenderbufferOES}, + {"glFramebufferTexture2DOES", (void*)glFramebufferTexture2DOES}, + {"glGetFramebufferAttachmentParameterivOES", (void*)glGetFramebufferAttachmentParameterivOES}, + {"glGenerateMipmapOES", (void*)glGenerateMipmapOES}, + {"glMapBufferOES", (void*)glMapBufferOES}, + {"glUnmapBufferOES", (void*)glUnmapBufferOES}, + {"glGetBufferPointervOES", (void*)glGetBufferPointervOES}, + {"glCurrentPaletteMatrixOES", (void*)glCurrentPaletteMatrixOES}, + {"glLoadPaletteFromModelViewMatrixOES", (void*)glLoadPaletteFromModelViewMatrixOES}, + {"glMatrixIndexPointerOES", (void*)glMatrixIndexPointerOES}, + {"glWeightPointerOES", (void*)glWeightPointerOES}, + {"glQueryMatrixxOES", (void*)glQueryMatrixxOES}, + {"glDepthRangefOES", (void*)glDepthRangefOES}, + {"glFrustumfOES", (void*)glFrustumfOES}, + {"glOrthofOES", (void*)glOrthofOES}, + {"glClipPlanefOES", (void*)glClipPlanefOES}, + {"glClipPlanefIMG", (void*)glClipPlanefIMG}, + {"glGetClipPlanefOES", (void*)glGetClipPlanefOES}, + {"glClearDepthfOES", (void*)glClearDepthfOES}, + {"glTexGenfOES", (void*)glTexGenfOES}, + {"glTexGenfvOES", (void*)glTexGenfvOES}, + {"glTexGeniOES", (void*)glTexGeniOES}, + {"glTexGenivOES", (void*)glTexGenivOES}, + {"glTexGenxOES", (void*)glTexGenxOES}, + {"glTexGenxvOES", (void*)glTexGenxvOES}, + {"glGetTexGenfvOES", (void*)glGetTexGenfvOES}, + {"glGetTexGenivOES", (void*)glGetTexGenivOES}, + {"glGetTexGenxvOES", (void*)glGetTexGenxvOES}, + {"glBindVertexArrayOES", (void*)glBindVertexArrayOES}, + {"glDeleteVertexArraysOES", (void*)glDeleteVertexArraysOES}, + {"glGenVertexArraysOES", (void*)glGenVertexArraysOES}, + {"glIsVertexArrayOES", (void*)glIsVertexArrayOES}, + {"glDiscardFramebufferEXT", (void*)glDiscardFramebufferEXT}, + {"glMultiDrawArraysEXT", (void*)glMultiDrawArraysEXT}, + {"glMultiDrawElementsEXT", (void*)glMultiDrawElementsEXT}, + {"glMultiDrawArraysSUN", (void*)glMultiDrawArraysSUN}, + {"glMultiDrawElementsSUN", (void*)glMultiDrawElementsSUN}, + {"glRenderbufferStorageMultisampleIMG", (void*)glRenderbufferStorageMultisampleIMG}, + {"glFramebufferTexture2DMultisampleIMG", (void*)glFramebufferTexture2DMultisampleIMG}, + {"glDeleteFencesNV", (void*)glDeleteFencesNV}, + {"glGenFencesNV", (void*)glGenFencesNV}, + {"glIsFenceNV", (void*)glIsFenceNV}, + {"glTestFenceNV", (void*)glTestFenceNV}, + {"glGetFenceivNV", (void*)glGetFenceivNV}, + {"glFinishFenceNV", (void*)glFinishFenceNV}, + {"glSetFenceNV", (void*)glSetFenceNV}, + {"glGetDriverControlsQCOM", (void*)glGetDriverControlsQCOM}, + {"glGetDriverControlStringQCOM", (void*)glGetDriverControlStringQCOM}, + {"glEnableDriverControlQCOM", (void*)glEnableDriverControlQCOM}, + {"glDisableDriverControlQCOM", (void*)glDisableDriverControlQCOM}, + {"glExtGetTexturesQCOM", (void*)glExtGetTexturesQCOM}, + {"glExtGetBuffersQCOM", (void*)glExtGetBuffersQCOM}, + {"glExtGetRenderbuffersQCOM", (void*)glExtGetRenderbuffersQCOM}, + {"glExtGetFramebuffersQCOM", (void*)glExtGetFramebuffersQCOM}, + {"glExtGetTexLevelParameterivQCOM", (void*)glExtGetTexLevelParameterivQCOM}, + {"glExtTexObjectStateOverrideiQCOM", (void*)glExtTexObjectStateOverrideiQCOM}, + {"glExtGetTexSubImageQCOM", (void*)glExtGetTexSubImageQCOM}, + {"glExtGetBufferPointervQCOM", (void*)glExtGetBufferPointervQCOM}, + {"glExtGetShadersQCOM", (void*)glExtGetShadersQCOM}, + {"glExtGetProgramsQCOM", (void*)glExtGetProgramsQCOM}, + {"glExtIsProgramBinaryQCOM", (void*)glExtIsProgramBinaryQCOM}, + {"glExtGetProgramBinarySourceQCOM", (void*)glExtGetProgramBinarySourceQCOM}, + {"glStartTilingQCOM", (void*)glStartTilingQCOM}, + {"glEndTilingQCOM", (void*)glEndTilingQCOM}, +}; +static const int gl_num_funcs = sizeof(gl_funcs_by_name) / sizeof(struct _gl_funcs_by_name); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_opcodes.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_opcodes.h new file mode 100644 index 0000000..319d0a1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_opcodes.h @@ -0,0 +1,300 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __GUARD_gl_opcodes_h_ +#define __GUARD_gl_opcodes_h_ + +#define OP_glAlphaFunc 1024 +#define OP_glClearColor 1025 +#define OP_glClearDepthf 1026 +#define OP_glClipPlanef 1027 +#define OP_glColor4f 1028 +#define OP_glDepthRangef 1029 +#define OP_glFogf 1030 +#define OP_glFogfv 1031 +#define OP_glFrustumf 1032 +#define OP_glGetClipPlanef 1033 +#define OP_glGetFloatv 1034 +#define OP_glGetLightfv 1035 +#define OP_glGetMaterialfv 1036 +#define OP_glGetTexEnvfv 1037 +#define OP_glGetTexParameterfv 1038 +#define OP_glLightModelf 1039 +#define OP_glLightModelfv 1040 +#define OP_glLightf 1041 +#define OP_glLightfv 1042 +#define OP_glLineWidth 1043 +#define OP_glLoadMatrixf 1044 +#define OP_glMaterialf 1045 +#define OP_glMaterialfv 1046 +#define OP_glMultMatrixf 1047 +#define OP_glMultiTexCoord4f 1048 +#define OP_glNormal3f 1049 +#define OP_glOrthof 1050 +#define OP_glPointParameterf 1051 +#define OP_glPointParameterfv 1052 +#define OP_glPointSize 1053 +#define OP_glPolygonOffset 1054 +#define OP_glRotatef 1055 +#define OP_glScalef 1056 +#define OP_glTexEnvf 1057 +#define OP_glTexEnvfv 1058 +#define OP_glTexParameterf 1059 +#define OP_glTexParameterfv 1060 +#define OP_glTranslatef 1061 +#define OP_glActiveTexture 1062 +#define OP_glAlphaFuncx 1063 +#define OP_glBindBuffer 1064 +#define OP_glBindTexture 1065 +#define OP_glBlendFunc 1066 +#define OP_glBufferData 1067 +#define OP_glBufferSubData 1068 +#define OP_glClear 1069 +#define OP_glClearColorx 1070 +#define OP_glClearDepthx 1071 +#define OP_glClearStencil 1072 +#define OP_glClientActiveTexture 1073 +#define OP_glColor4ub 1074 +#define OP_glColor4x 1075 +#define OP_glColorMask 1076 +#define OP_glColorPointer 1077 +#define OP_glCompressedTexImage2D 1078 +#define OP_glCompressedTexSubImage2D 1079 +#define OP_glCopyTexImage2D 1080 +#define OP_glCopyTexSubImage2D 1081 +#define OP_glCullFace 1082 +#define OP_glDeleteBuffers 1083 +#define OP_glDeleteTextures 1084 +#define OP_glDepthFunc 1085 +#define OP_glDepthMask 1086 +#define OP_glDepthRangex 1087 +#define OP_glDisable 1088 +#define OP_glDisableClientState 1089 +#define OP_glDrawArrays 1090 +#define OP_glDrawElements 1091 +#define OP_glEnable 1092 +#define OP_glEnableClientState 1093 +#define OP_glFinish 1094 +#define OP_glFlush 1095 +#define OP_glFogx 1096 +#define OP_glFogxv 1097 +#define OP_glFrontFace 1098 +#define OP_glFrustumx 1099 +#define OP_glGetBooleanv 1100 +#define OP_glGetBufferParameteriv 1101 +#define OP_glClipPlanex 1102 +#define OP_glGenBuffers 1103 +#define OP_glGenTextures 1104 +#define OP_glGetError 1105 +#define OP_glGetFixedv 1106 +#define OP_glGetIntegerv 1107 +#define OP_glGetLightxv 1108 +#define OP_glGetMaterialxv 1109 +#define OP_glGetPointerv 1110 +#define OP_glGetString 1111 +#define OP_glGetTexEnviv 1112 +#define OP_glGetTexEnvxv 1113 +#define OP_glGetTexParameteriv 1114 +#define OP_glGetTexParameterxv 1115 +#define OP_glHint 1116 +#define OP_glIsBuffer 1117 +#define OP_glIsEnabled 1118 +#define OP_glIsTexture 1119 +#define OP_glLightModelx 1120 +#define OP_glLightModelxv 1121 +#define OP_glLightx 1122 +#define OP_glLightxv 1123 +#define OP_glLineWidthx 1124 +#define OP_glLoadIdentity 1125 +#define OP_glLoadMatrixx 1126 +#define OP_glLogicOp 1127 +#define OP_glMaterialx 1128 +#define OP_glMaterialxv 1129 +#define OP_glMatrixMode 1130 +#define OP_glMultMatrixx 1131 +#define OP_glMultiTexCoord4x 1132 +#define OP_glNormal3x 1133 +#define OP_glNormalPointer 1134 +#define OP_glOrthox 1135 +#define OP_glPixelStorei 1136 +#define OP_glPointParameterx 1137 +#define OP_glPointParameterxv 1138 +#define OP_glPointSizex 1139 +#define OP_glPolygonOffsetx 1140 +#define OP_glPopMatrix 1141 +#define OP_glPushMatrix 1142 +#define OP_glReadPixels 1143 +#define OP_glRotatex 1144 +#define OP_glSampleCoverage 1145 +#define OP_glSampleCoveragex 1146 +#define OP_glScalex 1147 +#define OP_glScissor 1148 +#define OP_glShadeModel 1149 +#define OP_glStencilFunc 1150 +#define OP_glStencilMask 1151 +#define OP_glStencilOp 1152 +#define OP_glTexCoordPointer 1153 +#define OP_glTexEnvi 1154 +#define OP_glTexEnvx 1155 +#define OP_glTexEnviv 1156 +#define OP_glTexEnvxv 1157 +#define OP_glTexImage2D 1158 +#define OP_glTexParameteri 1159 +#define OP_glTexParameterx 1160 +#define OP_glTexParameteriv 1161 +#define OP_glTexParameterxv 1162 +#define OP_glTexSubImage2D 1163 +#define OP_glTranslatex 1164 +#define OP_glVertexPointer 1165 +#define OP_glViewport 1166 +#define OP_glPointSizePointerOES 1167 +#define OP_glVertexPointerOffset 1168 +#define OP_glColorPointerOffset 1169 +#define OP_glNormalPointerOffset 1170 +#define OP_glPointSizePointerOffset 1171 +#define OP_glTexCoordPointerOffset 1172 +#define OP_glWeightPointerOffset 1173 +#define OP_glMatrixIndexPointerOffset 1174 +#define OP_glVertexPointerData 1175 +#define OP_glColorPointerData 1176 +#define OP_glNormalPointerData 1177 +#define OP_glTexCoordPointerData 1178 +#define OP_glPointSizePointerData 1179 +#define OP_glWeightPointerData 1180 +#define OP_glMatrixIndexPointerData 1181 +#define OP_glDrawElementsOffset 1182 +#define OP_glDrawElementsData 1183 +#define OP_glGetCompressedTextureFormats 1184 +#define OP_glFinishRoundTrip 1185 +#define OP_glBlendEquationSeparateOES 1186 +#define OP_glBlendFuncSeparateOES 1187 +#define OP_glBlendEquationOES 1188 +#define OP_glDrawTexsOES 1189 +#define OP_glDrawTexiOES 1190 +#define OP_glDrawTexxOES 1191 +#define OP_glDrawTexsvOES 1192 +#define OP_glDrawTexivOES 1193 +#define OP_glDrawTexxvOES 1194 +#define OP_glDrawTexfOES 1195 +#define OP_glDrawTexfvOES 1196 +#define OP_glEGLImageTargetTexture2DOES 1197 +#define OP_glEGLImageTargetRenderbufferStorageOES 1198 +#define OP_glAlphaFuncxOES 1199 +#define OP_glClearColorxOES 1200 +#define OP_glClearDepthxOES 1201 +#define OP_glClipPlanexOES 1202 +#define OP_glClipPlanexIMG 1203 +#define OP_glColor4xOES 1204 +#define OP_glDepthRangexOES 1205 +#define OP_glFogxOES 1206 +#define OP_glFogxvOES 1207 +#define OP_glFrustumxOES 1208 +#define OP_glGetClipPlanexOES 1209 +#define OP_glGetClipPlanex 1210 +#define OP_glGetFixedvOES 1211 +#define OP_glGetLightxvOES 1212 +#define OP_glGetMaterialxvOES 1213 +#define OP_glGetTexEnvxvOES 1214 +#define OP_glGetTexParameterxvOES 1215 +#define OP_glLightModelxOES 1216 +#define OP_glLightModelxvOES 1217 +#define OP_glLightxOES 1218 +#define OP_glLightxvOES 1219 +#define OP_glLineWidthxOES 1220 +#define OP_glLoadMatrixxOES 1221 +#define OP_glMaterialxOES 1222 +#define OP_glMaterialxvOES 1223 +#define OP_glMultMatrixxOES 1224 +#define OP_glMultiTexCoord4xOES 1225 +#define OP_glNormal3xOES 1226 +#define OP_glOrthoxOES 1227 +#define OP_glPointParameterxOES 1228 +#define OP_glPointParameterxvOES 1229 +#define OP_glPointSizexOES 1230 +#define OP_glPolygonOffsetxOES 1231 +#define OP_glRotatexOES 1232 +#define OP_glSampleCoveragexOES 1233 +#define OP_glScalexOES 1234 +#define OP_glTexEnvxOES 1235 +#define OP_glTexEnvxvOES 1236 +#define OP_glTexParameterxOES 1237 +#define OP_glTexParameterxvOES 1238 +#define OP_glTranslatexOES 1239 +#define OP_glIsRenderbufferOES 1240 +#define OP_glBindRenderbufferOES 1241 +#define OP_glDeleteRenderbuffersOES 1242 +#define OP_glGenRenderbuffersOES 1243 +#define OP_glRenderbufferStorageOES 1244 +#define OP_glGetRenderbufferParameterivOES 1245 +#define OP_glIsFramebufferOES 1246 +#define OP_glBindFramebufferOES 1247 +#define OP_glDeleteFramebuffersOES 1248 +#define OP_glGenFramebuffersOES 1249 +#define OP_glCheckFramebufferStatusOES 1250 +#define OP_glFramebufferRenderbufferOES 1251 +#define OP_glFramebufferTexture2DOES 1252 +#define OP_glGetFramebufferAttachmentParameterivOES 1253 +#define OP_glGenerateMipmapOES 1254 +#define OP_glMapBufferOES 1255 +#define OP_glUnmapBufferOES 1256 +#define OP_glGetBufferPointervOES 1257 +#define OP_glCurrentPaletteMatrixOES 1258 +#define OP_glLoadPaletteFromModelViewMatrixOES 1259 +#define OP_glMatrixIndexPointerOES 1260 +#define OP_glWeightPointerOES 1261 +#define OP_glQueryMatrixxOES 1262 +#define OP_glDepthRangefOES 1263 +#define OP_glFrustumfOES 1264 +#define OP_glOrthofOES 1265 +#define OP_glClipPlanefOES 1266 +#define OP_glClipPlanefIMG 1267 +#define OP_glGetClipPlanefOES 1268 +#define OP_glClearDepthfOES 1269 +#define OP_glTexGenfOES 1270 +#define OP_glTexGenfvOES 1271 +#define OP_glTexGeniOES 1272 +#define OP_glTexGenivOES 1273 +#define OP_glTexGenxOES 1274 +#define OP_glTexGenxvOES 1275 +#define OP_glGetTexGenfvOES 1276 +#define OP_glGetTexGenivOES 1277 +#define OP_glGetTexGenxvOES 1278 +#define OP_glBindVertexArrayOES 1279 +#define OP_glDeleteVertexArraysOES 1280 +#define OP_glGenVertexArraysOES 1281 +#define OP_glIsVertexArrayOES 1282 +#define OP_glDiscardFramebufferEXT 1283 +#define OP_glMultiDrawArraysEXT 1284 +#define OP_glMultiDrawElementsEXT 1285 +#define OP_glMultiDrawArraysSUN 1286 +#define OP_glMultiDrawElementsSUN 1287 +#define OP_glRenderbufferStorageMultisampleIMG 1288 +#define OP_glFramebufferTexture2DMultisampleIMG 1289 +#define OP_glDeleteFencesNV 1290 +#define OP_glGenFencesNV 1291 +#define OP_glIsFenceNV 1292 +#define OP_glTestFenceNV 1293 +#define OP_glGetFenceivNV 1294 +#define OP_glFinishFenceNV 1295 +#define OP_glSetFenceNV 1296 +#define OP_glGetDriverControlsQCOM 1297 +#define OP_glGetDriverControlStringQCOM 1298 +#define OP_glEnableDriverControlQCOM 1299 +#define OP_glDisableDriverControlQCOM 1300 +#define OP_glExtGetTexturesQCOM 1301 +#define OP_glExtGetBuffersQCOM 1302 +#define OP_glExtGetRenderbuffersQCOM 1303 +#define OP_glExtGetFramebuffersQCOM 1304 +#define OP_glExtGetTexLevelParameterivQCOM 1305 +#define OP_glExtTexObjectStateOverrideiQCOM 1306 +#define OP_glExtGetTexSubImageQCOM 1307 +#define OP_glExtGetBufferPointervQCOM 1308 +#define OP_glExtGetShadersQCOM 1309 +#define OP_glExtGetProgramsQCOM 1310 +#define OP_glExtIsProgramBinaryQCOM 1311 +#define OP_glExtGetProgramBinarySourceQCOM 1312 +#define OP_glStartTilingQCOM 1313 +#define OP_glEndTilingQCOM 1314 +#define OP_last 1315 + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_types.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_types.h new file mode 100644 index 0000000..36fabfb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv1_enc/gl_types.h @@ -0,0 +1,20 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __GL_TYPES__H +#define __GL_TYPES__H + +#include "gl_base_types.h" +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/Android.mk new file mode 100644 index 0000000..5a23424 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH := $(call my-dir) + +### GLESv2 implementation ########################################### +$(call emugl-begin-shared-library,libGLESv2_emulation) +$(call emugl-import,libOpenglSystemCommon libGLESv2_enc lib_renderControl_enc) + +LOCAL_CFLAGS += -DLOG_TAG=\"GLESv2_emulation\" -DGL_GLEXT_PROTOTYPES + +LOCAL_SRC_FILES := gl2.cpp +LOCAL_MODULE_RELATIVE_PATH := egl + +$(call emugl-end-module) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/gl2.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/gl2.cpp new file mode 100644 index 0000000..5aaac5f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2/gl2.cpp @@ -0,0 +1,177 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "EGLClientIface.h" +#include "HostConnection.h" +#include "GL2Encoder.h" +#include "GLES/gl.h" +#include "GLES/glext.h" +#include "ErrorLog.h" +#include "gralloc_cb.h" +#include "ThreadInfo.h" +#include "EGLImage.h" + +//XXX: fix this macro to get the context from fast tls path +#define GET_CONTEXT GL2Encoder * ctx = getEGLThreadInfo()->hostConn->gl2Encoder(); + +#include "gl2_entry.cpp" + +//The functions table +#include "gl2_ftable.h" + + +static EGLClient_eglInterface * s_egl = NULL; +static EGLClient_glesInterface * s_gl = NULL; + +#define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \ + HostConnection *hostCon = HostConnection::get(); \ + if (!hostCon) { \ + ALOGE("egl: Failed to get host connection\n"); \ + return ret; \ + } \ + renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \ + if (!rcEnc) { \ + ALOGE("egl: Failed to get renderControl encoder context\n"); \ + return ret; \ + } + +//GL extensions +void glEGLImageTargetTexture2DOES(void * self, GLenum target, GLeglImageOES img) +{ + (void)self; + (void)target; + + DBG("glEGLImageTargetTexture2DOES v2 target=%#x img=%p\n", target, img); + + EGLImage_t *image = (EGLImage_t*)img; + + if (image->target == EGL_NATIVE_BUFFER_ANDROID) { + //TODO: check error - we don't have a way to set gl error + android_native_buffer_t* native_buffer = image->native_buffer; + + if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) { + return; + } + + if (native_buffer->common.version != sizeof(android_native_buffer_t)) { + return; + } + + GET_CONTEXT; + DEFINE_AND_VALIDATE_HOST_CONNECTION(); + + ctx->override2DTextureTarget(target); + rcEnc->rcBindTexture(rcEnc, ((cb_handle_t *)(native_buffer->handle))->hostHandle); + ctx->restore2DTextureTarget(); + } + else if (image->target == EGL_GL_TEXTURE_2D_KHR) { + GET_CONTEXT; + ctx->override2DTextureTarget(target); + GLeglImageOES hostImage = reinterpret_cast((intptr_t)image->host_egl_image); + ctx->m_glEGLImageTargetTexture2DOES_enc(self, target, hostImage); + ctx->restore2DTextureTarget(); + } +} + +void glEGLImageTargetRenderbufferStorageOES(void *self, GLenum target, GLeglImageOES image) +{ + (void)self; + (void)target; + + DBG("glEGLImageTargetRenderbufferStorageOES v2 image=%p\n", image); + //TODO: check error - we don't have a way to set gl error + android_native_buffer_t* native_buffer = (android_native_buffer_t*)image; + + if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) { + return; + } + + if (native_buffer->common.version != sizeof(android_native_buffer_t)) { + return; + } + + DEFINE_AND_VALIDATE_HOST_CONNECTION(); + rcEnc->rcBindRenderbuffer(rcEnc, ((cb_handle_t *)(native_buffer->handle))->hostHandle); + + return; +} + +void * getProcAddress(const char * procname) +{ + // search in GL function table + for (int i=0; igetGLString(name); + } + break; + default: + GET_CONTEXT; + ctx->setError(GL_INVALID_ENUM); + break; + } + return NULL; +} + +void init() +{ + GET_CONTEXT; + ctx->m_glEGLImageTargetTexture2DOES_enc = ctx->glEGLImageTargetTexture2DOES; + ctx->glEGLImageTargetTexture2DOES = &glEGLImageTargetTexture2DOES; + ctx->glEGLImageTargetRenderbufferStorageOES = &glEGLImageTargetRenderbufferStorageOES; + ctx->glGetString = &my_glGetString; +} + +extern "C" { +EGLClient_glesInterface * init_emul_gles(EGLClient_eglInterface *eglIface) +{ + s_egl = eglIface; + + if (!s_gl) { + s_gl = new EGLClient_glesInterface(); + s_gl->getProcAddress = getProcAddress; + s_gl->finish = finish; + s_gl->init = init; + } + + return s_gl; +} +} //extern + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/Android.mk new file mode 100644 index 0000000..e76a175 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/Android.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) + +### GLESv2_enc Encoder ########################################### +$(call emugl-begin-shared-library,libGLESv2_enc) + +LOCAL_SRC_FILES := \ + GL2EncoderUtils.cpp \ + GL2Encoder.cpp \ + gl2_client_context.cpp \ + gl2_enc.cpp \ + gl2_entry.cpp + +LOCAL_CFLAGS += -DLOG_TAG=\"emuglGLESv2_enc\" + +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +$(call emugl-import,libOpenglCodecCommon) + +$(call emugl-end-module) + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.cpp new file mode 100644 index 0000000..268f76c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.cpp @@ -0,0 +1,1488 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "GL2Encoder.h" +#include +#include +#include + +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +static GLubyte *gVendorString= (GLubyte *) "Android"; +static GLubyte *gRendererString= (GLubyte *) "Android HW-GLES 2.0"; +static GLubyte *gVersionString= (GLubyte *) "OpenGL ES 2.0"; +static GLubyte *gExtensionsString= (GLubyte *) "GL_OES_EGL_image_external "; + +#define SET_ERROR_IF(condition,err) if((condition)) { \ + ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \ + ctx->setError(err); \ + return; \ + } + + +#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) { \ + ALOGE("%s:%s:%d GL error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \ + ctx->setError(err); \ + return ret; \ + } + + +GL2Encoder::GL2Encoder(IOStream *stream, ChecksumCalculator *protocol) + : gl2_encoder_context_t(stream, protocol) +{ + m_initialized = false; + m_state = NULL; + m_error = GL_NO_ERROR; + m_num_compressedTextureFormats = 0; + m_max_cubeMapTextureSize = 0; + m_max_renderBufferSize = 0; + m_max_textureSize = 0; + m_compressedTextureFormats = NULL; + + //overrides +#define OVERRIDE(name) m_##name##_enc = this-> name ; this-> name = &s_##name + + OVERRIDE(glFlush); + OVERRIDE(glPixelStorei); + OVERRIDE(glGetString); + OVERRIDE(glBindBuffer); + OVERRIDE(glBufferData); + OVERRIDE(glBufferSubData); + OVERRIDE(glDeleteBuffers); + OVERRIDE(glDrawArrays); + OVERRIDE(glDrawElements); + OVERRIDE(glGetIntegerv); + OVERRIDE(glGetFloatv); + OVERRIDE(glGetBooleanv); + OVERRIDE(glVertexAttribPointer); + OVERRIDE(glEnableVertexAttribArray); + OVERRIDE(glDisableVertexAttribArray); + OVERRIDE(glGetVertexAttribiv); + OVERRIDE(glGetVertexAttribfv); + OVERRIDE(glGetVertexAttribPointerv); + + this->glShaderBinary = &s_glShaderBinary; + this->glShaderSource = &s_glShaderSource; + this->glFinish = &s_glFinish; + + OVERRIDE(glGetError); + OVERRIDE(glLinkProgram); + OVERRIDE(glDeleteProgram); + OVERRIDE(glGetUniformiv); + OVERRIDE(glGetUniformfv); + OVERRIDE(glCreateProgram); + OVERRIDE(glCreateShader); + OVERRIDE(glDeleteShader); + OVERRIDE(glAttachShader); + OVERRIDE(glDetachShader); + OVERRIDE(glGetAttachedShaders); + OVERRIDE(glGetShaderSource); + OVERRIDE(glGetShaderInfoLog); + OVERRIDE(glGetProgramInfoLog); + + OVERRIDE(glGetUniformLocation); + OVERRIDE(glUseProgram); + + OVERRIDE(glUniform1f); + OVERRIDE(glUniform1fv); + OVERRIDE(glUniform1i); + OVERRIDE(glUniform1iv); + OVERRIDE(glUniform2f); + OVERRIDE(glUniform2fv); + OVERRIDE(glUniform2i); + OVERRIDE(glUniform2iv); + OVERRIDE(glUniform3f); + OVERRIDE(glUniform3fv); + OVERRIDE(glUniform3i); + OVERRIDE(glUniform3iv); + OVERRIDE(glUniform4f); + OVERRIDE(glUniform4fv); + OVERRIDE(glUniform4i); + OVERRIDE(glUniform4iv); + OVERRIDE(glUniformMatrix2fv); + OVERRIDE(glUniformMatrix3fv); + OVERRIDE(glUniformMatrix4fv); + + OVERRIDE(glActiveTexture); + OVERRIDE(glBindTexture); + OVERRIDE(glDeleteTextures); + OVERRIDE(glGetTexParameterfv); + OVERRIDE(glGetTexParameteriv); + OVERRIDE(glTexParameterf); + OVERRIDE(glTexParameterfv); + OVERRIDE(glTexParameteri); + OVERRIDE(glTexParameteriv); + OVERRIDE(glTexImage2D); + OVERRIDE(glTexSubImage2D); +} + +GL2Encoder::~GL2Encoder() +{ + delete m_compressedTextureFormats; +} + +GLenum GL2Encoder::s_glGetError(void * self) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + GLenum err = ctx->getError(); + if(err != GL_NO_ERROR) { + ctx->setError(GL_NO_ERROR); + return err; + } + + return ctx->m_glGetError_enc(self); + +} + +void GL2Encoder::s_glFlush(void *self) +{ + GL2Encoder *ctx = (GL2Encoder *) self; + ctx->m_glFlush_enc(self); + ctx->m_stream->flush(); +} + +const GLubyte *GL2Encoder::s_glGetString(void *self, GLenum name) +{ + (void)self; + + GLubyte *retval = (GLubyte *) ""; + switch(name) { + case GL_VENDOR: + retval = gVendorString; + break; + case GL_RENDERER: + retval = gRendererString; + break; + case GL_VERSION: + retval = gVersionString; + break; + case GL_EXTENSIONS: + retval = gExtensionsString; + break; + } + return retval; +} + +void GL2Encoder::s_glPixelStorei(void *self, GLenum param, GLint value) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + ctx->m_glPixelStorei_enc(ctx, param, value); + assert(ctx->m_state != NULL); + ctx->m_state->setPixelStore(param, value); +} + + +void GL2Encoder::s_glBindBuffer(void *self, GLenum target, GLuint id) +{ + GL2Encoder *ctx = (GL2Encoder *) self; + assert(ctx->m_state != NULL); + ctx->m_state->bindBuffer(target, id); + // TODO set error state if needed; + ctx->m_glBindBuffer_enc(self, target, id); +} + +void GL2Encoder::s_glBufferData(void * self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) +{ + GL2Encoder *ctx = (GL2Encoder *) self; + SET_ERROR_IF(!(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER), GL_INVALID_ENUM); + GLuint bufferId = ctx->m_state->getBuffer(target); + SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION); + SET_ERROR_IF(size<0, GL_INVALID_VALUE); + + ctx->m_shared->updateBufferData(bufferId, size, (void*)data); + ctx->m_glBufferData_enc(self, target, size, data, usage); +} + +void GL2Encoder::s_glBufferSubData(void * self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) +{ + GL2Encoder *ctx = (GL2Encoder *) self; + SET_ERROR_IF(!(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER), GL_INVALID_ENUM); + GLuint bufferId = ctx->m_state->getBuffer(target); + SET_ERROR_IF(bufferId==0, GL_INVALID_OPERATION); + + GLenum res = ctx->m_shared->subUpdateBufferData(bufferId, offset, size, (void*)data); + SET_ERROR_IF(res, res); + + ctx->m_glBufferSubData_enc(self, target, offset, size, data); +} + +void GL2Encoder::s_glDeleteBuffers(void * self, GLsizei n, const GLuint * buffers) +{ + GL2Encoder *ctx = (GL2Encoder *) self; + SET_ERROR_IF(n<0, GL_INVALID_VALUE); + for (int i=0; im_shared->deleteBufferData(buffers[i]); + ctx->m_state->unBindBuffer(buffers[i]); + ctx->m_glDeleteBuffers_enc(self,1,&buffers[i]); + } +} + +void GL2Encoder::s_glVertexAttribPointer(void *self, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * ptr) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state != NULL); + ctx->m_state->setState(indx, size, type, normalized, stride, ptr); +} + +void GL2Encoder::s_glGetIntegerv(void *self, GLenum param, GLint *ptr) +{ + GL2Encoder *ctx = (GL2Encoder *) self; + assert(ctx->m_state != NULL); + GLClientState* state = ctx->m_state; + + switch (param) { + case GL_NUM_SHADER_BINARY_FORMATS: + *ptr = 0; + break; + case GL_SHADER_BINARY_FORMATS: + // do nothing + break; + + case GL_COMPRESSED_TEXTURE_FORMATS: { + GLint *compressedTextureFormats = ctx->getCompressedTextureFormats(); + if (ctx->m_num_compressedTextureFormats > 0 && + compressedTextureFormats != NULL) { + memcpy(ptr, compressedTextureFormats, + ctx->m_num_compressedTextureFormats * sizeof(GLint)); + } + break; + } + + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_TEXTURE_IMAGE_UNITS: + ctx->m_glGetIntegerv_enc(self, param, ptr); + *ptr = MIN(*ptr, GLClientState::MAX_TEXTURE_UNITS); + break; + + case GL_TEXTURE_BINDING_2D: + *ptr = state->getBoundTexture(GL_TEXTURE_2D); + break; + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES); + break; + + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + if (ctx->m_max_cubeMapTextureSize != 0) { + *ptr = ctx->m_max_cubeMapTextureSize; + } else { + ctx->m_glGetIntegerv_enc(self, param, ptr); + ctx->m_max_cubeMapTextureSize = *ptr; + } + break; + case GL_MAX_RENDERBUFFER_SIZE: + if (ctx->m_max_renderBufferSize != 0) { + *ptr = ctx->m_max_renderBufferSize; + } else { + ctx->m_glGetIntegerv_enc(self, param, ptr); + ctx->m_max_renderBufferSize = *ptr; + } + break; + case GL_MAX_TEXTURE_SIZE: + if (ctx->m_max_textureSize != 0) { + *ptr = ctx->m_max_textureSize; + } else { + ctx->m_glGetIntegerv_enc(self, param, ptr); + ctx->m_max_textureSize = *ptr; + } + break; + case GL_MAX_VERTEX_ATTRIBS: + if (!ctx->m_state->getClientStateParameter(param, ptr)) { + ctx->m_glGetIntegerv_enc(self, param, ptr); + ctx->m_state->setMaxVertexAttribs(*ptr); + } + break; + default: + if (!ctx->m_state->getClientStateParameter(param, ptr)) { + ctx->m_glGetIntegerv_enc(self, param, ptr); + } + break; + } +} + + +void GL2Encoder::s_glGetFloatv(void *self, GLenum param, GLfloat *ptr) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state != NULL); + GLClientState* state = ctx->m_state; + + switch (param) { + case GL_NUM_SHADER_BINARY_FORMATS: + *ptr = 0; + break; + case GL_SHADER_BINARY_FORMATS: + // do nothing + break; + + case GL_COMPRESSED_TEXTURE_FORMATS: { + GLint *compressedTextureFormats = ctx->getCompressedTextureFormats(); + if (ctx->m_num_compressedTextureFormats > 0 && + compressedTextureFormats != NULL) { + for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) { + ptr[i] = (GLfloat) compressedTextureFormats[i]; + } + } + break; + } + + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_TEXTURE_IMAGE_UNITS: + ctx->m_glGetFloatv_enc(self, param, ptr); + *ptr = MIN(*ptr, (GLfloat)GLClientState::MAX_TEXTURE_UNITS); + break; + + case GL_TEXTURE_BINDING_2D: + *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_2D); + break; + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *ptr = (GLfloat)state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES); + break; + + default: + if (!ctx->m_state->getClientStateParameter(param, ptr)) { + ctx->m_glGetFloatv_enc(self, param, ptr); + } + break; + } +} + + +void GL2Encoder::s_glGetBooleanv(void *self, GLenum param, GLboolean *ptr) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state != NULL); + GLClientState* state = ctx->m_state; + + switch (param) { + case GL_NUM_SHADER_BINARY_FORMATS: + *ptr = GL_FALSE; + break; + case GL_SHADER_BINARY_FORMATS: + // do nothing + break; + + case GL_COMPRESSED_TEXTURE_FORMATS: { + GLint *compressedTextureFormats = ctx->getCompressedTextureFormats(); + if (ctx->m_num_compressedTextureFormats > 0 && + compressedTextureFormats != NULL) { + for (int i = 0; i < ctx->m_num_compressedTextureFormats; i++) { + ptr[i] = compressedTextureFormats[i] != 0 ? GL_TRUE : GL_FALSE; + } + } + break; + } + + case GL_TEXTURE_BINDING_2D: + *ptr = state->getBoundTexture(GL_TEXTURE_2D) != 0 ? GL_TRUE : GL_FALSE; + break; + case GL_TEXTURE_BINDING_EXTERNAL_OES: + *ptr = state->getBoundTexture(GL_TEXTURE_EXTERNAL_OES) != 0 + ? GL_TRUE : GL_FALSE; + break; + + default: + if (!ctx->m_state->getClientStateParameter(param, ptr)) { + ctx->m_glGetBooleanv_enc(self, param, ptr); + } + *ptr = (*ptr != 0) ? GL_TRUE : GL_FALSE; + break; + } +} + + +void GL2Encoder::s_glEnableVertexAttribArray(void *self, GLuint index) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state); + GLint maxIndex; + ctx->glGetIntegerv(self, GL_MAX_VERTEX_ATTRIBS, &maxIndex); + SET_ERROR_IF(!(index < maxIndex), GL_INVALID_VALUE); + ctx->m_state->enable(index, 1); +} + +void GL2Encoder::s_glDisableVertexAttribArray(void *self, GLuint index) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state); + GLint maxIndex; + ctx->glGetIntegerv(self, GL_MAX_VERTEX_ATTRIBS, &maxIndex); + SET_ERROR_IF(!(index < maxIndex), GL_INVALID_VALUE); + ctx->m_state->enable(index, 0); +} + + +void GL2Encoder::s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state); + GLint maxIndex; + ctx->glGetIntegerv(self, GL_MAX_VERTEX_ATTRIBS, &maxIndex); + SET_ERROR_IF(!(index < maxIndex), GL_INVALID_VALUE); + + if (!ctx->m_state->getVertexAttribParameter(index, pname, params)) { + ctx->m_glGetVertexAttribiv_enc(self, index, pname, params); + } +} + +void GL2Encoder::s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state); + GLint maxIndex; + ctx->glGetIntegerv(self, GL_MAX_VERTEX_ATTRIBS, &maxIndex); + SET_ERROR_IF(!(index < maxIndex), GL_INVALID_VALUE); + + if (!ctx->m_state->getVertexAttribParameter(index, pname, params)) { + ctx->m_glGetVertexAttribfv_enc(self, index, pname, params); + } +} + +void GL2Encoder::s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + if (ctx->m_state == NULL) return; + GLint maxIndex; + ctx->glGetIntegerv(self, GL_MAX_VERTEX_ATTRIBS, &maxIndex); + SET_ERROR_IF(!(index < maxIndex), GL_INVALID_VALUE); + SET_ERROR_IF(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER, GL_INVALID_ENUM); + + (void)pname; + + const GLClientState::VertexAttribState *va_state = ctx->m_state->getState(index); + if (va_state != NULL) { + *pointer = va_state->data; + } +} + + +void GL2Encoder::sendVertexAttributes(GLint first, GLsizei count) +{ + assert(m_state); + + for (int i = 0; i < m_state->nLocations(); i++) { + bool enableDirty; + const GLClientState::VertexAttribState *state = m_state->getStateAndEnableDirty(i, &enableDirty); + + if (!state) { + continue; + } + + if (!enableDirty && !state->enabled) { + continue; + } + + + if (state->enabled) { + m_glEnableVertexAttribArray_enc(this, i); + + unsigned int datalen = state->elementSize * count; + int stride = state->stride == 0 ? state->elementSize : state->stride; + int firstIndex = stride * first; + + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, state->bufferObject); + if (state->bufferObject == 0) { + this->glVertexAttribPointerData(this, i, state->size, state->type, state->normalized, state->stride, + (unsigned char *)state->data + firstIndex, datalen); + } else { + this->glVertexAttribPointerOffset(this, i, state->size, state->type, state->normalized, state->stride, + (uintptr_t) state->data + firstIndex); + } + this->m_glBindBuffer_enc(this, GL_ARRAY_BUFFER, m_state->currentArrayVbo()); + } else { + this->m_glDisableVertexAttribArray_enc(this, i); + } + } +} + +static bool isValidDrawMode(GLenum mode) { + switch(mode) { + case GL_POINTS: + case GL_LINE_STRIP: + case GL_LINE_LOOP: + case GL_LINES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + case GL_TRIANGLES: + return true; + } + return false; +} + +static bool isValidDrawType(GLenum mode) { + return mode == GL_UNSIGNED_BYTE || + mode == GL_UNSIGNED_SHORT || + mode == GL_UNSIGNED_INT; +} + +void GL2Encoder::s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + + SET_ERROR_IF(!isValidDrawMode(mode), GL_INVALID_ENUM); + SET_ERROR_IF(count<0, GL_INVALID_VALUE); + + bool has_arrays = false; + int nLocations = ctx->m_state->nLocations(); + for (int i = 0; i < nLocations; i++) { + const GLClientState::VertexAttribState *state = ctx->m_state->getState(i); + if (state->enabled) { + if (state->bufferObject || state->data) { + has_arrays = true; + } + else { + ALOGE("glDrawArrays: a vertex attribute array is enabled with no data bound\n"); + ctx->setError(GL_INVALID_OPERATION); + return; + } + } + } + if (!has_arrays) { + ALOGE("glDrawArrays: no data bound to the command - ignoring\n"); + return; + } + + ctx->sendVertexAttributes(first, count); + ctx->m_glDrawArrays_enc(ctx, mode, 0, count); +} + +void GL2Encoder::s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices) +{ + + GL2Encoder *ctx = (GL2Encoder *)self; + assert(ctx->m_state != NULL); + SET_ERROR_IF(!(isValidDrawMode(mode) && isValidDrawType(type)),GL_INVALID_ENUM); + SET_ERROR_IF(count<0, GL_INVALID_VALUE); + + bool has_immediate_arrays = false; + bool has_indirect_arrays = false; + int nLocations = ctx->m_state->nLocations(); + + for (int i = 0; i < nLocations; i++) { + const GLClientState::VertexAttribState *state = ctx->m_state->getState(i); + if (state->enabled) { + if (state->bufferObject != 0) { + has_indirect_arrays = true; + } else if (state->data) { + has_immediate_arrays = true; + } else { + ALOGW("glDrawElements: a vertex attribute array is enabled with no data bound\n"); + ctx->setError(GL_INVALID_OPERATION); + return; + } + } + } + + if (!has_immediate_arrays && !has_indirect_arrays) { + ALOGE("glDrawElements: no data bound to the command - ignoring\n"); + return; + } + + bool adjustIndices = true; + if (ctx->m_state->currentIndexVbo() != 0) { + if (!has_immediate_arrays) { + ctx->sendVertexAttributes(0, count); + ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, ctx->m_state->currentIndexVbo()); + ctx->glDrawElementsOffset(ctx, mode, count, type, (uintptr_t)indices); + adjustIndices = false; + } else { + BufferData * buf = ctx->m_shared->getBufferData(ctx->m_state->currentIndexVbo()); + ctx->m_glBindBuffer_enc(self, GL_ELEMENT_ARRAY_BUFFER, 0); + indices = (void*)((GLintptr)buf->m_fixedBuffer.ptr() + (GLintptr)indices); + } + } + if (adjustIndices) { + void *adjustedIndices = (void*)indices; + int minIndex = 0, maxIndex = 0; + + switch(type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + GLUtils::minmax((unsigned char *)indices, count, &minIndex, &maxIndex); + if (minIndex != 0) { + adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count); + GLUtils::shiftIndices((unsigned char *)indices, + (unsigned char *)adjustedIndices, + count, -minIndex); + } + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + GLUtils::minmax((unsigned short *)indices, count, &minIndex, &maxIndex); + if (minIndex != 0) { + adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count); + GLUtils::shiftIndices((unsigned short *)indices, + (unsigned short *)adjustedIndices, + count, -minIndex); + } + break; + case GL_INT: + case GL_UNSIGNED_INT: + GLUtils::minmax((unsigned int *)indices, count, &minIndex, &maxIndex); + if (minIndex != 0) { + adjustedIndices = ctx->m_fixedBuffer.alloc(glSizeof(type) * count); + GLUtils::shiftIndices((unsigned int *)indices, + (unsigned int *)adjustedIndices, + count, -minIndex); + } + break; + default: + ALOGE("unsupported index buffer type %d\n", type); + } + if (has_indirect_arrays || 1) { + ctx->sendVertexAttributes(minIndex, maxIndex - minIndex + 1); + ctx->glDrawElementsData(ctx, mode, count, type, adjustedIndices, + count * glSizeof(type)); + // XXX - OPTIMIZATION (see the other else branch) should be implemented + if(!has_indirect_arrays) { + //ALOGD("unoptimized drawelements !!!\n"); + } + } else { + // we are all direct arrays and immidate mode index array - + // rebuild the arrays and the index array; + ALOGE("glDrawElements: direct index & direct buffer data - will be implemented in later versions;\n"); + } + } +} + + +GLint * GL2Encoder::getCompressedTextureFormats() +{ + if (m_compressedTextureFormats == NULL) { + this->glGetIntegerv(this, GL_NUM_COMPRESSED_TEXTURE_FORMATS, + &m_num_compressedTextureFormats); + if (m_num_compressedTextureFormats > 0) { + // get number of texture formats; + m_compressedTextureFormats = new GLint[m_num_compressedTextureFormats]; + this->glGetCompressedTextureFormats(this, m_num_compressedTextureFormats, m_compressedTextureFormats); + } + } + return m_compressedTextureFormats; +} + +// Replace uses of samplerExternalOES with sampler2D, recording the names of +// modified shaders in data. Also remove +// #extension GL_OES_EGL_image_external : require +// statements. +// +// This implementation assumes the input has already been pre-processed. If not, +// a few cases will be mishandled: +// +// 1. "mySampler" will be incorrectly recorded as being a samplerExternalOES in +// the following code: +// #if 1 +// uniform sampler2D mySampler; +// #else +// uniform samplerExternalOES mySampler; +// #endif +// +// 2. Comments that look like sampler declarations will be incorrectly modified +// and recorded: +// // samplerExternalOES hahaFooledYou +// +// 3. However, GLSL ES does not have a concatentation operator, so things like +// this (valid in C) are invalid and not a problem: +// #define SAMPLER(TYPE, NAME) uniform sampler#TYPE NAME +// SAMPLER(ExternalOES, mySampler); +// +static bool replaceSamplerExternalWith2D(char* const str, ShaderData* const data) +{ + static const char STR_HASH_EXTENSION[] = "#extension"; + static const char STR_GL_OES_EGL_IMAGE_EXTERNAL[] = "GL_OES_EGL_image_external"; + static const char STR_SAMPLER_EXTERNAL_OES[] = "samplerExternalOES"; + static const char STR_SAMPLER2D_SPACE[] = "sampler2D "; + + // -- overwrite all "#extension GL_OES_EGL_image_external : xxx" statements + char* c = str; + while ((c = strstr(c, STR_HASH_EXTENSION))) { + char* start = c; + c += sizeof(STR_HASH_EXTENSION)-1; + while (isspace(*c) && *c != '\0') { + c++; + } + if (strncmp(c, STR_GL_OES_EGL_IMAGE_EXTERNAL, + sizeof(STR_GL_OES_EGL_IMAGE_EXTERNAL)-1) == 0) + { + // #extension statements are terminated by end of line + c = start; + while (*c != '\0' && *c != '\r' && *c != '\n') { + *c++ = ' '; + } + } + } + + // -- replace "samplerExternalOES" with "sampler2D" and record name + c = str; + while ((c = strstr(c, STR_SAMPLER_EXTERNAL_OES))) { + // Make sure "samplerExternalOES" isn't a substring of a larger token + if (c == str || !isspace(*(c-1))) { + c++; + continue; + } + char* sampler_start = c; + c += sizeof(STR_SAMPLER_EXTERNAL_OES)-1; + if (!isspace(*c) && *c != '\0') { + continue; + } + + // capture sampler name + while (isspace(*c) && *c != '\0') { + c++; + } + if (!isalpha(*c) && *c != '_') { + // not an identifier + return false; + } + char* name_start = c; + do { + c++; + } while (isalnum(*c) || *c == '_'); + data->samplerExternalNames.push_back( + android::String8(name_start, c - name_start)); + + // memcpy instead of strcpy since we don't want the NUL terminator + memcpy(sampler_start, STR_SAMPLER2D_SPACE, sizeof(STR_SAMPLER2D_SPACE)-1); + } + + return true; +} + +void GL2Encoder::s_glShaderBinary(void *self, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + // Although it is not supported, need to set proper error code. + SET_ERROR_IF(1, GL_INVALID_ENUM); +} + +void GL2Encoder::s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + ShaderData* shaderData = ctx->m_shared->getShaderData(shader); + SET_ERROR_IF(!ctx->m_shared->isObject(shader), GL_INVALID_VALUE); + SET_ERROR_IF(!shaderData, GL_INVALID_OPERATION); + SET_ERROR_IF((count<0), GL_INVALID_VALUE); + + int len = glUtilsCalcShaderSourceLen((char**)string, (GLint*)length, count); + char *str = new char[len + 1]; + glUtilsPackStrings(str, (char**)string, (GLint*)length, count); + + // TODO: pre-process str before calling replaceSamplerExternalWith2D(). + // Perhaps we can borrow Mesa's pre-processor? + + if (!replaceSamplerExternalWith2D(str, shaderData)) { + delete str; + ctx->setError(GL_OUT_OF_MEMORY); + return; + } + + ctx->glShaderString(ctx, shader, str, len + 1); + delete str; +} + +void GL2Encoder::s_glFinish(void *self) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + ctx->glFinishRoundTrip(self); +} + +void GL2Encoder::s_glLinkProgram(void * self, GLuint program) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + ctx->m_glLinkProgram_enc(self, program); + + GLint linkStatus = 0; + ctx->glGetProgramiv(self,program,GL_LINK_STATUS,&linkStatus); + if (!linkStatus) + return; + + //get number of active uniforms in the program + GLint numUniforms=0; + ctx->glGetProgramiv(self, program, GL_ACTIVE_UNIFORMS, &numUniforms); + ctx->m_shared->initProgramData(program,numUniforms); + + //get the length of the longest uniform name + GLint maxLength=0; + ctx->glGetProgramiv(self, program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxLength); + + GLint size; + GLenum type; + GLchar *name = new GLchar[maxLength+1]; + GLint location; + //for each active uniform, get its size and starting location. + for (GLint i=0 ; iglGetActiveUniform(self, program, i, maxLength, NULL, &size, &type, name); + location = ctx->m_glGetUniformLocation_enc(self, program, name); + ctx->m_shared->setProgramIndexInfo(program, i, location, size, type, name); + } + ctx->m_shared->setupLocationShiftWAR(program); + + delete[] name; +} + +void GL2Encoder::s_glDeleteProgram(void *self, GLuint program) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + ctx->m_glDeleteProgram_enc(self, program); + + ctx->m_shared->deleteProgramData(program); +} + +void GL2Encoder::s_glGetUniformiv(void *self, GLuint program, GLint location, GLint* params) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(!ctx->m_shared->isObject(program), GL_INVALID_VALUE); + SET_ERROR_IF(!ctx->m_shared->isProgram(program), GL_INVALID_OPERATION); + SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION); + GLint hostLoc = ctx->m_shared->locationWARAppToHost(program, location); + SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION); + ctx->m_glGetUniformiv_enc(self, program, hostLoc, params); +} +void GL2Encoder::s_glGetUniformfv(void *self, GLuint program, GLint location, GLfloat* params) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(!ctx->m_shared->isObject(program), GL_INVALID_VALUE); + SET_ERROR_IF(!ctx->m_shared->isProgram(program), GL_INVALID_OPERATION); + SET_ERROR_IF(!ctx->m_shared->isProgramInitialized(program), GL_INVALID_OPERATION); + GLint hostLoc = ctx->m_shared->locationWARAppToHost(program,location); + SET_ERROR_IF(ctx->m_shared->getProgramUniformType(program,hostLoc)==0, GL_INVALID_OPERATION); + ctx->m_glGetUniformfv_enc(self, program, hostLoc, params); +} + +GLuint GL2Encoder::s_glCreateProgram(void * self) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLuint program = ctx->m_glCreateProgram_enc(self); + if (program!=0) + ctx->m_shared->addProgramData(program); + return program; +} + +GLuint GL2Encoder::s_glCreateShader(void *self, GLenum shaderType) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + RET_AND_SET_ERROR_IF(((shaderType != GL_VERTEX_SHADER) && (shaderType != GL_FRAGMENT_SHADER)), + GL_INVALID_ENUM, 0); + GLuint shader = ctx->m_glCreateShader_enc(self, shaderType); + if (shader != 0) { + if (!ctx->m_shared->addShaderData(shader)) { + ctx->m_glDeleteShader_enc(self, shader); + return 0; + } + } + return shader; +} + +void GL2Encoder::s_glGetAttachedShaders(void *self, GLuint program, GLsizei maxCount, + GLsizei* count, GLuint* shaders) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(maxCount < 0, GL_INVALID_VALUE); + ctx->m_glGetAttachedShaders_enc(self, program, maxCount, count, shaders); +} + +void GL2Encoder::s_glGetShaderSource(void *self, GLuint shader, GLsizei bufsize, + GLsizei* length, GLchar* source) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(bufsize < 0, GL_INVALID_VALUE); + ctx->m_glGetShaderSource_enc(self, shader, bufsize, length, source); +} + +void GL2Encoder::s_glGetShaderInfoLog(void *self, GLuint shader, GLsizei bufsize, + GLsizei* length, GLchar* infolog) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(bufsize < 0, GL_INVALID_VALUE); + ctx->m_glGetShaderInfoLog_enc(self, shader, bufsize, length, infolog); +} + +void GL2Encoder::s_glGetProgramInfoLog(void *self, GLuint program, GLsizei bufsize, + GLsizei* length, GLchar* infolog) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + SET_ERROR_IF(bufsize < 0, GL_INVALID_VALUE); + ctx->m_glGetProgramInfoLog_enc(self, program, bufsize, length, infolog); +} + +void GL2Encoder::s_glDeleteShader(void *self, GLenum shader) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + ctx->m_glDeleteShader_enc(self,shader); + ctx->m_shared->unrefShaderData(shader); +} + +void GL2Encoder::s_glAttachShader(void *self, GLuint program, GLuint shader) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + ctx->m_glAttachShader_enc(self, program, shader); + ctx->m_shared->attachShader(program, shader); +} + +void GL2Encoder::s_glDetachShader(void *self, GLuint program, GLuint shader) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + ctx->m_glDetachShader_enc(self, program, shader); + ctx->m_shared->detachShader(program, shader); +} + +int GL2Encoder::s_glGetUniformLocation(void *self, GLuint program, const GLchar *name) +{ + if (!name) return -1; + + GL2Encoder *ctx = (GL2Encoder*)self; + + // if we need the uniform location WAR + // parse array index from the end of the name string + int arrIndex = 0; + bool needLocationWAR = ctx->m_shared->needUniformLocationWAR(program); + if (needLocationWAR) { + int namelen = strlen(name); + if (name[namelen-1] == ']') { + char *brace = strrchr(name,'['); + if (!brace || sscanf(brace+1,"%d",&arrIndex) != 1) { + return -1; + } + + } + } + + int hostLoc = ctx->m_glGetUniformLocation_enc(self, program, name); + if (hostLoc >= 0 && needLocationWAR) { + return ctx->m_shared->locationWARHostToApp(program, hostLoc, arrIndex); + } + return hostLoc; +} + +bool GL2Encoder::updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget) +{ + if (newTarget != GL_TEXTURE_2D && newTarget != GL_TEXTURE_EXTERNAL_OES) + return false; + + m_state->setActiveTextureUnit(texUnit); + + GLenum oldTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D); + if (newTarget != oldTarget) { + if (newTarget == GL_TEXTURE_EXTERNAL_OES) { + m_state->disableTextureTarget(GL_TEXTURE_2D); + m_state->enableTextureTarget(GL_TEXTURE_EXTERNAL_OES); + } else { + m_state->disableTextureTarget(GL_TEXTURE_EXTERNAL_OES); + m_state->enableTextureTarget(GL_TEXTURE_2D); + } + m_glActiveTexture_enc(this, texUnit); + m_glBindTexture_enc(this, GL_TEXTURE_2D, + m_state->getBoundTexture(newTarget)); + return true; + } + + return false; +} + +void GL2Encoder::s_glUseProgram(void *self, GLuint program) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLClientState* state = ctx->m_state; + GLSharedGroupPtr shared = ctx->m_shared; + + ctx->m_glUseProgram_enc(self, program); + ctx->m_state->setCurrentProgram(program); + + GLenum origActiveTexture = state->getActiveTextureUnit(); + GLenum hostActiveTexture = origActiveTexture; + GLint samplerIdx = -1; + GLint samplerVal; + GLenum samplerTarget; + while ((samplerIdx = shared->getNextSamplerUniform(program, samplerIdx, &samplerVal, &samplerTarget)) != -1) { + if (samplerVal < 0 || samplerVal >= GLClientState::MAX_TEXTURE_UNITS) + continue; + if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + samplerVal, + samplerTarget)) + { + hostActiveTexture = GL_TEXTURE0 + samplerVal; + } + } + state->setActiveTextureUnit(origActiveTexture); + if (hostActiveTexture != origActiveTexture) { + ctx->m_glActiveTexture_enc(self, origActiveTexture); + } +} + +void GL2Encoder::checkValidUniformParam(void *self, GLsizei count, GLboolean transpose) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLuint program = ctx->m_state->currentProgram(); + SET_ERROR_IF(!ctx->m_shared->isProgram(program), GL_INVALID_OPERATION); + SET_ERROR_IF((count < 0 || transpose == GL_TRUE), GL_INVALID_VALUE); +} + +void GL2Encoder::getHostLocation(void *self, GLint location, GLint *hostLoc) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLuint program = ctx->m_state->currentProgram(); + if (location == -1) { + *hostLoc = location; + return; + } + SET_ERROR_IF((location < 0), GL_INVALID_OPERATION); + GLint curHostLoc = ctx->m_shared->locationWARAppToHost(program,location); + SET_ERROR_IF((ctx->m_shared->getProgramUniformType(program,curHostLoc) == 0 && + curHostLoc!=-1), GL_INVALID_OPERATION); + *hostLoc = curHostLoc; +} + +void GL2Encoder::s_glUniform1f(void *self , GLint location, GLfloat x) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform1f_enc(self, hostLoc, x); +} + +void GL2Encoder::s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform1fv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniform1i(void *self , GLint location, GLint x) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLClientState* state = ctx->m_state; + GLSharedGroupPtr shared = ctx->m_shared; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform1i_enc(self, hostLoc, x); + + GLenum target; + if (shared->setSamplerUniform(state->currentProgram(), location, x, &target)) { + GLenum origActiveTexture = state->getActiveTextureUnit(); + if (ctx->updateHostTexture2DBinding(GL_TEXTURE0 + x, target)) { + ctx->m_glActiveTexture_enc(self, origActiveTexture); + } + state->setActiveTextureUnit(origActiveTexture); + } +} + +void GL2Encoder::s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform1iv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform2f_enc(self, hostLoc, x, y); +} + +void GL2Encoder::s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform2fv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniform2i(void *self , GLint location, GLint x, GLint y) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform2i_enc(self, hostLoc, x, y); +} + +void GL2Encoder::s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform2iv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform3f_enc(self, hostLoc, x, y, z); +} + +void GL2Encoder::s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform3fv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform3i_enc(self, hostLoc, x, y, z); +} + +void GL2Encoder::s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform3iv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform4f_enc(self, hostLoc, x, y, z, w); +} + +void GL2Encoder::s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform4fv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, 0, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform4i_enc(self, hostLoc, x, y, z, w); +} + +void GL2Encoder::s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, GL_FALSE); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniform4iv_enc(self, hostLoc, count, v); +} + +void GL2Encoder::s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, transpose); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniformMatrix2fv_enc(self, hostLoc, count, transpose, value); +} + +void GL2Encoder::s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, transpose); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniformMatrix3fv_enc(self, hostLoc, count, transpose, value); +} + +void GL2Encoder::s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + GL2Encoder *ctx = (GL2Encoder*)self; + GLint hostLoc; + + ctx->checkValidUniformParam(self, count, transpose); + ctx->getHostLocation(self, location, &hostLoc); + ctx->m_glUniformMatrix4fv_enc(self, hostLoc, count, transpose, value); +} + +void GL2Encoder::s_glActiveTexture(void* self, GLenum texture) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + GLClientState* state = ctx->m_state; + GLenum err; + + SET_ERROR_IF((err = state->setActiveTextureUnit(texture)) != GL_NO_ERROR, err); + + ctx->m_glActiveTexture_enc(ctx, texture); +} + +void GL2Encoder::s_glBindTexture(void* self, GLenum target, GLuint texture) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + GLClientState* state = ctx->m_state; + GLenum err; + GLboolean firstUse; + + SET_ERROR_IF((err = state->bindTexture(target, texture, &firstUse)) != GL_NO_ERROR, err); + + if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) { + ctx->m_glBindTexture_enc(ctx, target, texture); + return; + } + + GLenum priorityTarget = state->getPriorityEnabledTarget(GL_TEXTURE_2D); + + if (target == GL_TEXTURE_EXTERNAL_OES && firstUse) { + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, + GL_TEXTURE_MIN_FILTER, GL_LINEAR); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, + GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, + GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + if (target != priorityTarget) { + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, + state->getBoundTexture(GL_TEXTURE_2D)); + } + } + + if (target == priorityTarget) { + ctx->m_glBindTexture_enc(ctx, GL_TEXTURE_2D, texture); + } +} + +void GL2Encoder::s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + GLClientState* state = ctx->m_state; + + state->deleteTextures(n, textures); + ctx->m_glDeleteTextures_enc(ctx, n, textures); +} + +void GL2Encoder::s_glGetTexParameterfv(void* self, + GLenum target, GLenum pname, GLfloat* params) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + const GLClientState* state = ctx->m_state; + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glGetTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glGetTexParameterfv_enc(ctx, target, pname, params); + } +} + +void GL2Encoder::s_glGetTexParameteriv(void* self, + GLenum target, GLenum pname, GLint* params) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + const GLClientState* state = ctx->m_state; + + switch (pname) { + case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: + *params = 1; + break; + + default: + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glGetTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glGetTexParameteriv_enc(ctx, target, pname, params); + } + break; + } +} + +static bool isValidTextureExternalParam(GLenum pname, GLenum param) +{ + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + return param == GL_NEAREST || param == GL_LINEAR; + + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + return param == GL_CLAMP_TO_EDGE; + + default: + return true; + } +} + +void GL2Encoder::s_glTexParameterf(void* self, + GLenum target, GLenum pname, GLfloat param) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)param)), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameterf_enc(ctx, GL_TEXTURE_2D, pname, param); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameterf_enc(ctx, target, pname, param); + } +} + +void GL2Encoder::s_glTexParameterfv(void* self, + GLenum target, GLenum pname, const GLfloat* params) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)params[0])), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameterfv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameterfv_enc(ctx, target, pname, params); + } +} + +void GL2Encoder::s_glTexParameteri(void* self, + GLenum target, GLenum pname, GLint param) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)param)), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameteri_enc(ctx, GL_TEXTURE_2D, pname, param); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameteri_enc(ctx, target, pname, param); + } +} + +void GL2Encoder::s_glTexImage2D(void* self, GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid* pixels) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexImage2D_enc(ctx, target, level, internalformat, width, + height, border, format, type, pixels); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexImage2D_enc(ctx, target, level, internalformat, width, + height, border, format, type, pixels); + } +} + +void GL2Encoder::s_glTexSubImage2D(void* self, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid* pixels) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + GLint maxTextureSize; + ctx->glGetIntegerv(self, GL_MAX_TEXTURE_SIZE, &maxTextureSize); + + SET_ERROR_IF((level < 0 || level > log2(maxTextureSize)), GL_INVALID_VALUE); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexSubImage2D_enc(ctx, target, level, xoffset, yoffset, width, + height, format, type, pixels); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexSubImage2D_enc(ctx, target, level, xoffset, yoffset, width, + height, format, type, pixels); + } +} + +void GL2Encoder::s_glTexParameteriv(void* self, + GLenum target, GLenum pname, const GLint* params) +{ + GL2Encoder* ctx = (GL2Encoder*)self; + const GLClientState* state = ctx->m_state; + + SET_ERROR_IF((target == GL_TEXTURE_EXTERNAL_OES && + !isValidTextureExternalParam(pname, (GLenum)params[0])), + GL_INVALID_ENUM); + + if (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) { + ctx->override2DTextureTarget(target); + ctx->m_glTexParameteriv_enc(ctx, GL_TEXTURE_2D, pname, params); + ctx->restore2DTextureTarget(); + } else { + ctx->m_glTexParameteriv_enc(ctx, target, pname, params); + } +} + +void GL2Encoder::override2DTextureTarget(GLenum target) +{ + if ((target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES) && + target != m_state->getPriorityEnabledTarget(GL_TEXTURE_2D)) { + m_glBindTexture_enc(this, GL_TEXTURE_2D, + m_state->getBoundTexture(target)); + } +} + +void GL2Encoder::restore2DTextureTarget() +{ + GLenum priorityTarget = m_state->getPriorityEnabledTarget(GL_TEXTURE_2D); + m_glBindTexture_enc(this, GL_TEXTURE_2D, + m_state->getBoundTexture(priorityTarget)); +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.h new file mode 100644 index 0000000..e3d343a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2Encoder.h @@ -0,0 +1,251 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GL2_ENCODER_H_ +#define _GL2_ENCODER_H_ + +#include "gl2_enc.h" +#include "GLClientState.h" +#include "GLSharedGroup.h" +#include "FixedBuffer.h" + +class GL2Encoder : public gl2_encoder_context_t { +public: + GL2Encoder(IOStream *stream, ChecksumCalculator* protocol); + virtual ~GL2Encoder(); + void setClientState(GLClientState *state) { + m_state = state; + } + void setSharedGroup(GLSharedGroupPtr shared){ m_shared = shared; } + const GLClientState *state() { return m_state; } + const GLSharedGroupPtr shared() { return m_shared; } + void flush() { m_stream->flush(); } + + void setInitialized(){ m_initialized = true; }; + bool isInitialized(){ return m_initialized; }; + + virtual void setError(GLenum error){ m_error = error; }; + virtual GLenum getError() { return m_error; }; + + void override2DTextureTarget(GLenum target); + void restore2DTextureTarget(); + +private: + + bool m_initialized; + GLClientState *m_state; + GLSharedGroupPtr m_shared; + GLenum m_error; + + GLint *m_compressedTextureFormats; + GLint m_num_compressedTextureFormats; + GLint *getCompressedTextureFormats(); + + GLint m_max_cubeMapTextureSize; + GLint m_max_renderBufferSize; + GLint m_max_textureSize; + FixedBuffer m_fixedBuffer; + + void sendVertexAttributes(GLint first, GLsizei count); + bool updateHostTexture2DBinding(GLenum texUnit, GLenum newTarget); + void checkValidUniformParam(void * self, GLsizei count, GLboolean transpose); + void getHostLocation(void *self, GLint location, GLint *hostLoc); + + + glGetError_client_proc_t m_glGetError_enc; + static GLenum s_glGetError(void * self); + + glFlush_client_proc_t m_glFlush_enc; + static void s_glFlush(void * self); + + glPixelStorei_client_proc_t m_glPixelStorei_enc; + static void s_glPixelStorei(void *self, GLenum param, GLint value); + + glGetString_client_proc_t m_glGetString_enc; + static const GLubyte * s_glGetString(void *self, GLenum name); + + glBindBuffer_client_proc_t m_glBindBuffer_enc; + static void s_glBindBuffer(void *self, GLenum target, GLuint id); + + + glBufferData_client_proc_t m_glBufferData_enc; + static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + glBufferSubData_client_proc_t m_glBufferSubData_enc; + static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); + glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc; + static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers); + + glDrawArrays_client_proc_t m_glDrawArrays_enc; + static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count); + + glDrawElements_client_proc_t m_glDrawElements_enc; + static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices); + + + glGetIntegerv_client_proc_t m_glGetIntegerv_enc; + static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr); + + glGetFloatv_client_proc_t m_glGetFloatv_enc; + static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr); + + glGetBooleanv_client_proc_t m_glGetBooleanv_enc; + static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr); + + glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc; + static void s_glVertexAttribPointer(void *self, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, const GLvoid * ptr); + + glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc; + static void s_glEnableVertexAttribArray(void *self, GLuint index); + + glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc; + static void s_glDisableVertexAttribArray(void *self, GLuint index); + + glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc; + static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params); + + glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc; + static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params); + + glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv_enc; + static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer); + + static void s_glShaderBinary(void *self, GLsizei n, const GLuint *shaders, GLenum binaryformat, const void* binary, GLsizei length); + + static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar * const *string, const GLint *length); + + static void s_glFinish(void *self); + + glLinkProgram_client_proc_t m_glLinkProgram_enc; + static void s_glLinkProgram(void *self, GLuint program); + + glDeleteProgram_client_proc_t m_glDeleteProgram_enc; + static void s_glDeleteProgram(void * self, GLuint program); + + glGetUniformiv_client_proc_t m_glGetUniformiv_enc; + static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params); + + glGetUniformfv_client_proc_t m_glGetUniformfv_enc; + static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params); + + glCreateProgram_client_proc_t m_glCreateProgram_enc; + static GLuint s_glCreateProgram(void *self); + + glCreateShader_client_proc_t m_glCreateShader_enc; + static GLuint s_glCreateShader(void *self, GLenum shaderType); + + glDeleteShader_client_proc_t m_glDeleteShader_enc; + static void s_glDeleteShader(void *self, GLuint shader); + + glAttachShader_client_proc_t m_glAttachShader_enc; + static void s_glAttachShader(void *self, GLuint program, GLuint shader); + + glDetachShader_client_proc_t m_glDetachShader_enc; + static void s_glDetachShader(void *self, GLuint program, GLuint shader); + + glGetAttachedShaders_client_proc_t m_glGetAttachedShaders_enc; + static void s_glGetAttachedShaders(void *self, GLuint program, GLsizei maxCount, + GLsizei* count, GLuint* shaders); + + glGetShaderSource_client_proc_t m_glGetShaderSource_enc; + static void s_glGetShaderSource(void *self, GLuint shader, GLsizei bufsize, + GLsizei* length, GLchar* source); + + glGetShaderInfoLog_client_proc_t m_glGetShaderInfoLog_enc; + static void s_glGetShaderInfoLog(void *self,GLuint shader, + GLsizei bufsize, GLsizei* length, GLchar* infolog); + + glGetProgramInfoLog_client_proc_t m_glGetProgramInfoLog_enc; + static void s_glGetProgramInfoLog(void *self,GLuint program, + GLsizei bufsize, GLsizei* length, GLchar* infolog); + + glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc; + static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name); + glUseProgram_client_proc_t m_glUseProgram_enc; + + glUniform1f_client_proc_t m_glUniform1f_enc; + glUniform1fv_client_proc_t m_glUniform1fv_enc; + glUniform1i_client_proc_t m_glUniform1i_enc; + glUniform1iv_client_proc_t m_glUniform1iv_enc; + glUniform2f_client_proc_t m_glUniform2f_enc; + glUniform2fv_client_proc_t m_glUniform2fv_enc; + glUniform2i_client_proc_t m_glUniform2i_enc; + glUniform2iv_client_proc_t m_glUniform2iv_enc; + glUniform3f_client_proc_t m_glUniform3f_enc; + glUniform3fv_client_proc_t m_glUniform3fv_enc; + glUniform3i_client_proc_t m_glUniform3i_enc; + glUniform3iv_client_proc_t m_glUniform3iv_enc; + glUniform4f_client_proc_t m_glUniform4f_enc; + glUniform4fv_client_proc_t m_glUniform4fv_enc; + glUniform4i_client_proc_t m_glUniform4i_enc; + glUniform4iv_client_proc_t m_glUniform4iv_enc; + glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc; + glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc; + glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc; + + static void s_glUseProgram(void *self, GLuint program); + static void s_glUniform1f(void *self , GLint location, GLfloat x); + static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v); + static void s_glUniform1i(void *self , GLint location, GLint x); + static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v); + static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y); + static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v); + static void s_glUniform2i(void *self , GLint location, GLint x, GLint y); + static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v); + static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z); + static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v); + static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z); + static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v); + static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v); + static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w); + static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v); + static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + + glActiveTexture_client_proc_t m_glActiveTexture_enc; + glBindTexture_client_proc_t m_glBindTexture_enc; + glDeleteTextures_client_proc_t m_glDeleteTextures_enc; + glGetTexParameterfv_client_proc_t m_glGetTexParameterfv_enc; + glGetTexParameteriv_client_proc_t m_glGetTexParameteriv_enc; + glTexParameterf_client_proc_t m_glTexParameterf_enc; + glTexParameterfv_client_proc_t m_glTexParameterfv_enc; + glTexParameteri_client_proc_t m_glTexParameteri_enc; + glTexParameteriv_client_proc_t m_glTexParameteriv_enc; + glTexImage2D_client_proc_t m_glTexImage2D_enc; + glTexSubImage2D_client_proc_t m_glTexSubImage2D_enc; + + static void s_glActiveTexture(void* self, GLenum texture); + static void s_glBindTexture(void* self, GLenum target, GLuint texture); + static void s_glDeleteTextures(void* self, GLsizei n, const GLuint* textures); + static void s_glGetTexParameterfv(void* self, GLenum target, GLenum pname, GLfloat* params); + static void s_glGetTexParameteriv(void* self, GLenum target, GLenum pname, GLint* params); + static void s_glTexParameterf(void* self, GLenum target, GLenum pname, GLfloat param); + static void s_glTexParameterfv(void* self, GLenum target, GLenum pname, const GLfloat* params); + static void s_glTexParameteri(void* self, GLenum target, GLenum pname, GLint param); + static void s_glTexParameteriv(void* self, GLenum target, GLenum pname, const GLint* params); + static void s_glTexImage2D(void* self, GLenum target, GLint level, GLint internalformat, + GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, + const GLvoid* pixels); + static void s_glTexSubImage2D(void* self, GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid* pixels); + +public: + glEGLImageTargetTexture2DOES_client_proc_t m_glEGLImageTargetTexture2DOES_enc; + +}; +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp new file mode 100644 index 0000000..fc2a723 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.cpp @@ -0,0 +1,43 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include "GL2Encoder.h" +#include + +namespace glesv2_enc { + +size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) +{ + GL2Encoder *ctx = (GL2Encoder *)self; + assert (ctx->state() != NULL); + return ctx->state()->pixelDataSize(width, height, format, type, pack); +} + +size_t pixelDataSize3D(void *self, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) +{ + size_t layerSize = pixelDataSize(self, width, height, format, type, pack); + return layerSize * depth; +} + +GLenum uniformType(void * self, GLuint program, GLint location) +{ + GL2Encoder * ctx = (GL2Encoder *) self; + assert (ctx->shared() != NULL); + return ctx->shared()->getProgramUniformType(program, location); +} + +} // namespace glesv2_enc diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.h new file mode 100644 index 0000000..211e966 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/GL2EncoderUtils.h @@ -0,0 +1,27 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef GL2_ENCODER_UTILS_H +#define GL2_ENCODER_UTILS_H + +namespace glesv2_enc { + +size_t pixelDataSize(void *self, GLsizei width, GLsizei height, GLenum format, GLenum type, int pack); +size_t pixelDataSize3D(void *self, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack); +GLenum uniformType(void * self, GLuint program, GLint location); + +} // namespace glesv2_enc + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.cpp new file mode 100644 index 0000000..f903542 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.cpp @@ -0,0 +1,223 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include "gl2_client_context.h" + + +#include + +int gl2_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + glActiveTexture = (glActiveTexture_client_proc_t) getProc("glActiveTexture", userData); + glAttachShader = (glAttachShader_client_proc_t) getProc("glAttachShader", userData); + glBindAttribLocation = (glBindAttribLocation_client_proc_t) getProc("glBindAttribLocation", userData); + glBindBuffer = (glBindBuffer_client_proc_t) getProc("glBindBuffer", userData); + glBindFramebuffer = (glBindFramebuffer_client_proc_t) getProc("glBindFramebuffer", userData); + glBindRenderbuffer = (glBindRenderbuffer_client_proc_t) getProc("glBindRenderbuffer", userData); + glBindTexture = (glBindTexture_client_proc_t) getProc("glBindTexture", userData); + glBlendColor = (glBlendColor_client_proc_t) getProc("glBlendColor", userData); + glBlendEquation = (glBlendEquation_client_proc_t) getProc("glBlendEquation", userData); + glBlendEquationSeparate = (glBlendEquationSeparate_client_proc_t) getProc("glBlendEquationSeparate", userData); + glBlendFunc = (glBlendFunc_client_proc_t) getProc("glBlendFunc", userData); + glBlendFuncSeparate = (glBlendFuncSeparate_client_proc_t) getProc("glBlendFuncSeparate", userData); + glBufferData = (glBufferData_client_proc_t) getProc("glBufferData", userData); + glBufferSubData = (glBufferSubData_client_proc_t) getProc("glBufferSubData", userData); + glCheckFramebufferStatus = (glCheckFramebufferStatus_client_proc_t) getProc("glCheckFramebufferStatus", userData); + glClear = (glClear_client_proc_t) getProc("glClear", userData); + glClearColor = (glClearColor_client_proc_t) getProc("glClearColor", userData); + glClearDepthf = (glClearDepthf_client_proc_t) getProc("glClearDepthf", userData); + glClearStencil = (glClearStencil_client_proc_t) getProc("glClearStencil", userData); + glColorMask = (glColorMask_client_proc_t) getProc("glColorMask", userData); + glCompileShader = (glCompileShader_client_proc_t) getProc("glCompileShader", userData); + glCompressedTexImage2D = (glCompressedTexImage2D_client_proc_t) getProc("glCompressedTexImage2D", userData); + glCompressedTexSubImage2D = (glCompressedTexSubImage2D_client_proc_t) getProc("glCompressedTexSubImage2D", userData); + glCopyTexImage2D = (glCopyTexImage2D_client_proc_t) getProc("glCopyTexImage2D", userData); + glCopyTexSubImage2D = (glCopyTexSubImage2D_client_proc_t) getProc("glCopyTexSubImage2D", userData); + glCreateProgram = (glCreateProgram_client_proc_t) getProc("glCreateProgram", userData); + glCreateShader = (glCreateShader_client_proc_t) getProc("glCreateShader", userData); + glCullFace = (glCullFace_client_proc_t) getProc("glCullFace", userData); + glDeleteBuffers = (glDeleteBuffers_client_proc_t) getProc("glDeleteBuffers", userData); + glDeleteFramebuffers = (glDeleteFramebuffers_client_proc_t) getProc("glDeleteFramebuffers", userData); + glDeleteProgram = (glDeleteProgram_client_proc_t) getProc("glDeleteProgram", userData); + glDeleteRenderbuffers = (glDeleteRenderbuffers_client_proc_t) getProc("glDeleteRenderbuffers", userData); + glDeleteShader = (glDeleteShader_client_proc_t) getProc("glDeleteShader", userData); + glDeleteTextures = (glDeleteTextures_client_proc_t) getProc("glDeleteTextures", userData); + glDepthFunc = (glDepthFunc_client_proc_t) getProc("glDepthFunc", userData); + glDepthMask = (glDepthMask_client_proc_t) getProc("glDepthMask", userData); + glDepthRangef = (glDepthRangef_client_proc_t) getProc("glDepthRangef", userData); + glDetachShader = (glDetachShader_client_proc_t) getProc("glDetachShader", userData); + glDisable = (glDisable_client_proc_t) getProc("glDisable", userData); + glDisableVertexAttribArray = (glDisableVertexAttribArray_client_proc_t) getProc("glDisableVertexAttribArray", userData); + glDrawArrays = (glDrawArrays_client_proc_t) getProc("glDrawArrays", userData); + glDrawElements = (glDrawElements_client_proc_t) getProc("glDrawElements", userData); + glEnable = (glEnable_client_proc_t) getProc("glEnable", userData); + glEnableVertexAttribArray = (glEnableVertexAttribArray_client_proc_t) getProc("glEnableVertexAttribArray", userData); + glFinish = (glFinish_client_proc_t) getProc("glFinish", userData); + glFlush = (glFlush_client_proc_t) getProc("glFlush", userData); + glFramebufferRenderbuffer = (glFramebufferRenderbuffer_client_proc_t) getProc("glFramebufferRenderbuffer", userData); + glFramebufferTexture2D = (glFramebufferTexture2D_client_proc_t) getProc("glFramebufferTexture2D", userData); + glFrontFace = (glFrontFace_client_proc_t) getProc("glFrontFace", userData); + glGenBuffers = (glGenBuffers_client_proc_t) getProc("glGenBuffers", userData); + glGenerateMipmap = (glGenerateMipmap_client_proc_t) getProc("glGenerateMipmap", userData); + glGenFramebuffers = (glGenFramebuffers_client_proc_t) getProc("glGenFramebuffers", userData); + glGenRenderbuffers = (glGenRenderbuffers_client_proc_t) getProc("glGenRenderbuffers", userData); + glGenTextures = (glGenTextures_client_proc_t) getProc("glGenTextures", userData); + glGetActiveAttrib = (glGetActiveAttrib_client_proc_t) getProc("glGetActiveAttrib", userData); + glGetActiveUniform = (glGetActiveUniform_client_proc_t) getProc("glGetActiveUniform", userData); + glGetAttachedShaders = (glGetAttachedShaders_client_proc_t) getProc("glGetAttachedShaders", userData); + glGetAttribLocation = (glGetAttribLocation_client_proc_t) getProc("glGetAttribLocation", userData); + glGetBooleanv = (glGetBooleanv_client_proc_t) getProc("glGetBooleanv", userData); + glGetBufferParameteriv = (glGetBufferParameteriv_client_proc_t) getProc("glGetBufferParameteriv", userData); + glGetError = (glGetError_client_proc_t) getProc("glGetError", userData); + glGetFloatv = (glGetFloatv_client_proc_t) getProc("glGetFloatv", userData); + glGetFramebufferAttachmentParameteriv = (glGetFramebufferAttachmentParameteriv_client_proc_t) getProc("glGetFramebufferAttachmentParameteriv", userData); + glGetIntegerv = (glGetIntegerv_client_proc_t) getProc("glGetIntegerv", userData); + glGetProgramiv = (glGetProgramiv_client_proc_t) getProc("glGetProgramiv", userData); + glGetProgramInfoLog = (glGetProgramInfoLog_client_proc_t) getProc("glGetProgramInfoLog", userData); + glGetRenderbufferParameteriv = (glGetRenderbufferParameteriv_client_proc_t) getProc("glGetRenderbufferParameteriv", userData); + glGetShaderiv = (glGetShaderiv_client_proc_t) getProc("glGetShaderiv", userData); + glGetShaderInfoLog = (glGetShaderInfoLog_client_proc_t) getProc("glGetShaderInfoLog", userData); + glGetShaderPrecisionFormat = (glGetShaderPrecisionFormat_client_proc_t) getProc("glGetShaderPrecisionFormat", userData); + glGetShaderSource = (glGetShaderSource_client_proc_t) getProc("glGetShaderSource", userData); + glGetString = (glGetString_client_proc_t) getProc("glGetString", userData); + glGetTexParameterfv = (glGetTexParameterfv_client_proc_t) getProc("glGetTexParameterfv", userData); + glGetTexParameteriv = (glGetTexParameteriv_client_proc_t) getProc("glGetTexParameteriv", userData); + glGetUniformfv = (glGetUniformfv_client_proc_t) getProc("glGetUniformfv", userData); + glGetUniformiv = (glGetUniformiv_client_proc_t) getProc("glGetUniformiv", userData); + glGetUniformLocation = (glGetUniformLocation_client_proc_t) getProc("glGetUniformLocation", userData); + glGetVertexAttribfv = (glGetVertexAttribfv_client_proc_t) getProc("glGetVertexAttribfv", userData); + glGetVertexAttribiv = (glGetVertexAttribiv_client_proc_t) getProc("glGetVertexAttribiv", userData); + glGetVertexAttribPointerv = (glGetVertexAttribPointerv_client_proc_t) getProc("glGetVertexAttribPointerv", userData); + glHint = (glHint_client_proc_t) getProc("glHint", userData); + glIsBuffer = (glIsBuffer_client_proc_t) getProc("glIsBuffer", userData); + glIsEnabled = (glIsEnabled_client_proc_t) getProc("glIsEnabled", userData); + glIsFramebuffer = (glIsFramebuffer_client_proc_t) getProc("glIsFramebuffer", userData); + glIsProgram = (glIsProgram_client_proc_t) getProc("glIsProgram", userData); + glIsRenderbuffer = (glIsRenderbuffer_client_proc_t) getProc("glIsRenderbuffer", userData); + glIsShader = (glIsShader_client_proc_t) getProc("glIsShader", userData); + glIsTexture = (glIsTexture_client_proc_t) getProc("glIsTexture", userData); + glLineWidth = (glLineWidth_client_proc_t) getProc("glLineWidth", userData); + glLinkProgram = (glLinkProgram_client_proc_t) getProc("glLinkProgram", userData); + glPixelStorei = (glPixelStorei_client_proc_t) getProc("glPixelStorei", userData); + glPolygonOffset = (glPolygonOffset_client_proc_t) getProc("glPolygonOffset", userData); + glReadPixels = (glReadPixels_client_proc_t) getProc("glReadPixels", userData); + glReleaseShaderCompiler = (glReleaseShaderCompiler_client_proc_t) getProc("glReleaseShaderCompiler", userData); + glRenderbufferStorage = (glRenderbufferStorage_client_proc_t) getProc("glRenderbufferStorage", userData); + glSampleCoverage = (glSampleCoverage_client_proc_t) getProc("glSampleCoverage", userData); + glScissor = (glScissor_client_proc_t) getProc("glScissor", userData); + glShaderBinary = (glShaderBinary_client_proc_t) getProc("glShaderBinary", userData); + glShaderSource = (glShaderSource_client_proc_t) getProc("glShaderSource", userData); + glStencilFunc = (glStencilFunc_client_proc_t) getProc("glStencilFunc", userData); + glStencilFuncSeparate = (glStencilFuncSeparate_client_proc_t) getProc("glStencilFuncSeparate", userData); + glStencilMask = (glStencilMask_client_proc_t) getProc("glStencilMask", userData); + glStencilMaskSeparate = (glStencilMaskSeparate_client_proc_t) getProc("glStencilMaskSeparate", userData); + glStencilOp = (glStencilOp_client_proc_t) getProc("glStencilOp", userData); + glStencilOpSeparate = (glStencilOpSeparate_client_proc_t) getProc("glStencilOpSeparate", userData); + glTexImage2D = (glTexImage2D_client_proc_t) getProc("glTexImage2D", userData); + glTexParameterf = (glTexParameterf_client_proc_t) getProc("glTexParameterf", userData); + glTexParameterfv = (glTexParameterfv_client_proc_t) getProc("glTexParameterfv", userData); + glTexParameteri = (glTexParameteri_client_proc_t) getProc("glTexParameteri", userData); + glTexParameteriv = (glTexParameteriv_client_proc_t) getProc("glTexParameteriv", userData); + glTexSubImage2D = (glTexSubImage2D_client_proc_t) getProc("glTexSubImage2D", userData); + glUniform1f = (glUniform1f_client_proc_t) getProc("glUniform1f", userData); + glUniform1fv = (glUniform1fv_client_proc_t) getProc("glUniform1fv", userData); + glUniform1i = (glUniform1i_client_proc_t) getProc("glUniform1i", userData); + glUniform1iv = (glUniform1iv_client_proc_t) getProc("glUniform1iv", userData); + glUniform2f = (glUniform2f_client_proc_t) getProc("glUniform2f", userData); + glUniform2fv = (glUniform2fv_client_proc_t) getProc("glUniform2fv", userData); + glUniform2i = (glUniform2i_client_proc_t) getProc("glUniform2i", userData); + glUniform2iv = (glUniform2iv_client_proc_t) getProc("glUniform2iv", userData); + glUniform3f = (glUniform3f_client_proc_t) getProc("glUniform3f", userData); + glUniform3fv = (glUniform3fv_client_proc_t) getProc("glUniform3fv", userData); + glUniform3i = (glUniform3i_client_proc_t) getProc("glUniform3i", userData); + glUniform3iv = (glUniform3iv_client_proc_t) getProc("glUniform3iv", userData); + glUniform4f = (glUniform4f_client_proc_t) getProc("glUniform4f", userData); + glUniform4fv = (glUniform4fv_client_proc_t) getProc("glUniform4fv", userData); + glUniform4i = (glUniform4i_client_proc_t) getProc("glUniform4i", userData); + glUniform4iv = (glUniform4iv_client_proc_t) getProc("glUniform4iv", userData); + glUniformMatrix2fv = (glUniformMatrix2fv_client_proc_t) getProc("glUniformMatrix2fv", userData); + glUniformMatrix3fv = (glUniformMatrix3fv_client_proc_t) getProc("glUniformMatrix3fv", userData); + glUniformMatrix4fv = (glUniformMatrix4fv_client_proc_t) getProc("glUniformMatrix4fv", userData); + glUseProgram = (glUseProgram_client_proc_t) getProc("glUseProgram", userData); + glValidateProgram = (glValidateProgram_client_proc_t) getProc("glValidateProgram", userData); + glVertexAttrib1f = (glVertexAttrib1f_client_proc_t) getProc("glVertexAttrib1f", userData); + glVertexAttrib1fv = (glVertexAttrib1fv_client_proc_t) getProc("glVertexAttrib1fv", userData); + glVertexAttrib2f = (glVertexAttrib2f_client_proc_t) getProc("glVertexAttrib2f", userData); + glVertexAttrib2fv = (glVertexAttrib2fv_client_proc_t) getProc("glVertexAttrib2fv", userData); + glVertexAttrib3f = (glVertexAttrib3f_client_proc_t) getProc("glVertexAttrib3f", userData); + glVertexAttrib3fv = (glVertexAttrib3fv_client_proc_t) getProc("glVertexAttrib3fv", userData); + glVertexAttrib4f = (glVertexAttrib4f_client_proc_t) getProc("glVertexAttrib4f", userData); + glVertexAttrib4fv = (glVertexAttrib4fv_client_proc_t) getProc("glVertexAttrib4fv", userData); + glVertexAttribPointer = (glVertexAttribPointer_client_proc_t) getProc("glVertexAttribPointer", userData); + glViewport = (glViewport_client_proc_t) getProc("glViewport", userData); + glEGLImageTargetTexture2DOES = (glEGLImageTargetTexture2DOES_client_proc_t) getProc("glEGLImageTargetTexture2DOES", userData); + glEGLImageTargetRenderbufferStorageOES = (glEGLImageTargetRenderbufferStorageOES_client_proc_t) getProc("glEGLImageTargetRenderbufferStorageOES", userData); + glGetProgramBinaryOES = (glGetProgramBinaryOES_client_proc_t) getProc("glGetProgramBinaryOES", userData); + glProgramBinaryOES = (glProgramBinaryOES_client_proc_t) getProc("glProgramBinaryOES", userData); + glMapBufferOES = (glMapBufferOES_client_proc_t) getProc("glMapBufferOES", userData); + glUnmapBufferOES = (glUnmapBufferOES_client_proc_t) getProc("glUnmapBufferOES", userData); + glTexImage3DOES = (glTexImage3DOES_client_proc_t) getProc("glTexImage3DOES", userData); + glTexSubImage3DOES = (glTexSubImage3DOES_client_proc_t) getProc("glTexSubImage3DOES", userData); + glCopyTexSubImage3DOES = (glCopyTexSubImage3DOES_client_proc_t) getProc("glCopyTexSubImage3DOES", userData); + glCompressedTexImage3DOES = (glCompressedTexImage3DOES_client_proc_t) getProc("glCompressedTexImage3DOES", userData); + glCompressedTexSubImage3DOES = (glCompressedTexSubImage3DOES_client_proc_t) getProc("glCompressedTexSubImage3DOES", userData); + glFramebufferTexture3DOES = (glFramebufferTexture3DOES_client_proc_t) getProc("glFramebufferTexture3DOES", userData); + glBindVertexArrayOES = (glBindVertexArrayOES_client_proc_t) getProc("glBindVertexArrayOES", userData); + glDeleteVertexArraysOES = (glDeleteVertexArraysOES_client_proc_t) getProc("glDeleteVertexArraysOES", userData); + glGenVertexArraysOES = (glGenVertexArraysOES_client_proc_t) getProc("glGenVertexArraysOES", userData); + glIsVertexArrayOES = (glIsVertexArrayOES_client_proc_t) getProc("glIsVertexArrayOES", userData); + glDiscardFramebufferEXT = (glDiscardFramebufferEXT_client_proc_t) getProc("glDiscardFramebufferEXT", userData); + glMultiDrawArraysEXT = (glMultiDrawArraysEXT_client_proc_t) getProc("glMultiDrawArraysEXT", userData); + glMultiDrawElementsEXT = (glMultiDrawElementsEXT_client_proc_t) getProc("glMultiDrawElementsEXT", userData); + glGetPerfMonitorGroupsAMD = (glGetPerfMonitorGroupsAMD_client_proc_t) getProc("glGetPerfMonitorGroupsAMD", userData); + glGetPerfMonitorCountersAMD = (glGetPerfMonitorCountersAMD_client_proc_t) getProc("glGetPerfMonitorCountersAMD", userData); + glGetPerfMonitorGroupStringAMD = (glGetPerfMonitorGroupStringAMD_client_proc_t) getProc("glGetPerfMonitorGroupStringAMD", userData); + glGetPerfMonitorCounterStringAMD = (glGetPerfMonitorCounterStringAMD_client_proc_t) getProc("glGetPerfMonitorCounterStringAMD", userData); + glGetPerfMonitorCounterInfoAMD = (glGetPerfMonitorCounterInfoAMD_client_proc_t) getProc("glGetPerfMonitorCounterInfoAMD", userData); + glGenPerfMonitorsAMD = (glGenPerfMonitorsAMD_client_proc_t) getProc("glGenPerfMonitorsAMD", userData); + glDeletePerfMonitorsAMD = (glDeletePerfMonitorsAMD_client_proc_t) getProc("glDeletePerfMonitorsAMD", userData); + glSelectPerfMonitorCountersAMD = (glSelectPerfMonitorCountersAMD_client_proc_t) getProc("glSelectPerfMonitorCountersAMD", userData); + glBeginPerfMonitorAMD = (glBeginPerfMonitorAMD_client_proc_t) getProc("glBeginPerfMonitorAMD", userData); + glEndPerfMonitorAMD = (glEndPerfMonitorAMD_client_proc_t) getProc("glEndPerfMonitorAMD", userData); + glGetPerfMonitorCounterDataAMD = (glGetPerfMonitorCounterDataAMD_client_proc_t) getProc("glGetPerfMonitorCounterDataAMD", userData); + glRenderbufferStorageMultisampleIMG = (glRenderbufferStorageMultisampleIMG_client_proc_t) getProc("glRenderbufferStorageMultisampleIMG", userData); + glFramebufferTexture2DMultisampleIMG = (glFramebufferTexture2DMultisampleIMG_client_proc_t) getProc("glFramebufferTexture2DMultisampleIMG", userData); + glDeleteFencesNV = (glDeleteFencesNV_client_proc_t) getProc("glDeleteFencesNV", userData); + glGenFencesNV = (glGenFencesNV_client_proc_t) getProc("glGenFencesNV", userData); + glIsFenceNV = (glIsFenceNV_client_proc_t) getProc("glIsFenceNV", userData); + glTestFenceNV = (glTestFenceNV_client_proc_t) getProc("glTestFenceNV", userData); + glGetFenceivNV = (glGetFenceivNV_client_proc_t) getProc("glGetFenceivNV", userData); + glFinishFenceNV = (glFinishFenceNV_client_proc_t) getProc("glFinishFenceNV", userData); + glSetFenceNV = (glSetFenceNV_client_proc_t) getProc("glSetFenceNV", userData); + glCoverageMaskNV = (glCoverageMaskNV_client_proc_t) getProc("glCoverageMaskNV", userData); + glCoverageOperationNV = (glCoverageOperationNV_client_proc_t) getProc("glCoverageOperationNV", userData); + glGetDriverControlsQCOM = (glGetDriverControlsQCOM_client_proc_t) getProc("glGetDriverControlsQCOM", userData); + glGetDriverControlStringQCOM = (glGetDriverControlStringQCOM_client_proc_t) getProc("glGetDriverControlStringQCOM", userData); + glEnableDriverControlQCOM = (glEnableDriverControlQCOM_client_proc_t) getProc("glEnableDriverControlQCOM", userData); + glDisableDriverControlQCOM = (glDisableDriverControlQCOM_client_proc_t) getProc("glDisableDriverControlQCOM", userData); + glExtGetTexturesQCOM = (glExtGetTexturesQCOM_client_proc_t) getProc("glExtGetTexturesQCOM", userData); + glExtGetBuffersQCOM = (glExtGetBuffersQCOM_client_proc_t) getProc("glExtGetBuffersQCOM", userData); + glExtGetRenderbuffersQCOM = (glExtGetRenderbuffersQCOM_client_proc_t) getProc("glExtGetRenderbuffersQCOM", userData); + glExtGetFramebuffersQCOM = (glExtGetFramebuffersQCOM_client_proc_t) getProc("glExtGetFramebuffersQCOM", userData); + glExtGetTexLevelParameterivQCOM = (glExtGetTexLevelParameterivQCOM_client_proc_t) getProc("glExtGetTexLevelParameterivQCOM", userData); + glExtTexObjectStateOverrideiQCOM = (glExtTexObjectStateOverrideiQCOM_client_proc_t) getProc("glExtTexObjectStateOverrideiQCOM", userData); + glExtGetTexSubImageQCOM = (glExtGetTexSubImageQCOM_client_proc_t) getProc("glExtGetTexSubImageQCOM", userData); + glExtGetBufferPointervQCOM = (glExtGetBufferPointervQCOM_client_proc_t) getProc("glExtGetBufferPointervQCOM", userData); + glExtGetShadersQCOM = (glExtGetShadersQCOM_client_proc_t) getProc("glExtGetShadersQCOM", userData); + glExtGetProgramsQCOM = (glExtGetProgramsQCOM_client_proc_t) getProc("glExtGetProgramsQCOM", userData); + glExtIsProgramBinaryQCOM = (glExtIsProgramBinaryQCOM_client_proc_t) getProc("glExtIsProgramBinaryQCOM", userData); + glExtGetProgramBinarySourceQCOM = (glExtGetProgramBinarySourceQCOM_client_proc_t) getProc("glExtGetProgramBinarySourceQCOM", userData); + glStartTilingQCOM = (glStartTilingQCOM_client_proc_t) getProc("glStartTilingQCOM", userData); + glEndTilingQCOM = (glEndTilingQCOM_client_proc_t) getProc("glEndTilingQCOM", userData); + glVertexAttribPointerData = (glVertexAttribPointerData_client_proc_t) getProc("glVertexAttribPointerData", userData); + glVertexAttribPointerOffset = (glVertexAttribPointerOffset_client_proc_t) getProc("glVertexAttribPointerOffset", userData); + glDrawElementsOffset = (glDrawElementsOffset_client_proc_t) getProc("glDrawElementsOffset", userData); + glDrawElementsData = (glDrawElementsData_client_proc_t) getProc("glDrawElementsData", userData); + glGetCompressedTextureFormats = (glGetCompressedTextureFormats_client_proc_t) getProc("glGetCompressedTextureFormats", userData); + glShaderString = (glShaderString_client_proc_t) getProc("glShaderString", userData); + glFinishRoundTrip = (glFinishRoundTrip_client_proc_t) getProc("glFinishRoundTrip", userData); + return 0; +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.h new file mode 100644 index 0000000..7035fec --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_context.h @@ -0,0 +1,230 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __gl2_client_context_t_h +#define __gl2_client_context_t_h + +#include "gl2_client_proc.h" + +#include "gl2_types.h" + + +struct gl2_client_context_t { + + glActiveTexture_client_proc_t glActiveTexture; + glAttachShader_client_proc_t glAttachShader; + glBindAttribLocation_client_proc_t glBindAttribLocation; + glBindBuffer_client_proc_t glBindBuffer; + glBindFramebuffer_client_proc_t glBindFramebuffer; + glBindRenderbuffer_client_proc_t glBindRenderbuffer; + glBindTexture_client_proc_t glBindTexture; + glBlendColor_client_proc_t glBlendColor; + glBlendEquation_client_proc_t glBlendEquation; + glBlendEquationSeparate_client_proc_t glBlendEquationSeparate; + glBlendFunc_client_proc_t glBlendFunc; + glBlendFuncSeparate_client_proc_t glBlendFuncSeparate; + glBufferData_client_proc_t glBufferData; + glBufferSubData_client_proc_t glBufferSubData; + glCheckFramebufferStatus_client_proc_t glCheckFramebufferStatus; + glClear_client_proc_t glClear; + glClearColor_client_proc_t glClearColor; + glClearDepthf_client_proc_t glClearDepthf; + glClearStencil_client_proc_t glClearStencil; + glColorMask_client_proc_t glColorMask; + glCompileShader_client_proc_t glCompileShader; + glCompressedTexImage2D_client_proc_t glCompressedTexImage2D; + glCompressedTexSubImage2D_client_proc_t glCompressedTexSubImage2D; + glCopyTexImage2D_client_proc_t glCopyTexImage2D; + glCopyTexSubImage2D_client_proc_t glCopyTexSubImage2D; + glCreateProgram_client_proc_t glCreateProgram; + glCreateShader_client_proc_t glCreateShader; + glCullFace_client_proc_t glCullFace; + glDeleteBuffers_client_proc_t glDeleteBuffers; + glDeleteFramebuffers_client_proc_t glDeleteFramebuffers; + glDeleteProgram_client_proc_t glDeleteProgram; + glDeleteRenderbuffers_client_proc_t glDeleteRenderbuffers; + glDeleteShader_client_proc_t glDeleteShader; + glDeleteTextures_client_proc_t glDeleteTextures; + glDepthFunc_client_proc_t glDepthFunc; + glDepthMask_client_proc_t glDepthMask; + glDepthRangef_client_proc_t glDepthRangef; + glDetachShader_client_proc_t glDetachShader; + glDisable_client_proc_t glDisable; + glDisableVertexAttribArray_client_proc_t glDisableVertexAttribArray; + glDrawArrays_client_proc_t glDrawArrays; + glDrawElements_client_proc_t glDrawElements; + glEnable_client_proc_t glEnable; + glEnableVertexAttribArray_client_proc_t glEnableVertexAttribArray; + glFinish_client_proc_t glFinish; + glFlush_client_proc_t glFlush; + glFramebufferRenderbuffer_client_proc_t glFramebufferRenderbuffer; + glFramebufferTexture2D_client_proc_t glFramebufferTexture2D; + glFrontFace_client_proc_t glFrontFace; + glGenBuffers_client_proc_t glGenBuffers; + glGenerateMipmap_client_proc_t glGenerateMipmap; + glGenFramebuffers_client_proc_t glGenFramebuffers; + glGenRenderbuffers_client_proc_t glGenRenderbuffers; + glGenTextures_client_proc_t glGenTextures; + glGetActiveAttrib_client_proc_t glGetActiveAttrib; + glGetActiveUniform_client_proc_t glGetActiveUniform; + glGetAttachedShaders_client_proc_t glGetAttachedShaders; + glGetAttribLocation_client_proc_t glGetAttribLocation; + glGetBooleanv_client_proc_t glGetBooleanv; + glGetBufferParameteriv_client_proc_t glGetBufferParameteriv; + glGetError_client_proc_t glGetError; + glGetFloatv_client_proc_t glGetFloatv; + glGetFramebufferAttachmentParameteriv_client_proc_t glGetFramebufferAttachmentParameteriv; + glGetIntegerv_client_proc_t glGetIntegerv; + glGetProgramiv_client_proc_t glGetProgramiv; + glGetProgramInfoLog_client_proc_t glGetProgramInfoLog; + glGetRenderbufferParameteriv_client_proc_t glGetRenderbufferParameteriv; + glGetShaderiv_client_proc_t glGetShaderiv; + glGetShaderInfoLog_client_proc_t glGetShaderInfoLog; + glGetShaderPrecisionFormat_client_proc_t glGetShaderPrecisionFormat; + glGetShaderSource_client_proc_t glGetShaderSource; + glGetString_client_proc_t glGetString; + glGetTexParameterfv_client_proc_t glGetTexParameterfv; + glGetTexParameteriv_client_proc_t glGetTexParameteriv; + glGetUniformfv_client_proc_t glGetUniformfv; + glGetUniformiv_client_proc_t glGetUniformiv; + glGetUniformLocation_client_proc_t glGetUniformLocation; + glGetVertexAttribfv_client_proc_t glGetVertexAttribfv; + glGetVertexAttribiv_client_proc_t glGetVertexAttribiv; + glGetVertexAttribPointerv_client_proc_t glGetVertexAttribPointerv; + glHint_client_proc_t glHint; + glIsBuffer_client_proc_t glIsBuffer; + glIsEnabled_client_proc_t glIsEnabled; + glIsFramebuffer_client_proc_t glIsFramebuffer; + glIsProgram_client_proc_t glIsProgram; + glIsRenderbuffer_client_proc_t glIsRenderbuffer; + glIsShader_client_proc_t glIsShader; + glIsTexture_client_proc_t glIsTexture; + glLineWidth_client_proc_t glLineWidth; + glLinkProgram_client_proc_t glLinkProgram; + glPixelStorei_client_proc_t glPixelStorei; + glPolygonOffset_client_proc_t glPolygonOffset; + glReadPixels_client_proc_t glReadPixels; + glReleaseShaderCompiler_client_proc_t glReleaseShaderCompiler; + glRenderbufferStorage_client_proc_t glRenderbufferStorage; + glSampleCoverage_client_proc_t glSampleCoverage; + glScissor_client_proc_t glScissor; + glShaderBinary_client_proc_t glShaderBinary; + glShaderSource_client_proc_t glShaderSource; + glStencilFunc_client_proc_t glStencilFunc; + glStencilFuncSeparate_client_proc_t glStencilFuncSeparate; + glStencilMask_client_proc_t glStencilMask; + glStencilMaskSeparate_client_proc_t glStencilMaskSeparate; + glStencilOp_client_proc_t glStencilOp; + glStencilOpSeparate_client_proc_t glStencilOpSeparate; + glTexImage2D_client_proc_t glTexImage2D; + glTexParameterf_client_proc_t glTexParameterf; + glTexParameterfv_client_proc_t glTexParameterfv; + glTexParameteri_client_proc_t glTexParameteri; + glTexParameteriv_client_proc_t glTexParameteriv; + glTexSubImage2D_client_proc_t glTexSubImage2D; + glUniform1f_client_proc_t glUniform1f; + glUniform1fv_client_proc_t glUniform1fv; + glUniform1i_client_proc_t glUniform1i; + glUniform1iv_client_proc_t glUniform1iv; + glUniform2f_client_proc_t glUniform2f; + glUniform2fv_client_proc_t glUniform2fv; + glUniform2i_client_proc_t glUniform2i; + glUniform2iv_client_proc_t glUniform2iv; + glUniform3f_client_proc_t glUniform3f; + glUniform3fv_client_proc_t glUniform3fv; + glUniform3i_client_proc_t glUniform3i; + glUniform3iv_client_proc_t glUniform3iv; + glUniform4f_client_proc_t glUniform4f; + glUniform4fv_client_proc_t glUniform4fv; + glUniform4i_client_proc_t glUniform4i; + glUniform4iv_client_proc_t glUniform4iv; + glUniformMatrix2fv_client_proc_t glUniformMatrix2fv; + glUniformMatrix3fv_client_proc_t glUniformMatrix3fv; + glUniformMatrix4fv_client_proc_t glUniformMatrix4fv; + glUseProgram_client_proc_t glUseProgram; + glValidateProgram_client_proc_t glValidateProgram; + glVertexAttrib1f_client_proc_t glVertexAttrib1f; + glVertexAttrib1fv_client_proc_t glVertexAttrib1fv; + glVertexAttrib2f_client_proc_t glVertexAttrib2f; + glVertexAttrib2fv_client_proc_t glVertexAttrib2fv; + glVertexAttrib3f_client_proc_t glVertexAttrib3f; + glVertexAttrib3fv_client_proc_t glVertexAttrib3fv; + glVertexAttrib4f_client_proc_t glVertexAttrib4f; + glVertexAttrib4fv_client_proc_t glVertexAttrib4fv; + glVertexAttribPointer_client_proc_t glVertexAttribPointer; + glViewport_client_proc_t glViewport; + glEGLImageTargetTexture2DOES_client_proc_t glEGLImageTargetTexture2DOES; + glEGLImageTargetRenderbufferStorageOES_client_proc_t glEGLImageTargetRenderbufferStorageOES; + glGetProgramBinaryOES_client_proc_t glGetProgramBinaryOES; + glProgramBinaryOES_client_proc_t glProgramBinaryOES; + glMapBufferOES_client_proc_t glMapBufferOES; + glUnmapBufferOES_client_proc_t glUnmapBufferOES; + glTexImage3DOES_client_proc_t glTexImage3DOES; + glTexSubImage3DOES_client_proc_t glTexSubImage3DOES; + glCopyTexSubImage3DOES_client_proc_t glCopyTexSubImage3DOES; + glCompressedTexImage3DOES_client_proc_t glCompressedTexImage3DOES; + glCompressedTexSubImage3DOES_client_proc_t glCompressedTexSubImage3DOES; + glFramebufferTexture3DOES_client_proc_t glFramebufferTexture3DOES; + glBindVertexArrayOES_client_proc_t glBindVertexArrayOES; + glDeleteVertexArraysOES_client_proc_t glDeleteVertexArraysOES; + glGenVertexArraysOES_client_proc_t glGenVertexArraysOES; + glIsVertexArrayOES_client_proc_t glIsVertexArrayOES; + glDiscardFramebufferEXT_client_proc_t glDiscardFramebufferEXT; + glMultiDrawArraysEXT_client_proc_t glMultiDrawArraysEXT; + glMultiDrawElementsEXT_client_proc_t glMultiDrawElementsEXT; + glGetPerfMonitorGroupsAMD_client_proc_t glGetPerfMonitorGroupsAMD; + glGetPerfMonitorCountersAMD_client_proc_t glGetPerfMonitorCountersAMD; + glGetPerfMonitorGroupStringAMD_client_proc_t glGetPerfMonitorGroupStringAMD; + glGetPerfMonitorCounterStringAMD_client_proc_t glGetPerfMonitorCounterStringAMD; + glGetPerfMonitorCounterInfoAMD_client_proc_t glGetPerfMonitorCounterInfoAMD; + glGenPerfMonitorsAMD_client_proc_t glGenPerfMonitorsAMD; + glDeletePerfMonitorsAMD_client_proc_t glDeletePerfMonitorsAMD; + glSelectPerfMonitorCountersAMD_client_proc_t glSelectPerfMonitorCountersAMD; + glBeginPerfMonitorAMD_client_proc_t glBeginPerfMonitorAMD; + glEndPerfMonitorAMD_client_proc_t glEndPerfMonitorAMD; + glGetPerfMonitorCounterDataAMD_client_proc_t glGetPerfMonitorCounterDataAMD; + glRenderbufferStorageMultisampleIMG_client_proc_t glRenderbufferStorageMultisampleIMG; + glFramebufferTexture2DMultisampleIMG_client_proc_t glFramebufferTexture2DMultisampleIMG; + glDeleteFencesNV_client_proc_t glDeleteFencesNV; + glGenFencesNV_client_proc_t glGenFencesNV; + glIsFenceNV_client_proc_t glIsFenceNV; + glTestFenceNV_client_proc_t glTestFenceNV; + glGetFenceivNV_client_proc_t glGetFenceivNV; + glFinishFenceNV_client_proc_t glFinishFenceNV; + glSetFenceNV_client_proc_t glSetFenceNV; + glCoverageMaskNV_client_proc_t glCoverageMaskNV; + glCoverageOperationNV_client_proc_t glCoverageOperationNV; + glGetDriverControlsQCOM_client_proc_t glGetDriverControlsQCOM; + glGetDriverControlStringQCOM_client_proc_t glGetDriverControlStringQCOM; + glEnableDriverControlQCOM_client_proc_t glEnableDriverControlQCOM; + glDisableDriverControlQCOM_client_proc_t glDisableDriverControlQCOM; + glExtGetTexturesQCOM_client_proc_t glExtGetTexturesQCOM; + glExtGetBuffersQCOM_client_proc_t glExtGetBuffersQCOM; + glExtGetRenderbuffersQCOM_client_proc_t glExtGetRenderbuffersQCOM; + glExtGetFramebuffersQCOM_client_proc_t glExtGetFramebuffersQCOM; + glExtGetTexLevelParameterivQCOM_client_proc_t glExtGetTexLevelParameterivQCOM; + glExtTexObjectStateOverrideiQCOM_client_proc_t glExtTexObjectStateOverrideiQCOM; + glExtGetTexSubImageQCOM_client_proc_t glExtGetTexSubImageQCOM; + glExtGetBufferPointervQCOM_client_proc_t glExtGetBufferPointervQCOM; + glExtGetShadersQCOM_client_proc_t glExtGetShadersQCOM; + glExtGetProgramsQCOM_client_proc_t glExtGetProgramsQCOM; + glExtIsProgramBinaryQCOM_client_proc_t glExtIsProgramBinaryQCOM; + glExtGetProgramBinarySourceQCOM_client_proc_t glExtGetProgramBinarySourceQCOM; + glStartTilingQCOM_client_proc_t glStartTilingQCOM; + glEndTilingQCOM_client_proc_t glEndTilingQCOM; + glVertexAttribPointerData_client_proc_t glVertexAttribPointerData; + glVertexAttribPointerOffset_client_proc_t glVertexAttribPointerOffset; + glDrawElementsOffset_client_proc_t glDrawElementsOffset; + glDrawElementsData_client_proc_t glDrawElementsData; + glGetCompressedTextureFormats_client_proc_t glGetCompressedTextureFormats; + glShaderString_client_proc_t glShaderString; + glFinishRoundTrip_client_proc_t glFinishRoundTrip; + virtual ~gl2_client_context_t() {} + + typedef gl2_client_context_t *CONTEXT_ACCESSOR_TYPE(void); + static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); + virtual void setError(unsigned int error){ (void)error; }; + virtual unsigned int getError(){ return 0; }; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_proc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_proc.h new file mode 100644 index 0000000..445910d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_client_proc.h @@ -0,0 +1,222 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __gl2_client_proc_t_h +#define __gl2_client_proc_t_h + + + +#include "gl2_types.h" +#ifndef gl2_APIENTRY +#define gl2_APIENTRY +#endif +typedef void (gl2_APIENTRY *glActiveTexture_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glAttachShader_client_proc_t) (void * ctx, GLuint, GLuint); +typedef void (gl2_APIENTRY *glBindAttribLocation_client_proc_t) (void * ctx, GLuint, GLuint, const GLchar*); +typedef void (gl2_APIENTRY *glBindBuffer_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl2_APIENTRY *glBindFramebuffer_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl2_APIENTRY *glBindRenderbuffer_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl2_APIENTRY *glBindTexture_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl2_APIENTRY *glBlendColor_client_proc_t) (void * ctx, GLclampf, GLclampf, GLclampf, GLclampf); +typedef void (gl2_APIENTRY *glBlendEquation_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glBlendEquationSeparate_client_proc_t) (void * ctx, GLenum, GLenum); +typedef void (gl2_APIENTRY *glBlendFunc_client_proc_t) (void * ctx, GLenum, GLenum); +typedef void (gl2_APIENTRY *glBlendFuncSeparate_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLenum); +typedef void (gl2_APIENTRY *glBufferData_client_proc_t) (void * ctx, GLenum, GLsizeiptr, const GLvoid*, GLenum); +typedef void (gl2_APIENTRY *glBufferSubData_client_proc_t) (void * ctx, GLenum, GLintptr, GLsizeiptr, const GLvoid*); +typedef GLenum (gl2_APIENTRY *glCheckFramebufferStatus_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glClear_client_proc_t) (void * ctx, GLbitfield); +typedef void (gl2_APIENTRY *glClearColor_client_proc_t) (void * ctx, GLclampf, GLclampf, GLclampf, GLclampf); +typedef void (gl2_APIENTRY *glClearDepthf_client_proc_t) (void * ctx, GLclampf); +typedef void (gl2_APIENTRY *glClearStencil_client_proc_t) (void * ctx, GLint); +typedef void (gl2_APIENTRY *glColorMask_client_proc_t) (void * ctx, GLboolean, GLboolean, GLboolean, GLboolean); +typedef void (gl2_APIENTRY *glCompileShader_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glCompressedTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*); +typedef void (gl2_APIENTRY *glCompressedTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*); +typedef void (gl2_APIENTRY *glCopyTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +typedef void (gl2_APIENTRY *glCopyTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +typedef GLuint (gl2_APIENTRY *glCreateProgram_client_proc_t) (void * ctx); +typedef GLuint (gl2_APIENTRY *glCreateShader_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glCullFace_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glDeleteBuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl2_APIENTRY *glDeleteFramebuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl2_APIENTRY *glDeleteProgram_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glDeleteRenderbuffers_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl2_APIENTRY *glDeleteShader_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glDeleteTextures_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl2_APIENTRY *glDepthFunc_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glDepthMask_client_proc_t) (void * ctx, GLboolean); +typedef void (gl2_APIENTRY *glDepthRangef_client_proc_t) (void * ctx, GLclampf, GLclampf); +typedef void (gl2_APIENTRY *glDetachShader_client_proc_t) (void * ctx, GLuint, GLuint); +typedef void (gl2_APIENTRY *glDisable_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glDisableVertexAttribArray_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glDrawArrays_client_proc_t) (void * ctx, GLenum, GLint, GLsizei); +typedef void (gl2_APIENTRY *glDrawElements_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, const GLvoid*); +typedef void (gl2_APIENTRY *glEnable_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glEnableVertexAttribArray_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glFinish_client_proc_t) (void * ctx); +typedef void (gl2_APIENTRY *glFlush_client_proc_t) (void * ctx); +typedef void (gl2_APIENTRY *glFramebufferRenderbuffer_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint); +typedef void (gl2_APIENTRY *glFramebufferTexture2D_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint); +typedef void (gl2_APIENTRY *glFrontFace_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glGenBuffers_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glGenerateMipmap_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glGenFramebuffers_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glGenRenderbuffers_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glGenTextures_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glGetActiveAttrib_client_proc_t) (void * ctx, GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*); +typedef void (gl2_APIENTRY *glGetActiveUniform_client_proc_t) (void * ctx, GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*); +typedef void (gl2_APIENTRY *glGetAttachedShaders_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLuint*); +typedef int (gl2_APIENTRY *glGetAttribLocation_client_proc_t) (void * ctx, GLuint, const GLchar*); +typedef void (gl2_APIENTRY *glGetBooleanv_client_proc_t) (void * ctx, GLenum, GLboolean*); +typedef void (gl2_APIENTRY *glGetBufferParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef GLenum (gl2_APIENTRY *glGetError_client_proc_t) (void * ctx); +typedef void (gl2_APIENTRY *glGetFloatv_client_proc_t) (void * ctx, GLenum, GLfloat*); +typedef void (gl2_APIENTRY *glGetFramebufferAttachmentParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLint*); +typedef void (gl2_APIENTRY *glGetIntegerv_client_proc_t) (void * ctx, GLenum, GLint*); +typedef void (gl2_APIENTRY *glGetProgramiv_client_proc_t) (void * ctx, GLuint, GLenum, GLint*); +typedef void (gl2_APIENTRY *glGetProgramInfoLog_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*); +typedef void (gl2_APIENTRY *glGetRenderbufferParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef void (gl2_APIENTRY *glGetShaderiv_client_proc_t) (void * ctx, GLuint, GLenum, GLint*); +typedef void (gl2_APIENTRY *glGetShaderInfoLog_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*); +typedef void (gl2_APIENTRY *glGetShaderPrecisionFormat_client_proc_t) (void * ctx, GLenum, GLenum, GLint*, GLint*); +typedef void (gl2_APIENTRY *glGetShaderSource_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*); +typedef const GLubyte* (gl2_APIENTRY *glGetString_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glGetTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat*); +typedef void (gl2_APIENTRY *glGetTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, GLint*); +typedef void (gl2_APIENTRY *glGetUniformfv_client_proc_t) (void * ctx, GLuint, GLint, GLfloat*); +typedef void (gl2_APIENTRY *glGetUniformiv_client_proc_t) (void * ctx, GLuint, GLint, GLint*); +typedef int (gl2_APIENTRY *glGetUniformLocation_client_proc_t) (void * ctx, GLuint, const GLchar*); +typedef void (gl2_APIENTRY *glGetVertexAttribfv_client_proc_t) (void * ctx, GLuint, GLenum, GLfloat*); +typedef void (gl2_APIENTRY *glGetVertexAttribiv_client_proc_t) (void * ctx, GLuint, GLenum, GLint*); +typedef void (gl2_APIENTRY *glGetVertexAttribPointerv_client_proc_t) (void * ctx, GLuint, GLenum, GLvoid**); +typedef void (gl2_APIENTRY *glHint_client_proc_t) (void * ctx, GLenum, GLenum); +typedef GLboolean (gl2_APIENTRY *glIsBuffer_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl2_APIENTRY *glIsEnabled_client_proc_t) (void * ctx, GLenum); +typedef GLboolean (gl2_APIENTRY *glIsFramebuffer_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl2_APIENTRY *glIsProgram_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl2_APIENTRY *glIsRenderbuffer_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl2_APIENTRY *glIsShader_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl2_APIENTRY *glIsTexture_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glLineWidth_client_proc_t) (void * ctx, GLfloat); +typedef void (gl2_APIENTRY *glLinkProgram_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glPixelStorei_client_proc_t) (void * ctx, GLenum, GLint); +typedef void (gl2_APIENTRY *glPolygonOffset_client_proc_t) (void * ctx, GLfloat, GLfloat); +typedef void (gl2_APIENTRY *glReadPixels_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); +typedef void (gl2_APIENTRY *glReleaseShaderCompiler_client_proc_t) (void * ctx); +typedef void (gl2_APIENTRY *glRenderbufferStorage_client_proc_t) (void * ctx, GLenum, GLenum, GLsizei, GLsizei); +typedef void (gl2_APIENTRY *glSampleCoverage_client_proc_t) (void * ctx, GLclampf, GLboolean); +typedef void (gl2_APIENTRY *glScissor_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei); +typedef void (gl2_APIENTRY *glShaderBinary_client_proc_t) (void * ctx, GLsizei, const GLuint*, GLenum, const GLvoid*, GLsizei); +typedef void (gl2_APIENTRY *glShaderSource_client_proc_t) (void * ctx, GLuint, GLsizei, const GLchar* const*, const GLint*); +typedef void (gl2_APIENTRY *glStencilFunc_client_proc_t) (void * ctx, GLenum, GLint, GLuint); +typedef void (gl2_APIENTRY *glStencilFuncSeparate_client_proc_t) (void * ctx, GLenum, GLenum, GLint, GLuint); +typedef void (gl2_APIENTRY *glStencilMask_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glStencilMaskSeparate_client_proc_t) (void * ctx, GLenum, GLuint); +typedef void (gl2_APIENTRY *glStencilOp_client_proc_t) (void * ctx, GLenum, GLenum, GLenum); +typedef void (gl2_APIENTRY *glStencilOpSeparate_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLenum); +typedef void (gl2_APIENTRY *glTexImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); +typedef void (gl2_APIENTRY *glTexParameterf_client_proc_t) (void * ctx, GLenum, GLenum, GLfloat); +typedef void (gl2_APIENTRY *glTexParameterfv_client_proc_t) (void * ctx, GLenum, GLenum, const GLfloat*); +typedef void (gl2_APIENTRY *glTexParameteri_client_proc_t) (void * ctx, GLenum, GLenum, GLint); +typedef void (gl2_APIENTRY *glTexParameteriv_client_proc_t) (void * ctx, GLenum, GLenum, const GLint*); +typedef void (gl2_APIENTRY *glTexSubImage2D_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*); +typedef void (gl2_APIENTRY *glUniform1f_client_proc_t) (void * ctx, GLint, GLfloat); +typedef void (gl2_APIENTRY *glUniform1fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*); +typedef void (gl2_APIENTRY *glUniform1i_client_proc_t) (void * ctx, GLint, GLint); +typedef void (gl2_APIENTRY *glUniform1iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*); +typedef void (gl2_APIENTRY *glUniform2f_client_proc_t) (void * ctx, GLint, GLfloat, GLfloat); +typedef void (gl2_APIENTRY *glUniform2fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*); +typedef void (gl2_APIENTRY *glUniform2i_client_proc_t) (void * ctx, GLint, GLint, GLint); +typedef void (gl2_APIENTRY *glUniform2iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*); +typedef void (gl2_APIENTRY *glUniform3f_client_proc_t) (void * ctx, GLint, GLfloat, GLfloat, GLfloat); +typedef void (gl2_APIENTRY *glUniform3fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*); +typedef void (gl2_APIENTRY *glUniform3i_client_proc_t) (void * ctx, GLint, GLint, GLint, GLint); +typedef void (gl2_APIENTRY *glUniform3iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*); +typedef void (gl2_APIENTRY *glUniform4f_client_proc_t) (void * ctx, GLint, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl2_APIENTRY *glUniform4fv_client_proc_t) (void * ctx, GLint, GLsizei, const GLfloat*); +typedef void (gl2_APIENTRY *glUniform4i_client_proc_t) (void * ctx, GLint, GLint, GLint, GLint, GLint); +typedef void (gl2_APIENTRY *glUniform4iv_client_proc_t) (void * ctx, GLint, GLsizei, const GLint*); +typedef void (gl2_APIENTRY *glUniformMatrix2fv_client_proc_t) (void * ctx, GLint, GLsizei, GLboolean, const GLfloat*); +typedef void (gl2_APIENTRY *glUniformMatrix3fv_client_proc_t) (void * ctx, GLint, GLsizei, GLboolean, const GLfloat*); +typedef void (gl2_APIENTRY *glUniformMatrix4fv_client_proc_t) (void * ctx, GLint, GLsizei, GLboolean, const GLfloat*); +typedef void (gl2_APIENTRY *glUseProgram_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glValidateProgram_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glVertexAttrib1f_client_proc_t) (void * ctx, GLuint, GLfloat); +typedef void (gl2_APIENTRY *glVertexAttrib1fv_client_proc_t) (void * ctx, GLuint, const GLfloat*); +typedef void (gl2_APIENTRY *glVertexAttrib2f_client_proc_t) (void * ctx, GLuint, GLfloat, GLfloat); +typedef void (gl2_APIENTRY *glVertexAttrib2fv_client_proc_t) (void * ctx, GLuint, const GLfloat*); +typedef void (gl2_APIENTRY *glVertexAttrib3f_client_proc_t) (void * ctx, GLuint, GLfloat, GLfloat, GLfloat); +typedef void (gl2_APIENTRY *glVertexAttrib3fv_client_proc_t) (void * ctx, GLuint, const GLfloat*); +typedef void (gl2_APIENTRY *glVertexAttrib4f_client_proc_t) (void * ctx, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (gl2_APIENTRY *glVertexAttrib4fv_client_proc_t) (void * ctx, GLuint, const GLfloat*); +typedef void (gl2_APIENTRY *glVertexAttribPointer_client_proc_t) (void * ctx, GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*); +typedef void (gl2_APIENTRY *glViewport_client_proc_t) (void * ctx, GLint, GLint, GLsizei, GLsizei); +typedef void (gl2_APIENTRY *glEGLImageTargetTexture2DOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES); +typedef void (gl2_APIENTRY *glEGLImageTargetRenderbufferStorageOES_client_proc_t) (void * ctx, GLenum, GLeglImageOES); +typedef void (gl2_APIENTRY *glGetProgramBinaryOES_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLenum*, GLvoid*); +typedef void (gl2_APIENTRY *glProgramBinaryOES_client_proc_t) (void * ctx, GLuint, GLenum, const GLvoid*, GLint); +typedef void* (gl2_APIENTRY *glMapBufferOES_client_proc_t) (void * ctx, GLenum, GLenum); +typedef GLboolean (gl2_APIENTRY *glUnmapBufferOES_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glTexImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); +typedef void (gl2_APIENTRY *glTexSubImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*); +typedef void (gl2_APIENTRY *glCopyTexSubImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +typedef void (gl2_APIENTRY *glCompressedTexImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*); +typedef void (gl2_APIENTRY *glCompressedTexSubImage3DOES_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*); +typedef void (gl2_APIENTRY *glFramebufferTexture3DOES_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint, GLint); +typedef void (gl2_APIENTRY *glBindVertexArrayOES_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glDeleteVertexArraysOES_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl2_APIENTRY *glGenVertexArraysOES_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef GLboolean (gl2_APIENTRY *glIsVertexArrayOES_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glDiscardFramebufferEXT_client_proc_t) (void * ctx, GLenum, GLsizei, const GLenum*); +typedef void (gl2_APIENTRY *glMultiDrawArraysEXT_client_proc_t) (void * ctx, GLenum, const GLint*, const GLsizei*, GLsizei); +typedef void (gl2_APIENTRY *glMultiDrawElementsEXT_client_proc_t) (void * ctx, GLenum, const GLsizei*, GLenum, const GLvoid* const*, GLsizei); +typedef void (gl2_APIENTRY *glGetPerfMonitorGroupsAMD_client_proc_t) (void * ctx, GLint*, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glGetPerfMonitorCountersAMD_client_proc_t) (void * ctx, GLuint, GLint*, GLint*, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glGetPerfMonitorGroupStringAMD_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*); +typedef void (gl2_APIENTRY *glGetPerfMonitorCounterStringAMD_client_proc_t) (void * ctx, GLuint, GLuint, GLsizei, GLsizei*, GLchar*); +typedef void (gl2_APIENTRY *glGetPerfMonitorCounterInfoAMD_client_proc_t) (void * ctx, GLuint, GLuint, GLenum, GLvoid*); +typedef void (gl2_APIENTRY *glGenPerfMonitorsAMD_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glDeletePerfMonitorsAMD_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glSelectPerfMonitorCountersAMD_client_proc_t) (void * ctx, GLuint, GLboolean, GLuint, GLint, GLuint*); +typedef void (gl2_APIENTRY *glBeginPerfMonitorAMD_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glEndPerfMonitorAMD_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glGetPerfMonitorCounterDataAMD_client_proc_t) (void * ctx, GLuint, GLenum, GLsizei, GLuint*, GLint*); +typedef void (gl2_APIENTRY *glRenderbufferStorageMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLsizei, GLsizei); +typedef void (gl2_APIENTRY *glFramebufferTexture2DMultisampleIMG_client_proc_t) (void * ctx, GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); +typedef void (gl2_APIENTRY *glDeleteFencesNV_client_proc_t) (void * ctx, GLsizei, const GLuint*); +typedef void (gl2_APIENTRY *glGenFencesNV_client_proc_t) (void * ctx, GLsizei, GLuint*); +typedef GLboolean (gl2_APIENTRY *glIsFenceNV_client_proc_t) (void * ctx, GLuint); +typedef GLboolean (gl2_APIENTRY *glTestFenceNV_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glGetFenceivNV_client_proc_t) (void * ctx, GLuint, GLenum, GLint*); +typedef void (gl2_APIENTRY *glFinishFenceNV_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glSetFenceNV_client_proc_t) (void * ctx, GLuint, GLenum); +typedef void (gl2_APIENTRY *glCoverageMaskNV_client_proc_t) (void * ctx, GLboolean); +typedef void (gl2_APIENTRY *glCoverageOperationNV_client_proc_t) (void * ctx, GLenum); +typedef void (gl2_APIENTRY *glGetDriverControlsQCOM_client_proc_t) (void * ctx, GLint*, GLsizei, GLuint*); +typedef void (gl2_APIENTRY *glGetDriverControlStringQCOM_client_proc_t) (void * ctx, GLuint, GLsizei, GLsizei*, GLchar*); +typedef void (gl2_APIENTRY *glEnableDriverControlQCOM_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glDisableDriverControlQCOM_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glExtGetTexturesQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl2_APIENTRY *glExtGetBuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl2_APIENTRY *glExtGetRenderbuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl2_APIENTRY *glExtGetFramebuffersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl2_APIENTRY *glExtGetTexLevelParameterivQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLint, GLenum, GLint*); +typedef void (gl2_APIENTRY *glExtTexObjectStateOverrideiQCOM_client_proc_t) (void * ctx, GLenum, GLenum, GLint); +typedef void (gl2_APIENTRY *glExtGetTexSubImageQCOM_client_proc_t) (void * ctx, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); +typedef void (gl2_APIENTRY *glExtGetBufferPointervQCOM_client_proc_t) (void * ctx, GLenum, GLvoidptr*); +typedef void (gl2_APIENTRY *glExtGetShadersQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef void (gl2_APIENTRY *glExtGetProgramsQCOM_client_proc_t) (void * ctx, GLuint*, GLint, GLint*); +typedef GLboolean (gl2_APIENTRY *glExtIsProgramBinaryQCOM_client_proc_t) (void * ctx, GLuint); +typedef void (gl2_APIENTRY *glExtGetProgramBinarySourceQCOM_client_proc_t) (void * ctx, GLuint, GLenum, GLchar*, GLint*); +typedef void (gl2_APIENTRY *glStartTilingQCOM_client_proc_t) (void * ctx, GLuint, GLuint, GLuint, GLuint, GLbitfield); +typedef void (gl2_APIENTRY *glEndTilingQCOM_client_proc_t) (void * ctx, GLbitfield); +typedef void (gl2_APIENTRY *glVertexAttribPointerData_client_proc_t) (void * ctx, GLuint, GLint, GLenum, GLboolean, GLsizei, void*, GLuint); +typedef void (gl2_APIENTRY *glVertexAttribPointerOffset_client_proc_t) (void * ctx, GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint); +typedef void (gl2_APIENTRY *glDrawElementsOffset_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, GLuint); +typedef void (gl2_APIENTRY *glDrawElementsData_client_proc_t) (void * ctx, GLenum, GLsizei, GLenum, void*, GLuint); +typedef void (gl2_APIENTRY *glGetCompressedTextureFormats_client_proc_t) (void * ctx, int, GLint*); +typedef void (gl2_APIENTRY *glShaderString_client_proc_t) (void * ctx, GLuint, const GLchar*, GLsizei); +typedef int (gl2_APIENTRY *glFinishRoundTrip_client_proc_t) (void * ctx); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.cpp new file mode 100644 index 0000000..615dcc1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.cpp @@ -0,0 +1,5191 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include +#include "gl2_opcodes.h" + +#include "gl2_enc.h" + + +#include + +namespace { + +void enc_unsupported() +{ + ALOGE("Function is unsupported\n"); +} + +void glActiveTexture_enc(void *self , GLenum texture) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glActiveTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &texture, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glAttachShader_enc(void *self , GLuint program, GLuint shader) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glAttachShader;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &shader, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindAttribLocation_enc(void *self , GLuint program, GLuint index, const GLchar* name) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_name = (strlen(name) + 1); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_name + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindAttribLocation;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &index, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_name; ptr += 4; + memcpy(ptr, name, __size_name);ptr += __size_name; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindBuffer_enc(void *self , GLenum target, GLuint buffer) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &buffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindFramebuffer_enc(void *self , GLenum target, GLuint framebuffer) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindFramebuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &framebuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindRenderbuffer_enc(void *self , GLenum target, GLuint renderbuffer) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &renderbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindTexture_enc(void *self , GLenum target, GLuint texture) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &texture, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendColor;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendEquation_enc(void *self , GLenum mode) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendEquation;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendEquationSeparate_enc(void *self , GLenum modeRGB, GLenum modeAlpha) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendEquationSeparate;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &modeRGB, 4); ptr += 4; + memcpy(ptr, &modeAlpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendFunc_enc(void *self , GLenum sfactor, GLenum dfactor) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &sfactor, 4); ptr += 4; + memcpy(ptr, &dfactor, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBlendFuncSeparate_enc(void *self , GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBlendFuncSeparate;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &srcRGB, 4); ptr += 4; + memcpy(ptr, &dstRGB, 4); ptr += 4; + memcpy(ptr, &srcAlpha, 4); ptr += 4; + memcpy(ptr, &dstAlpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBufferData_enc(void *self , GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? size : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4); + ptr = buf; + int tmp = OP_glBufferData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_data,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_data,4); + if (data != NULL) { + stream->writeFully(data, __size_data); + if (useChecksum) checksumCalculator->addBuffer(data, __size_data); + } + buf = stream->alloc(4); + ptr = buf; + memcpy(ptr, &usage, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glBufferSubData_enc(void *self , GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? size : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glBufferSubData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_data,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_data,4); + if (data != NULL) { + stream->writeFully(data, __size_data); + if (useChecksum) checksumCalculator->addBuffer(data, __size_data); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +GLenum glCheckFramebufferStatus_enc(void *self , GLenum target) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCheckFramebufferStatus;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLenum retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glCheckFramebufferStatus: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glClear_enc(void *self , GLbitfield mask) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClear;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearColor_enc(void *self , GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearColor;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 4); ptr += 4; + memcpy(ptr, &green, 4); ptr += 4; + memcpy(ptr, &blue, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearDepthf_enc(void *self , GLclampf depth) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearDepthf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &depth, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glClearStencil_enc(void *self , GLint s) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glClearStencil;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &s, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glColorMask_enc(void *self , GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 1 + 1 + 1 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glColorMask;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &red, 1); ptr += 1; + memcpy(ptr, &green, 1); ptr += 1; + memcpy(ptr, &blue, 1); ptr += 1; + memcpy(ptr, &alpha, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCompileShader_enc(void *self , GLuint shader) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCompileShader;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shader, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCompressedTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? imageSize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glCompressedTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + memcpy(ptr, &imageSize, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_data,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_data,4); + if (data != NULL) { + stream->writeFully(data, __size_data); + if (useChecksum) checksumCalculator->addBuffer(data, __size_data); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glCompressedTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? imageSize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glCompressedTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &imageSize, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_data,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_data,4); + if (data != NULL) { + stream->writeFully(data, __size_data); + if (useChecksum) checksumCalculator->addBuffer(data, __size_data); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glCopyTexImage2D_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCopyTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCopyTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCopyTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLuint glCreateProgram_enc(void *self ) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCreateProgram;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLuint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glCreateProgram: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLuint glCreateShader_enc(void *self , GLenum type) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCreateShader;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLuint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glCreateShader: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glCullFace_enc(void *self , GLenum mode) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCullFace;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteBuffers_enc(void *self , GLsizei n, const GLuint* buffers) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_buffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteBuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_buffers; ptr += 4; + memcpy(ptr, buffers, __size_buffers);ptr += __size_buffers; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteFramebuffers_enc(void *self , GLsizei n, const GLuint* framebuffers) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_framebuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_framebuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteFramebuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_framebuffers; ptr += 4; + memcpy(ptr, framebuffers, __size_framebuffers);ptr += __size_framebuffers; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteProgram_enc(void *self , GLuint program) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteProgram;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteRenderbuffers_enc(void *self , GLsizei n, const GLuint* renderbuffers) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_renderbuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_renderbuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteRenderbuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4; + memcpy(ptr, renderbuffers, __size_renderbuffers);ptr += __size_renderbuffers; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteShader_enc(void *self , GLuint shader) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteShader;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shader, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteTextures_enc(void *self , GLsizei n, const GLuint* textures) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_textures = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_textures + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteTextures;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_textures; ptr += 4; + memcpy(ptr, textures, __size_textures);ptr += __size_textures; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthFunc_enc(void *self , GLenum func) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthMask_enc(void *self , GLboolean flag) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthMask;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &flag, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDepthRangef_enc(void *self , GLclampf zNear, GLclampf zFar) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDepthRangef;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &zNear, 4); ptr += 4; + memcpy(ptr, &zFar, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDetachShader_enc(void *self , GLuint program, GLuint shader) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDetachShader;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &shader, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDisable_enc(void *self , GLenum cap) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDisable;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &cap, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDisableVertexAttribArray_enc(void *self , GLuint index) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDisableVertexAttribArray;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &index, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawArrays_enc(void *self , GLenum mode, GLint first, GLsizei count) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawArrays;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + memcpy(ptr, &first, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEnable_enc(void *self , GLenum cap) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEnable;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &cap, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEnableVertexAttribArray_enc(void *self , GLuint index) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEnableVertexAttribArray;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &index, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFinish_enc(void *self ) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFinish;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFlush_enc(void *self ) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFlush;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFramebufferRenderbuffer_enc(void *self , GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFramebufferRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &renderbuffertarget, 4); ptr += 4; + memcpy(ptr, &renderbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFramebufferTexture2D_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFramebufferTexture2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &textarget, 4); ptr += 4; + memcpy(ptr, &texture, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glFrontFace_enc(void *self , GLenum mode) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFrontFace;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenBuffers_enc(void *self , GLsizei n, GLuint* buffers) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_buffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenBuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_buffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(buffers, __size_buffers); + if (useChecksum) checksumCalculator->addBuffer(buffers, __size_buffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenBuffers: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGenerateMipmap_enc(void *self , GLenum target) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenerateMipmap;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenFramebuffers_enc(void *self , GLsizei n, GLuint* framebuffers) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_framebuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_framebuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenFramebuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_framebuffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(framebuffers, __size_framebuffers); + if (useChecksum) checksumCalculator->addBuffer(framebuffers, __size_framebuffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenFramebuffers: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGenRenderbuffers_enc(void *self , GLsizei n, GLuint* renderbuffers) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_renderbuffers = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_renderbuffers + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenRenderbuffers;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_renderbuffers; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(renderbuffers, __size_renderbuffers); + if (useChecksum) checksumCalculator->addBuffer(renderbuffers, __size_renderbuffers); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenRenderbuffers: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGenTextures_enc(void *self , GLsizei n, GLuint* textures) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_textures = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_textures + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenTextures;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_textures; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(textures, __size_textures); + if (useChecksum) checksumCalculator->addBuffer(textures, __size_textures); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenTextures: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetActiveAttrib_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0); + const unsigned int __size_size = ((size != NULL) ? (sizeof(GLint)) : 0); + const unsigned int __size_type = ((type != NULL) ? (sizeof(GLenum)) : 0); + const unsigned int __size_name = ((name != NULL) ? bufsize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_length + __size_size + __size_type + __size_name + 4*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetActiveAttrib;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &index, 4); ptr += 4; + memcpy(ptr, &bufsize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_length; ptr += 4; + *(unsigned int *)(ptr) = __size_size; ptr += 4; + *(unsigned int *)(ptr) = __size_type; ptr += 4; + *(unsigned int *)(ptr) = __size_name; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + if (length != NULL) { + stream->readback(length, __size_length); + if (useChecksum) checksumCalculator->addBuffer(length, __size_length); + } + if (size != NULL) { + stream->readback(size, __size_size); + if (useChecksum) checksumCalculator->addBuffer(size, __size_size); + } + if (type != NULL) { + stream->readback(type, __size_type); + if (useChecksum) checksumCalculator->addBuffer(type, __size_type); + } + if (name != NULL) { + stream->readback(name, __size_name); + if (useChecksum) checksumCalculator->addBuffer(name, __size_name); + } + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetActiveAttrib: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetActiveUniform_enc(void *self , GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0); + const unsigned int __size_size = ((size != NULL) ? (sizeof(GLint)) : 0); + const unsigned int __size_type = ((type != NULL) ? (sizeof(GLenum)) : 0); + const unsigned int __size_name = ((name != NULL) ? bufsize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_length + __size_size + __size_type + __size_name + 4*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetActiveUniform;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &index, 4); ptr += 4; + memcpy(ptr, &bufsize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_length; ptr += 4; + *(unsigned int *)(ptr) = __size_size; ptr += 4; + *(unsigned int *)(ptr) = __size_type; ptr += 4; + *(unsigned int *)(ptr) = __size_name; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + if (length != NULL) { + stream->readback(length, __size_length); + if (useChecksum) checksumCalculator->addBuffer(length, __size_length); + } + if (size != NULL) { + stream->readback(size, __size_size); + if (useChecksum) checksumCalculator->addBuffer(size, __size_size); + } + if (type != NULL) { + stream->readback(type, __size_type); + if (useChecksum) checksumCalculator->addBuffer(type, __size_type); + } + if (name != NULL) { + stream->readback(name, __size_name); + if (useChecksum) checksumCalculator->addBuffer(name, __size_name); + } + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetActiveUniform: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetAttachedShaders_enc(void *self , GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_count = ((count != NULL) ? (sizeof(GLsizei)) : 0); + const unsigned int __size_shaders = (maxcount*sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_count + __size_shaders + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetAttachedShaders;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &maxcount, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_count; ptr += 4; + *(unsigned int *)(ptr) = __size_shaders; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + if (count != NULL) { + stream->readback(count, __size_count); + if (useChecksum) checksumCalculator->addBuffer(count, __size_count); + } + stream->readback(shaders, __size_shaders); + if (useChecksum) checksumCalculator->addBuffer(shaders, __size_shaders); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetAttachedShaders: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +int glGetAttribLocation_enc(void *self , GLuint program, const GLchar* name) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_name = (strlen(name) + 1); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_name + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetAttribLocation;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_name; ptr += 4; + memcpy(ptr, name, __size_name);ptr += __size_name; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetAttribLocation: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glGetBooleanv_enc(void *self , GLenum pname, GLboolean* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLboolean)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetBooleanv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetBooleanv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetBufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetBufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetBufferParameteriv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +GLenum glGetError_enc(void *self ) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetError;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLenum retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetError: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glGetFloatv_enc(void *self , GLenum pname, GLfloat* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetFloatv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetFloatv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetFramebufferAttachmentParameteriv_enc(void *self , GLenum target, GLenum attachment, GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetFramebufferAttachmentParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetFramebufferAttachmentParameteriv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetIntegerv_enc(void *self , GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetIntegerv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetIntegerv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetProgramiv_enc(void *self , GLuint program, GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = sizeof(GLint); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetProgramiv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetProgramiv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetProgramInfoLog_enc(void *self , GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_length = ((length != NULL) ? sizeof(GLsizei) : 0); + const unsigned int __size_infolog = bufsize; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_length + __size_infolog + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetProgramInfoLog;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &bufsize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_length; ptr += 4; + *(unsigned int *)(ptr) = __size_infolog; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + if (length != NULL) { + stream->readback(length, __size_length); + if (useChecksum) checksumCalculator->addBuffer(length, __size_length); + } + stream->readback(infolog, __size_infolog); + if (useChecksum) checksumCalculator->addBuffer(infolog, __size_infolog); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetProgramInfoLog: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetRenderbufferParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = sizeof(GLint); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetRenderbufferParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetRenderbufferParameteriv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetShaderiv_enc(void *self , GLuint shader, GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = sizeof(GLint); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetShaderiv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shader, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetShaderiv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetShaderInfoLog_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0); + const unsigned int __size_infolog = bufsize; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_length + __size_infolog + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetShaderInfoLog;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shader, 4); ptr += 4; + memcpy(ptr, &bufsize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_length; ptr += 4; + *(unsigned int *)(ptr) = __size_infolog; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + if (length != NULL) { + stream->readback(length, __size_length); + if (useChecksum) checksumCalculator->addBuffer(length, __size_length); + } + stream->readback(infolog, __size_infolog); + if (useChecksum) checksumCalculator->addBuffer(infolog, __size_infolog); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetShaderInfoLog: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetShaderPrecisionFormat_enc(void *self , GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_range = (2 * sizeof(GLint)); + const unsigned int __size_precision = (sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_range + __size_precision + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetShaderPrecisionFormat;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shadertype, 4); ptr += 4; + memcpy(ptr, &precisiontype, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_range; ptr += 4; + *(unsigned int *)(ptr) = __size_precision; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(range, __size_range); + if (useChecksum) checksumCalculator->addBuffer(range, __size_range); + stream->readback(precision, __size_precision); + if (useChecksum) checksumCalculator->addBuffer(precision, __size_precision); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetShaderPrecisionFormat: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetShaderSource_enc(void *self , GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_length = ((length != NULL) ? (sizeof(GLsizei)) : 0); + const unsigned int __size_source = bufsize; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_length + __size_source + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetShaderSource;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shader, 4); ptr += 4; + memcpy(ptr, &bufsize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_length; ptr += 4; + *(unsigned int *)(ptr) = __size_source; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + if (length != NULL) { + stream->readback(length, __size_length); + if (useChecksum) checksumCalculator->addBuffer(length, __size_length); + } + stream->readback(source, __size_source); + if (useChecksum) checksumCalculator->addBuffer(source, __size_source); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetShaderSource: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexParameterfv_enc(void *self , GLenum target, GLenum pname, GLfloat* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexParameterfv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetTexParameteriv_enc(void *self , GLenum target, GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetTexParameteriv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetUniformfv_enc(void *self , GLuint program, GLint location, GLfloat* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = glSizeof(glesv2_enc::uniformType(self, program, location)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetUniformfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &location, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetUniformfv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetUniformiv_enc(void *self , GLuint program, GLint location, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = glSizeof(glesv2_enc::uniformType(self, program, location)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetUniformiv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + memcpy(ptr, &location, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetUniformiv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +int glGetUniformLocation_enc(void *self , GLuint program, const GLchar* name) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_name = (strlen(name) + 1); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_name + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetUniformLocation;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_name; ptr += 4; + memcpy(ptr, name, __size_name);ptr += __size_name; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetUniformLocation: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glGetVertexAttribfv_enc(void *self , GLuint index, GLenum pname, GLfloat* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetVertexAttribfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &index, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetVertexAttribfv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glGetVertexAttribiv_enc(void *self , GLuint index, GLenum pname, GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetVertexAttribiv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &index, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(params, __size_params); + if (useChecksum) checksumCalculator->addBuffer(params, __size_params); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetVertexAttribiv: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glHint_enc(void *self , GLenum target, GLenum mode) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glHint;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &mode, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLboolean glIsBuffer_enc(void *self , GLuint buffer) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &buffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsEnabled_enc(void *self , GLenum cap) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsEnabled;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &cap, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsEnabled: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsFramebuffer_enc(void *self , GLuint framebuffer) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsFramebuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &framebuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsFramebuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsProgram_enc(void *self , GLuint program) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsProgram;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsProgram: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsRenderbuffer_enc(void *self , GLuint renderbuffer) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &renderbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsRenderbuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsShader_enc(void *self , GLuint shader) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsShader;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shader, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsShader: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +GLboolean glIsTexture_enc(void *self , GLuint texture) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &texture, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsTexture: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glLineWidth_enc(void *self , GLfloat width) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLineWidth;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &width, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glLinkProgram_enc(void *self , GLuint program) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glLinkProgram;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPixelStorei_enc(void *self , GLenum pname, GLint param) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPixelStorei;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glPolygonOffset_enc(void *self , GLfloat factor, GLfloat units) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glPolygonOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &factor, 4); ptr += 4; + memcpy(ptr, &units, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = glesv2_enc::pixelDataSize(self, width, height, format, type, 1); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glReadPixels;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_pixels; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glReadPixels: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glReleaseShaderCompiler_enc(void *self ) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glReleaseShaderCompiler;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glRenderbufferStorage_enc(void *self , GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glRenderbufferStorage;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glSampleCoverage_enc(void *self , GLclampf value, GLboolean invert) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 1; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glSampleCoverage;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &value, 4); ptr += 4; + memcpy(ptr, &invert, 1); ptr += 1; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glScissor_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glScissor;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilFunc_enc(void *self , GLenum func, GLint ref, GLuint mask) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilFuncSeparate_enc(void *self , GLenum face, GLenum func, GLint ref, GLuint mask) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilFuncSeparate;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilMask_enc(void *self , GLuint mask) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilMask;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilMaskSeparate_enc(void *self , GLenum face, GLuint mask) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilMaskSeparate;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &mask, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilOp_enc(void *self , GLenum fail, GLenum zfail, GLenum zpass) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilOp;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &fail, 4); ptr += 4; + memcpy(ptr, &zfail, 4); ptr += 4; + memcpy(ptr, &zpass, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glStencilOpSeparate_enc(void *self , GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glStencilOpSeparate;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &face, 4); ptr += 4; + memcpy(ptr, &fail, 4); ptr += 4; + memcpy(ptr, &zfail, 4); ptr += 4; + memcpy(ptr, &zpass, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexImage2D_enc(void *self , GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize(self, width, height, format, type, 0) : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glTexImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_pixels,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4); + if (pixels != NULL) { + stream->writeFully(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glTexParameterf_enc(void *self , GLenum target, GLenum pname, GLfloat param) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterf;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameterfv_enc(void *self , GLenum target, GLenum pname, const GLfloat* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameterfv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameteri_enc(void *self , GLenum target, GLenum pname, GLint param) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameteri;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexParameteriv_enc(void *self , GLenum target, GLenum pname, const GLint* params) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_params = (glUtilsParamSize(pname) * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_params + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glTexParameteriv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &pname, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_params; ptr += 4; + memcpy(ptr, params, __size_params);ptr += __size_params; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glTexSubImage2D_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize(self, width, height, format, type, 0) : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glTexSubImage2D;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_pixels,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4); + if (pixels != NULL) { + stream->writeFully(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glUniform1f_enc(void *self , GLint location, GLfloat x) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform1f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform1fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (count * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform1fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform1i_enc(void *self , GLint location, GLint x) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform1i;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform1iv_enc(void *self , GLint location, GLsizei count, const GLint* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (count * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform1iv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform2f_enc(void *self , GLint location, GLfloat x, GLfloat y) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform2f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform2fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (count * 2 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform2fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform2i_enc(void *self , GLint location, GLint x, GLint y) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform2i;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform2iv_enc(void *self , GLint location, GLsizei count, const GLint* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (count * 2 * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform2iv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform3f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform3f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform3fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (count * 3 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform3fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform3i_enc(void *self , GLint location, GLint x, GLint y, GLint z) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform3i;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform3iv_enc(void *self , GLint location, GLsizei count, const GLint* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (3 * count * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform3iv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform4f_enc(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform4f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + memcpy(ptr, &w, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform4fv_enc(void *self , GLint location, GLsizei count, const GLfloat* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (4 * count * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform4fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform4i_enc(void *self , GLint location, GLint x, GLint y, GLint z, GLint w) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform4i;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + memcpy(ptr, &w, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniform4iv_enc(void *self , GLint location, GLsizei count, const GLint* v) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_v = (4 * count * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_v + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniform4iv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_v; ptr += 4; + memcpy(ptr, v, __size_v);ptr += __size_v; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniformMatrix2fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_value = (count * 4 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 1 + __size_value + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniformMatrix2fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + memcpy(ptr, &transpose, 1); ptr += 1; + *(unsigned int *)(ptr) = __size_value; ptr += 4; + memcpy(ptr, value, __size_value);ptr += __size_value; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniformMatrix3fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_value = (count * 9 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 1 + __size_value + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniformMatrix3fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + memcpy(ptr, &transpose, 1); ptr += 1; + *(unsigned int *)(ptr) = __size_value; ptr += 4; + memcpy(ptr, value, __size_value);ptr += __size_value; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUniformMatrix4fv_enc(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_value = (count * 16 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 1 + __size_value + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUniformMatrix4fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &location, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + memcpy(ptr, &transpose, 1); ptr += 1; + *(unsigned int *)(ptr) = __size_value; ptr += 4; + memcpy(ptr, value, __size_value);ptr += __size_value; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glUseProgram_enc(void *self , GLuint program) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUseProgram;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glValidateProgram_enc(void *self , GLuint program) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glValidateProgram;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &program, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib1f_enc(void *self , GLuint indx, GLfloat x) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib1f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib1fv_enc(void *self , GLuint indx, const GLfloat* values) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_values = (sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib1fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_values; ptr += 4; + memcpy(ptr, values, __size_values);ptr += __size_values; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib2f_enc(void *self , GLuint indx, GLfloat x, GLfloat y) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib2f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib2fv_enc(void *self , GLuint indx, const GLfloat* values) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_values = (2 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib2fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_values; ptr += 4; + memcpy(ptr, values, __size_values);ptr += __size_values; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib3f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib3f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib3fv_enc(void *self , GLuint indx, const GLfloat* values) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_values = (3 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib3fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_values; ptr += 4; + memcpy(ptr, values, __size_values);ptr += __size_values; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib4f_enc(void *self , GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib4f;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &z, 4); ptr += 4; + memcpy(ptr, &w, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttrib4fv_enc(void *self , GLuint indx, const GLfloat* values) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_values = (4 * sizeof(GLfloat)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_values + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttrib4fv;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_values; ptr += 4; + memcpy(ptr, values, __size_values);ptr += __size_values; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glViewport_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei height) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glViewport;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEGLImageTargetTexture2DOES_enc(void *self , GLenum target, GLeglImageOES image) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEGLImageTargetTexture2DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &image, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glEGLImageTargetRenderbufferStorageOES_enc(void *self , GLenum target, GLeglImageOES image) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glEGLImageTargetRenderbufferStorageOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &image, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +GLboolean glUnmapBufferOES_enc(void *self , GLenum target) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glUnmapBufferOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glUnmapBufferOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glTexImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &depth, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_pixels,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4); + if (pixels != NULL) { + stream->writeFully(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = ((pixels != NULL) ? glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &zoffset, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &depth, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_pixels,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4); + if (pixels != NULL) { + stream->writeFully(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glCopyTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glCopyTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &zoffset, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glCompressedTexImage3DOES_enc(void *self , GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? imageSize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glCompressedTexImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &internalformat, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &depth, 4); ptr += 4; + memcpy(ptr, &border, 4); ptr += 4; + memcpy(ptr, &imageSize, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_data,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_data,4); + if (data != NULL) { + stream->writeFully(data, __size_data); + if (useChecksum) checksumCalculator->addBuffer(data, __size_data); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glCompressedTexSubImage3DOES_enc(void *self , GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = ((data != NULL) ? imageSize : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_data + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_glCompressedTexSubImage3DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &xoffset, 4); ptr += 4; + memcpy(ptr, &yoffset, 4); ptr += 4; + memcpy(ptr, &zoffset, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &depth, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &imageSize, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_data,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_data,4); + if (data != NULL) { + stream->writeFully(data, __size_data); + if (useChecksum) checksumCalculator->addBuffer(data, __size_data); + } + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + +} + +void glFramebufferTexture3DOES_enc(void *self , GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFramebufferTexture3DOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &attachment, 4); ptr += 4; + memcpy(ptr, &textarget, 4); ptr += 4; + memcpy(ptr, &texture, 4); ptr += 4; + memcpy(ptr, &level, 4); ptr += 4; + memcpy(ptr, &zoffset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glBindVertexArrayOES_enc(void *self , GLuint array) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glBindVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &array, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDeleteVertexArraysOES_enc(void *self , GLsizei n, const GLuint* arrays) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_arrays = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_arrays + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDeleteVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_arrays; ptr += 4; + memcpy(ptr, arrays, __size_arrays);ptr += __size_arrays; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGenVertexArraysOES_enc(void *self , GLsizei n, GLuint* arrays) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_arrays = (n * sizeof(GLuint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_arrays + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGenVertexArraysOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &n, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_arrays; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(arrays, __size_arrays); + if (useChecksum) checksumCalculator->addBuffer(arrays, __size_arrays); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGenVertexArraysOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +GLboolean glIsVertexArrayOES_enc(void *self , GLuint array) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glIsVertexArrayOES;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &array, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLboolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glIsVertexArrayOES: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void glDiscardFramebufferEXT_enc(void *self , GLenum target, GLsizei numAttachments, const GLenum* attachments) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_attachments = (numAttachments * sizeof(GLenum)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + __size_attachments + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDiscardFramebufferEXT;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &numAttachments, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_attachments; ptr += 4; + memcpy(ptr, attachments, __size_attachments);ptr += __size_attachments; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttribPointerData_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 1 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttribPointerData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &normalized, 1); ptr += 1; + memcpy(ptr, &stride, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glVertexAttribPointerOffset_enc(void *self , GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 1 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glVertexAttribPointerOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &indx, 4); ptr += 4; + memcpy(ptr, &size, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &normalized, 1); ptr += 1; + memcpy(ptr, &stride, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawElementsOffset_enc(void *self , GLenum mode, GLsizei count, GLenum type, GLuint offset) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawElementsOffset;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + memcpy(ptr, &offset, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glDrawElementsData_enc(void *self , GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_data = datalen; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + __size_data + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glDrawElementsData;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &mode, 4); ptr += 4; + memcpy(ptr, &count, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_data; ptr += 4; + memcpy(ptr, data, __size_data);ptr += __size_data; + memcpy(ptr, &datalen, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void glGetCompressedTextureFormats_enc(void *self , int count, GLint* formats) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_formats = (count * sizeof(GLint)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_formats + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glGetCompressedTextureFormats;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &count, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_formats; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(formats, __size_formats); + if (useChecksum) checksumCalculator->addBuffer(formats, __size_formats); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glGetCompressedTextureFormats: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +void glShaderString_enc(void *self , GLuint shader, const GLchar* string, GLsizei len) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_string = len; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_string + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glShaderString;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &shader, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_string; ptr += 4; + memcpy(ptr, string, __size_string);ptr += __size_string; + memcpy(ptr, &len, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +int glFinishRoundTrip_enc(void *self ) +{ + + gl2_encoder_context_t *ctx = (gl2_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_glFinishRoundTrip;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("glFinishRoundTrip: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +} // namespace + +gl2_encoder_context_t::gl2_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator) +{ + m_stream = stream; + m_checksumCalculator = checksumCalculator; + + this->glActiveTexture = &glActiveTexture_enc; + this->glAttachShader = &glAttachShader_enc; + this->glBindAttribLocation = &glBindAttribLocation_enc; + this->glBindBuffer = &glBindBuffer_enc; + this->glBindFramebuffer = &glBindFramebuffer_enc; + this->glBindRenderbuffer = &glBindRenderbuffer_enc; + this->glBindTexture = &glBindTexture_enc; + this->glBlendColor = &glBlendColor_enc; + this->glBlendEquation = &glBlendEquation_enc; + this->glBlendEquationSeparate = &glBlendEquationSeparate_enc; + this->glBlendFunc = &glBlendFunc_enc; + this->glBlendFuncSeparate = &glBlendFuncSeparate_enc; + this->glBufferData = &glBufferData_enc; + this->glBufferSubData = &glBufferSubData_enc; + this->glCheckFramebufferStatus = &glCheckFramebufferStatus_enc; + this->glClear = &glClear_enc; + this->glClearColor = &glClearColor_enc; + this->glClearDepthf = &glClearDepthf_enc; + this->glClearStencil = &glClearStencil_enc; + this->glColorMask = &glColorMask_enc; + this->glCompileShader = &glCompileShader_enc; + this->glCompressedTexImage2D = &glCompressedTexImage2D_enc; + this->glCompressedTexSubImage2D = &glCompressedTexSubImage2D_enc; + this->glCopyTexImage2D = &glCopyTexImage2D_enc; + this->glCopyTexSubImage2D = &glCopyTexSubImage2D_enc; + this->glCreateProgram = &glCreateProgram_enc; + this->glCreateShader = &glCreateShader_enc; + this->glCullFace = &glCullFace_enc; + this->glDeleteBuffers = &glDeleteBuffers_enc; + this->glDeleteFramebuffers = &glDeleteFramebuffers_enc; + this->glDeleteProgram = &glDeleteProgram_enc; + this->glDeleteRenderbuffers = &glDeleteRenderbuffers_enc; + this->glDeleteShader = &glDeleteShader_enc; + this->glDeleteTextures = &glDeleteTextures_enc; + this->glDepthFunc = &glDepthFunc_enc; + this->glDepthMask = &glDepthMask_enc; + this->glDepthRangef = &glDepthRangef_enc; + this->glDetachShader = &glDetachShader_enc; + this->glDisable = &glDisable_enc; + this->glDisableVertexAttribArray = &glDisableVertexAttribArray_enc; + this->glDrawArrays = &glDrawArrays_enc; + this->glDrawElements = (glDrawElements_client_proc_t) &enc_unsupported; + this->glEnable = &glEnable_enc; + this->glEnableVertexAttribArray = &glEnableVertexAttribArray_enc; + this->glFinish = &glFinish_enc; + this->glFlush = &glFlush_enc; + this->glFramebufferRenderbuffer = &glFramebufferRenderbuffer_enc; + this->glFramebufferTexture2D = &glFramebufferTexture2D_enc; + this->glFrontFace = &glFrontFace_enc; + this->glGenBuffers = &glGenBuffers_enc; + this->glGenerateMipmap = &glGenerateMipmap_enc; + this->glGenFramebuffers = &glGenFramebuffers_enc; + this->glGenRenderbuffers = &glGenRenderbuffers_enc; + this->glGenTextures = &glGenTextures_enc; + this->glGetActiveAttrib = &glGetActiveAttrib_enc; + this->glGetActiveUniform = &glGetActiveUniform_enc; + this->glGetAttachedShaders = &glGetAttachedShaders_enc; + this->glGetAttribLocation = &glGetAttribLocation_enc; + this->glGetBooleanv = &glGetBooleanv_enc; + this->glGetBufferParameteriv = &glGetBufferParameteriv_enc; + this->glGetError = &glGetError_enc; + this->glGetFloatv = &glGetFloatv_enc; + this->glGetFramebufferAttachmentParameteriv = &glGetFramebufferAttachmentParameteriv_enc; + this->glGetIntegerv = &glGetIntegerv_enc; + this->glGetProgramiv = &glGetProgramiv_enc; + this->glGetProgramInfoLog = &glGetProgramInfoLog_enc; + this->glGetRenderbufferParameteriv = &glGetRenderbufferParameteriv_enc; + this->glGetShaderiv = &glGetShaderiv_enc; + this->glGetShaderInfoLog = &glGetShaderInfoLog_enc; + this->glGetShaderPrecisionFormat = &glGetShaderPrecisionFormat_enc; + this->glGetShaderSource = &glGetShaderSource_enc; + this->glGetString = (glGetString_client_proc_t) &enc_unsupported; + this->glGetTexParameterfv = &glGetTexParameterfv_enc; + this->glGetTexParameteriv = &glGetTexParameteriv_enc; + this->glGetUniformfv = &glGetUniformfv_enc; + this->glGetUniformiv = &glGetUniformiv_enc; + this->glGetUniformLocation = &glGetUniformLocation_enc; + this->glGetVertexAttribfv = &glGetVertexAttribfv_enc; + this->glGetVertexAttribiv = &glGetVertexAttribiv_enc; + this->glGetVertexAttribPointerv = (glGetVertexAttribPointerv_client_proc_t) &enc_unsupported; + this->glHint = &glHint_enc; + this->glIsBuffer = &glIsBuffer_enc; + this->glIsEnabled = &glIsEnabled_enc; + this->glIsFramebuffer = &glIsFramebuffer_enc; + this->glIsProgram = &glIsProgram_enc; + this->glIsRenderbuffer = &glIsRenderbuffer_enc; + this->glIsShader = &glIsShader_enc; + this->glIsTexture = &glIsTexture_enc; + this->glLineWidth = &glLineWidth_enc; + this->glLinkProgram = &glLinkProgram_enc; + this->glPixelStorei = &glPixelStorei_enc; + this->glPolygonOffset = &glPolygonOffset_enc; + this->glReadPixels = &glReadPixels_enc; + this->glReleaseShaderCompiler = &glReleaseShaderCompiler_enc; + this->glRenderbufferStorage = &glRenderbufferStorage_enc; + this->glSampleCoverage = &glSampleCoverage_enc; + this->glScissor = &glScissor_enc; + this->glShaderBinary = (glShaderBinary_client_proc_t) &enc_unsupported; + this->glShaderSource = (glShaderSource_client_proc_t) &enc_unsupported; + this->glStencilFunc = &glStencilFunc_enc; + this->glStencilFuncSeparate = &glStencilFuncSeparate_enc; + this->glStencilMask = &glStencilMask_enc; + this->glStencilMaskSeparate = &glStencilMaskSeparate_enc; + this->glStencilOp = &glStencilOp_enc; + this->glStencilOpSeparate = &glStencilOpSeparate_enc; + this->glTexImage2D = &glTexImage2D_enc; + this->glTexParameterf = &glTexParameterf_enc; + this->glTexParameterfv = &glTexParameterfv_enc; + this->glTexParameteri = &glTexParameteri_enc; + this->glTexParameteriv = &glTexParameteriv_enc; + this->glTexSubImage2D = &glTexSubImage2D_enc; + this->glUniform1f = &glUniform1f_enc; + this->glUniform1fv = &glUniform1fv_enc; + this->glUniform1i = &glUniform1i_enc; + this->glUniform1iv = &glUniform1iv_enc; + this->glUniform2f = &glUniform2f_enc; + this->glUniform2fv = &glUniform2fv_enc; + this->glUniform2i = &glUniform2i_enc; + this->glUniform2iv = &glUniform2iv_enc; + this->glUniform3f = &glUniform3f_enc; + this->glUniform3fv = &glUniform3fv_enc; + this->glUniform3i = &glUniform3i_enc; + this->glUniform3iv = &glUniform3iv_enc; + this->glUniform4f = &glUniform4f_enc; + this->glUniform4fv = &glUniform4fv_enc; + this->glUniform4i = &glUniform4i_enc; + this->glUniform4iv = &glUniform4iv_enc; + this->glUniformMatrix2fv = &glUniformMatrix2fv_enc; + this->glUniformMatrix3fv = &glUniformMatrix3fv_enc; + this->glUniformMatrix4fv = &glUniformMatrix4fv_enc; + this->glUseProgram = &glUseProgram_enc; + this->glValidateProgram = &glValidateProgram_enc; + this->glVertexAttrib1f = &glVertexAttrib1f_enc; + this->glVertexAttrib1fv = &glVertexAttrib1fv_enc; + this->glVertexAttrib2f = &glVertexAttrib2f_enc; + this->glVertexAttrib2fv = &glVertexAttrib2fv_enc; + this->glVertexAttrib3f = &glVertexAttrib3f_enc; + this->glVertexAttrib3fv = &glVertexAttrib3fv_enc; + this->glVertexAttrib4f = &glVertexAttrib4f_enc; + this->glVertexAttrib4fv = &glVertexAttrib4fv_enc; + this->glVertexAttribPointer = (glVertexAttribPointer_client_proc_t) &enc_unsupported; + this->glViewport = &glViewport_enc; + this->glEGLImageTargetTexture2DOES = &glEGLImageTargetTexture2DOES_enc; + this->glEGLImageTargetRenderbufferStorageOES = &glEGLImageTargetRenderbufferStorageOES_enc; + this->glGetProgramBinaryOES = (glGetProgramBinaryOES_client_proc_t) &enc_unsupported; + this->glProgramBinaryOES = (glProgramBinaryOES_client_proc_t) &enc_unsupported; + this->glMapBufferOES = (glMapBufferOES_client_proc_t) &enc_unsupported; + this->glUnmapBufferOES = &glUnmapBufferOES_enc; + this->glTexImage3DOES = &glTexImage3DOES_enc; + this->glTexSubImage3DOES = &glTexSubImage3DOES_enc; + this->glCopyTexSubImage3DOES = &glCopyTexSubImage3DOES_enc; + this->glCompressedTexImage3DOES = &glCompressedTexImage3DOES_enc; + this->glCompressedTexSubImage3DOES = &glCompressedTexSubImage3DOES_enc; + this->glFramebufferTexture3DOES = &glFramebufferTexture3DOES_enc; + this->glBindVertexArrayOES = &glBindVertexArrayOES_enc; + this->glDeleteVertexArraysOES = &glDeleteVertexArraysOES_enc; + this->glGenVertexArraysOES = &glGenVertexArraysOES_enc; + this->glIsVertexArrayOES = &glIsVertexArrayOES_enc; + this->glDiscardFramebufferEXT = &glDiscardFramebufferEXT_enc; + this->glMultiDrawArraysEXT = (glMultiDrawArraysEXT_client_proc_t) &enc_unsupported; + this->glMultiDrawElementsEXT = (glMultiDrawElementsEXT_client_proc_t) &enc_unsupported; + this->glGetPerfMonitorGroupsAMD = (glGetPerfMonitorGroupsAMD_client_proc_t) &enc_unsupported; + this->glGetPerfMonitorCountersAMD = (glGetPerfMonitorCountersAMD_client_proc_t) &enc_unsupported; + this->glGetPerfMonitorGroupStringAMD = (glGetPerfMonitorGroupStringAMD_client_proc_t) &enc_unsupported; + this->glGetPerfMonitorCounterStringAMD = (glGetPerfMonitorCounterStringAMD_client_proc_t) &enc_unsupported; + this->glGetPerfMonitorCounterInfoAMD = (glGetPerfMonitorCounterInfoAMD_client_proc_t) &enc_unsupported; + this->glGenPerfMonitorsAMD = (glGenPerfMonitorsAMD_client_proc_t) &enc_unsupported; + this->glDeletePerfMonitorsAMD = (glDeletePerfMonitorsAMD_client_proc_t) &enc_unsupported; + this->glSelectPerfMonitorCountersAMD = (glSelectPerfMonitorCountersAMD_client_proc_t) &enc_unsupported; + this->glBeginPerfMonitorAMD = (glBeginPerfMonitorAMD_client_proc_t) &enc_unsupported; + this->glEndPerfMonitorAMD = (glEndPerfMonitorAMD_client_proc_t) &enc_unsupported; + this->glGetPerfMonitorCounterDataAMD = (glGetPerfMonitorCounterDataAMD_client_proc_t) &enc_unsupported; + this->glRenderbufferStorageMultisampleIMG = (glRenderbufferStorageMultisampleIMG_client_proc_t) &enc_unsupported; + this->glFramebufferTexture2DMultisampleIMG = (glFramebufferTexture2DMultisampleIMG_client_proc_t) &enc_unsupported; + this->glDeleteFencesNV = (glDeleteFencesNV_client_proc_t) &enc_unsupported; + this->glGenFencesNV = (glGenFencesNV_client_proc_t) &enc_unsupported; + this->glIsFenceNV = (glIsFenceNV_client_proc_t) &enc_unsupported; + this->glTestFenceNV = (glTestFenceNV_client_proc_t) &enc_unsupported; + this->glGetFenceivNV = (glGetFenceivNV_client_proc_t) &enc_unsupported; + this->glFinishFenceNV = (glFinishFenceNV_client_proc_t) &enc_unsupported; + this->glSetFenceNV = (glSetFenceNV_client_proc_t) &enc_unsupported; + this->glCoverageMaskNV = (glCoverageMaskNV_client_proc_t) &enc_unsupported; + this->glCoverageOperationNV = (glCoverageOperationNV_client_proc_t) &enc_unsupported; + this->glGetDriverControlsQCOM = (glGetDriverControlsQCOM_client_proc_t) &enc_unsupported; + this->glGetDriverControlStringQCOM = (glGetDriverControlStringQCOM_client_proc_t) &enc_unsupported; + this->glEnableDriverControlQCOM = (glEnableDriverControlQCOM_client_proc_t) &enc_unsupported; + this->glDisableDriverControlQCOM = (glDisableDriverControlQCOM_client_proc_t) &enc_unsupported; + this->glExtGetTexturesQCOM = (glExtGetTexturesQCOM_client_proc_t) &enc_unsupported; + this->glExtGetBuffersQCOM = (glExtGetBuffersQCOM_client_proc_t) &enc_unsupported; + this->glExtGetRenderbuffersQCOM = (glExtGetRenderbuffersQCOM_client_proc_t) &enc_unsupported; + this->glExtGetFramebuffersQCOM = (glExtGetFramebuffersQCOM_client_proc_t) &enc_unsupported; + this->glExtGetTexLevelParameterivQCOM = (glExtGetTexLevelParameterivQCOM_client_proc_t) &enc_unsupported; + this->glExtTexObjectStateOverrideiQCOM = (glExtTexObjectStateOverrideiQCOM_client_proc_t) &enc_unsupported; + this->glExtGetTexSubImageQCOM = (glExtGetTexSubImageQCOM_client_proc_t) &enc_unsupported; + this->glExtGetBufferPointervQCOM = (glExtGetBufferPointervQCOM_client_proc_t) &enc_unsupported; + this->glExtGetShadersQCOM = (glExtGetShadersQCOM_client_proc_t) &enc_unsupported; + this->glExtGetProgramsQCOM = (glExtGetProgramsQCOM_client_proc_t) &enc_unsupported; + this->glExtIsProgramBinaryQCOM = (glExtIsProgramBinaryQCOM_client_proc_t) &enc_unsupported; + this->glExtGetProgramBinarySourceQCOM = (glExtGetProgramBinarySourceQCOM_client_proc_t) &enc_unsupported; + this->glStartTilingQCOM = (glStartTilingQCOM_client_proc_t) &enc_unsupported; + this->glEndTilingQCOM = (glEndTilingQCOM_client_proc_t) &enc_unsupported; + this->glVertexAttribPointerData = &glVertexAttribPointerData_enc; + this->glVertexAttribPointerOffset = &glVertexAttribPointerOffset_enc; + this->glDrawElementsOffset = &glDrawElementsOffset_enc; + this->glDrawElementsData = &glDrawElementsData_enc; + this->glGetCompressedTextureFormats = &glGetCompressedTextureFormats_enc; + this->glShaderString = &glShaderString_enc; + this->glFinishRoundTrip = &glFinishRoundTrip_enc; +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.h new file mode 100644 index 0000000..760d729 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_enc.h @@ -0,0 +1,24 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + +#ifndef GUARD_gl2_encoder_context_t +#define GUARD_gl2_encoder_context_t + +#include "IOStream.h" +#include "ChecksumCalculator.h" +#include "gl2_client_context.h" + + +#include +#include "glUtils.h" +#include "GL2EncoderUtils.h" + +struct gl2_encoder_context_t : public gl2_client_context_t { + + IOStream *m_stream; + ChecksumCalculator *m_checksumCalculator; + + gl2_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator); +}; + +#endif // GUARD_gl2_encoder_context_t \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_entry.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_entry.cpp new file mode 100644 index 0000000..3812aae --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_entry.cpp @@ -0,0 +1,1483 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#include +#include +#include "gl2_client_context.h" + +#ifndef GL_TRUE +extern "C" { + void glActiveTexture(GLenum texture); + void glAttachShader(GLuint program, GLuint shader); + void glBindAttribLocation(GLuint program, GLuint index, const GLchar* name); + void glBindBuffer(GLenum target, GLuint buffer); + void glBindFramebuffer(GLenum target, GLuint framebuffer); + void glBindRenderbuffer(GLenum target, GLuint renderbuffer); + void glBindTexture(GLenum target, GLuint texture); + void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void glBlendEquation(GLenum mode); + void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); + void glBlendFunc(GLenum sfactor, GLenum dfactor); + void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); + void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); + GLenum glCheckFramebufferStatus(GLenum target); + void glClear(GLbitfield mask); + void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void glClearDepthf(GLclampf depth); + void glClearStencil(GLint s); + void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + void glCompileShader(GLuint shader); + void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); + void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); + void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLuint glCreateProgram(); + GLuint glCreateShader(GLenum type); + void glCullFace(GLenum mode); + void glDeleteBuffers(GLsizei n, const GLuint* buffers); + void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers); + void glDeleteProgram(GLuint program); + void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers); + void glDeleteShader(GLuint shader); + void glDeleteTextures(GLsizei n, const GLuint* textures); + void glDepthFunc(GLenum func); + void glDepthMask(GLboolean flag); + void glDepthRangef(GLclampf zNear, GLclampf zFar); + void glDetachShader(GLuint program, GLuint shader); + void glDisable(GLenum cap); + void glDisableVertexAttribArray(GLuint index); + void glDrawArrays(GLenum mode, GLint first, GLsizei count); + void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); + void glEnable(GLenum cap); + void glEnableVertexAttribArray(GLuint index); + void glFinish(); + void glFlush(); + void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void glFrontFace(GLenum mode); + void glGenBuffers(GLsizei n, GLuint* buffers); + void glGenerateMipmap(GLenum target); + void glGenFramebuffers(GLsizei n, GLuint* framebuffers); + void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers); + void glGenTextures(GLsizei n, GLuint* textures); + void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); + void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); + void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); + int glGetAttribLocation(GLuint program, const GLchar* name); + void glGetBooleanv(GLenum pname, GLboolean* params); + void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params); + GLenum glGetError(); + void glGetFloatv(GLenum pname, GLfloat* params); + void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params); + void glGetIntegerv(GLenum pname, GLint* params); + void glGetProgramiv(GLuint program, GLenum pname, GLint* params); + void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); + void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params); + void glGetShaderiv(GLuint shader, GLenum pname, GLint* params); + void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); + void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); + void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); + const GLubyte* glGetString(GLenum name); + void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params); + void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params); + void glGetUniformfv(GLuint program, GLint location, GLfloat* params); + void glGetUniformiv(GLuint program, GLint location, GLint* params); + int glGetUniformLocation(GLuint program, const GLchar* name); + void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); + void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); + void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer); + void glHint(GLenum target, GLenum mode); + GLboolean glIsBuffer(GLuint buffer); + GLboolean glIsEnabled(GLenum cap); + GLboolean glIsFramebuffer(GLuint framebuffer); + GLboolean glIsProgram(GLuint program); + GLboolean glIsRenderbuffer(GLuint renderbuffer); + GLboolean glIsShader(GLuint shader); + GLboolean glIsTexture(GLuint texture); + void glLineWidth(GLfloat width); + void glLinkProgram(GLuint program); + void glPixelStorei(GLenum pname, GLint param); + void glPolygonOffset(GLfloat factor, GLfloat units); + void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); + void glReleaseShaderCompiler(); + void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void glSampleCoverage(GLclampf value, GLboolean invert); + void glScissor(GLint x, GLint y, GLsizei width, GLsizei height); + void glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); + void glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); + void glStencilFunc(GLenum func, GLint ref, GLuint mask); + void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); + void glStencilMask(GLuint mask); + void glStencilMaskSeparate(GLenum face, GLuint mask); + void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); + void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); + void glTexParameterf(GLenum target, GLenum pname, GLfloat param); + void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); + void glTexParameteri(GLenum target, GLenum pname, GLint param); + void glTexParameteriv(GLenum target, GLenum pname, const GLint* params); + void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); + void glUniform1f(GLint location, GLfloat x); + void glUniform1fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform1i(GLint location, GLint x); + void glUniform1iv(GLint location, GLsizei count, const GLint* v); + void glUniform2f(GLint location, GLfloat x, GLfloat y); + void glUniform2fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform2i(GLint location, GLint x, GLint y); + void glUniform2iv(GLint location, GLsizei count, const GLint* v); + void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z); + void glUniform3fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform3i(GLint location, GLint x, GLint y, GLint z); + void glUniform3iv(GLint location, GLsizei count, const GLint* v); + void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void glUniform4fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w); + void glUniform4iv(GLint location, GLsizei count, const GLint* v); + void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void glUseProgram(GLuint program); + void glValidateProgram(GLuint program); + void glVertexAttrib1f(GLuint indx, GLfloat x); + void glVertexAttrib1fv(GLuint indx, const GLfloat* values); + void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); + void glVertexAttrib2fv(GLuint indx, const GLfloat* values); + void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); + void glVertexAttrib3fv(GLuint indx, const GLfloat* values); + void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void glVertexAttrib4fv(GLuint indx, const GLfloat* values); + void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); + void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); + void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); + void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); + void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary); + void glProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length); + void* glMapBufferOES(GLenum target, GLenum access); + GLboolean glUnmapBufferOES(GLenum target); + void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); + void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); + void glCopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); + void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); + void glFramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + void glBindVertexArrayOES(GLuint array); + void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays); + void glGenVertexArraysOES(GLsizei n, GLuint* arrays); + GLboolean glIsVertexArrayOES(GLuint array); + void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments); + void glMultiDrawArraysEXT(GLenum mode, const GLint* first, const GLsizei* count, GLsizei primcount); + void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices, GLsizei primcount); + void glGetPerfMonitorGroupsAMD(GLint* numGroups, GLsizei groupsSize, GLuint* groups); + void glGetPerfMonitorCountersAMD(GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters); + void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei* length, GLchar* groupString); + void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar* counterString); + void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid* data); + void glGenPerfMonitorsAMD(GLsizei n, GLuint* monitors); + void glDeletePerfMonitorsAMD(GLsizei n, GLuint* monitors); + void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList); + void glBeginPerfMonitorAMD(GLuint monitor); + void glEndPerfMonitorAMD(GLuint monitor); + void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten); + void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); + void glDeleteFencesNV(GLsizei n, const GLuint* fences); + void glGenFencesNV(GLsizei n, GLuint* fences); + GLboolean glIsFenceNV(GLuint fence); + GLboolean glTestFenceNV(GLuint fence); + void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params); + void glFinishFenceNV(GLuint fence); + void glSetFenceNV(GLuint fence, GLenum condition); + void glCoverageMaskNV(GLboolean mask); + void glCoverageOperationNV(GLenum operation); + void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls); + void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString); + void glEnableDriverControlQCOM(GLuint driverControl); + void glDisableDriverControlQCOM(GLuint driverControl); + void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures); + void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers); + void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers); + void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers); + void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params); + void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param); + void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels); + void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr* params); + void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders); + void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms); + GLboolean glExtIsProgramBinaryQCOM(GLuint program); + void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length); + void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); + void glEndTilingQCOM(GLbitfield preserveMask); + void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen); + void glVertexAttribPointerOffset(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset); + void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset); + void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen); + void glGetCompressedTextureFormats(int count, GLint* formats); + void glShaderString(GLuint shader, const GLchar* string, GLsizei len); + int glFinishRoundTrip(); +}; + +#endif +#ifndef GET_CONTEXT +static gl2_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; +void gl2_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } +#define GET_CONTEXT gl2_client_context_t * ctx = getCurrentContext() +#endif + +void glActiveTexture(GLenum texture) +{ + GET_CONTEXT; + ctx->glActiveTexture(ctx, texture); +} + +void glAttachShader(GLuint program, GLuint shader) +{ + GET_CONTEXT; + ctx->glAttachShader(ctx, program, shader); +} + +void glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) +{ + GET_CONTEXT; + ctx->glBindAttribLocation(ctx, program, index, name); +} + +void glBindBuffer(GLenum target, GLuint buffer) +{ + GET_CONTEXT; + ctx->glBindBuffer(ctx, target, buffer); +} + +void glBindFramebuffer(GLenum target, GLuint framebuffer) +{ + GET_CONTEXT; + ctx->glBindFramebuffer(ctx, target, framebuffer); +} + +void glBindRenderbuffer(GLenum target, GLuint renderbuffer) +{ + GET_CONTEXT; + ctx->glBindRenderbuffer(ctx, target, renderbuffer); +} + +void glBindTexture(GLenum target, GLuint texture) +{ + GET_CONTEXT; + ctx->glBindTexture(ctx, target, texture); +} + +void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + GET_CONTEXT; + ctx->glBlendColor(ctx, red, green, blue, alpha); +} + +void glBlendEquation(GLenum mode) +{ + GET_CONTEXT; + ctx->glBlendEquation(ctx, mode); +} + +void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) +{ + GET_CONTEXT; + ctx->glBlendEquationSeparate(ctx, modeRGB, modeAlpha); +} + +void glBlendFunc(GLenum sfactor, GLenum dfactor) +{ + GET_CONTEXT; + ctx->glBlendFunc(ctx, sfactor, dfactor); +} + +void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + GET_CONTEXT; + ctx->glBlendFuncSeparate(ctx, srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) +{ + GET_CONTEXT; + ctx->glBufferData(ctx, target, size, data, usage); +} + +void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glBufferSubData(ctx, target, offset, size, data); +} + +GLenum glCheckFramebufferStatus(GLenum target) +{ + GET_CONTEXT; + return ctx->glCheckFramebufferStatus(ctx, target); +} + +void glClear(GLbitfield mask) +{ + GET_CONTEXT; + ctx->glClear(ctx, mask); +} + +void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + GET_CONTEXT; + ctx->glClearColor(ctx, red, green, blue, alpha); +} + +void glClearDepthf(GLclampf depth) +{ + GET_CONTEXT; + ctx->glClearDepthf(ctx, depth); +} + +void glClearStencil(GLint s) +{ + GET_CONTEXT; + ctx->glClearStencil(ctx, s); +} + +void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + GET_CONTEXT; + ctx->glColorMask(ctx, red, green, blue, alpha); +} + +void glCompileShader(GLuint shader) +{ + GET_CONTEXT; + ctx->glCompileShader(ctx, shader); +} + +void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glCompressedTexImage2D(ctx, target, level, internalformat, width, height, border, imageSize, data); +} + +void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glCompressedTexSubImage2D(ctx, target, level, xoffset, yoffset, width, height, format, imageSize, data); +} + +void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + GET_CONTEXT; + ctx->glCopyTexImage2D(ctx, target, level, internalformat, x, y, width, height, border); +} + +void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glCopyTexSubImage2D(ctx, target, level, xoffset, yoffset, x, y, width, height); +} + +GLuint glCreateProgram() +{ + GET_CONTEXT; + return ctx->glCreateProgram(ctx); +} + +GLuint glCreateShader(GLenum type) +{ + GET_CONTEXT; + return ctx->glCreateShader(ctx, type); +} + +void glCullFace(GLenum mode) +{ + GET_CONTEXT; + ctx->glCullFace(ctx, mode); +} + +void glDeleteBuffers(GLsizei n, const GLuint* buffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteBuffers(ctx, n, buffers); +} + +void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteFramebuffers(ctx, n, framebuffers); +} + +void glDeleteProgram(GLuint program) +{ + GET_CONTEXT; + ctx->glDeleteProgram(ctx, program); +} + +void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteRenderbuffers(ctx, n, renderbuffers); +} + +void glDeleteShader(GLuint shader) +{ + GET_CONTEXT; + ctx->glDeleteShader(ctx, shader); +} + +void glDeleteTextures(GLsizei n, const GLuint* textures) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteTextures(ctx, n, textures); +} + +void glDepthFunc(GLenum func) +{ + GET_CONTEXT; + ctx->glDepthFunc(ctx, func); +} + +void glDepthMask(GLboolean flag) +{ + GET_CONTEXT; + ctx->glDepthMask(ctx, flag); +} + +void glDepthRangef(GLclampf zNear, GLclampf zFar) +{ + GET_CONTEXT; + ctx->glDepthRangef(ctx, zNear, zFar); +} + +void glDetachShader(GLuint program, GLuint shader) +{ + GET_CONTEXT; + ctx->glDetachShader(ctx, program, shader); +} + +void glDisable(GLenum cap) +{ + GET_CONTEXT; + ctx->glDisable(ctx, cap); +} + +void glDisableVertexAttribArray(GLuint index) +{ + GET_CONTEXT; + ctx->glDisableVertexAttribArray(ctx, index); +} + +void glDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + GET_CONTEXT; + ctx->glDrawArrays(ctx, mode, first, count); +} + +void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) +{ + GET_CONTEXT; + ctx->glDrawElements(ctx, mode, count, type, indices); +} + +void glEnable(GLenum cap) +{ + GET_CONTEXT; + ctx->glEnable(ctx, cap); +} + +void glEnableVertexAttribArray(GLuint index) +{ + GET_CONTEXT; + ctx->glEnableVertexAttribArray(ctx, index); +} + +void glFinish() +{ + GET_CONTEXT; + ctx->glFinish(ctx); +} + +void glFlush() +{ + GET_CONTEXT; + ctx->glFlush(ctx); +} + +void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + GET_CONTEXT; + ctx->glFramebufferRenderbuffer(ctx, target, attachment, renderbuffertarget, renderbuffer); +} + +void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + GET_CONTEXT; + ctx->glFramebufferTexture2D(ctx, target, attachment, textarget, texture, level); +} + +void glFrontFace(GLenum mode) +{ + GET_CONTEXT; + ctx->glFrontFace(ctx, mode); +} + +void glGenBuffers(GLsizei n, GLuint* buffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenBuffers(ctx, n, buffers); +} + +void glGenerateMipmap(GLenum target) +{ + GET_CONTEXT; + ctx->glGenerateMipmap(ctx, target); +} + +void glGenFramebuffers(GLsizei n, GLuint* framebuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenFramebuffers(ctx, n, framebuffers); +} + +void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenRenderbuffers(ctx, n, renderbuffers); +} + +void glGenTextures(GLsizei n, GLuint* textures) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenTextures(ctx, n, textures); +} + +void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +{ + GET_CONTEXT; + ctx->glGetActiveAttrib(ctx, program, index, bufsize, length, size, type, name); +} + +void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +{ + GET_CONTEXT; + ctx->glGetActiveUniform(ctx, program, index, bufsize, length, size, type, name); +} + +void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) +{ + GET_CONTEXT; + ctx->glGetAttachedShaders(ctx, program, maxcount, count, shaders); +} + +int glGetAttribLocation(GLuint program, const GLchar* name) +{ + GET_CONTEXT; + return ctx->glGetAttribLocation(ctx, program, name); +} + +void glGetBooleanv(GLenum pname, GLboolean* params) +{ + GET_CONTEXT; + ctx->glGetBooleanv(ctx, pname, params); +} + +void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetBufferParameteriv(ctx, target, pname, params); +} + +GLenum glGetError() +{ + GET_CONTEXT; + return ctx->glGetError(ctx); +} + +void glGetFloatv(GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetFloatv(ctx, pname, params); +} + +void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetFramebufferAttachmentParameteriv(ctx, target, attachment, pname, params); +} + +void glGetIntegerv(GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetIntegerv(ctx, pname, params); +} + +void glGetProgramiv(GLuint program, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetProgramiv(ctx, program, pname, params); +} + +void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) +{ + GET_CONTEXT; + ctx->glGetProgramInfoLog(ctx, program, bufsize, length, infolog); +} + +void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetRenderbufferParameteriv(ctx, target, pname, params); +} + +void glGetShaderiv(GLuint shader, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetShaderiv(ctx, shader, pname, params); +} + +void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) +{ + GET_CONTEXT; + ctx->glGetShaderInfoLog(ctx, shader, bufsize, length, infolog); +} + +void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +{ + GET_CONTEXT; + ctx->glGetShaderPrecisionFormat(ctx, shadertype, precisiontype, range, precision); +} + +void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) +{ + GET_CONTEXT; + ctx->glGetShaderSource(ctx, shader, bufsize, length, source); +} + +const GLubyte* glGetString(GLenum name) +{ + GET_CONTEXT; + return ctx->glGetString(ctx, name); +} + +void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetTexParameterfv(ctx, target, pname, params); +} + +void glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetTexParameteriv(ctx, target, pname, params); +} + +void glGetUniformfv(GLuint program, GLint location, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetUniformfv(ctx, program, location, params); +} + +void glGetUniformiv(GLuint program, GLint location, GLint* params) +{ + GET_CONTEXT; + ctx->glGetUniformiv(ctx, program, location, params); +} + +int glGetUniformLocation(GLuint program, const GLchar* name) +{ + GET_CONTEXT; + return ctx->glGetUniformLocation(ctx, program, name); +} + +void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) +{ + GET_CONTEXT; + ctx->glGetVertexAttribfv(ctx, index, pname, params); +} + +void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetVertexAttribiv(ctx, index, pname, params); +} + +void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) +{ + GET_CONTEXT; + ctx->glGetVertexAttribPointerv(ctx, index, pname, pointer); +} + +void glHint(GLenum target, GLenum mode) +{ + GET_CONTEXT; + ctx->glHint(ctx, target, mode); +} + +GLboolean glIsBuffer(GLuint buffer) +{ + GET_CONTEXT; + return ctx->glIsBuffer(ctx, buffer); +} + +GLboolean glIsEnabled(GLenum cap) +{ + GET_CONTEXT; + return ctx->glIsEnabled(ctx, cap); +} + +GLboolean glIsFramebuffer(GLuint framebuffer) +{ + GET_CONTEXT; + return ctx->glIsFramebuffer(ctx, framebuffer); +} + +GLboolean glIsProgram(GLuint program) +{ + GET_CONTEXT; + return ctx->glIsProgram(ctx, program); +} + +GLboolean glIsRenderbuffer(GLuint renderbuffer) +{ + GET_CONTEXT; + return ctx->glIsRenderbuffer(ctx, renderbuffer); +} + +GLboolean glIsShader(GLuint shader) +{ + GET_CONTEXT; + return ctx->glIsShader(ctx, shader); +} + +GLboolean glIsTexture(GLuint texture) +{ + GET_CONTEXT; + return ctx->glIsTexture(ctx, texture); +} + +void glLineWidth(GLfloat width) +{ + GET_CONTEXT; + ctx->glLineWidth(ctx, width); +} + +void glLinkProgram(GLuint program) +{ + GET_CONTEXT; + ctx->glLinkProgram(ctx, program); +} + +void glPixelStorei(GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glPixelStorei(ctx, pname, param); +} + +void glPolygonOffset(GLfloat factor, GLfloat units) +{ + GET_CONTEXT; + ctx->glPolygonOffset(ctx, factor, units); +} + +void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glReadPixels(ctx, x, y, width, height, format, type, pixels); +} + +void glReleaseShaderCompiler() +{ + GET_CONTEXT; + ctx->glReleaseShaderCompiler(ctx); +} + +void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glRenderbufferStorage(ctx, target, internalformat, width, height); +} + +void glSampleCoverage(GLclampf value, GLboolean invert) +{ + GET_CONTEXT; + ctx->glSampleCoverage(ctx, value, invert); +} + +void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glScissor(ctx, x, y, width, height); +} + +void glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length) +{ + GET_CONTEXT; + ctx->glShaderBinary(ctx, n, shaders, binaryformat, binary, length); +} + +void glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) +{ + GET_CONTEXT; + ctx->glShaderSource(ctx, shader, count, string, length); +} + +void glStencilFunc(GLenum func, GLint ref, GLuint mask) +{ + GET_CONTEXT; + ctx->glStencilFunc(ctx, func, ref, mask); +} + +void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + GET_CONTEXT; + ctx->glStencilFuncSeparate(ctx, face, func, ref, mask); +} + +void glStencilMask(GLuint mask) +{ + GET_CONTEXT; + ctx->glStencilMask(ctx, mask); +} + +void glStencilMaskSeparate(GLenum face, GLuint mask) +{ + GET_CONTEXT; + ctx->glStencilMaskSeparate(ctx, face, mask); +} + +void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CONTEXT; + ctx->glStencilOp(ctx, fail, zfail, zpass); +} + +void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + GET_CONTEXT; + ctx->glStencilOpSeparate(ctx, face, fail, zfail, zpass); +} + +void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glTexImage2D(ctx, target, level, internalformat, width, height, border, format, type, pixels); +} + +void glTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CONTEXT; + ctx->glTexParameterf(ctx, target, pname, param); +} + +void glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) +{ + GET_CONTEXT; + ctx->glTexParameterfv(ctx, target, pname, params); +} + +void glTexParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glTexParameteri(ctx, target, pname, param); +} + +void glTexParameteriv(GLenum target, GLenum pname, const GLint* params) +{ + GET_CONTEXT; + ctx->glTexParameteriv(ctx, target, pname, params); +} + +void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glTexSubImage2D(ctx, target, level, xoffset, yoffset, width, height, format, type, pixels); +} + +void glUniform1f(GLint location, GLfloat x) +{ + GET_CONTEXT; + ctx->glUniform1f(ctx, location, x); +} + +void glUniform1fv(GLint location, GLsizei count, const GLfloat* v) +{ + GET_CONTEXT; + ctx->glUniform1fv(ctx, location, count, v); +} + +void glUniform1i(GLint location, GLint x) +{ + GET_CONTEXT; + ctx->glUniform1i(ctx, location, x); +} + +void glUniform1iv(GLint location, GLsizei count, const GLint* v) +{ + GET_CONTEXT; + ctx->glUniform1iv(ctx, location, count, v); +} + +void glUniform2f(GLint location, GLfloat x, GLfloat y) +{ + GET_CONTEXT; + ctx->glUniform2f(ctx, location, x, y); +} + +void glUniform2fv(GLint location, GLsizei count, const GLfloat* v) +{ + GET_CONTEXT; + ctx->glUniform2fv(ctx, location, count, v); +} + +void glUniform2i(GLint location, GLint x, GLint y) +{ + GET_CONTEXT; + ctx->glUniform2i(ctx, location, x, y); +} + +void glUniform2iv(GLint location, GLsizei count, const GLint* v) +{ + GET_CONTEXT; + ctx->glUniform2iv(ctx, location, count, v); +} + +void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CONTEXT; + ctx->glUniform3f(ctx, location, x, y, z); +} + +void glUniform3fv(GLint location, GLsizei count, const GLfloat* v) +{ + GET_CONTEXT; + ctx->glUniform3fv(ctx, location, count, v); +} + +void glUniform3i(GLint location, GLint x, GLint y, GLint z) +{ + GET_CONTEXT; + ctx->glUniform3i(ctx, location, x, y, z); +} + +void glUniform3iv(GLint location, GLsizei count, const GLint* v) +{ + GET_CONTEXT; + ctx->glUniform3iv(ctx, location, count, v); +} + +void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CONTEXT; + ctx->glUniform4f(ctx, location, x, y, z, w); +} + +void glUniform4fv(GLint location, GLsizei count, const GLfloat* v) +{ + GET_CONTEXT; + ctx->glUniform4fv(ctx, location, count, v); +} + +void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + GET_CONTEXT; + ctx->glUniform4i(ctx, location, x, y, z, w); +} + +void glUniform4iv(GLint location, GLsizei count, const GLint* v) +{ + GET_CONTEXT; + ctx->glUniform4iv(ctx, location, count, v); +} + +void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + GET_CONTEXT; + ctx->glUniformMatrix2fv(ctx, location, count, transpose, value); +} + +void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + GET_CONTEXT; + ctx->glUniformMatrix3fv(ctx, location, count, transpose, value); +} + +void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + GET_CONTEXT; + ctx->glUniformMatrix4fv(ctx, location, count, transpose, value); +} + +void glUseProgram(GLuint program) +{ + GET_CONTEXT; + ctx->glUseProgram(ctx, program); +} + +void glValidateProgram(GLuint program) +{ + GET_CONTEXT; + ctx->glValidateProgram(ctx, program); +} + +void glVertexAttrib1f(GLuint indx, GLfloat x) +{ + GET_CONTEXT; + ctx->glVertexAttrib1f(ctx, indx, x); +} + +void glVertexAttrib1fv(GLuint indx, const GLfloat* values) +{ + GET_CONTEXT; + ctx->glVertexAttrib1fv(ctx, indx, values); +} + +void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) +{ + GET_CONTEXT; + ctx->glVertexAttrib2f(ctx, indx, x, y); +} + +void glVertexAttrib2fv(GLuint indx, const GLfloat* values) +{ + GET_CONTEXT; + ctx->glVertexAttrib2fv(ctx, indx, values); +} + +void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ + GET_CONTEXT; + ctx->glVertexAttrib3f(ctx, indx, x, y, z); +} + +void glVertexAttrib3fv(GLuint indx, const GLfloat* values) +{ + GET_CONTEXT; + ctx->glVertexAttrib3fv(ctx, indx, values); +} + +void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CONTEXT; + ctx->glVertexAttrib4f(ctx, indx, x, y, z, w); +} + +void glVertexAttrib4fv(GLuint indx, const GLfloat* values) +{ + GET_CONTEXT; + ctx->glVertexAttrib4fv(ctx, indx, values); +} + +void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) +{ + GET_CONTEXT; + ctx->glVertexAttribPointer(ctx, indx, size, type, normalized, stride, ptr); +} + +void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glViewport(ctx, x, y, width, height); +} + +void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +{ + GET_CONTEXT; + ctx->glEGLImageTargetTexture2DOES(ctx, target, image); +} + +void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + GET_CONTEXT; + ctx->glEGLImageTargetRenderbufferStorageOES(ctx, target, image); +} + +void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) +{ + GET_CONTEXT; + ctx->glGetProgramBinaryOES(ctx, program, bufSize, length, binaryFormat, binary); +} + +void glProgramBinaryOES(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length) +{ + GET_CONTEXT; + ctx->glProgramBinaryOES(ctx, program, binaryFormat, binary, length); +} + +void* glMapBufferOES(GLenum target, GLenum access) +{ + GET_CONTEXT; + return ctx->glMapBufferOES(ctx, target, access); +} + +GLboolean glUnmapBufferOES(GLenum target) +{ + GET_CONTEXT; + return ctx->glUnmapBufferOES(ctx, target); +} + +void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glTexImage3DOES(ctx, target, level, internalformat, width, height, depth, border, format, type, pixels); +} + +void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) +{ + GET_CONTEXT; + ctx->glTexSubImage3DOES(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); +} + +void glCopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glCopyTexSubImage3DOES(ctx, target, level, xoffset, yoffset, zoffset, x, y, width, height); +} + +void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glCompressedTexImage3DOES(ctx, target, level, internalformat, width, height, depth, border, imageSize, data); +} + +void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) +{ + GET_CONTEXT; + ctx->glCompressedTexSubImage3DOES(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); +} + +void glFramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) +{ + GET_CONTEXT; + ctx->glFramebufferTexture3DOES(ctx, target, attachment, textarget, texture, level, zoffset); +} + +void glBindVertexArrayOES(GLuint array) +{ + GET_CONTEXT; + ctx->glBindVertexArrayOES(ctx, array); +} + +void glDeleteVertexArraysOES(GLsizei n, const GLuint* arrays) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glDeleteVertexArraysOES(ctx, n, arrays); +} + +void glGenVertexArraysOES(GLsizei n, GLuint* arrays) +{ + GET_CONTEXT; + if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + ctx->glGenVertexArraysOES(ctx, n, arrays); +} + +GLboolean glIsVertexArrayOES(GLuint array) +{ + GET_CONTEXT; + return ctx->glIsVertexArrayOES(ctx, array); +} + +void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum* attachments) +{ + GET_CONTEXT; + ctx->glDiscardFramebufferEXT(ctx, target, numAttachments, attachments); +} + +void glMultiDrawArraysEXT(GLenum mode, const GLint* first, const GLsizei* count, GLsizei primcount) +{ + GET_CONTEXT; + ctx->glMultiDrawArraysEXT(ctx, mode, first, count, primcount); +} + +void glMultiDrawElementsEXT(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices, GLsizei primcount) +{ + GET_CONTEXT; + ctx->glMultiDrawElementsEXT(ctx, mode, count, type, indices, primcount); +} + +void glGetPerfMonitorGroupsAMD(GLint* numGroups, GLsizei groupsSize, GLuint* groups) +{ + GET_CONTEXT; + ctx->glGetPerfMonitorGroupsAMD(ctx, numGroups, groupsSize, groups); +} + +void glGetPerfMonitorCountersAMD(GLuint group, GLint* numCounters, GLint* maxActiveCounters, GLsizei counterSize, GLuint* counters) +{ + GET_CONTEXT; + ctx->glGetPerfMonitorCountersAMD(ctx, group, numCounters, maxActiveCounters, counterSize, counters); +} + +void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei* length, GLchar* groupString) +{ + GET_CONTEXT; + ctx->glGetPerfMonitorGroupStringAMD(ctx, group, bufSize, length, groupString); +} + +void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar* counterString) +{ + GET_CONTEXT; + ctx->glGetPerfMonitorCounterStringAMD(ctx, group, counter, bufSize, length, counterString); +} + +void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid* data) +{ + GET_CONTEXT; + ctx->glGetPerfMonitorCounterInfoAMD(ctx, group, counter, pname, data); +} + +void glGenPerfMonitorsAMD(GLsizei n, GLuint* monitors) +{ + GET_CONTEXT; + ctx->glGenPerfMonitorsAMD(ctx, n, monitors); +} + +void glDeletePerfMonitorsAMD(GLsizei n, GLuint* monitors) +{ + GET_CONTEXT; + ctx->glDeletePerfMonitorsAMD(ctx, n, monitors); +} + +void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* countersList) +{ + GET_CONTEXT; + ctx->glSelectPerfMonitorCountersAMD(ctx, monitor, enable, group, numCounters, countersList); +} + +void glBeginPerfMonitorAMD(GLuint monitor) +{ + GET_CONTEXT; + ctx->glBeginPerfMonitorAMD(ctx, monitor); +} + +void glEndPerfMonitorAMD(GLuint monitor) +{ + GET_CONTEXT; + ctx->glEndPerfMonitorAMD(ctx, monitor); +} + +void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint* bytesWritten) +{ + GET_CONTEXT; + ctx->glGetPerfMonitorCounterDataAMD(ctx, monitor, pname, dataSize, data, bytesWritten); +} + +void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +{ + GET_CONTEXT; + ctx->glRenderbufferStorageMultisampleIMG(ctx, target, samples, internalformat, width, height); +} + +void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +{ + GET_CONTEXT; + ctx->glFramebufferTexture2DMultisampleIMG(ctx, target, attachment, textarget, texture, level, samples); +} + +void glDeleteFencesNV(GLsizei n, const GLuint* fences) +{ + GET_CONTEXT; + ctx->glDeleteFencesNV(ctx, n, fences); +} + +void glGenFencesNV(GLsizei n, GLuint* fences) +{ + GET_CONTEXT; + ctx->glGenFencesNV(ctx, n, fences); +} + +GLboolean glIsFenceNV(GLuint fence) +{ + GET_CONTEXT; + return ctx->glIsFenceNV(ctx, fence); +} + +GLboolean glTestFenceNV(GLuint fence) +{ + GET_CONTEXT; + return ctx->glTestFenceNV(ctx, fence); +} + +void glGetFenceivNV(GLuint fence, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glGetFenceivNV(ctx, fence, pname, params); +} + +void glFinishFenceNV(GLuint fence) +{ + GET_CONTEXT; + ctx->glFinishFenceNV(ctx, fence); +} + +void glSetFenceNV(GLuint fence, GLenum condition) +{ + GET_CONTEXT; + ctx->glSetFenceNV(ctx, fence, condition); +} + +void glCoverageMaskNV(GLboolean mask) +{ + GET_CONTEXT; + ctx->glCoverageMaskNV(ctx, mask); +} + +void glCoverageOperationNV(GLenum operation) +{ + GET_CONTEXT; + ctx->glCoverageOperationNV(ctx, operation); +} + +void glGetDriverControlsQCOM(GLint* num, GLsizei size, GLuint* driverControls) +{ + GET_CONTEXT; + ctx->glGetDriverControlsQCOM(ctx, num, size, driverControls); +} + +void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei* length, GLchar* driverControlString) +{ + GET_CONTEXT; + ctx->glGetDriverControlStringQCOM(ctx, driverControl, bufSize, length, driverControlString); +} + +void glEnableDriverControlQCOM(GLuint driverControl) +{ + GET_CONTEXT; + ctx->glEnableDriverControlQCOM(ctx, driverControl); +} + +void glDisableDriverControlQCOM(GLuint driverControl) +{ + GET_CONTEXT; + ctx->glDisableDriverControlQCOM(ctx, driverControl); +} + +void glExtGetTexturesQCOM(GLuint* textures, GLint maxTextures, GLint* numTextures) +{ + GET_CONTEXT; + ctx->glExtGetTexturesQCOM(ctx, textures, maxTextures, numTextures); +} + +void glExtGetBuffersQCOM(GLuint* buffers, GLint maxBuffers, GLint* numBuffers) +{ + GET_CONTEXT; + ctx->glExtGetBuffersQCOM(ctx, buffers, maxBuffers, numBuffers); +} + +void glExtGetRenderbuffersQCOM(GLuint* renderbuffers, GLint maxRenderbuffers, GLint* numRenderbuffers) +{ + GET_CONTEXT; + ctx->glExtGetRenderbuffersQCOM(ctx, renderbuffers, maxRenderbuffers, numRenderbuffers); +} + +void glExtGetFramebuffersQCOM(GLuint* framebuffers, GLint maxFramebuffers, GLint* numFramebuffers) +{ + GET_CONTEXT; + ctx->glExtGetFramebuffersQCOM(ctx, framebuffers, maxFramebuffers, numFramebuffers); +} + +void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint* params) +{ + GET_CONTEXT; + ctx->glExtGetTexLevelParameterivQCOM(ctx, texture, face, level, pname, params); +} + +void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param) +{ + GET_CONTEXT; + ctx->glExtTexObjectStateOverrideiQCOM(ctx, target, pname, param); +} + +void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* texels) +{ + GET_CONTEXT; + ctx->glExtGetTexSubImageQCOM(ctx, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels); +} + +void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr* params) +{ + GET_CONTEXT; + ctx->glExtGetBufferPointervQCOM(ctx, target, params); +} + +void glExtGetShadersQCOM(GLuint* shaders, GLint maxShaders, GLint* numShaders) +{ + GET_CONTEXT; + ctx->glExtGetShadersQCOM(ctx, shaders, maxShaders, numShaders); +} + +void glExtGetProgramsQCOM(GLuint* programs, GLint maxPrograms, GLint* numPrograms) +{ + GET_CONTEXT; + ctx->glExtGetProgramsQCOM(ctx, programs, maxPrograms, numPrograms); +} + +GLboolean glExtIsProgramBinaryQCOM(GLuint program) +{ + GET_CONTEXT; + return ctx->glExtIsProgramBinaryQCOM(ctx, program); +} + +void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar* source, GLint* length) +{ + GET_CONTEXT; + ctx->glExtGetProgramBinarySourceQCOM(ctx, program, shadertype, source, length); +} + +void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) +{ + GET_CONTEXT; + ctx->glStartTilingQCOM(ctx, x, y, width, height, preserveMask); +} + +void glEndTilingQCOM(GLbitfield preserveMask) +{ + GET_CONTEXT; + ctx->glEndTilingQCOM(ctx, preserveMask); +} + +void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glVertexAttribPointerData(ctx, indx, size, type, normalized, stride, data, datalen); +} + +void glVertexAttribPointerOffset(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset) +{ + GET_CONTEXT; + ctx->glVertexAttribPointerOffset(ctx, indx, size, type, normalized, stride, offset); +} + +void glDrawElementsOffset(GLenum mode, GLsizei count, GLenum type, GLuint offset) +{ + GET_CONTEXT; + ctx->glDrawElementsOffset(ctx, mode, count, type, offset); +} + +void glDrawElementsData(GLenum mode, GLsizei count, GLenum type, void* data, GLuint datalen) +{ + GET_CONTEXT; + ctx->glDrawElementsData(ctx, mode, count, type, data, datalen); +} + +void glGetCompressedTextureFormats(int count, GLint* formats) +{ + GET_CONTEXT; + ctx->glGetCompressedTextureFormats(ctx, count, formats); +} + +void glShaderString(GLuint shader, const GLchar* string, GLsizei len) +{ + GET_CONTEXT; + ctx->glShaderString(ctx, shader, string, len); +} + +int glFinishRoundTrip() +{ + GET_CONTEXT; + return ctx->glFinishRoundTrip(ctx); +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_ftable.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_ftable.h new file mode 100644 index 0000000..25df4f0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_ftable.h @@ -0,0 +1,216 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __gl2_client_ftable_t_h +#define __gl2_client_ftable_t_h + + +static const struct _gl2_funcs_by_name { + const char *name; + void *proc; +} gl2_funcs_by_name[] = { + {"glActiveTexture", (void*)glActiveTexture}, + {"glAttachShader", (void*)glAttachShader}, + {"glBindAttribLocation", (void*)glBindAttribLocation}, + {"glBindBuffer", (void*)glBindBuffer}, + {"glBindFramebuffer", (void*)glBindFramebuffer}, + {"glBindRenderbuffer", (void*)glBindRenderbuffer}, + {"glBindTexture", (void*)glBindTexture}, + {"glBlendColor", (void*)glBlendColor}, + {"glBlendEquation", (void*)glBlendEquation}, + {"glBlendEquationSeparate", (void*)glBlendEquationSeparate}, + {"glBlendFunc", (void*)glBlendFunc}, + {"glBlendFuncSeparate", (void*)glBlendFuncSeparate}, + {"glBufferData", (void*)glBufferData}, + {"glBufferSubData", (void*)glBufferSubData}, + {"glCheckFramebufferStatus", (void*)glCheckFramebufferStatus}, + {"glClear", (void*)glClear}, + {"glClearColor", (void*)glClearColor}, + {"glClearDepthf", (void*)glClearDepthf}, + {"glClearStencil", (void*)glClearStencil}, + {"glColorMask", (void*)glColorMask}, + {"glCompileShader", (void*)glCompileShader}, + {"glCompressedTexImage2D", (void*)glCompressedTexImage2D}, + {"glCompressedTexSubImage2D", (void*)glCompressedTexSubImage2D}, + {"glCopyTexImage2D", (void*)glCopyTexImage2D}, + {"glCopyTexSubImage2D", (void*)glCopyTexSubImage2D}, + {"glCreateProgram", (void*)glCreateProgram}, + {"glCreateShader", (void*)glCreateShader}, + {"glCullFace", (void*)glCullFace}, + {"glDeleteBuffers", (void*)glDeleteBuffers}, + {"glDeleteFramebuffers", (void*)glDeleteFramebuffers}, + {"glDeleteProgram", (void*)glDeleteProgram}, + {"glDeleteRenderbuffers", (void*)glDeleteRenderbuffers}, + {"glDeleteShader", (void*)glDeleteShader}, + {"glDeleteTextures", (void*)glDeleteTextures}, + {"glDepthFunc", (void*)glDepthFunc}, + {"glDepthMask", (void*)glDepthMask}, + {"glDepthRangef", (void*)glDepthRangef}, + {"glDetachShader", (void*)glDetachShader}, + {"glDisable", (void*)glDisable}, + {"glDisableVertexAttribArray", (void*)glDisableVertexAttribArray}, + {"glDrawArrays", (void*)glDrawArrays}, + {"glDrawElements", (void*)glDrawElements}, + {"glEnable", (void*)glEnable}, + {"glEnableVertexAttribArray", (void*)glEnableVertexAttribArray}, + {"glFinish", (void*)glFinish}, + {"glFlush", (void*)glFlush}, + {"glFramebufferRenderbuffer", (void*)glFramebufferRenderbuffer}, + {"glFramebufferTexture2D", (void*)glFramebufferTexture2D}, + {"glFrontFace", (void*)glFrontFace}, + {"glGenBuffers", (void*)glGenBuffers}, + {"glGenerateMipmap", (void*)glGenerateMipmap}, + {"glGenFramebuffers", (void*)glGenFramebuffers}, + {"glGenRenderbuffers", (void*)glGenRenderbuffers}, + {"glGenTextures", (void*)glGenTextures}, + {"glGetActiveAttrib", (void*)glGetActiveAttrib}, + {"glGetActiveUniform", (void*)glGetActiveUniform}, + {"glGetAttachedShaders", (void*)glGetAttachedShaders}, + {"glGetAttribLocation", (void*)glGetAttribLocation}, + {"glGetBooleanv", (void*)glGetBooleanv}, + {"glGetBufferParameteriv", (void*)glGetBufferParameteriv}, + {"glGetError", (void*)glGetError}, + {"glGetFloatv", (void*)glGetFloatv}, + {"glGetFramebufferAttachmentParameteriv", (void*)glGetFramebufferAttachmentParameteriv}, + {"glGetIntegerv", (void*)glGetIntegerv}, + {"glGetProgramiv", (void*)glGetProgramiv}, + {"glGetProgramInfoLog", (void*)glGetProgramInfoLog}, + {"glGetRenderbufferParameteriv", (void*)glGetRenderbufferParameteriv}, + {"glGetShaderiv", (void*)glGetShaderiv}, + {"glGetShaderInfoLog", (void*)glGetShaderInfoLog}, + {"glGetShaderPrecisionFormat", (void*)glGetShaderPrecisionFormat}, + {"glGetShaderSource", (void*)glGetShaderSource}, + {"glGetString", (void*)glGetString}, + {"glGetTexParameterfv", (void*)glGetTexParameterfv}, + {"glGetTexParameteriv", (void*)glGetTexParameteriv}, + {"glGetUniformfv", (void*)glGetUniformfv}, + {"glGetUniformiv", (void*)glGetUniformiv}, + {"glGetUniformLocation", (void*)glGetUniformLocation}, + {"glGetVertexAttribfv", (void*)glGetVertexAttribfv}, + {"glGetVertexAttribiv", (void*)glGetVertexAttribiv}, + {"glGetVertexAttribPointerv", (void*)glGetVertexAttribPointerv}, + {"glHint", (void*)glHint}, + {"glIsBuffer", (void*)glIsBuffer}, + {"glIsEnabled", (void*)glIsEnabled}, + {"glIsFramebuffer", (void*)glIsFramebuffer}, + {"glIsProgram", (void*)glIsProgram}, + {"glIsRenderbuffer", (void*)glIsRenderbuffer}, + {"glIsShader", (void*)glIsShader}, + {"glIsTexture", (void*)glIsTexture}, + {"glLineWidth", (void*)glLineWidth}, + {"glLinkProgram", (void*)glLinkProgram}, + {"glPixelStorei", (void*)glPixelStorei}, + {"glPolygonOffset", (void*)glPolygonOffset}, + {"glReadPixels", (void*)glReadPixels}, + {"glReleaseShaderCompiler", (void*)glReleaseShaderCompiler}, + {"glRenderbufferStorage", (void*)glRenderbufferStorage}, + {"glSampleCoverage", (void*)glSampleCoverage}, + {"glScissor", (void*)glScissor}, + {"glShaderBinary", (void*)glShaderBinary}, + {"glShaderSource", (void*)glShaderSource}, + {"glStencilFunc", (void*)glStencilFunc}, + {"glStencilFuncSeparate", (void*)glStencilFuncSeparate}, + {"glStencilMask", (void*)glStencilMask}, + {"glStencilMaskSeparate", (void*)glStencilMaskSeparate}, + {"glStencilOp", (void*)glStencilOp}, + {"glStencilOpSeparate", (void*)glStencilOpSeparate}, + {"glTexImage2D", (void*)glTexImage2D}, + {"glTexParameterf", (void*)glTexParameterf}, + {"glTexParameterfv", (void*)glTexParameterfv}, + {"glTexParameteri", (void*)glTexParameteri}, + {"glTexParameteriv", (void*)glTexParameteriv}, + {"glTexSubImage2D", (void*)glTexSubImage2D}, + {"glUniform1f", (void*)glUniform1f}, + {"glUniform1fv", (void*)glUniform1fv}, + {"glUniform1i", (void*)glUniform1i}, + {"glUniform1iv", (void*)glUniform1iv}, + {"glUniform2f", (void*)glUniform2f}, + {"glUniform2fv", (void*)glUniform2fv}, + {"glUniform2i", (void*)glUniform2i}, + {"glUniform2iv", (void*)glUniform2iv}, + {"glUniform3f", (void*)glUniform3f}, + {"glUniform3fv", (void*)glUniform3fv}, + {"glUniform3i", (void*)glUniform3i}, + {"glUniform3iv", (void*)glUniform3iv}, + {"glUniform4f", (void*)glUniform4f}, + {"glUniform4fv", (void*)glUniform4fv}, + {"glUniform4i", (void*)glUniform4i}, + {"glUniform4iv", (void*)glUniform4iv}, + {"glUniformMatrix2fv", (void*)glUniformMatrix2fv}, + {"glUniformMatrix3fv", (void*)glUniformMatrix3fv}, + {"glUniformMatrix4fv", (void*)glUniformMatrix4fv}, + {"glUseProgram", (void*)glUseProgram}, + {"glValidateProgram", (void*)glValidateProgram}, + {"glVertexAttrib1f", (void*)glVertexAttrib1f}, + {"glVertexAttrib1fv", (void*)glVertexAttrib1fv}, + {"glVertexAttrib2f", (void*)glVertexAttrib2f}, + {"glVertexAttrib2fv", (void*)glVertexAttrib2fv}, + {"glVertexAttrib3f", (void*)glVertexAttrib3f}, + {"glVertexAttrib3fv", (void*)glVertexAttrib3fv}, + {"glVertexAttrib4f", (void*)glVertexAttrib4f}, + {"glVertexAttrib4fv", (void*)glVertexAttrib4fv}, + {"glVertexAttribPointer", (void*)glVertexAttribPointer}, + {"glViewport", (void*)glViewport}, + {"glEGLImageTargetTexture2DOES", (void*)glEGLImageTargetTexture2DOES}, + {"glEGLImageTargetRenderbufferStorageOES", (void*)glEGLImageTargetRenderbufferStorageOES}, + {"glGetProgramBinaryOES", (void*)glGetProgramBinaryOES}, + {"glProgramBinaryOES", (void*)glProgramBinaryOES}, + {"glMapBufferOES", (void*)glMapBufferOES}, + {"glUnmapBufferOES", (void*)glUnmapBufferOES}, + {"glTexImage3DOES", (void*)glTexImage3DOES}, + {"glTexSubImage3DOES", (void*)glTexSubImage3DOES}, + {"glCopyTexSubImage3DOES", (void*)glCopyTexSubImage3DOES}, + {"glCompressedTexImage3DOES", (void*)glCompressedTexImage3DOES}, + {"glCompressedTexSubImage3DOES", (void*)glCompressedTexSubImage3DOES}, + {"glFramebufferTexture3DOES", (void*)glFramebufferTexture3DOES}, + {"glBindVertexArrayOES", (void*)glBindVertexArrayOES}, + {"glDeleteVertexArraysOES", (void*)glDeleteVertexArraysOES}, + {"glGenVertexArraysOES", (void*)glGenVertexArraysOES}, + {"glIsVertexArrayOES", (void*)glIsVertexArrayOES}, + {"glDiscardFramebufferEXT", (void*)glDiscardFramebufferEXT}, + {"glMultiDrawArraysEXT", (void*)glMultiDrawArraysEXT}, + {"glMultiDrawElementsEXT", (void*)glMultiDrawElementsEXT}, + {"glGetPerfMonitorGroupsAMD", (void*)glGetPerfMonitorGroupsAMD}, + {"glGetPerfMonitorCountersAMD", (void*)glGetPerfMonitorCountersAMD}, + {"glGetPerfMonitorGroupStringAMD", (void*)glGetPerfMonitorGroupStringAMD}, + {"glGetPerfMonitorCounterStringAMD", (void*)glGetPerfMonitorCounterStringAMD}, + {"glGetPerfMonitorCounterInfoAMD", (void*)glGetPerfMonitorCounterInfoAMD}, + {"glGenPerfMonitorsAMD", (void*)glGenPerfMonitorsAMD}, + {"glDeletePerfMonitorsAMD", (void*)glDeletePerfMonitorsAMD}, + {"glSelectPerfMonitorCountersAMD", (void*)glSelectPerfMonitorCountersAMD}, + {"glBeginPerfMonitorAMD", (void*)glBeginPerfMonitorAMD}, + {"glEndPerfMonitorAMD", (void*)glEndPerfMonitorAMD}, + {"glGetPerfMonitorCounterDataAMD", (void*)glGetPerfMonitorCounterDataAMD}, + {"glRenderbufferStorageMultisampleIMG", (void*)glRenderbufferStorageMultisampleIMG}, + {"glFramebufferTexture2DMultisampleIMG", (void*)glFramebufferTexture2DMultisampleIMG}, + {"glDeleteFencesNV", (void*)glDeleteFencesNV}, + {"glGenFencesNV", (void*)glGenFencesNV}, + {"glIsFenceNV", (void*)glIsFenceNV}, + {"glTestFenceNV", (void*)glTestFenceNV}, + {"glGetFenceivNV", (void*)glGetFenceivNV}, + {"glFinishFenceNV", (void*)glFinishFenceNV}, + {"glSetFenceNV", (void*)glSetFenceNV}, + {"glCoverageMaskNV", (void*)glCoverageMaskNV}, + {"glCoverageOperationNV", (void*)glCoverageOperationNV}, + {"glGetDriverControlsQCOM", (void*)glGetDriverControlsQCOM}, + {"glGetDriverControlStringQCOM", (void*)glGetDriverControlStringQCOM}, + {"glEnableDriverControlQCOM", (void*)glEnableDriverControlQCOM}, + {"glDisableDriverControlQCOM", (void*)glDisableDriverControlQCOM}, + {"glExtGetTexturesQCOM", (void*)glExtGetTexturesQCOM}, + {"glExtGetBuffersQCOM", (void*)glExtGetBuffersQCOM}, + {"glExtGetRenderbuffersQCOM", (void*)glExtGetRenderbuffersQCOM}, + {"glExtGetFramebuffersQCOM", (void*)glExtGetFramebuffersQCOM}, + {"glExtGetTexLevelParameterivQCOM", (void*)glExtGetTexLevelParameterivQCOM}, + {"glExtTexObjectStateOverrideiQCOM", (void*)glExtTexObjectStateOverrideiQCOM}, + {"glExtGetTexSubImageQCOM", (void*)glExtGetTexSubImageQCOM}, + {"glExtGetBufferPointervQCOM", (void*)glExtGetBufferPointervQCOM}, + {"glExtGetShadersQCOM", (void*)glExtGetShadersQCOM}, + {"glExtGetProgramsQCOM", (void*)glExtGetProgramsQCOM}, + {"glExtIsProgramBinaryQCOM", (void*)glExtIsProgramBinaryQCOM}, + {"glExtGetProgramBinarySourceQCOM", (void*)glExtGetProgramBinarySourceQCOM}, + {"glStartTilingQCOM", (void*)glStartTilingQCOM}, + {"glEndTilingQCOM", (void*)glEndTilingQCOM}, +}; +static const int gl2_num_funcs = sizeof(gl2_funcs_by_name) / sizeof(struct _gl2_funcs_by_name); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_opcodes.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_opcodes.h new file mode 100644 index 0000000..5e7857f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_opcodes.h @@ -0,0 +1,217 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __GUARD_gl2_opcodes_h_ +#define __GUARD_gl2_opcodes_h_ + +#define OP_glActiveTexture 2048 +#define OP_glAttachShader 2049 +#define OP_glBindAttribLocation 2050 +#define OP_glBindBuffer 2051 +#define OP_glBindFramebuffer 2052 +#define OP_glBindRenderbuffer 2053 +#define OP_glBindTexture 2054 +#define OP_glBlendColor 2055 +#define OP_glBlendEquation 2056 +#define OP_glBlendEquationSeparate 2057 +#define OP_glBlendFunc 2058 +#define OP_glBlendFuncSeparate 2059 +#define OP_glBufferData 2060 +#define OP_glBufferSubData 2061 +#define OP_glCheckFramebufferStatus 2062 +#define OP_glClear 2063 +#define OP_glClearColor 2064 +#define OP_glClearDepthf 2065 +#define OP_glClearStencil 2066 +#define OP_glColorMask 2067 +#define OP_glCompileShader 2068 +#define OP_glCompressedTexImage2D 2069 +#define OP_glCompressedTexSubImage2D 2070 +#define OP_glCopyTexImage2D 2071 +#define OP_glCopyTexSubImage2D 2072 +#define OP_glCreateProgram 2073 +#define OP_glCreateShader 2074 +#define OP_glCullFace 2075 +#define OP_glDeleteBuffers 2076 +#define OP_glDeleteFramebuffers 2077 +#define OP_glDeleteProgram 2078 +#define OP_glDeleteRenderbuffers 2079 +#define OP_glDeleteShader 2080 +#define OP_glDeleteTextures 2081 +#define OP_glDepthFunc 2082 +#define OP_glDepthMask 2083 +#define OP_glDepthRangef 2084 +#define OP_glDetachShader 2085 +#define OP_glDisable 2086 +#define OP_glDisableVertexAttribArray 2087 +#define OP_glDrawArrays 2088 +#define OP_glDrawElements 2089 +#define OP_glEnable 2090 +#define OP_glEnableVertexAttribArray 2091 +#define OP_glFinish 2092 +#define OP_glFlush 2093 +#define OP_glFramebufferRenderbuffer 2094 +#define OP_glFramebufferTexture2D 2095 +#define OP_glFrontFace 2096 +#define OP_glGenBuffers 2097 +#define OP_glGenerateMipmap 2098 +#define OP_glGenFramebuffers 2099 +#define OP_glGenRenderbuffers 2100 +#define OP_glGenTextures 2101 +#define OP_glGetActiveAttrib 2102 +#define OP_glGetActiveUniform 2103 +#define OP_glGetAttachedShaders 2104 +#define OP_glGetAttribLocation 2105 +#define OP_glGetBooleanv 2106 +#define OP_glGetBufferParameteriv 2107 +#define OP_glGetError 2108 +#define OP_glGetFloatv 2109 +#define OP_glGetFramebufferAttachmentParameteriv 2110 +#define OP_glGetIntegerv 2111 +#define OP_glGetProgramiv 2112 +#define OP_glGetProgramInfoLog 2113 +#define OP_glGetRenderbufferParameteriv 2114 +#define OP_glGetShaderiv 2115 +#define OP_glGetShaderInfoLog 2116 +#define OP_glGetShaderPrecisionFormat 2117 +#define OP_glGetShaderSource 2118 +#define OP_glGetString 2119 +#define OP_glGetTexParameterfv 2120 +#define OP_glGetTexParameteriv 2121 +#define OP_glGetUniformfv 2122 +#define OP_glGetUniformiv 2123 +#define OP_glGetUniformLocation 2124 +#define OP_glGetVertexAttribfv 2125 +#define OP_glGetVertexAttribiv 2126 +#define OP_glGetVertexAttribPointerv 2127 +#define OP_glHint 2128 +#define OP_glIsBuffer 2129 +#define OP_glIsEnabled 2130 +#define OP_glIsFramebuffer 2131 +#define OP_glIsProgram 2132 +#define OP_glIsRenderbuffer 2133 +#define OP_glIsShader 2134 +#define OP_glIsTexture 2135 +#define OP_glLineWidth 2136 +#define OP_glLinkProgram 2137 +#define OP_glPixelStorei 2138 +#define OP_glPolygonOffset 2139 +#define OP_glReadPixels 2140 +#define OP_glReleaseShaderCompiler 2141 +#define OP_glRenderbufferStorage 2142 +#define OP_glSampleCoverage 2143 +#define OP_glScissor 2144 +#define OP_glShaderBinary 2145 +#define OP_glShaderSource 2146 +#define OP_glStencilFunc 2147 +#define OP_glStencilFuncSeparate 2148 +#define OP_glStencilMask 2149 +#define OP_glStencilMaskSeparate 2150 +#define OP_glStencilOp 2151 +#define OP_glStencilOpSeparate 2152 +#define OP_glTexImage2D 2153 +#define OP_glTexParameterf 2154 +#define OP_glTexParameterfv 2155 +#define OP_glTexParameteri 2156 +#define OP_glTexParameteriv 2157 +#define OP_glTexSubImage2D 2158 +#define OP_glUniform1f 2159 +#define OP_glUniform1fv 2160 +#define OP_glUniform1i 2161 +#define OP_glUniform1iv 2162 +#define OP_glUniform2f 2163 +#define OP_glUniform2fv 2164 +#define OP_glUniform2i 2165 +#define OP_glUniform2iv 2166 +#define OP_glUniform3f 2167 +#define OP_glUniform3fv 2168 +#define OP_glUniform3i 2169 +#define OP_glUniform3iv 2170 +#define OP_glUniform4f 2171 +#define OP_glUniform4fv 2172 +#define OP_glUniform4i 2173 +#define OP_glUniform4iv 2174 +#define OP_glUniformMatrix2fv 2175 +#define OP_glUniformMatrix3fv 2176 +#define OP_glUniformMatrix4fv 2177 +#define OP_glUseProgram 2178 +#define OP_glValidateProgram 2179 +#define OP_glVertexAttrib1f 2180 +#define OP_glVertexAttrib1fv 2181 +#define OP_glVertexAttrib2f 2182 +#define OP_glVertexAttrib2fv 2183 +#define OP_glVertexAttrib3f 2184 +#define OP_glVertexAttrib3fv 2185 +#define OP_glVertexAttrib4f 2186 +#define OP_glVertexAttrib4fv 2187 +#define OP_glVertexAttribPointer 2188 +#define OP_glViewport 2189 +#define OP_glEGLImageTargetTexture2DOES 2190 +#define OP_glEGLImageTargetRenderbufferStorageOES 2191 +#define OP_glGetProgramBinaryOES 2192 +#define OP_glProgramBinaryOES 2193 +#define OP_glMapBufferOES 2194 +#define OP_glUnmapBufferOES 2195 +#define OP_glTexImage3DOES 2196 +#define OP_glTexSubImage3DOES 2197 +#define OP_glCopyTexSubImage3DOES 2198 +#define OP_glCompressedTexImage3DOES 2199 +#define OP_glCompressedTexSubImage3DOES 2200 +#define OP_glFramebufferTexture3DOES 2201 +#define OP_glBindVertexArrayOES 2202 +#define OP_glDeleteVertexArraysOES 2203 +#define OP_glGenVertexArraysOES 2204 +#define OP_glIsVertexArrayOES 2205 +#define OP_glDiscardFramebufferEXT 2206 +#define OP_glMultiDrawArraysEXT 2207 +#define OP_glMultiDrawElementsEXT 2208 +#define OP_glGetPerfMonitorGroupsAMD 2209 +#define OP_glGetPerfMonitorCountersAMD 2210 +#define OP_glGetPerfMonitorGroupStringAMD 2211 +#define OP_glGetPerfMonitorCounterStringAMD 2212 +#define OP_glGetPerfMonitorCounterInfoAMD 2213 +#define OP_glGenPerfMonitorsAMD 2214 +#define OP_glDeletePerfMonitorsAMD 2215 +#define OP_glSelectPerfMonitorCountersAMD 2216 +#define OP_glBeginPerfMonitorAMD 2217 +#define OP_glEndPerfMonitorAMD 2218 +#define OP_glGetPerfMonitorCounterDataAMD 2219 +#define OP_glRenderbufferStorageMultisampleIMG 2220 +#define OP_glFramebufferTexture2DMultisampleIMG 2221 +#define OP_glDeleteFencesNV 2222 +#define OP_glGenFencesNV 2223 +#define OP_glIsFenceNV 2224 +#define OP_glTestFenceNV 2225 +#define OP_glGetFenceivNV 2226 +#define OP_glFinishFenceNV 2227 +#define OP_glSetFenceNV 2228 +#define OP_glCoverageMaskNV 2229 +#define OP_glCoverageOperationNV 2230 +#define OP_glGetDriverControlsQCOM 2231 +#define OP_glGetDriverControlStringQCOM 2232 +#define OP_glEnableDriverControlQCOM 2233 +#define OP_glDisableDriverControlQCOM 2234 +#define OP_glExtGetTexturesQCOM 2235 +#define OP_glExtGetBuffersQCOM 2236 +#define OP_glExtGetRenderbuffersQCOM 2237 +#define OP_glExtGetFramebuffersQCOM 2238 +#define OP_glExtGetTexLevelParameterivQCOM 2239 +#define OP_glExtTexObjectStateOverrideiQCOM 2240 +#define OP_glExtGetTexSubImageQCOM 2241 +#define OP_glExtGetBufferPointervQCOM 2242 +#define OP_glExtGetShadersQCOM 2243 +#define OP_glExtGetProgramsQCOM 2244 +#define OP_glExtIsProgramBinaryQCOM 2245 +#define OP_glExtGetProgramBinarySourceQCOM 2246 +#define OP_glStartTilingQCOM 2247 +#define OP_glEndTilingQCOM 2248 +#define OP_glVertexAttribPointerData 2249 +#define OP_glVertexAttribPointerOffset 2250 +#define OP_glDrawElementsOffset 2251 +#define OP_glDrawElementsData 2252 +#define OP_glGetCompressedTextureFormats 2253 +#define OP_glShaderString 2254 +#define OP_glFinishRoundTrip 2255 +#define OP_last 2256 + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_types.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_types.h new file mode 100644 index 0000000..bfff61d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/GLESv2_enc/gl2_types.h @@ -0,0 +1,21 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GL_2_TYPES_H_ +#define _GL_2_TYPES_H_ +#include "gl_base_types.h" + +typedef void *GLvoidptr; +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/Android.mk new file mode 100644 index 0000000..6198748 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/Android.mk @@ -0,0 +1,13 @@ +LOCAL_PATH := $(call my-dir) + +$(call emugl-begin-shared-library,libOpenglSystemCommon) +$(call emugl-import,libGLESv1_enc libGLESv2_enc lib_renderControl_enc) + +LOCAL_SRC_FILES := \ + HostConnection.cpp \ + QemuPipeStream.cpp \ + ThreadInfo.cpp + +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH) bionic/libc/private) + +$(call emugl-end-module) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLClientIface.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLClientIface.h new file mode 100644 index 0000000..3c8cb55 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLClientIface.h @@ -0,0 +1,41 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef _SYSTEM_COMMON_EGL_CLIENT_IFACE_H +#define _SYSTEM_COMMON_EGL_CLIENT_IFACE_H + +struct EGLThreadInfo; // defined in ThreadInfo.h + +typedef struct { + EGLThreadInfo* (*getThreadInfo)(); + const char* (*getGLString)(int glEnum); +} EGLClient_eglInterface; + +typedef struct { + void* (*getProcAddress)(const char *funcName); + void (*init)(); + void (*finish)(); +} EGLClient_glesInterface; + +// +// Any GLES/GLES2 client API library should define a function named "init_emul_gles" +// with the following prototype, +// It will be called by EGL after loading the GLES library for initialization +// and exchanging interface function pointers. +// +typedef EGLClient_glesInterface *(*init_emul_gles_t)(EGLClient_eglInterface *eglIface); + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLImage.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLImage.h new file mode 100644 index 0000000..5edb44e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/EGLImage.h @@ -0,0 +1,36 @@ +/* +* Copyright (C) 2015 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __COMMON_EGL_IMAGE_H +#define __COMMON_EGL_IMAGE_H + +#include +#include +#include +#include + +struct EGLImage_t +{ + EGLDisplay dpy; + EGLenum target; + + union + { + android_native_buffer_t *native_buffer; + uint32_t host_egl_image; + }; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.cpp new file mode 100644 index 0000000..bc3b634 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.cpp @@ -0,0 +1,186 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "HostConnection.h" +#include "TcpStream.h" +#include "QemuPipeStream.h" +#include "ThreadInfo.h" +#include +#include "GLEncoder.h" +#include "GL2Encoder.h" +#include + +#define STREAM_BUFFER_SIZE 4*1024*1024 +#define STREAM_PORT_NUM 22468 + +/* Set to 1 to use a QEMU pipe, or 0 for a TCP connection */ +#define USE_QEMU_PIPE 1 + +HostConnection::HostConnection() : + m_stream(NULL), + m_glEnc(NULL), + m_gl2Enc(NULL), + m_rcEnc(NULL), + m_checksumHelper() +{ +} + +HostConnection::~HostConnection() +{ + delete m_stream; + delete m_glEnc; + delete m_gl2Enc; + delete m_rcEnc; +} + +HostConnection *HostConnection::get() +{ + /* TODO: Make this configurable with a system property */ + const int useQemuPipe = USE_QEMU_PIPE; + + // Get thread info + EGLThreadInfo *tinfo = getEGLThreadInfo(); + if (!tinfo) { + return NULL; + } + + if (tinfo->hostConn == NULL) { + HostConnection *con = new HostConnection(); + if (NULL == con) { + return NULL; + } + + if (useQemuPipe) { + QemuPipeStream *stream = new QemuPipeStream(STREAM_BUFFER_SIZE); + if (!stream) { + ALOGE("Failed to create QemuPipeStream for host connection!!!\n"); + delete con; + return NULL; + } + if (stream->connect() < 0) { + ALOGE("Failed to connect to host (QemuPipeStream)!!!\n"); + delete stream; + delete con; + return NULL; + } + con->m_stream = stream; + } + else /* !useQemuPipe */ + { + TcpStream *stream = new TcpStream(STREAM_BUFFER_SIZE); + if (!stream) { + ALOGE("Failed to create TcpStream for host connection!!!\n"); + delete con; + return NULL; + } + + if (stream->connect("10.0.2.2", STREAM_PORT_NUM) < 0) { + ALOGE("Failed to connect to host (TcpStream)!!!\n"); + delete stream; + delete con; + return NULL; + } + con->m_stream = stream; + } + + // send zero 'clientFlags' to the host. + unsigned int *pClientFlags = + (unsigned int *)con->m_stream->allocBuffer(sizeof(unsigned int)); + *pClientFlags = 0; + con->m_stream->commitBuffer(sizeof(unsigned int)); + + ALOGD("HostConnection::get() New Host Connection established %p, tid %d\n", con, gettid()); + tinfo->hostConn = con; + } + + return tinfo->hostConn; +} + +GLEncoder *HostConnection::glEncoder() +{ + if (!m_glEnc) { + m_glEnc = new GLEncoder(m_stream, checksumHelper()); + DBG("HostConnection::glEncoder new encoder %p, tid %d", m_glEnc, gettid()); + m_glEnc->setContextAccessor(s_getGLContext); + } + return m_glEnc; +} + +GL2Encoder *HostConnection::gl2Encoder() +{ + if (!m_gl2Enc) { + m_gl2Enc = new GL2Encoder(m_stream, checksumHelper()); + DBG("HostConnection::gl2Encoder new encoder %p, tid %d", m_gl2Enc, gettid()); + m_gl2Enc->setContextAccessor(s_getGL2Context); + } + return m_gl2Enc; +} + +renderControl_encoder_context_t *HostConnection::rcEncoder() +{ + if (!m_rcEnc) { + m_rcEnc = new renderControl_encoder_context_t(m_stream, checksumHelper()); + // TODO: disable checksum as a workaround in a glTexSubImage2D problem + // Uncomment the following line when the root cause is solved + //setChecksumHelper(m_rcEnc); + } + return m_rcEnc; +} + +gl_client_context_t *HostConnection::s_getGLContext() +{ + EGLThreadInfo *ti = getEGLThreadInfo(); + if (ti->hostConn) { + return ti->hostConn->m_glEnc; + } + return NULL; +} + +gl2_client_context_t *HostConnection::s_getGL2Context() +{ + EGLThreadInfo *ti = getEGLThreadInfo(); + if (ti->hostConn) { + return ti->hostConn->m_gl2Enc; + } + return NULL; +} + +void HostConnection::setChecksumHelper(renderControl_encoder_context_t *rcEnc) { + std::unique_ptr glExtensions; + int extensionSize = rcEnc->rcGetGLString(rcEnc, GL_EXTENSIONS, NULL, 0); + if (extensionSize < 0) { + glExtensions = std::unique_ptr(new char[-extensionSize]); + extensionSize = rcEnc->rcGetGLString(rcEnc, GL_EXTENSIONS, glExtensions.get(), -extensionSize); + if (extensionSize <= 0) { + glExtensions.reset(); + } + } + // check the host supported version + uint32_t checksumVersion = 0; + const char* checksumPrefix = ChecksumCalculator::getMaxVersionStrPrefix(); + const char* glProtocolStr = glExtensions.get() ? + strstr(glExtensions.get(), checksumPrefix) : NULL; + if (glProtocolStr) { + uint32_t maxVersion = ChecksumCalculator::getMaxVersion(); + sscanf(glProtocolStr+strlen(checksumPrefix), "%d", &checksumVersion); + if (maxVersion < checksumVersion) { + checksumVersion = maxVersion; + } + // The ordering of the following two commands matters! + // Must tell the host first before setting it in the guest + rcEnc->rcSelectChecksumCalculator(rcEnc, checksumVersion, 0); + m_checksumHelper.setVersion(checksumVersion); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.h new file mode 100644 index 0000000..a52fbfa --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/HostConnection.h @@ -0,0 +1,61 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __COMMON_HOST_CONNECTION_H +#define __COMMON_HOST_CONNECTION_H + +#include "IOStream.h" +#include "renderControl_enc.h" +#include "ChecksumCalculator.h" + +class GLEncoder; +class gl_client_context_t; +class GL2Encoder; +class gl2_client_context_t; + +class HostConnection +{ +public: + static HostConnection *get(); + ~HostConnection(); + + GLEncoder *glEncoder(); + GL2Encoder *gl2Encoder(); + renderControl_encoder_context_t *rcEncoder(); + ChecksumCalculator *checksumHelper() { return &m_checksumHelper; } + + void flush() { + if (m_stream) { + m_stream->flush(); + } + } + +private: + HostConnection(); + static gl_client_context_t *s_getGLContext(); + static gl2_client_context_t *s_getGL2Context(); + // setProtocol initilizes GL communication protocol for checksums + // should be called when m_rcEnc is created + void setChecksumHelper(renderControl_encoder_context_t *rcEnc); + +private: + IOStream *m_stream; + GLEncoder *m_glEnc; + GL2Encoder *m_gl2Enc; + renderControl_encoder_context_t *m_rcEnc; + ChecksumCalculator m_checksumHelper; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp new file mode 100644 index 0000000..581aec3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp @@ -0,0 +1,209 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "QemuPipeStream.h" +#include +#include +#include +#include +#include +#include + +QemuPipeStream::QemuPipeStream(size_t bufSize) : + IOStream(bufSize), + m_sock(-1), + m_bufsize(bufSize), + m_buf(NULL) +{ +} + +QemuPipeStream::QemuPipeStream(int sock, size_t bufSize) : + IOStream(bufSize), + m_sock(sock), + m_bufsize(bufSize), + m_buf(NULL) +{ +} + +QemuPipeStream::~QemuPipeStream() +{ + if (m_sock >= 0) { + flush(); + ::close(m_sock); + } + if (m_buf != NULL) { + free(m_buf); + } +} + + +int QemuPipeStream::connect(void) +{ + m_sock = qemu_pipe_open("opengles"); + if (!valid()) return -1; + return 0; +} + +void *QemuPipeStream::allocBuffer(size_t minSize) +{ + size_t allocSize = (m_bufsize < minSize ? minSize : m_bufsize); + if (!m_buf) { + m_buf = (unsigned char *)malloc(allocSize); + } + else if (m_bufsize < allocSize) { + unsigned char *p = (unsigned char *)realloc(m_buf, allocSize); + if (p != NULL) { + m_buf = p; + m_bufsize = allocSize; + } else { + ERR("realloc (%d) failed\n", allocSize); + free(m_buf); + m_buf = NULL; + m_bufsize = 0; + } + } + + return m_buf; +}; + +int QemuPipeStream::commitBuffer(size_t size) +{ + return writeFully(m_buf, size); +} + +int QemuPipeStream::writeFully(const void *buf, size_t len) +{ + //DBG(">> QemuPipeStream::writeFully %d\n", len); + if (!valid()) return -1; + if (!buf) { + if (len>0) { + // If len is non-zero, buf must not be NULL. Otherwise the pipe would be + // in a corrupted state, which is lethal for the emulator. + ERR("QemuPipeStream::writeFully failed, buf=NULL, len %d," + " lethal error, exiting", len); + abort(); + } + return 0; + } + + size_t res = len; + int retval = 0; + + while (res > 0) { + ssize_t stat = ::write(m_sock, (const char *)(buf) + (len - res), res); + if (stat > 0) { + res -= stat; + continue; + } + if (stat == 0) { /* EOF */ + ERR("QemuPipeStream::writeFully failed: premature EOF\n"); + retval = -1; + break; + } + if (errno == EINTR) { + continue; + } + retval = stat; + ERR("QemuPipeStream::writeFully failed: %s, lethal error, exiting.\n", + strerror(errno)); + abort(); + } + //DBG("<< QemuPipeStream::writeFully %d\n", len ); + return retval; +} + +const unsigned char *QemuPipeStream::readFully(void *buf, size_t len) +{ + //DBG(">> QemuPipeStream::readFully %d\n", len); + if (!valid()) return NULL; + if (!buf) { + if (len > 0) { + // If len is non-zero, buf must not be NULL. Otherwise the pipe would be + // in a corrupted state, which is lethal for the emulator. + ERR("QemuPipeStream::readFully failed, buf=NULL, len %zu, lethal" + " error, exiting.", len); + abort(); + } + return NULL; // do not allow NULL buf in that implementation + } + size_t res = len; + while (res > 0) { + ssize_t stat = ::read(m_sock, (char *)(buf) + len - res, res); + if (stat == 0) { + // client shutdown; + return NULL; + } else if (stat < 0) { + if (errno == EINTR) { + continue; + } else { + ERR("QemuPipeStream::readFully failed (buf %p, len %zu" + ", res %zu): %s, lethal error, exiting.", buf, len, res, + strerror(errno)); + abort(); + } + } else { + res -= stat; + } + } + //DBG("<< QemuPipeStream::readFully %d\n", len); + return (const unsigned char *)buf; +} + +const unsigned char *QemuPipeStream::read( void *buf, size_t *inout_len) +{ + //DBG(">> QemuPipeStream::read %d\n", *inout_len); + if (!valid()) return NULL; + if (!buf) { + ERR("QemuPipeStream::read failed, buf=NULL"); + return NULL; // do not allow NULL buf in that implementation + } + + int n = recv(buf, *inout_len); + + if (n > 0) { + *inout_len = n; + return (const unsigned char *)buf; + } + + //DBG("<< QemuPipeStream::read %d\n", *inout_len); + return NULL; +} + +int QemuPipeStream::recv(void *buf, size_t len) +{ + if (!valid()) return int(ERR_INVALID_SOCKET); + char* p = (char *)buf; + int ret = 0; + while(len > 0) { + int res = ::read(m_sock, p, len); + if (res > 0) { + p += res; + ret += res; + len -= res; + continue; + } + if (res == 0) { /* EOF */ + break; + } + if (errno == EINTR) + continue; + + /* A real error */ + if (ret == 0) + ret = -1; + break; + } + return ret; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.h new file mode 100644 index 0000000..57ee399 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/QemuPipeStream.h @@ -0,0 +1,51 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __QEMU_PIPE_STREAM_H +#define __QEMU_PIPE_STREAM_H + +/* This file implements an IOStream that uses a QEMU fast-pipe + * to communicate with the emulator's 'opengles' service. See + * for more details. + */ +#include +#include "IOStream.h" + +class QemuPipeStream : public IOStream { +public: + typedef enum { ERR_INVALID_SOCKET = -1000 } QemuPipeStreamError; + + explicit QemuPipeStream(size_t bufsize = 10000); + ~QemuPipeStream(); + int connect(void); + + virtual void *allocBuffer(size_t minSize); + virtual int commitBuffer(size_t size); + virtual const unsigned char *readFully( void *buf, size_t len); + virtual const unsigned char *read( void *buf, size_t *inout_len); + + bool valid() { return m_sock >= 0; } + int recv(void *buf, size_t len); + + virtual int writeFully(const void *buf, size_t len); + +private: + int m_sock; + size_t m_bufsize; + unsigned char *m_buf; + QemuPipeStream(int sock, size_t bufSize); +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.cpp new file mode 100644 index 0000000..04ce508 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.cpp @@ -0,0 +1,40 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "ThreadInfo.h" +#include "cutils/threads.h" + +thread_store_t s_tls = THREAD_STORE_INITIALIZER; + +static void tlsDestruct(void *ptr) +{ + if (ptr) { + EGLThreadInfo *ti = (EGLThreadInfo *)ptr; + delete ti->hostConn; + delete ti; + ((void **)__get_tls())[TLS_SLOT_OPENGL] = NULL; + } +} + +EGLThreadInfo *slow_getEGLThreadInfo() +{ + EGLThreadInfo *ti = (EGLThreadInfo *)thread_store_get(&s_tls); + if (ti) return ti; + + ti = new EGLThreadInfo(); + thread_store_set(&s_tls, ti, tlsDestruct); + + return ti; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.h new file mode 100644 index 0000000..9a5dc88 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/ThreadInfo.h @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _THREAD_INFO_H +#define _THREAD_INFO_H + +#include "HostConnection.h" +#include +#ifdef __ANDROID__ +#include +#endif + +struct EGLContext_t; + +struct EGLThreadInfo +{ + EGLThreadInfo() : currentContext(NULL), hostConn(NULL), eglError(EGL_SUCCESS) {} + + EGLContext_t *currentContext; + HostConnection *hostConn; + int eglError; +}; + + +EGLThreadInfo *slow_getEGLThreadInfo(); + +#ifdef __ANDROID__ + // We have a dedicated TLS slot in bionic + inline EGLThreadInfo* getEGLThreadInfo() { + EGLThreadInfo *tInfo = + (EGLThreadInfo *)(((uintptr_t *)__get_tls())[TLS_SLOT_OPENGL]); + if (!tInfo) { + tInfo = slow_getEGLThreadInfo(); + ((uintptr_t *)__get_tls())[TLS_SLOT_OPENGL] = (uintptr_t)tInfo; + } + return tInfo; + } +#else + inline EGLThreadInfo* getEGLThreadInfo() { + return slow_getEGLThreadInfo(); + } +#endif + + + + +#endif // of _THREAD_INFO_H diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/gralloc_cb.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/gralloc_cb.h new file mode 100644 index 0000000..d2d6f35 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/OpenglSystemCommon/gralloc_cb.h @@ -0,0 +1,114 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __GRALLOC_CB_H__ +#define __GRALLOC_CB_H__ + +#include +#include +#include + +#define BUFFER_HANDLE_MAGIC ((int)0xabfabfab) +#define CB_HANDLE_NUM_INTS(nfds) (int)((sizeof(cb_handle_t) - (nfds)*sizeof(int)) / sizeof(int)) + +// +// Our buffer handle structure +// +struct cb_handle_t : public native_handle { + + cb_handle_t(int p_fd, int p_ashmemSize, int p_usage, + int p_width, int p_height, int p_frameworkFormat, + int p_format, int p_glFormat, int p_glType) : + fd(p_fd), + magic(BUFFER_HANDLE_MAGIC), + usage(p_usage), + width(p_width), + height(p_height), + frameworkFormat(p_frameworkFormat), + format(p_format), + glFormat(p_glFormat), + glType(p_glType), + ashmemSize(p_ashmemSize), + ashmemBase(0), + ashmemBasePid(0), + mappedPid(0), + lockedLeft(0), + lockedTop(0), + lockedWidth(0), + lockedHeight(0), + hostHandle(0) + { + version = sizeof(native_handle); + numFds = 0; + numInts = CB_HANDLE_NUM_INTS(numFds); + } + + ~cb_handle_t() { + magic = 0; + } + + void setFd(int p_fd) { + if (p_fd >= 0) { + numFds = 1; + } + else { + numFds = 0; + } + fd = p_fd; + numInts = CB_HANDLE_NUM_INTS(numFds); + } + + static bool validate(const cb_handle_t* hnd) { + return (hnd && + hnd->version == sizeof(native_handle) && + hnd->magic == BUFFER_HANDLE_MAGIC && + hnd->numInts == CB_HANDLE_NUM_INTS(hnd->numFds)); + } + + bool canBePosted() { + return (0 != (usage & GRALLOC_USAGE_HW_FB)); + } + + // file-descriptors + int fd; // ashmem fd (-1 of ashmem region did not allocated, i.e. no SW access needed) + + // ints + int magic; // magic number in order to validate a pointer to be a cb_handle_t + int usage; // usage bits the buffer was created with + int width; // buffer width + int height; // buffer height + int frameworkFormat; // format requested by the Android framework + int format; // real internal pixel format format + int glFormat; // OpenGL format enum used for host h/w color buffer + int glType; // OpenGL type enum used when uploading to host + int ashmemSize; // ashmem region size for the buffer (0 unless is HW_FB buffer or + // s/w access is needed) + union { + intptr_t ashmemBase; // CPU address of the mapped ashmem region + uint64_t padding; // enforce same size on 32-bit/64-bit + } __attribute__((aligned(8))); + + int ashmemBasePid; // process id which mapped the ashmem region + int mappedPid; // process id which succeeded gralloc_register call + int lockedLeft; // region of buffer locked for s/w write + int lockedTop; + int lockedWidth; + int lockedHeight; + uint32_t hostHandle; +}; + + +#endif //__GRALLOC_CB_H__ diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/Android.mk new file mode 100644 index 0000000..241cefe --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/Android.mk @@ -0,0 +1,41 @@ +ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER)) + +LOCAL_PATH := $(call my-dir) + +$(call emugl-begin-shared-library,libEGL_emulation) +$(call emugl-import,libOpenglSystemCommon) +$(call emugl-set-shared-library-subpath,egl) + +LOCAL_CFLAGS += -DLOG_TAG=\"EGL_emulation\" -DEGL_EGLEXT_PROTOTYPES -DWITH_GLES2 + +LOCAL_SRC_FILES := \ + eglDisplay.cpp \ + egl.cpp \ + ClientAPIExts.cpp + +LOCAL_SHARED_LIBRARIES += libdl + +# Used to access the Bionic private OpenGL TLS slot +LOCAL_C_INCLUDES += bionic/libc/private + +$(call emugl-end-module) + +#### egl.cfg #### + +# Ensure that this file is only copied to emulator-specific builds. +# Other builds are device-specific and will provide their own +# version of this file to point to the appropriate HW EGL libraries. +# +ifneq (,$(filter aosp_arm aosp_x86 aosp_mips full full_x86 full_mips sdk sdk_x86 sdk_mips google_sdk google_sdk_x86 google_sdk_mips,$(TARGET_PRODUCT))) +include $(CLEAR_VARS) + +LOCAL_MODULE := egl.cfg +LOCAL_SRC_FILES := $(LOCAL_MODULE) + +LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/egl +LOCAL_MODULE_CLASS := ETC + +include $(BUILD_PREBUILT) +endif # TARGET_PRODUCT in 'full full_x86 full_mips sdk sdk_x86 sdk_mips google_sdk google_sdk_x86 google_sdk_mips') + +endif # BUILD_EMULATOR_OPENGL_DRIVER != false diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/ClientAPIExts.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/ClientAPIExts.cpp new file mode 100644 index 0000000..5e81afe --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/ClientAPIExts.cpp @@ -0,0 +1,157 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "ClientAPIExts.h" +#include "ThreadInfo.h" +#include +#include +#include "eglContext.h" + +namespace ClientAPIExts +{ + +// +// define function pointer type for each extention function +// typename has the form __egl_{funcname}_t +// +#define FUNC_TYPE(fname) __egl_ ## fname ## _t +#define API_ENTRY(fname,params,args) \ + typedef void (GL_APIENTRY *FUNC_TYPE(fname)) params; + +#define API_ENTRY_RET(rtype,fname,params,args) \ + typedef rtype (GL_APIENTRY *FUNC_TYPE(fname)) params; + +#include "ClientAPIExts.in" +#undef API_ENTRY +#undef API_ENTRY_RET + +///// +// Define static table to store the function value for each +// client API. functions pointers will get initialized through +// ClientAPIExts::initClientFuncs function after each client API has been +// loaded. +///// +#define API_ENTRY(fname,params,args) \ + FUNC_TYPE(fname) fname; + +#define API_ENTRY_RET(rtype,fname,params,args) \ + API_ENTRY(fname,params,args) + +static struct _ext_table +{ +#include "ClientAPIExts.in" +} s_client_extensions[2]; + +#undef API_ENTRY +#undef API_ENTRY_RET + +// +// This function initialized each entry in the s_client_extensions +// struct at the givven index using the givven client interface +// +void initClientFuncs(const EGLClient_glesInterface *iface, int idx) +{ +#define API_ENTRY(fname,params,args) \ + s_client_extensions[idx].fname = \ + (FUNC_TYPE(fname))iface->getProcAddress(#fname); + +#define API_ENTRY_RET(rtype,fname,params,args) \ + API_ENTRY(fname,params,args) + + // + // reset all func pointers to NULL + // + memset(&s_client_extensions[idx], 0, sizeof(struct _ext_table)); + + // + // And now query the GLES library for each proc address + // +#include "ClientAPIExts.in" +#undef API_ENTRY +#undef API_ENTRY_RET +} + +// +// Define implementation for each extension function which checks +// the current context version and calls to the correct client API +// function. +// +#define API_ENTRY(fname,params,args) \ + static void _egl_ ## fname params \ + { \ + EGLThreadInfo* thread = getEGLThreadInfo(); \ + if (!thread->currentContext) { \ + return; \ + } \ + int idx = (int)thread->currentContext->version - 1; \ + if (!s_client_extensions[idx].fname) { \ + return; \ + } \ + (*s_client_extensions[idx].fname) args; \ + } + +#define API_ENTRY_RET(rtype,fname,params,args) \ + static rtype _egl_ ## fname params \ + { \ + EGLThreadInfo* thread = getEGLThreadInfo(); \ + if (!thread->currentContext) { \ + return (rtype)0; \ + } \ + int idx = (int)thread->currentContext->version - 1; \ + if (!s_client_extensions[idx].fname) { \ + return (rtype)0; \ + } \ + return (*s_client_extensions[idx].fname) args; \ + } + +#include "ClientAPIExts.in" +#undef API_ENTRY +#undef API_ENTRY_RET + +// +// Define a table to map function names to the local _egl_ version of +// the extension function, to be used in eglGetProcAddress. +// +#define API_ENTRY(fname,params,args) \ + { #fname, (void*)_egl_ ## fname}, +#define API_ENTRY_RET(rtype,fname,params,args) \ + API_ENTRY(fname,params,args) + +static const struct _client_ext_funcs { + const char *fname; + void* proc; +} s_client_ext_funcs[] = { +#include "ClientAPIExts.in" +}; +static const int numExtFuncs = sizeof(s_client_ext_funcs) / + sizeof(s_client_ext_funcs[0]); + +#undef API_ENTRY +#undef API_ENTRY_RET + +// +// returns the __egl_ version of the givven extension function name. +// +void* getProcAddress(const char *fname) +{ + for (int i=0; i +#include "gralloc_cb.h" +#include "GLClientState.h" +#include "GLSharedGroup.h" +#include "eglContext.h" +#include "ClientAPIExts.h" +#include "EGLImage.h" + +#include "GLEncoder.h" +#ifdef WITH_GLES2 +#include "GL2Encoder.h" +#endif + +#include + +template +static T setErrorFunc(GLint error, T returnValue) { + getEGLThreadInfo()->eglError = error; + return returnValue; +} + +const char * eglStrError(EGLint err) +{ + switch (err){ + case EGL_SUCCESS: return "EGL_SUCCESS"; + case EGL_NOT_INITIALIZED: return "EGL_NOT_INITIALIZED"; + case EGL_BAD_ACCESS: return "EGL_BAD_ACCESS"; + case EGL_BAD_ALLOC: return "EGL_BAD_ALLOC"; + case EGL_BAD_ATTRIBUTE: return "EGL_BAD_ATTRIBUTE"; + case EGL_BAD_CONFIG: return "EGL_BAD_CONFIG"; + case EGL_BAD_CONTEXT: return "EGL_BAD_CONTEXT"; + case EGL_BAD_CURRENT_SURFACE: return "EGL_BAD_CURRENT_SURFACE"; + case EGL_BAD_DISPLAY: return "EGL_BAD_DISPLAY"; + case EGL_BAD_MATCH: return "EGL_BAD_MATCH"; + case EGL_BAD_NATIVE_PIXMAP: return "EGL_BAD_NATIVE_PIXMAP"; + case EGL_BAD_NATIVE_WINDOW: return "EGL_BAD_NATIVE_WINDOW"; + case EGL_BAD_PARAMETER: return "EGL_BAD_PARAMETER"; + case EGL_BAD_SURFACE: return "EGL_BAD_SURFACE"; + case EGL_CONTEXT_LOST: return "EGL_CONTEXT_LOST"; + default: return "UNKNOWN"; + } +} + +#define LOG_EGL_ERRORS 1 + +#ifdef LOG_EGL_ERRORS + +#define setErrorReturn(error, retVal) \ + { \ + ALOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, error, eglStrError(error)); \ + return setErrorFunc(error, retVal); \ + } + +#define RETURN_ERROR(ret,err) \ + ALOGE("tid %d: %s(%d): error 0x%x (%s)", gettid(), __FUNCTION__, __LINE__, err, eglStrError(err)); \ + getEGLThreadInfo()->eglError = err; \ + return ret; + +#else //!LOG_EGL_ERRORS + +#define setErrorReturn(error, retVal) return setErrorFunc(error, retVal); + +#define RETURN_ERROR(ret,err) \ + getEGLThreadInfo()->eglError = err; \ + return ret; + +#endif //LOG_EGL_ERRORS + +#define VALIDATE_CONFIG(cfg,ret) \ + if(((intptr_t)cfg<0)||((intptr_t)cfg>s_display.getNumConfigs())) { \ + RETURN_ERROR(ret,EGL_BAD_CONFIG); \ + } + +#define VALIDATE_DISPLAY(dpy,ret) \ + if ((dpy) != (EGLDisplay)&s_display) { \ + RETURN_ERROR(ret, EGL_BAD_DISPLAY); \ + } + +#define VALIDATE_DISPLAY_INIT(dpy,ret) \ + VALIDATE_DISPLAY(dpy, ret) \ + if (!s_display.initialized()) { \ + RETURN_ERROR(ret, EGL_NOT_INITIALIZED); \ + } + +#define DEFINE_HOST_CONNECTION \ + HostConnection *hostCon = HostConnection::get(); \ + renderControl_encoder_context_t *rcEnc = (hostCon ? hostCon->rcEncoder() : NULL) + +#define DEFINE_AND_VALIDATE_HOST_CONNECTION(ret) \ + HostConnection *hostCon = HostConnection::get(); \ + if (!hostCon) { \ + ALOGE("egl: Failed to get host connection\n"); \ + return ret; \ + } \ + renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \ + if (!rcEnc) { \ + ALOGE("egl: Failed to get renderControl encoder context\n"); \ + return ret; \ + } + +#define VALIDATE_CONTEXT_RETURN(context,ret) \ + if (!context) { \ + RETURN_ERROR(ret,EGL_BAD_CONTEXT); \ + } + +#define VALIDATE_SURFACE_RETURN(surface, ret) \ + if (surface != EGL_NO_SURFACE) { \ + egl_surface_t* s( static_cast(surface) ); \ + if (s->dpy != (EGLDisplay)&s_display) \ + setErrorReturn(EGL_BAD_DISPLAY, EGL_FALSE); \ + } + + +EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* shareCtx) : + dpy(dpy), + config(config), + read(EGL_NO_SURFACE), + draw(EGL_NO_SURFACE), + shareCtx(shareCtx), + rcContext(0), + versionString(NULL), + vendorString(NULL), + rendererString(NULL), + shaderVersionString(NULL), + extensionString(NULL), + deletePending(0) +{ + flags = 0; + version = 1; + clientState = new GLClientState(); + if (shareCtx) + sharedGroup = shareCtx->getSharedGroup(); + else + sharedGroup = GLSharedGroupPtr(new GLSharedGroup()); +}; + +EGLContext_t::~EGLContext_t() +{ + delete clientState; + delete [] versionString; + delete [] vendorString; + delete [] rendererString; + delete [] shaderVersionString; + delete [] extensionString; +} + +// ---------------------------------------------------------------------------- +//egl_surface_t + +//we don't need to handle depth since it's handled when window created on the host + +struct egl_surface_t { + + EGLDisplay dpy; + EGLConfig config; + + + egl_surface_t(EGLDisplay dpy, EGLConfig config, EGLint surfaceType); + virtual ~egl_surface_t(); + + virtual void setSwapInterval(int interval) = 0; + virtual EGLBoolean swapBuffers() = 0; + + EGLint getSwapBehavior() const; + uint32_t getRcSurface() { return rcSurface; } + EGLint getSurfaceType() { return surfaceType; } + + EGLint getWidth(){ return width; } + EGLint getHeight(){ return height; } + void setTextureFormat(EGLint _texFormat) { texFormat = _texFormat; } + EGLint getTextureFormat() { return texFormat; } + void setTextureTarget(EGLint _texTarget) { texTarget = _texTarget; } + EGLint getTextureTarget() { return texTarget; } + +private: + // + //Surface attributes + // + EGLint width; + EGLint height; + EGLint texFormat; + EGLint texTarget; + +protected: + void setWidth(EGLint w) { width = w; } + void setHeight(EGLint h) { height = h; } + + EGLint surfaceType; + uint32_t rcSurface; //handle to surface created via remote control +}; + +egl_surface_t::egl_surface_t(EGLDisplay dpy, EGLConfig config, EGLint surfaceType) + : dpy(dpy), config(config), surfaceType(surfaceType), rcSurface(0) +{ + width = 0; + height = 0; + texFormat = EGL_NO_TEXTURE; + texTarget = EGL_NO_TEXTURE; +} + +EGLint egl_surface_t::getSwapBehavior() const { + return EGL_BUFFER_PRESERVED; +} + +egl_surface_t::~egl_surface_t() +{ +} + +// ---------------------------------------------------------------------------- +// egl_window_surface_t + +struct egl_window_surface_t : public egl_surface_t { + static egl_window_surface_t* create( + EGLDisplay dpy, EGLConfig config, EGLint surfType, + ANativeWindow* window); + + virtual ~egl_window_surface_t(); + + virtual void setSwapInterval(int interval); + virtual EGLBoolean swapBuffers(); + +private: + egl_window_surface_t( + EGLDisplay dpy, EGLConfig config, EGLint surfType, + ANativeWindow* window); + EGLBoolean init(); + + ANativeWindow* nativeWindow; + android_native_buffer_t* buffer; +}; + +egl_window_surface_t::egl_window_surface_t ( + EGLDisplay dpy, EGLConfig config, EGLint surfType, + ANativeWindow* window) +: egl_surface_t(dpy, config, surfType), + nativeWindow(window), + buffer(NULL) +{ + // keep a reference on the window + nativeWindow->common.incRef(&nativeWindow->common); +} + +EGLBoolean egl_window_surface_t::init() +{ + if (nativeWindow->dequeueBuffer_DEPRECATED(nativeWindow, &buffer) != NO_ERROR) { + setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE); + } + setWidth(buffer->width); + setHeight(buffer->height); + + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)config, + getWidth(), getHeight()); + if (!rcSurface) { + ALOGE("rcCreateWindowSurface returned 0"); + return EGL_FALSE; + } + rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, + ((cb_handle_t*)(buffer->handle))->hostHandle); + + return EGL_TRUE; +} + +egl_window_surface_t* egl_window_surface_t::create( + EGLDisplay dpy, EGLConfig config, EGLint surfType, + ANativeWindow* window) +{ + egl_window_surface_t* wnd = new egl_window_surface_t( + dpy, config, surfType, window); + if (wnd && !wnd->init()) { + delete wnd; + wnd = NULL; + } + return wnd; +} + +egl_window_surface_t::~egl_window_surface_t() { + DEFINE_HOST_CONNECTION; + if (rcSurface && rcEnc) { + rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface); + } + if (buffer) { + nativeWindow->cancelBuffer_DEPRECATED(nativeWindow, buffer); + } + nativeWindow->common.decRef(&nativeWindow->common); +} + +void egl_window_surface_t::setSwapInterval(int interval) +{ + nativeWindow->setSwapInterval(nativeWindow, interval); +} + +EGLBoolean egl_window_surface_t::swapBuffers() +{ + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + + rcEnc->rcFlushWindowColorBuffer(rcEnc, rcSurface); + + nativeWindow->queueBuffer_DEPRECATED(nativeWindow, buffer); + if (nativeWindow->dequeueBuffer_DEPRECATED(nativeWindow, &buffer)) { + buffer = NULL; + setErrorReturn(EGL_BAD_ALLOC, EGL_FALSE); + } + + rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, + ((cb_handle_t *)(buffer->handle))->hostHandle); + + setWidth(buffer->width); + setHeight(buffer->height); + + return EGL_TRUE; +} + +// ---------------------------------------------------------------------------- +//egl_pbuffer_surface_t + +struct egl_pbuffer_surface_t : public egl_surface_t { + static egl_pbuffer_surface_t* create(EGLDisplay dpy, EGLConfig config, + EGLint surfType, int32_t w, int32_t h, GLenum pixelFormat); + + virtual ~egl_pbuffer_surface_t(); + + virtual void setSwapInterval(int interval) { (void)interval; } + virtual EGLBoolean swapBuffers() { return EGL_TRUE; } + + uint32_t getRcColorBuffer() { return rcColorBuffer; } + +private: + egl_pbuffer_surface_t(EGLDisplay dpy, EGLConfig config, EGLint surfType, + int32_t w, int32_t h); + EGLBoolean init(GLenum format); + + uint32_t rcColorBuffer; +}; + +egl_pbuffer_surface_t::egl_pbuffer_surface_t(EGLDisplay dpy, EGLConfig config, + EGLint surfType, int32_t w, int32_t h) +: egl_surface_t(dpy, config, surfType), + rcColorBuffer(0) +{ + setWidth(w); + setHeight(h); +} + +egl_pbuffer_surface_t::~egl_pbuffer_surface_t() +{ + DEFINE_HOST_CONNECTION; + if (rcEnc) { + if (rcColorBuffer) rcEnc->rcCloseColorBuffer(rcEnc, rcColorBuffer); + if (rcSurface) rcEnc->rcDestroyWindowSurface(rcEnc, rcSurface); + } +} + +EGLBoolean egl_pbuffer_surface_t::init(GLenum pixelFormat) +{ + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + + rcSurface = rcEnc->rcCreateWindowSurface(rcEnc, (uintptr_t)config, + getWidth(), getHeight()); + if (!rcSurface) { + ALOGE("rcCreateWindowSurface returned 0"); + return EGL_FALSE; + } + + rcColorBuffer = rcEnc->rcCreateColorBuffer(rcEnc, getWidth(), getHeight(), + pixelFormat); + if (!rcColorBuffer) { + ALOGE("rcCreateColorBuffer returned 0"); + return EGL_FALSE; + } + + rcEnc->rcSetWindowColorBuffer(rcEnc, rcSurface, rcColorBuffer); + + return EGL_TRUE; +} + +egl_pbuffer_surface_t* egl_pbuffer_surface_t::create(EGLDisplay dpy, + EGLConfig config, EGLint surfType, int32_t w, int32_t h, + GLenum pixelFormat) +{ + egl_pbuffer_surface_t* pb = new egl_pbuffer_surface_t(dpy, config, surfType, + w, h); + if (pb && !pb->init(pixelFormat)) { + delete pb; + pb = NULL; + } + return pb; +} + +static const char *getGLString(int glEnum) +{ + EGLThreadInfo *tInfo = getEGLThreadInfo(); + if (!tInfo || !tInfo->currentContext) { + return NULL; + } + + const char** strPtr = NULL; + +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_EXTENSIONS 0x1F03 + + switch(glEnum) { + case GL_VERSION: + strPtr = &tInfo->currentContext->versionString; + break; + case GL_VENDOR: + strPtr = &tInfo->currentContext->vendorString; + break; + case GL_RENDERER: + strPtr = &tInfo->currentContext->rendererString; + break; + case GL_SHADING_LANGUAGE_VERSION: + strPtr = &tInfo->currentContext->shaderVersionString; + break; + case GL_EXTENSIONS: + strPtr = &tInfo->currentContext->extensionString; + break; + } + + if (!strPtr) { + return NULL; + } + + if (*strPtr != NULL) { + // + // string is already cached + // + return *strPtr; + } + + // + // first query of that string - need to query host + // + DEFINE_AND_VALIDATE_HOST_CONNECTION(NULL); + char *hostStr = NULL; + int n = rcEnc->rcGetGLString(rcEnc, glEnum, NULL, 0); + if (n < 0) { + hostStr = new char[-n+1]; + n = rcEnc->rcGetGLString(rcEnc, glEnum, hostStr, -n); + if (n <= 0) { + delete [] hostStr; + hostStr = NULL; + } + } + + // + // keep the string in the context and return its value + // + *strPtr = hostStr; + return hostStr; +} + +// ---------------------------------------------------------------------------- + +// The one and only supported display object. +static eglDisplay s_display; + +static EGLClient_eglInterface s_eglIface = { + getThreadInfo: getEGLThreadInfo, + getGLString: getGLString +}; + +#define DBG_FUNC DBG("%s\n", __FUNCTION__) +EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) +{ + // + // we support only EGL_DEFAULT_DISPLAY. + // + if (display_id != EGL_DEFAULT_DISPLAY) { + return EGL_NO_DISPLAY; + } + + return (EGLDisplay)&s_display; +} + +EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) +{ + VALIDATE_DISPLAY(dpy,EGL_FALSE); + + if (!s_display.initialize(&s_eglIface)) { + return EGL_FALSE; + } + if (major!=NULL) + *major = s_display.getVersionMajor(); + if (minor!=NULL) + *minor = s_display.getVersionMinor(); + return EGL_TRUE; +} + +EGLBoolean eglTerminate(EGLDisplay dpy) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + + s_display.terminate(); + return EGL_TRUE; +} + +EGLint eglGetError() +{ + EGLint error = getEGLThreadInfo()->eglError; + getEGLThreadInfo()->eglError = EGL_SUCCESS; + return error; +} + +__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) +{ + // search in EGL function table + for (int i=0; ircChooseConfig(rcEnc, (EGLint*)attrib_list, attribs_size * sizeof(EGLint), (uint32_t*)tempConfigs, config_size); + if (configs!=NULL) { + EGLint i=0; + for (i=0;i<(*num_config);i++) { + *((uintptr_t*)configs+i) = *((uint32_t*)tempConfigs+i); + } + } + + if (*num_config <= 0) + return EGL_FALSE; + return EGL_TRUE; +} + +EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_CONFIG(config, EGL_FALSE); + + if (s_display.getConfigAttrib(config, attribute, value)) + { + return EGL_TRUE; + } + else + { + RETURN_ERROR(EGL_FALSE, EGL_BAD_ATTRIBUTE); + } +} + +EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) +{ + (void)attrib_list; + + VALIDATE_DISPLAY_INIT(dpy, NULL); + VALIDATE_CONFIG(config, EGL_FALSE); + if (win == 0) { + setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE); + } + + EGLint surfaceType; + if (s_display.getConfigAttrib(config, EGL_SURFACE_TYPE, &surfaceType) == EGL_FALSE) return EGL_FALSE; + + if (!(surfaceType & EGL_WINDOW_BIT)) { + setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE); + } + + if (static_cast(win)->common.magic != ANDROID_NATIVE_WINDOW_MAGIC) { + setErrorReturn(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); + } + + egl_surface_t* surface = egl_window_surface_t::create( + &s_display, config, EGL_WINDOW_BIT, static_cast(win)); + if (!surface) { + setErrorReturn(EGL_BAD_ALLOC, EGL_NO_SURFACE); + } + + return surface; +} + +EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) +{ + VALIDATE_DISPLAY_INIT(dpy, NULL); + VALIDATE_CONFIG(config, EGL_FALSE); + + EGLint surfaceType; + if (s_display.getConfigAttrib(config, EGL_SURFACE_TYPE, &surfaceType) == EGL_FALSE) return EGL_FALSE; + + if (!(surfaceType & EGL_PBUFFER_BIT)) { + setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE); + } + + int32_t w = 0; + int32_t h = 0; + EGLint texFormat = EGL_NO_TEXTURE; + EGLint texTarget = EGL_NO_TEXTURE; + while (attrib_list[0] != EGL_NONE) { + switch (attrib_list[0]) { + case EGL_WIDTH: + w = attrib_list[1]; + break; + case EGL_HEIGHT: + h = attrib_list[1]; + break; + case EGL_TEXTURE_FORMAT: + texFormat = attrib_list[1]; + break; + case EGL_TEXTURE_TARGET: + texTarget = attrib_list[1]; + break; + default: + break; + }; + attrib_list+=2; + } + if (((texFormat == EGL_NO_TEXTURE)&&(texTarget != EGL_NO_TEXTURE)) || + ((texFormat != EGL_NO_TEXTURE)&&(texTarget == EGL_NO_TEXTURE))) { + setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE); + } + // TODO: check EGL_TEXTURE_FORMAT - need to support eglBindTexImage + + GLenum pixelFormat; + if (s_display.getConfigGLPixelFormat(config, &pixelFormat) == EGL_FALSE) + setErrorReturn(EGL_BAD_MATCH, EGL_NO_SURFACE); + + egl_surface_t* surface = egl_pbuffer_surface_t::create(dpy, config, + EGL_PBUFFER_BIT, w, h, pixelFormat); + if (!surface) { + setErrorReturn(EGL_BAD_ALLOC, EGL_NO_SURFACE); + } + + //setup attributes + surface->setTextureFormat(texFormat); + surface->setTextureTarget(texTarget); + + return surface; +} + +EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) +{ + //XXX: Pixmap not supported. The host cannot render to a pixmap resource + // located on host. In order to support Pixmaps we should either punt + // to s/w rendering -or- let the host render to a buffer that will be + // copied back to guest at some sync point. None of those methods not + // implemented and pixmaps are not used with OpenGL anyway ... + (void)dpy; + (void)config; + (void)pixmap; + (void)attrib_list; + return EGL_NO_SURFACE; +} + +EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface eglSurface) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE); + + egl_surface_t* surface(static_cast(eglSurface)); + delete surface; + + return EGL_TRUE; +} + +EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface eglSurface, EGLint attribute, EGLint *value) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE); + + egl_surface_t* surface( static_cast(eglSurface) ); + EGLBoolean ret = EGL_TRUE; + switch (attribute) { + case EGL_CONFIG_ID: + ret = s_display.getConfigAttrib(surface->config, EGL_CONFIG_ID, value); + break; + case EGL_WIDTH: + *value = surface->getWidth(); + break; + case EGL_HEIGHT: + *value = surface->getHeight(); + break; + case EGL_TEXTURE_FORMAT: + *value = surface->getTextureFormat(); + break; + case EGL_TEXTURE_TARGET: + *value = surface->getTextureTarget(); + break; + case EGL_SWAP_BEHAVIOR: + *value = surface->getSwapBehavior(); + break; + case EGL_LARGEST_PBUFFER: + // not modified for a window or pixmap surface + // and we ignore it when creating a PBuffer surface (default is EGL_FALSE) + if (surface->getSurfaceType() & EGL_PBUFFER_BIT) *value = EGL_FALSE; + break; + case EGL_MIPMAP_LEVEL: + // not modified for a window or pixmap surface + // and we ignore it when creating a PBuffer surface (default is 0) + if (surface->getSurfaceType() & EGL_PBUFFER_BIT) *value = 0; + break; + case EGL_MULTISAMPLE_RESOLVE: + // ignored when creating the surface, return default + *value = EGL_MULTISAMPLE_RESOLVE_DEFAULT; + break; + //TODO: complete other attributes + default: + ALOGE("eglQuerySurface %x EGL_BAD_ATTRIBUTE", attribute); + ret = setErrorFunc(EGL_BAD_ATTRIBUTE, EGL_FALSE); + break; + } + + return ret; +} + +EGLBoolean eglBindAPI(EGLenum api) +{ + if (api != EGL_OPENGL_ES_API) + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + return EGL_TRUE; +} + +EGLenum eglQueryAPI() +{ + return EGL_OPENGL_ES_API; +} + +EGLBoolean eglWaitClient() +{ + return eglWaitGL(); +} + +EGLBoolean eglReleaseThread() +{ + EGLThreadInfo *tInfo = getEGLThreadInfo(); + if (tInfo && tInfo->currentContext) { + return eglMakeCurrent(&s_display, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); + } + return EGL_TRUE; +} + +EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) +{ + //TODO + (void)dpy; + (void)buftype; + (void)buffer; + (void)config; + (void)attrib_list; + ALOGW("%s not implemented", __FUNCTION__); + return 0; +} + +EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) +{ + // Right now we don't do anything when using host GPU. + // This is purely just to pass the data through + // without issuing a warning. We may benefit from validating the + // display and surface for debug purposes. + // TODO: Find cases where we actually need to do something. + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_SURFACE_RETURN(surface, EGL_FALSE); + if (surface == EGL_NO_SURFACE) { + setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE); + } + + (void)value; + + switch (attribute) { + case EGL_MIPMAP_LEVEL: + case EGL_MULTISAMPLE_RESOLVE: + case EGL_SWAP_BEHAVIOR: + return true; + break; + default: + ALOGW("%s: attr=0x%x not implemented", __FUNCTION__, attribute); + } + return false; +} + +EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface eglSurface, EGLint buffer) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_SURFACE_RETURN(eglSurface, EGL_FALSE); + if (eglSurface == EGL_NO_SURFACE) { + setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE); + } + + if (buffer != EGL_BACK_BUFFER) { + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + } + + egl_surface_t* surface( static_cast(eglSurface) ); + + if (surface->getTextureFormat() == EGL_NO_TEXTURE) { + setErrorReturn(EGL_BAD_MATCH, EGL_FALSE); + } + + if (!(surface->getSurfaceType() & EGL_PBUFFER_BIT)) { + setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE); + } + + //It's now safe to cast to pbuffer surface + egl_pbuffer_surface_t* pbSurface = (egl_pbuffer_surface_t*)surface; + + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + rcEnc->rcBindTexture(rcEnc, pbSurface->getRcColorBuffer()); + + return GL_TRUE; +} + +EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +{ + //TODO + (void)dpy; + (void)surface; + (void)buffer; + ALOGW("%s not implemented", __FUNCTION__); + return 0; +} + +EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + + EGLContext_t* ctx = getEGLThreadInfo()->currentContext; + if (!ctx) { + setErrorReturn(EGL_BAD_CONTEXT, EGL_FALSE); + } + if (!ctx->draw) { + setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE); + } + egl_surface_t* draw(static_cast(ctx->draw)); + draw->setSwapInterval(interval); + + rcEnc->rcFBSetSwapInterval(rcEnc, interval); //TODO: implement on the host + + return EGL_TRUE; +} + +EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_NO_CONTEXT); + VALIDATE_CONFIG(config, EGL_NO_CONTEXT); + + EGLint version = 1; //default + while (attrib_list && attrib_list[0] != EGL_NONE) { + if (attrib_list[0] == EGL_CONTEXT_CLIENT_VERSION) version = attrib_list[1]; + attrib_list+=2; + } + + // Currently only support GLES1 and 2 + if (version != 1 && version != 2) { + setErrorReturn(EGL_BAD_CONFIG, EGL_NO_CONTEXT); + } + + uint32_t rcShareCtx = 0; + EGLContext_t * shareCtx = NULL; + if (share_context) { + shareCtx = static_cast(share_context); + rcShareCtx = shareCtx->rcContext; + if (shareCtx->dpy != dpy) + setErrorReturn(EGL_BAD_MATCH, EGL_NO_CONTEXT); + } + + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_NO_CONTEXT); + uint32_t rcContext = rcEnc->rcCreateContext(rcEnc, (uintptr_t)config, rcShareCtx, version); + if (!rcContext) { + ALOGE("rcCreateContext returned 0"); + setErrorReturn(EGL_BAD_ALLOC, EGL_NO_CONTEXT); + } + + EGLContext_t * context = new EGLContext_t(dpy, config, shareCtx); + if (!context) + setErrorReturn(EGL_BAD_ALLOC, EGL_NO_CONTEXT); + + context->version = version; + context->rcContext = rcContext; + + + return context; +} + +EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_CONTEXT_RETURN(ctx, EGL_FALSE); + + EGLContext_t * context = static_cast(ctx); + + if (!context) return EGL_TRUE; + + if (getEGLThreadInfo()->currentContext == context) { + getEGLThreadInfo()->currentContext->deletePending = 1; + return EGL_TRUE; + } + + if (context->rcContext) { + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + rcEnc->rcDestroyContext(rcEnc, context->rcContext); + context->rcContext = 0; + } + + delete context; + return EGL_TRUE; +} + +EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_SURFACE_RETURN(draw, EGL_FALSE); + VALIDATE_SURFACE_RETURN(read, EGL_FALSE); + + if ((read == EGL_NO_SURFACE && draw == EGL_NO_SURFACE) && (ctx != EGL_NO_CONTEXT)) + setErrorReturn(EGL_BAD_MATCH, EGL_FALSE); + if ((read != EGL_NO_SURFACE || draw != EGL_NO_SURFACE) && (ctx == EGL_NO_CONTEXT)) + setErrorReturn(EGL_BAD_MATCH, EGL_FALSE); + + EGLContext_t * context = static_cast(ctx); + uint32_t ctxHandle = (context) ? context->rcContext : 0; + egl_surface_t * drawSurf = static_cast(draw); + uint32_t drawHandle = (drawSurf) ? drawSurf->getRcSurface() : 0; + egl_surface_t * readSurf = static_cast(read); + uint32_t readHandle = (readSurf) ? readSurf->getRcSurface() : 0; + + // + // Nothing to do if no binding change has made + // + EGLThreadInfo *tInfo = getEGLThreadInfo(); + + if (tInfo->currentContext == context && + (context == NULL || + (context && context->draw == draw && context->read == read))) { + return EGL_TRUE; + } + + if (tInfo->currentContext && tInfo->currentContext->deletePending) { + if (tInfo->currentContext != context) { + EGLContext_t * contextToDelete = tInfo->currentContext; + tInfo->currentContext = 0; + eglDestroyContext(dpy, contextToDelete); + } + } + + if (context && (context->flags & EGLContext_t::IS_CURRENT) && (context != tInfo->currentContext)) { + //context is current to another thread + setErrorReturn(EGL_BAD_ACCESS, EGL_FALSE); + } + + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + if (rcEnc->rcMakeCurrent(rcEnc, ctxHandle, drawHandle, readHandle) == EGL_FALSE) { + ALOGE("rcMakeCurrent returned EGL_FALSE"); + setErrorReturn(EGL_BAD_CONTEXT, EGL_FALSE); + } + + //Now make the local bind + if (context) { + context->draw = draw; + context->read = read; + context->flags |= EGLContext_t::IS_CURRENT; + //set the client state + if (context->version == 2) { + hostCon->gl2Encoder()->setClientState(context->getClientState()); + hostCon->gl2Encoder()->setSharedGroup(context->getSharedGroup()); + } + else { + hostCon->glEncoder()->setClientState(context->getClientState()); + hostCon->glEncoder()->setSharedGroup(context->getSharedGroup()); + } + } + else if (tInfo->currentContext) { + //release ClientState & SharedGroup + if (tInfo->currentContext->version == 2) { + hostCon->gl2Encoder()->setClientState(NULL); + hostCon->gl2Encoder()->setSharedGroup(GLSharedGroupPtr(NULL)); + } + else { + hostCon->glEncoder()->setClientState(NULL); + hostCon->glEncoder()->setSharedGroup(GLSharedGroupPtr(NULL)); + } + + } + + if (tInfo->currentContext) + tInfo->currentContext->flags &= ~EGLContext_t::IS_CURRENT; + + //Now make current + tInfo->currentContext = context; + + //Check maybe we need to init the encoder, if it's first eglMakeCurrent + if (tInfo->currentContext) { + if (tInfo->currentContext->version == 2) { + if (!hostCon->gl2Encoder()->isInitialized()) { + s_display.gles2_iface()->init(); + hostCon->gl2Encoder()->setInitialized(); + ClientAPIExts::initClientFuncs(s_display.gles2_iface(), 1); + } + } + else { + if (!hostCon->glEncoder()->isInitialized()) { + s_display.gles_iface()->init(); + hostCon->glEncoder()->setInitialized(); + ClientAPIExts::initClientFuncs(s_display.gles_iface(), 0); + } + } + } + + return EGL_TRUE; +} + +EGLContext eglGetCurrentContext() +{ + return getEGLThreadInfo()->currentContext; +} + +EGLSurface eglGetCurrentSurface(EGLint readdraw) +{ + EGLContext_t * context = getEGLThreadInfo()->currentContext; + if (!context) + return EGL_NO_SURFACE; //not an error + + switch (readdraw) { + case EGL_READ: + return context->read; + case EGL_DRAW: + return context->draw; + default: + setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_SURFACE); + } +} + +EGLDisplay eglGetCurrentDisplay() +{ + EGLContext_t * context = getEGLThreadInfo()->currentContext; + if (!context) + return EGL_NO_DISPLAY; //not an error + + return context->dpy; +} + +EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + VALIDATE_CONTEXT_RETURN(ctx, EGL_FALSE); + + EGLContext_t * context = static_cast(ctx); + + EGLBoolean ret = EGL_TRUE; + switch (attribute) { + case EGL_CONFIG_ID: + ret = s_display.getConfigAttrib(context->config, EGL_CONFIG_ID, value); + break; + case EGL_CONTEXT_CLIENT_TYPE: + *value = EGL_OPENGL_ES_API; + break; + case EGL_CONTEXT_CLIENT_VERSION: + *value = context->version; + break; + case EGL_RENDER_BUFFER: + if (!context->draw) + *value = EGL_NONE; + else + *value = EGL_BACK_BUFFER; //single buffer not supported + break; + default: + ALOGE("eglQueryContext %x EGL_BAD_ATTRIBUTE", attribute); + setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE); + break; + } + + return ret; +} + +EGLBoolean eglWaitGL() +{ + EGLThreadInfo *tInfo = getEGLThreadInfo(); + if (!tInfo || !tInfo->currentContext) { + return EGL_FALSE; + } + + if (tInfo->currentContext->version == 2) { + s_display.gles2_iface()->finish(); + } + else { + s_display.gles_iface()->finish(); + } + + return EGL_TRUE; +} + +EGLBoolean eglWaitNative(EGLint engine) +{ + (void)engine; + return EGL_TRUE; +} + +EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface eglSurface) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + if (eglSurface == EGL_NO_SURFACE) + setErrorReturn(EGL_BAD_SURFACE, EGL_FALSE); + + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + + egl_surface_t* d = static_cast(eglSurface); + if (d->dpy != dpy) + setErrorReturn(EGL_BAD_DISPLAY, EGL_FALSE); + + // post the surface + d->swapBuffers(); + + hostCon->flush(); + return EGL_TRUE; +} + +EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) +{ + //TODO :later + (void)dpy; + (void)surface; + (void)target; + return 0; +} + +EGLBoolean eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list) +{ + //TODO later + (void)display; + (void)surface; + (void)attrib_list; + return 0; +} + +EGLBoolean eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface) +{ + //TODO later + (void)display; + (void)surface; + return 0; +} + +EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +{ + (void)attrib_list; + + VALIDATE_DISPLAY_INIT(dpy, EGL_NO_IMAGE_KHR); + + if (target == EGL_NATIVE_BUFFER_ANDROID) { + if (ctx != EGL_NO_CONTEXT) { + setErrorReturn(EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR); + } + + android_native_buffer_t* native_buffer = (android_native_buffer_t*)buffer; + + if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) + setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR); + + if (native_buffer->common.version != sizeof(android_native_buffer_t)) + setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR); + + cb_handle_t *cb = (cb_handle_t *)(native_buffer->handle); + + switch (cb->format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGB_888: + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_BGRA_8888: + break; + default: + setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR); + } + + native_buffer->common.incRef(&native_buffer->common); + + EGLImage_t *image = new EGLImage_t(); + image->dpy = dpy; + image->target = target; + image->native_buffer = native_buffer; + + return (EGLImageKHR)image; + } + else if (target == EGL_GL_TEXTURE_2D_KHR) { + VALIDATE_CONTEXT_RETURN(ctx, EGL_NO_IMAGE_KHR); + + EGLContext_t *context = static_cast(ctx); + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_NO_IMAGE_KHR); + + uint32_t ctxHandle = (context) ? context->rcContext : 0; + GLuint texture = (GLuint)reinterpret_cast(buffer); + uint32_t img = rcEnc->rcCreateClientImage(rcEnc, ctxHandle, target, texture); + EGLImage_t *image = new EGLImage_t(); + image->dpy = dpy; + image->target = target; + image->host_egl_image = img; + + return (EGLImageKHR)image; + } + + setErrorReturn(EGL_BAD_PARAMETER, EGL_NO_IMAGE_KHR); +} + +EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) +{ + VALIDATE_DISPLAY_INIT(dpy, EGL_FALSE); + EGLImage_t *image = (EGLImage_t*)img; + + if (!image || image->dpy != dpy) { + RETURN_ERROR(EGL_FALSE, EGL_BAD_PARAMETER); + } + + if (image->target == EGL_NATIVE_BUFFER_ANDROID) { + android_native_buffer_t* native_buffer = image->native_buffer; + + if (native_buffer->common.magic != ANDROID_NATIVE_BUFFER_MAGIC) + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + + if (native_buffer->common.version != sizeof(android_native_buffer_t)) + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + + native_buffer->common.decRef(&native_buffer->common); + delete image; + + return EGL_TRUE; + } + else if (image->target == EGL_GL_TEXTURE_2D_KHR) { + uint32_t host_egl_image = image->host_egl_image; + delete image; + DEFINE_AND_VALIDATE_HOST_CONNECTION(EGL_FALSE); + return rcEnc->rcDestroyClientImage(rcEnc, host_egl_image); + } + + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); +} + +#define FENCE_SYNC_HANDLE (EGLSyncKHR)0xFE4CE + +EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, + const EGLint *attrib_list) +{ + // TODO: This implementation could be faster. We should require the host EGL + // to support KHR_fence_sync, or at least pipe the fence command to the host + // and wait for it (probably involving a glFinish on the host) in + // eglClientWaitSyncKHR. + + VALIDATE_DISPLAY(dpy, EGL_NO_SYNC_KHR); + + if (type != EGL_SYNC_FENCE_KHR || + (attrib_list != NULL && attrib_list[0] != EGL_NONE)) { + setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR); + } + + EGLThreadInfo *tInfo = getEGLThreadInfo(); + if (!tInfo || !tInfo->currentContext) { + setErrorReturn(EGL_BAD_MATCH, EGL_NO_SYNC_KHR); + } + + if (tInfo->currentContext->version == 2) { + s_display.gles2_iface()->finish(); + } else { + s_display.gles_iface()->finish(); + } + + return FENCE_SYNC_HANDLE; +} + +EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) +{ + (void)dpy; + + if (sync != FENCE_SYNC_HANDLE) { + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + } + + return EGL_TRUE; +} + +EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, + EGLTimeKHR timeout) +{ + (void)dpy; + (void)flags; + (void)timeout; + + if (sync != FENCE_SYNC_HANDLE) { + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + } + + return EGL_CONDITION_SATISFIED_KHR; +} + +EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, + EGLint attribute, EGLint *value) +{ + (void)dpy; + + if (sync != FENCE_SYNC_HANDLE) { + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + } + + switch (attribute) { + case EGL_SYNC_TYPE_KHR: + *value = EGL_SYNC_FENCE_KHR; + return EGL_TRUE; + case EGL_SYNC_STATUS_KHR: + *value = EGL_SIGNALED_KHR; + return EGL_TRUE; + case EGL_SYNC_CONDITION_KHR: + *value = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; + return EGL_TRUE; + default: + setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglContext.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglContext.h new file mode 100644 index 0000000..5b6a428 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglContext.h @@ -0,0 +1,52 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _EGL_CONTEXT_H +#define _EGL_CONTEXT_H + +#include "GLClientState.h" +#include "GLSharedGroup.h" + +struct EGLContext_t { + + enum { + IS_CURRENT = 0x00010000, + NEVER_CURRENT = 0x00020000 + }; + + EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* shareCtx); + ~EGLContext_t(); + uint32_t flags; + EGLDisplay dpy; + EGLConfig config; + EGLSurface read; + EGLSurface draw; + EGLContext_t * shareCtx; + EGLint version; + uint32_t rcContext; + const char* versionString; + const char* vendorString; + const char* rendererString; + const char* shaderVersionString; + const char* extensionString; + EGLint deletePending; + GLClientState * getClientState(){ return clientState; } + GLSharedGroupPtr getSharedGroup(){ return sharedGroup; } +private: + GLClientState * clientState; + GLSharedGroupPtr sharedGroup; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.cpp new file mode 100644 index 0000000..9340482 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.cpp @@ -0,0 +1,485 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "eglDisplay.h" +#include "HostConnection.h" +#include + +static const int systemEGLVersionMajor = 1; +static const int systemEGLVersionMinor = 4; +static const char systemEGLVendor[] = "Google Android emulator"; + +// list of extensions supported by this EGL implementation +// NOTE that each extension name should be suffixed with space +static const char systemStaticEGLExtensions[] = + "EGL_ANDROID_image_native_buffer " + "EGL_KHR_fence_sync " + "EGL_KHR_image_base " + "EGL_KHR_gl_texture_2d_image "; + +static void *s_gles_lib = NULL; +static void *s_gles2_lib = NULL; + +// The following function will be called when we (libEGL) +// gets unloaded +// At this point we want to unload the gles libraries we +// might have loaded during initialization +static void __attribute__ ((destructor)) do_on_unload(void) +{ + if (s_gles_lib) { + dlclose(s_gles_lib); + } + + if (s_gles2_lib) { + dlclose(s_gles2_lib); + } +} + +eglDisplay::eglDisplay() : + m_initialized(false), + m_major(0), + m_minor(0), + m_hostRendererVersion(0), + m_numConfigs(0), + m_numConfigAttribs(0), + m_attribs(DefaultKeyedVector(ATTRIBUTE_NONE)), + m_configs(NULL), + m_gles_iface(NULL), + m_gles2_iface(NULL), + m_versionString(NULL), + m_vendorString(NULL), + m_extensionString(NULL) +{ + pthread_mutex_init(&m_lock, NULL); +} + +eglDisplay::~eglDisplay() +{ + pthread_mutex_destroy(&m_lock); +} + +bool eglDisplay::initialize(EGLClient_eglInterface *eglIface) +{ + pthread_mutex_lock(&m_lock); + if (!m_initialized) { + + // + // load GLES client API + // +#if __LP64__ + m_gles_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv1_CM_emulation.so", + eglIface, + &s_gles_lib); +#else + m_gles_iface = loadGLESClientAPI("/system/lib/egl/libGLESv1_CM_emulation.so", + eglIface, + &s_gles_lib); +#endif + if (!m_gles_iface) { + pthread_mutex_unlock(&m_lock); + ALOGE("Failed to load gles1 iface"); + return false; + } + +#ifdef WITH_GLES2 +#if __LP64__ + m_gles2_iface = loadGLESClientAPI("/system/lib64/egl/libGLESv2_emulation.so", + eglIface, + &s_gles2_lib); +#else + m_gles2_iface = loadGLESClientAPI("/system/lib/egl/libGLESv2_emulation.so", + eglIface, + &s_gles2_lib); +#endif + // Note that if loading gles2 failed, we can still run with no + // GLES2 support, having GLES2 is not mandatory. +#endif + + // + // establish connection with the host + // + HostConnection *hcon = HostConnection::get(); + if (!hcon) { + pthread_mutex_unlock(&m_lock); + ALOGE("Failed to establish connection with the host\n"); + return false; + } + + // + // get renderControl encoder instance + // + renderControl_encoder_context_t *rcEnc = hcon->rcEncoder(); + if (!rcEnc) { + pthread_mutex_unlock(&m_lock); + ALOGE("Failed to get renderControl encoder instance"); + return false; + } + + // + // Query host reneder and EGL version + // + m_hostRendererVersion = rcEnc->rcGetRendererVersion(rcEnc); + EGLint status = rcEnc->rcGetEGLVersion(rcEnc, &m_major, &m_minor); + if (status != EGL_TRUE) { + // host EGL initialization failed !! + pthread_mutex_unlock(&m_lock); + return false; + } + + // + // Take minimum version beween what we support and what the host support + // + if (m_major > systemEGLVersionMajor) { + m_major = systemEGLVersionMajor; + m_minor = systemEGLVersionMinor; + } + else if (m_major == systemEGLVersionMajor && + m_minor > systemEGLVersionMinor) { + m_minor = systemEGLVersionMinor; + } + + // + // Query the host for the set of configs + // + m_numConfigs = rcEnc->rcGetNumConfigs(rcEnc, (uint32_t*)&m_numConfigAttribs); + if (m_numConfigs <= 0 || m_numConfigAttribs <= 0) { + // just sanity check - should never happen + pthread_mutex_unlock(&m_lock); + return false; + } + + uint32_t nInts = m_numConfigAttribs * (m_numConfigs + 1); + EGLint tmp_buf[nInts]; + m_configs = new EGLint[nInts-m_numConfigAttribs]; + if (!m_configs) { + pthread_mutex_unlock(&m_lock); + return false; + } + + //EGLint n = rcEnc->rcGetConfigs(rcEnc, nInts*sizeof(EGLint), m_configs); + EGLint n = rcEnc->rcGetConfigs(rcEnc, nInts*sizeof(EGLint), (GLuint*)tmp_buf); + if (n != m_numConfigs) { + pthread_mutex_unlock(&m_lock); + return false; + } + + //Fill the attributes vector. + //The first m_numConfigAttribs values of tmp_buf are the actual attributes enums. + for (int i=0; ircEncoder(); + if (rcEnc) { + int n = rcEnc->rcQueryEGLString(rcEnc, name, NULL, 0); + if (n < 0) { + // allocate space for the string with additional + // space charachter to be suffixed at the end. + char *str = (char *)malloc(-n+2); + n = rcEnc->rcQueryEGLString(rcEnc, name, str, -n); + if (n > 0) { + // add extra space at end of string which will be + // needed later when filtering the extension list. + strcat(str, " "); + return str; + } + + free(str); + } + } + } + + return NULL; +} + +static bool findExtInList(const char* token, int tokenlen, const char* list) +{ + const char* p = list; + while (*p != '\0') { + const char* q = strchr(p, ' '); + if (q == NULL) { + /* should not happen, list must be space-terminated */ + break; + } + if (tokenlen == (q - p) && !memcmp(token, p, tokenlen)) { + return true; /* found it */ + } + p = q+1; + } + return false; /* not found */ +} + +static char *buildExtensionString() +{ + //Query host extension string + char *hostExt = queryHostEGLString(EGL_EXTENSIONS); + if (!hostExt || (hostExt[1] == '\0')) { + // no extensions on host - only static extension list supported + return strdup(systemStaticEGLExtensions); + } + + int n = strlen(hostExt); + if (n > 0) { + char *str; + asprintf(&str,"%s%s", systemStaticEGLExtensions, hostExt); + free((char*)hostExt); + return str; + } + else { + free((char*)hostExt); + return strdup(systemStaticEGLExtensions); + } +} + +const char *eglDisplay::queryString(EGLint name) +{ + if (name == EGL_CLIENT_APIS) { + return "OpenGL_ES"; + } + else if (name == EGL_VERSION) { + pthread_mutex_lock(&m_lock); + if (m_versionString) { + pthread_mutex_unlock(&m_lock); + return m_versionString; + } + + // build version string + asprintf(&m_versionString, "%d.%d", m_major, m_minor); + pthread_mutex_unlock(&m_lock); + + return m_versionString; + } + else if (name == EGL_VENDOR) { + pthread_mutex_lock(&m_lock); + if (m_vendorString) { + pthread_mutex_unlock(&m_lock); + return m_vendorString; + } + + // build vendor string + const char *hostVendor = queryHostEGLString(EGL_VENDOR); + + if (hostVendor) { + asprintf(&m_vendorString, "%s Host: %s", + systemEGLVendor, hostVendor); + free((char*)hostVendor); + } + else { + m_vendorString = (char *)systemEGLVendor; + } + pthread_mutex_unlock(&m_lock); + + return m_vendorString; + } + else if (name == EGL_EXTENSIONS) { + pthread_mutex_lock(&m_lock); + if (m_extensionString) { + pthread_mutex_unlock(&m_lock); + return m_extensionString; + } + + // build extension string + m_extensionString = buildExtensionString(); + pthread_mutex_unlock(&m_lock); + + return m_extensionString; + } + else { + ALOGE("[%s] Unknown name %d\n", __FUNCTION__, name); + return NULL; + } +} + +/* To get the value of attribute of config use the following formula: + * value = *(m_configs + (int)c*m_numConfigAttribs + a); + */ +EGLBoolean eglDisplay::getAttribValue(EGLConfig config, EGLint attribIdx, EGLint * value) +{ + if (attribIdx == ATTRIBUTE_NONE) + { + ALOGE("[%s] Bad attribute idx\n", __FUNCTION__); + return EGL_FALSE; + } + *value = *(m_configs + (intptr_t)config*m_numConfigAttribs + attribIdx); + return EGL_TRUE; +} + +EGLBoolean eglDisplay::getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value) +{ + //Though it seems that valueFor() is thread-safe, we don't take chanses + pthread_mutex_lock(&m_lock); + EGLBoolean ret = getAttribValue(config, m_attribs.valueFor(attrib), value); + pthread_mutex_unlock(&m_lock); + return ret; +} + +void eglDisplay::dumpConfig(EGLConfig config) +{ + EGLint value = 0; + DBG("^^^^^^^^^^ dumpConfig %d ^^^^^^^^^^^^^^^^^^", (int)config); + for (int i=0; i of config use the following formula: + * *(m_configs + (int)c*m_numConfigAttribs + a) = value; + */ +EGLBoolean eglDisplay::setAttribValue(EGLConfig config, EGLint attribIdx, EGLint value) +{ + if (attribIdx == ATTRIBUTE_NONE) + { + ALOGE("[%s] Bad attribute idx\n", __FUNCTION__); + return EGL_FALSE; + } + *(m_configs + (intptr_t)config*m_numConfigAttribs + attribIdx) = value; + return EGL_TRUE; +} + +EGLBoolean eglDisplay::setConfigAttrib(EGLConfig config, EGLint attrib, EGLint value) +{ + //Though it seems that valueFor() is thread-safe, we don't take chanses + pthread_mutex_lock(&m_lock); + EGLBoolean ret = setAttribValue(config, m_attribs.valueFor(attrib), value); + pthread_mutex_unlock(&m_lock); + return ret; +} + + +EGLBoolean eglDisplay::getConfigNativePixelFormat(EGLConfig config, PixelFormat * format) +{ + EGLint redSize, blueSize, greenSize, alphaSize; + + if ( !(getAttribValue(config, m_attribs.valueFor(EGL_RED_SIZE), &redSize) && + getAttribValue(config, m_attribs.valueFor(EGL_BLUE_SIZE), &blueSize) && + getAttribValue(config, m_attribs.valueFor(EGL_GREEN_SIZE), &greenSize) && + getAttribValue(config, m_attribs.valueFor(EGL_ALPHA_SIZE), &alphaSize)) ) + { + ALOGE("Couldn't find value for one of the pixel format attributes"); + return EGL_FALSE; + } + + //calculate the GL internal format + if ((redSize==8)&&(greenSize==8)&&(blueSize==8)&&(alphaSize==8)) *format = PIXEL_FORMAT_RGBA_8888; //XXX: BGR? + else if ((redSize==8)&&(greenSize==8)&&(blueSize==8)&&(alphaSize==0)) *format = PIXEL_FORMAT_RGBX_8888; //XXX or PIXEL_FORMAT_RGB_888 + else if ((redSize==5)&&(greenSize==6)&&(blueSize==5)&&(alphaSize==0)) *format = PIXEL_FORMAT_RGB_565; + else if ((redSize==5)&&(greenSize==5)&&(blueSize==5)&&(alphaSize==1)) *format = PIXEL_FORMAT_RGBA_5551; + else if ((redSize==4)&&(greenSize==4)&&(blueSize==4)&&(alphaSize==4)) *format = PIXEL_FORMAT_RGBA_4444; + else { + return EGL_FALSE; + } + return EGL_TRUE; +} +EGLBoolean eglDisplay::getConfigGLPixelFormat(EGLConfig config, GLenum * format) +{ + EGLint redSize, blueSize, greenSize, alphaSize; + + if ( !(getAttribValue(config, m_attribs.valueFor(EGL_RED_SIZE), &redSize) && + getAttribValue(config, m_attribs.valueFor(EGL_BLUE_SIZE), &blueSize) && + getAttribValue(config, m_attribs.valueFor(EGL_GREEN_SIZE), &greenSize) && + getAttribValue(config, m_attribs.valueFor(EGL_ALPHA_SIZE), &alphaSize)) ) + { + ALOGE("Couldn't find value for one of the pixel format attributes"); + return EGL_FALSE; + } + + //calculate the GL internal format + if ((redSize == greenSize) && (redSize == blueSize) && + ((redSize == 8) || (redSize == 16) || (redSize == 32))) + { + if (alphaSize == 0) *format = GL_RGB; + else *format = GL_RGBA; + } + else if ((redSize==5)&&(greenSize==6)&&(blueSize==5)&&(alphaSize==0)) *format = GL_RGB565_OES; + else if ((redSize==5)&&(greenSize==5)&&(blueSize==5)&&(alphaSize==1)) *format = GL_RGB5_A1_OES; + else if ((redSize==4)&&(greenSize==4)&&(blueSize==4)&&(alphaSize==4)) *format = GL_RGBA4_OES; + else return EGL_FALSE; + + return EGL_TRUE; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.h new file mode 100644 index 0000000..9d979d9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/eglDisplay.h @@ -0,0 +1,89 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _SYSTEM_EGL_DISPLAY_H +#define _SYSTEM_EGL_DISPLAY_H + +#include +#include "glUtils.h" +#include +#include +#include "EGLClientIface.h" +#include + +#include + +#define ATTRIBUTE_NONE -1 +//FIXME: are we in this namespace? +using namespace android; + +class eglDisplay +{ +public: + eglDisplay(); + ~eglDisplay(); + + bool initialize(EGLClient_eglInterface *eglIface); + void terminate(); + + int getVersionMajor() const { return m_major; } + int getVersionMinor() const { return m_minor; } + bool initialized() const { return m_initialized; } + + const char *queryString(EGLint name); + + const EGLClient_glesInterface *gles_iface() const { return m_gles_iface; } + const EGLClient_glesInterface *gles2_iface() const { return m_gles2_iface; } + + int getNumConfigs(){ return m_numConfigs; } + EGLBoolean getConfigAttrib(EGLConfig config, EGLint attrib, EGLint * value); + EGLBoolean setConfigAttrib(EGLConfig config, EGLint attrib, EGLint value); + EGLBoolean getConfigGLPixelFormat(EGLConfig config, GLenum * format); + EGLBoolean getConfigNativePixelFormat(EGLConfig config, PixelFormat * format); + + void dumpConfig(EGLConfig config); +private: + EGLClient_glesInterface *loadGLESClientAPI(const char *libName, + EGLClient_eglInterface *eglIface, + void **libHandle); + EGLBoolean getAttribValue(EGLConfig config, EGLint attribIdxi, EGLint * value); + EGLBoolean setAttribValue(EGLConfig config, EGLint attribIdxi, EGLint value); + void processConfigs(); + +private: + pthread_mutex_t m_lock; + bool m_initialized; + int m_major; + int m_minor; + int m_hostRendererVersion; + int m_numConfigs; + int m_numConfigAttribs; + + /* This is the mapping between an attribute name to it's index in any given config */ + DefaultKeyedVector m_attribs; + /* This is an array of all config's attributes values stored in the following sequencial fasion (read: v[c,a] = the value of attribute of config ) + * v[0,0],..,v[0,m_numConfigAttribs-1], + *... + * v[m_numConfigs-1,0],..,v[m_numConfigs-1,m_numConfigAttribs-1] + */ + EGLint *m_configs; + EGLClient_glesInterface *m_gles_iface; + EGLClient_glesInterface *m_gles2_iface; + char *m_versionString; + char *m_vendorString; + char *m_extensionString; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/egl_ftable.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/egl_ftable.h new file mode 100644 index 0000000..16d130c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/egl/egl_ftable.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +static const struct _egl_funcs_by_name { + const char *name; + void *proc; +} egl_funcs_by_name[] = { + {"eglGetError", (void *)eglGetError}, + {"eglGetDisplay", (void *)eglGetDisplay}, + {"eglInitialize", (void *)eglInitialize}, + {"eglTerminate", (void *)eglTerminate}, + {"eglQueryString", (void *)eglQueryString}, + {"eglGetConfigs", (void *)eglGetConfigs}, + {"eglChooseConfig", (void *)eglChooseConfig}, + {"eglGetConfigAttrib", (void *)eglGetConfigAttrib}, + {"eglCreateWindowSurface", (void *)eglCreateWindowSurface}, + {"eglCreatePbufferSurface", (void *)eglCreatePbufferSurface}, + {"eglCreatePixmapSurface", (void *)eglCreatePixmapSurface}, + {"eglDestroySurface", (void *)eglDestroySurface}, + {"eglQuerySurface", (void *)eglQuerySurface}, + {"eglBindAPI", (void *)eglBindAPI}, + {"eglQueryAPI", (void *)eglQueryAPI}, + {"eglWaitClient", (void *)eglWaitClient}, + {"eglReleaseThread", (void *)eglReleaseThread}, + {"eglCreatePbufferFromClientBuffer", (void *)eglCreatePbufferFromClientBuffer}, + {"eglSurfaceAttrib", (void *)eglSurfaceAttrib}, + {"eglBindTexImage", (void *)eglBindTexImage}, + {"eglReleaseTexImage", (void *)eglReleaseTexImage}, + {"eglSwapInterval", (void *)eglSwapInterval}, + {"eglCreateContext", (void *)eglCreateContext}, + {"eglDestroyContext", (void *)eglDestroyContext}, + {"eglMakeCurrent", (void *)eglMakeCurrent}, + {"eglGetCurrentContext", (void *)eglGetCurrentContext}, + {"eglGetCurrentSurface", (void *)eglGetCurrentSurface}, + {"eglGetCurrentDisplay", (void *)eglGetCurrentDisplay}, + {"eglQueryContext", (void *)eglQueryContext}, + {"eglWaitGL", (void *)eglWaitGL}, + {"eglWaitNative", (void *)eglWaitNative}, + {"eglSwapBuffers", (void *)eglSwapBuffers}, + {"eglCopyBuffers", (void *)eglCopyBuffers}, + {"eglGetProcAddress", (void *)eglGetProcAddress}, + {"eglLockSurfaceKHR", (void *)eglLockSurfaceKHR}, + {"eglUnlockSurfaceKHR", (void *)eglUnlockSurfaceKHR}, + {"eglCreateImageKHR", (void *)eglCreateImageKHR}, + {"eglDestroyImageKHR", (void *)eglDestroyImageKHR}, + {"eglCreateSyncKHR", (void *)eglCreateSyncKHR}, + {"eglDestroySyncKHR", (void *)eglDestroySyncKHR}, + {"eglClientWaitSyncKHR", (void *)eglClientWaitSyncKHR}, + {"eglGetSyncAttribKHR", (void *)eglGetSyncAttribKHR} +}; + +static const int egl_num_funcs = sizeof(egl_funcs_by_name) / sizeof(struct _egl_funcs_by_name); diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/Android.mk new file mode 100644 index 0000000..71ac2f2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/Android.mk @@ -0,0 +1,20 @@ +ifneq (false,$(BUILD_EMULATOR_OPENGL_DRIVER)) + +LOCAL_PATH := $(call my-dir) + +$(call emugl-begin-shared-library,gralloc.goldfish) +$(call emugl-import,libGLESv1_enc lib_renderControl_enc libOpenglSystemCommon) +$(call emugl-set-shared-library-subpath,hw) + +LOCAL_CFLAGS += -DLOG_TAG=\"gralloc_goldfish\" +LOCAL_CFLAGS += -Wno-missing-field-initializers + +LOCAL_SRC_FILES := gralloc.cpp + +# Need to access the special OPENGL TLS Slot +LOCAL_C_INCLUDES += bionic/libc/private +LOCAL_SHARED_LIBRARIES += libdl + +$(call emugl-end-module) + +endif # BUILD_EMULATOR_OPENGL_DRIVER != false diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/gralloc.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/gralloc.cpp new file mode 100644 index 0000000..e89fa0f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/gralloc/gralloc.cpp @@ -0,0 +1,1059 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include "gralloc_cb.h" +#include "HostConnection.h" +#include "glUtils.h" +#include +#include + +/* Set to 1 or 2 to enable debug traces */ +#define DEBUG 0 + +#if DEBUG >= 1 +# define D(...) ALOGD(__VA_ARGS__) +#else +# define D(...) ((void)0) +#endif + +#if DEBUG >= 2 +# define DD(...) ALOGD(__VA_ARGS__) +#else +# define DD(...) ((void)0) +#endif + +#define DBG_FUNC DBG("%s\n", __FUNCTION__) +// +// our private gralloc module structure +// +struct private_module_t { + gralloc_module_t base; +}; + +/* If not NULL, this is a pointer to the fallback module. + * This really is gralloc.default, which we'll use if we detect + * that the emulator we're running in does not support GPU emulation. + */ +static gralloc_module_t* sFallback; +static pthread_once_t sFallbackOnce = PTHREAD_ONCE_INIT; + +static void fallback_init(void); // forward + + +typedef struct _alloc_list_node { + buffer_handle_t handle; + _alloc_list_node *next; + _alloc_list_node *prev; +} AllocListNode; + +// +// Our gralloc device structure (alloc interface) +// +struct gralloc_device_t { + alloc_device_t device; + + AllocListNode *allocListHead; // double linked list of allocated buffers + pthread_mutex_t lock; +}; + +// +// Our framebuffer device structure +// +struct fb_device_t { + framebuffer_device_t device; +}; + +static int map_buffer(cb_handle_t *cb, void **vaddr) +{ + if (cb->fd < 0 || cb->ashmemSize <= 0) { + return -EINVAL; + } + + void *addr = mmap(0, cb->ashmemSize, PROT_READ | PROT_WRITE, + MAP_SHARED, cb->fd, 0); + if (addr == MAP_FAILED) { + return -errno; + } + + cb->ashmemBase = intptr_t(addr); + cb->ashmemBasePid = getpid(); + + *vaddr = addr; + return 0; +} + +#define DEFINE_HOST_CONNECTION \ + HostConnection *hostCon = HostConnection::get(); \ + renderControl_encoder_context_t *rcEnc = (hostCon ? hostCon->rcEncoder() : NULL) + +#define DEFINE_AND_VALIDATE_HOST_CONNECTION \ + HostConnection *hostCon = HostConnection::get(); \ + if (!hostCon) { \ + ALOGE("gralloc: Failed to get host connection\n"); \ + return -EIO; \ + } \ + renderControl_encoder_context_t *rcEnc = hostCon->rcEncoder(); \ + if (!rcEnc) { \ + ALOGE("gralloc: Failed to get renderControl encoder context\n"); \ + return -EIO; \ + } + + +// +// gralloc device functions (alloc interface) +// +static int gralloc_alloc(alloc_device_t* dev, + int w, int h, int format, int usage, + buffer_handle_t* pHandle, int* pStride) +{ + D("gralloc_alloc w=%d h=%d usage=0x%x\n", w, h, usage); + + gralloc_device_t *grdev = (gralloc_device_t *)dev; + if (!grdev || !pHandle || !pStride) { + ALOGE("gralloc_alloc: Bad inputs (grdev: %p, pHandle: %p, pStride: %p", + grdev, pHandle, pStride); + return -EINVAL; + } + + // + // Note: in screen capture mode, both sw_write and hw_write will be on + // and this is a valid usage + // + bool sw_write = (0 != (usage & GRALLOC_USAGE_SW_WRITE_MASK)); + bool hw_write = (usage & GRALLOC_USAGE_HW_RENDER); + bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK)); + bool hw_cam_write = usage & GRALLOC_USAGE_HW_CAMERA_WRITE; + bool hw_cam_read = usage & GRALLOC_USAGE_HW_CAMERA_READ; + bool hw_vid_enc_read = usage & GRALLOC_USAGE_HW_VIDEO_ENCODER; + + // Keep around original requested format for later validation + int frameworkFormat = format; + // Pick the right concrete pixel format given the endpoints as encoded in + // the usage bits. Every end-point pair needs explicit listing here. + if (format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { + // Camera as producer + if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE) { + if (usage & GRALLOC_USAGE_HW_TEXTURE) { + // Camera-to-display is RGBA + format = HAL_PIXEL_FORMAT_RGBA_8888; + } else if (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) { + // Camera-to-encoder is NV21 + format = HAL_PIXEL_FORMAT_YCrCb_420_SP; + } else if ((usage & GRALLOC_USAGE_HW_CAMERA_MASK) == + GRALLOC_USAGE_HW_CAMERA_ZSL) { + // Camera-to-ZSL-queue is RGB_888 + format = HAL_PIXEL_FORMAT_RGB_888; + } + } + + if (format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) { + ALOGE("gralloc_alloc: Requested auto format selection, " + "but no known format for this usage: %d x %d, usage %x", + w, h, usage); + return -EINVAL; + } + } else if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { + // Flexible framework-accessible YUV format; map to NV21 for now + if (usage & GRALLOC_USAGE_HW_CAMERA_WRITE) { + format = HAL_PIXEL_FORMAT_YCrCb_420_SP; + } + if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { + ALOGE("gralloc_alloc: Requested YCbCr_420_888, but no known " + "specific format for this usage: %d x %d, usage %x", + w, h, usage); + } + } + bool yuv_format = false; + + int ashmem_size = 0; + int stride = w; + + GLenum glFormat = 0; + GLenum glType = 0; + + int bpp = 0; + int align = 1; + switch (format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_BGRA_8888: + bpp = 4; + glFormat = GL_RGBA; + glType = GL_UNSIGNED_BYTE; + break; + case HAL_PIXEL_FORMAT_RGB_888: + bpp = 3; + glFormat = GL_RGB; + glType = GL_UNSIGNED_BYTE; + break; + case HAL_PIXEL_FORMAT_RGB_565: + bpp = 2; + glFormat = GL_RGB; + glType = GL_UNSIGNED_SHORT_5_6_5; + break; + case HAL_PIXEL_FORMAT_RAW16: + case HAL_PIXEL_FORMAT_Y16: + bpp = 2; + align = 16*bpp; + if (! ((sw_read || hw_cam_read) && (sw_write || hw_cam_write) ) ) { + // Raw sensor data or Y16 only goes between camera and CPU + return -EINVAL; + } + // Not expecting to actually create any GL surfaces for this + glFormat = GL_LUMINANCE; + glType = GL_UNSIGNED_SHORT; + break; + case HAL_PIXEL_FORMAT_BLOB: + bpp = 1; + if (! (sw_read && hw_cam_write) ) { + // Blob data cannot be used by HW other than camera emulator + return -EINVAL; + } + // Not expecting to actually create any GL surfaces for this + glFormat = GL_LUMINANCE; + glType = GL_UNSIGNED_BYTE; + break; + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + align = 1; + bpp = 1; // per-channel bpp + yuv_format = true; + // Not expecting to actually create any GL surfaces for this + break; + case HAL_PIXEL_FORMAT_YV12: + align = 16; + bpp = 1; // per-channel bpp + yuv_format = true; + // Not expecting to actually create any GL surfaces for this + break; + default: + ALOGE("gralloc_alloc: Unknown format %d", format); + return -EINVAL; + } + + if (usage & GRALLOC_USAGE_HW_FB) { + // keep space for postCounter + ashmem_size += sizeof(uint32_t); + } + + if (sw_read || sw_write || hw_cam_write || hw_vid_enc_read) { + // keep space for image on guest memory if SW access is needed + // or if the camera is doing writing + if (yuv_format) { + size_t yStride = (w*bpp + (align - 1)) & ~(align-1); + size_t uvStride = (yStride / 2 + (align - 1)) & ~(align-1); + size_t uvHeight = h / 2; + ashmem_size += yStride * h + 2 * (uvHeight * uvStride); + stride = yStride / bpp; + } else { + size_t bpr = (w*bpp + (align-1)) & ~(align-1); + ashmem_size += (bpr * h); + stride = bpr / bpp; + } + } + + D("gralloc_alloc format=%d, ashmem_size=%d, stride=%d, tid %d\n", format, + ashmem_size, stride, gettid()); + + // + // Allocate space in ashmem if needed + // + int fd = -1; + if (ashmem_size > 0) { + // round to page size; + ashmem_size = (ashmem_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); + + fd = ashmem_create_region("gralloc-buffer", ashmem_size); + if (fd < 0) { + ALOGE("gralloc_alloc failed to create ashmem region: %s\n", + strerror(errno)); + return -errno; + } + } + + cb_handle_t *cb = new cb_handle_t(fd, ashmem_size, usage, + w, h, frameworkFormat, format, + glFormat, glType); + + if (ashmem_size > 0) { + // + // map ashmem region if exist + // + void *vaddr; + int err = map_buffer(cb, &vaddr); + if (err) { + close(fd); + delete cb; + return err; + } + + cb->setFd(fd); + } + + // + // Allocate ColorBuffer handle on the host (only if h/w access is allowed) + // Only do this for some h/w usages, not all. + // Also do this if we need to read from the surface, in this case the + // rendering will still happen on the host but we also need to be able to + // read back from the color buffer, which requires that there is a buffer + // + if (usage & (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER | + GRALLOC_USAGE_HW_2D | GRALLOC_USAGE_HW_COMPOSER | + GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_SW_READ_MASK) ) { + DEFINE_HOST_CONNECTION; + if (hostCon && rcEnc) { + cb->hostHandle = rcEnc->rcCreateColorBuffer(rcEnc, w, h, glFormat); + D("Created host ColorBuffer 0x%x\n", cb->hostHandle); + } + + if (!cb->hostHandle) { + // Could not create colorbuffer on host !!! + close(fd); + delete cb; + return -EIO; + } + } + + // + // alloc succeeded - insert the allocated handle to the allocated list + // + AllocListNode *node = new AllocListNode(); + pthread_mutex_lock(&grdev->lock); + node->handle = cb; + node->next = grdev->allocListHead; + node->prev = NULL; + if (grdev->allocListHead) { + grdev->allocListHead->prev = node; + } + grdev->allocListHead = node; + pthread_mutex_unlock(&grdev->lock); + + *pHandle = cb; + if (frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) { + *pStride = 0; + } else { + *pStride = stride; + } + return 0; +} + +static int gralloc_free(alloc_device_t* dev, + buffer_handle_t handle) +{ + const cb_handle_t *cb = (const cb_handle_t *)handle; + if (!cb_handle_t::validate((cb_handle_t*)cb)) { + ERR("gralloc_free: invalid handle"); + return -EINVAL; + } + + if (cb->hostHandle != 0) { + DEFINE_AND_VALIDATE_HOST_CONNECTION; + D("Closing host ColorBuffer 0x%x\n", cb->hostHandle); + rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle); + } + + // + // detach and unmap ashmem area if present + // + if (cb->fd > 0) { + if (cb->ashmemSize > 0 && cb->ashmemBase) { + munmap((void *)cb->ashmemBase, cb->ashmemSize); + } + close(cb->fd); + } + + // remove it from the allocated list + gralloc_device_t *grdev = (gralloc_device_t *)dev; + pthread_mutex_lock(&grdev->lock); + AllocListNode *n = grdev->allocListHead; + while( n && n->handle != cb ) { + n = n->next; + } + if (n) { + // buffer found on list - remove it from list + if (n->next) { + n->next->prev = n->prev; + } + if (n->prev) { + n->prev->next = n->next; + } + else { + grdev->allocListHead = n->next; + } + + delete n; + } + pthread_mutex_unlock(&grdev->lock); + + delete cb; + + return 0; +} + +static int gralloc_device_close(struct hw_device_t *dev) +{ + gralloc_device_t* d = reinterpret_cast(dev); + if (d) { + + // free still allocated buffers + while( d->allocListHead != NULL ) { + gralloc_free(&d->device, d->allocListHead->handle); + } + + // free device + free(d); + } + return 0; +} + +static int fb_compositionComplete(struct framebuffer_device_t* dev) +{ + (void)dev; + + return 0; +} + +// +// Framebuffer device functions +// +static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer) +{ + fb_device_t *fbdev = (fb_device_t *)dev; + cb_handle_t *cb = (cb_handle_t *)buffer; + + if (!fbdev || !cb_handle_t::validate(cb) || !cb->canBePosted()) { + return -EINVAL; + } + + // Make sure we have host connection + DEFINE_AND_VALIDATE_HOST_CONNECTION; + + // increment the post count of the buffer + intptr_t *postCountPtr = (intptr_t *)cb->ashmemBase; + if (!postCountPtr) { + // This should not happen + return -EINVAL; + } + (*postCountPtr)++; + + // send post request to host + rcEnc->rcFBPost(rcEnc, cb->hostHandle); + hostCon->flush(); + + return 0; +} + +static int fb_setUpdateRect(struct framebuffer_device_t* dev, + int l, int t, int w, int h) +{ + fb_device_t *fbdev = (fb_device_t *)dev; + + (void)l; + (void)t; + (void)w; + (void)h; + + if (!fbdev) { + return -EINVAL; + } + + // Make sure we have host connection + DEFINE_AND_VALIDATE_HOST_CONNECTION; + + // send request to host + // TODO: XXX - should be implemented + //rcEnc->rc_XXX + + return 0; +} + +static int fb_setSwapInterval(struct framebuffer_device_t* dev, + int interval) +{ + fb_device_t *fbdev = (fb_device_t *)dev; + + if (!fbdev) { + return -EINVAL; + } + + // Make sure we have host connection + DEFINE_AND_VALIDATE_HOST_CONNECTION; + + // send request to host + rcEnc->rcFBSetSwapInterval(rcEnc, interval); + hostCon->flush(); + + return 0; +} + +static int fb_close(struct hw_device_t *dev) +{ + fb_device_t *fbdev = (fb_device_t *)dev; + + delete fbdev; + + return 0; +} + + +// +// gralloc module functions - refcount + locking interface +// +static int gralloc_register_buffer(gralloc_module_t const* module, + buffer_handle_t handle) +{ + pthread_once(&sFallbackOnce, fallback_init); + if (sFallback != NULL) { + return sFallback->registerBuffer(sFallback, handle); + } + + D("gralloc_register_buffer(%p) called", handle); + + private_module_t *gr = (private_module_t *)module; + cb_handle_t *cb = (cb_handle_t *)handle; + if (!gr || !cb_handle_t::validate(cb)) { + ERR("gralloc_register_buffer(%p): invalid buffer", cb); + return -EINVAL; + } + + if (cb->hostHandle != 0) { + DEFINE_AND_VALIDATE_HOST_CONNECTION; + D("Opening host ColorBuffer 0x%x\n", cb->hostHandle); + rcEnc->rcOpenColorBuffer2(rcEnc, cb->hostHandle); + } + + // + // if the color buffer has ashmem region and it is not mapped in this + // process map it now. + // + if (cb->ashmemSize > 0 && cb->mappedPid != getpid()) { + void *vaddr; + int err = map_buffer(cb, &vaddr); + if (err) { + ERR("gralloc_register_buffer(%p): map failed: %s", cb, strerror(-err)); + return -err; + } + cb->mappedPid = getpid(); + } + + return 0; +} + +static int gralloc_unregister_buffer(gralloc_module_t const* module, + buffer_handle_t handle) +{ + if (sFallback != NULL) { + return sFallback->unregisterBuffer(sFallback, handle); + } + + private_module_t *gr = (private_module_t *)module; + cb_handle_t *cb = (cb_handle_t *)handle; + if (!gr || !cb_handle_t::validate(cb)) { + ERR("gralloc_unregister_buffer(%p): invalid buffer", cb); + return -EINVAL; + } + + if (cb->hostHandle != 0) { + DEFINE_AND_VALIDATE_HOST_CONNECTION; + D("Closing host ColorBuffer 0x%x\n", cb->hostHandle); + rcEnc->rcCloseColorBuffer(rcEnc, cb->hostHandle); + } + + // + // unmap ashmem region if it was previously mapped in this process + // (through register_buffer) + // + if (cb->ashmemSize > 0 && cb->mappedPid == getpid()) { + void *vaddr; + int err = munmap((void *)cb->ashmemBase, cb->ashmemSize); + if (err) { + ERR("gralloc_unregister_buffer(%p): unmap failed", cb); + return -EINVAL; + } + cb->ashmemBase = 0; + cb->mappedPid = 0; + } + + D("gralloc_unregister_buffer(%p) done\n", cb); + + return 0; +} + +static int gralloc_lock(gralloc_module_t const* module, + buffer_handle_t handle, int usage, + int l, int t, int w, int h, + void** vaddr) +{ + if (sFallback != NULL) { + return sFallback->lock(sFallback, handle, usage, l, t, w, h, vaddr); + } + + private_module_t *gr = (private_module_t *)module; + cb_handle_t *cb = (cb_handle_t *)handle; + if (!gr || !cb_handle_t::validate(cb)) { + ALOGE("gralloc_lock bad handle\n"); + return -EINVAL; + } + + // validate format + if (cb->frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) { + ALOGE("gralloc_lock can't be used with YCbCr_420_888 format"); + return -EINVAL; + } + + // Validate usage, + // 1. cannot be locked for hw access + // 2. lock for either sw read or write. + // 3. locked sw access must match usage during alloc time. + bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK)); + bool sw_write = (0 != (usage & GRALLOC_USAGE_SW_WRITE_MASK)); + bool hw_read = (usage & GRALLOC_USAGE_HW_TEXTURE); + bool hw_write = (usage & GRALLOC_USAGE_HW_RENDER); + bool hw_vid_enc_read = (usage & GRALLOC_USAGE_HW_VIDEO_ENCODER); + bool hw_cam_write = (usage & GRALLOC_USAGE_HW_CAMERA_WRITE); + bool hw_cam_read = (usage & GRALLOC_USAGE_HW_CAMERA_READ); + bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK)); + bool sw_write_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_WRITE_MASK)); + + if ( (hw_read || hw_write) || + (!sw_read && !sw_write && + !hw_cam_write && !hw_cam_read && + !hw_vid_enc_read) || + (sw_read && !sw_read_allowed) || + (sw_write && !sw_write_allowed) ) { + ALOGE("gralloc_lock usage mismatch usage=0x%x cb->usage=0x%x\n", usage, + cb->usage); + return -EINVAL; + } + + intptr_t postCount = 0; + void *cpu_addr = NULL; + + // + // make sure ashmem area is mapped if needed + // + if (cb->canBePosted() || sw_read || sw_write || + hw_cam_write || hw_cam_read || + hw_vid_enc_read) { + if (cb->ashmemBasePid != getpid() || !cb->ashmemBase) { + return -EACCES; + } + + if (cb->canBePosted()) { + postCount = *((intptr_t *)cb->ashmemBase); + cpu_addr = (void *)(cb->ashmemBase + sizeof(intptr_t)); + } + else { + cpu_addr = (void *)(cb->ashmemBase); + } + } + + if (cb->hostHandle) { + // Make sure we have host connection + DEFINE_AND_VALIDATE_HOST_CONNECTION; + + // + // flush color buffer write cache on host and get its sync status. + // + int hostSyncStatus = rcEnc->rcColorBufferCacheFlush(rcEnc, cb->hostHandle, + postCount, + sw_read); + if (hostSyncStatus < 0) { + // host failed the color buffer sync - probably since it was already + // locked for write access. fail the lock. + ALOGE("gralloc_lock cacheFlush failed postCount=%d sw_read=%d\n", + postCount, sw_read); + return -EBUSY; + } + + if (sw_read) { + D("gralloc_lock read back color buffer %d %d\n", cb->width, cb->height); + rcEnc->rcReadColorBuffer(rcEnc, cb->hostHandle, + 0, 0, cb->width, cb->height, cb->glFormat, cb->glType, cpu_addr); + } + } + + // + // is virtual address required ? + // + if (sw_read || sw_write || hw_cam_write || hw_cam_read || hw_vid_enc_read) { + *vaddr = cpu_addr; + } + + if (sw_write || hw_cam_write) { + // + // Keep locked region if locked for s/w write access. + // + cb->lockedLeft = l; + cb->lockedTop = t; + cb->lockedWidth = w; + cb->lockedHeight = h; + } + + DD("gralloc_lock success. vaddr: %p, *vaddr: %p, usage: %x, cpu_addr: %p", + vaddr, vaddr ? *vaddr : 0, usage, cpu_addr); + + return 0; +} + +static int gralloc_unlock(gralloc_module_t const* module, + buffer_handle_t handle) +{ + if (sFallback != NULL) { + return sFallback->unlock(sFallback, handle); + } + + private_module_t *gr = (private_module_t *)module; + cb_handle_t *cb = (cb_handle_t *)handle; + if (!gr || !cb_handle_t::validate(cb)) { + return -EINVAL; + } + + // + // if buffer was locked for s/w write, we need to update the host with + // the updated data + // + if (cb->hostHandle) { + + // Make sure we have host connection + DEFINE_AND_VALIDATE_HOST_CONNECTION; + + void *cpu_addr; + if (cb->canBePosted()) { + cpu_addr = (void *)(cb->ashmemBase + sizeof(int)); + } + else { + cpu_addr = (void *)(cb->ashmemBase); + } + + if (cb->lockedWidth < cb->width || cb->lockedHeight < cb->height) { + int bpp = glUtilsPixelBitSize(cb->glFormat, cb->glType) >> 3; + char *tmpBuf = new char[cb->lockedWidth * cb->lockedHeight * bpp]; + + int dst_line_len = cb->lockedWidth * bpp; + int src_line_len = cb->width * bpp; + char *src = (char *)cpu_addr + cb->lockedTop*src_line_len + cb->lockedLeft*bpp; + char *dst = tmpBuf; + for (int y=0; ylockedHeight; y++) { + memcpy(dst, src, dst_line_len); + src += src_line_len; + dst += dst_line_len; + } + + rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle, + cb->lockedLeft, cb->lockedTop, + cb->lockedWidth, cb->lockedHeight, + cb->glFormat, cb->glType, + tmpBuf); + + delete [] tmpBuf; + } + else { + rcEnc->rcUpdateColorBuffer(rcEnc, cb->hostHandle, 0, 0, + cb->width, cb->height, + cb->glFormat, cb->glType, + cpu_addr); + } + } + + cb->lockedWidth = cb->lockedHeight = 0; + return 0; +} + +static int gralloc_lock_ycbcr(gralloc_module_t const* module, + buffer_handle_t handle, int usage, + int l, int t, int w, int h, + android_ycbcr *ycbcr) +{ + // Not supporting fallback module for YCbCr + if (sFallback != NULL) { + return -EINVAL; + } + + if (!ycbcr) { + ALOGE("gralloc_lock_ycbcr got NULL ycbcr struct"); + return -EINVAL; + } + + private_module_t *gr = (private_module_t *)module; + cb_handle_t *cb = (cb_handle_t *)handle; + if (!gr || !cb_handle_t::validate(cb)) { + ALOGE("gralloc_lock_ycbcr bad handle\n"); + return -EINVAL; + } + + if (cb->frameworkFormat != HAL_PIXEL_FORMAT_YCbCr_420_888) { + ALOGE("gralloc_lock_ycbcr can only be used with " + "HAL_PIXEL_FORMAT_YCbCr_420_888, got %x instead", + cb->frameworkFormat); + return -EINVAL; + } + + // Validate usage + // For now, only allow camera write, software read. + bool sw_read = (0 != (usage & GRALLOC_USAGE_SW_READ_MASK)); + bool hw_cam_write = (usage & GRALLOC_USAGE_HW_CAMERA_WRITE); + bool sw_read_allowed = (0 != (cb->usage & GRALLOC_USAGE_SW_READ_MASK)); + + if ( (!hw_cam_write && !sw_read) || + (sw_read && !sw_read_allowed) ) { + ALOGE("gralloc_lock_ycbcr usage mismatch usage:0x%x cb->usage:0x%x\n", + usage, cb->usage); + return -EINVAL; + } + + // Make sure memory is mapped, get address + if (cb->ashmemBasePid != getpid() || !cb->ashmemBase) { + return -EACCES; + } + + uint8_t *cpu_addr = NULL; + + if (cb->canBePosted()) { + cpu_addr = (uint8_t *)(cb->ashmemBase + sizeof(int)); + } + else { + cpu_addr = (uint8_t *)(cb->ashmemBase); + } + + // Calculate offsets to underlying YUV data + size_t yStride; + size_t cStride; + size_t yOffset; + size_t uOffset; + size_t vOffset; + size_t cStep; + switch (cb->format) { + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + yStride = cb->width; + cStride = cb->width; + yOffset = 0; + vOffset = yStride * cb->height; + uOffset = vOffset + 1; + cStep = 2; + break; + default: + ALOGE("gralloc_lock_ycbcr unexpected internal format %x", + cb->format); + return -EINVAL; + } + + ycbcr->y = cpu_addr + yOffset; + ycbcr->cb = cpu_addr + uOffset; + ycbcr->cr = cpu_addr + vOffset; + ycbcr->ystride = yStride; + ycbcr->cstride = cStride; + ycbcr->chroma_step = cStep; + + // Zero out reserved fields + memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved)); + + // + // Keep locked region if locked for s/w write access. + // + cb->lockedLeft = l; + cb->lockedTop = t; + cb->lockedWidth = w; + cb->lockedHeight = h; + + DD("gralloc_lock_ycbcr success. usage: %x, ycbcr.y: %p, .cb: %p, .cr: %p, " + ".ystride: %d , .cstride: %d, .chroma_step: %d", usage, + ycbcr->y, ycbcr->cb, ycbcr->cr, ycbcr->ystride, ycbcr->cstride, + ycbcr->chroma_step); + + return 0; +} + +static int gralloc_device_open(const hw_module_t* module, + const char* name, + hw_device_t** device) +{ + int status = -EINVAL; + + D("gralloc_device_open %s\n", name); + + pthread_once( &sFallbackOnce, fallback_init ); + if (sFallback != NULL) { + return sFallback->common.methods->open(&sFallback->common, name, device); + } + + if (!strcmp(name, GRALLOC_HARDWARE_GPU0)) { + + // Create host connection and keep it in the TLS. + // return error if connection with host can not be established + HostConnection *hostCon = HostConnection::get(); + if (!hostCon) { + ALOGE("gralloc: failed to get host connection while opening %s\n", name); + return -EIO; + } + + // + // Allocate memory for the gralloc device (alloc interface) + // + gralloc_device_t *dev; + dev = (gralloc_device_t*)malloc(sizeof(gralloc_device_t)); + if (NULL == dev) { + return -ENOMEM; + } + + // Initialize our device structure + // + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = 0; + dev->device.common.module = const_cast(module); + dev->device.common.close = gralloc_device_close; + + dev->device.alloc = gralloc_alloc; + dev->device.free = gralloc_free; + dev->allocListHead = NULL; + pthread_mutex_init(&dev->lock, NULL); + + *device = &dev->device.common; + status = 0; + } + else if (!strcmp(name, GRALLOC_HARDWARE_FB0)) { + + // return error if connection with host can not be established + DEFINE_AND_VALIDATE_HOST_CONNECTION; + + // + // Query the host for Framebuffer attributes + // + D("gralloc: query Frabuffer attribs\n"); + EGLint width = rcEnc->rcGetFBParam(rcEnc, FB_WIDTH); + D("gralloc: width=%d\n", width); + EGLint height = rcEnc->rcGetFBParam(rcEnc, FB_HEIGHT); + D("gralloc: height=%d\n", height); + EGLint xdpi = rcEnc->rcGetFBParam(rcEnc, FB_XDPI); + D("gralloc: xdpi=%d\n", xdpi); + EGLint ydpi = rcEnc->rcGetFBParam(rcEnc, FB_YDPI); + D("gralloc: ydpi=%d\n", ydpi); + EGLint fps = rcEnc->rcGetFBParam(rcEnc, FB_FPS); + D("gralloc: fps=%d\n", fps); + EGLint min_si = rcEnc->rcGetFBParam(rcEnc, FB_MIN_SWAP_INTERVAL); + D("gralloc: min_swap=%d\n", min_si); + EGLint max_si = rcEnc->rcGetFBParam(rcEnc, FB_MAX_SWAP_INTERVAL); + D("gralloc: max_swap=%d\n", max_si); + + // + // Allocate memory for the framebuffer device + // + fb_device_t *dev; + dev = (fb_device_t*)malloc(sizeof(fb_device_t)); + if (NULL == dev) { + return -ENOMEM; + } + memset(dev, 0, sizeof(fb_device_t)); + + // Initialize our device structure + // + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = 0; + dev->device.common.module = const_cast(module); + dev->device.common.close = fb_close; + dev->device.setSwapInterval = fb_setSwapInterval; + dev->device.post = fb_post; + dev->device.setUpdateRect = 0; //fb_setUpdateRect; + dev->device.compositionComplete = fb_compositionComplete; //XXX: this is a dummy + + const_cast(dev->device.flags) = 0; + const_cast(dev->device.width) = width; + const_cast(dev->device.height) = height; + const_cast(dev->device.stride) = width; + const_cast(dev->device.format) = HAL_PIXEL_FORMAT_RGBA_8888; + const_cast(dev->device.xdpi) = xdpi; + const_cast(dev->device.ydpi) = ydpi; + const_cast(dev->device.fps) = fps; + const_cast(dev->device.minSwapInterval) = min_si; + const_cast(dev->device.maxSwapInterval) = max_si; + *device = &dev->device.common; + + status = 0; + } + + return status; +} + +// +// define the HMI symbol - our module interface +// +static struct hw_module_methods_t gralloc_module_methods = { + open: gralloc_device_open +}; + +struct private_module_t HAL_MODULE_INFO_SYM = { + base: { + common: { + tag: HARDWARE_MODULE_TAG, + module_api_version: GRALLOC_MODULE_API_VERSION_0_2, + hal_api_version: 0, + id: GRALLOC_HARDWARE_MODULE_ID, + name: "Graphics Memory Allocator Module", + author: "The Android Open Source Project", + methods: &gralloc_module_methods, + dso: NULL, + reserved: {0, } + }, + registerBuffer: gralloc_register_buffer, + unregisterBuffer: gralloc_unregister_buffer, + lock: gralloc_lock, + unlock: gralloc_unlock, + perform: NULL, + lock_ycbcr: gralloc_lock_ycbcr, + } +}; + +/* This function is called once to detect whether the emulator supports + * GPU emulation (this is done by looking at the qemu.gles kernel + * parameter, which must be == 1 if this is the case). + * + * If not, then load gralloc.default instead as a fallback. + */ +static void +fallback_init(void) +{ + char prop[PROPERTY_VALUE_MAX]; + void* module; + + // qemu.gles=0 -> no GLES 2.x support (only 1.x through software). + // qemu.gles=1 -> host-side GPU emulation through EmuGL + // qemu.gles=2 -> guest-side GPU emulation. + property_get("ro.kernel.qemu.gles", prop, "0"); + if (atoi(prop) == 1) { + return; + } + ALOGD("Emulator without host-side GPU emulation detected."); +#if __LP64__ + module = dlopen("/system/lib64/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL); +#else + module = dlopen("/system/lib/hw/gralloc.default.so", RTLD_LAZY|RTLD_LOCAL); +#endif + if (module != NULL) { + sFallback = reinterpret_cast(dlsym(module, HAL_MODULE_INFO_SYM_AS_STR)); + if (sFallback == NULL) { + dlclose(module); + } + } + if (sFallback == NULL) { + ALOGE("Could not find software fallback module!?"); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/Android.mk new file mode 100644 index 0000000..5792440 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/Android.mk @@ -0,0 +1,12 @@ +LOCAL_PATH := $(call my-dir) + +$(call emugl-begin-shared-library,lib_renderControl_enc) + +LOCAL_SRC_FILES := \ + renderControl_client_context.cpp \ + renderControl_enc.cpp \ + renderControl_entry.cpp + +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +$(call emugl-import,libOpenglCodecCommon) +$(call emugl-end-module) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/README b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/README new file mode 100644 index 0000000..349b6db --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/README @@ -0,0 +1,142 @@ +The renderControl.in file in this directory defines an API which is decoded +on the android guest into a stream and get decoded and executed on the host. +It is used in order to query the host renderer as well as send the host renderer +control commands. + +The following describes each of the entries defined by this renderControl API. + + +GLint rcGetRendererVersion(); + This function queries the host renderer version number. + +EGLint rcGetEGLVersion(EGLint* major, EGLint* minor); + This function queries the host renderer for the EGL version + it supports. returns EGL_FALSE on failure. + +EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize); + This function queries the host for EGL string (.i.e EGL_EXTENSIONS). + if buffer is NULL or the bufferSize is not big enough the return value + is the negative number of bytes required to store the string value + otherwise the string value is copied to buffer and its size is + returned. + +EGLint rcGetNumConfigs(uint32_t* numAttribs); + queries the host for the number of supported EGL configs. + The function returns the number of supported configs and returns in + numAttribs the number of attributes available for each config. + +EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer); + This function queries the host for the all set of supported configs + with their attribute values. + bufSize is the size of buffer, the size should be at least equal to + (numConfigs + 1) * numAttribs * sizeof(GLuint) + where numConfigs and numAttribs are the values returned in + rcGetNumConfigs. if bufSize is not big enough then the negative number + of required bytes is returned otherwise the function returns the number + of configs and buffer is filled as follows: The first 'numAttribs' + integer values are filled with the EGL enumerant describing a config + attribute, next for each config there are 'numAttribs' integer values + holding the attribute values for that config, the values are specified + in the same order as the attribute vector. + +EGLint rcChooseConfig(EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size) + This function triggers an eglChooseConfig on the host, to get a list of + configs matching the given attribs values. + attribs - a list of attribute names followed by the desired values, terminated by EGL_NONE + attribs_size - the size of the list + configs - the returned matching configuration names (same names as familiar to the client in rcGetConfigs) + configs_size - the size of the configs buffers + returns - the actual number of matching configurations (<= configs_size) + +EGLint rcGetFBParam(EGLint param); + queries the host for framebuffer parameter, see renderControl_types.h + for possible values of 'param'. + +uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion); + This function creates a rendering context on the host and returns its + handle. config is the config index for the context, share is either zero + or a handle to a sharing context. glVersion is either 1 or 2 for GLES1 + or GLES2 context respectively. + + +void rcDestroyContext(uint32_t context); + This function destroys a rendering context on the host. + context is a handle returned in rcCreateContext. + +uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height); + This function creates a 'window' surface on the host which can be then + bind for rendering through rcMakeCurrent. + The function returns a handle to the created window surface. + +void rcDestroyWindowSurface(uint32_t windowSurface); + This function destoys a window surface. + +uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat); + This function creates a colorBuffer object on the host which can be then + be specified as a render target for a window surface through + rcSetWindowColorBuffer or to be displayed on the framebuffer window + through rcFBPost. + The function returns a handle to the colorBuffer object, with an initial + reference count of 1. + +void rcOpenColorBuffer(uint32_t colorbuffer); + Adds an additional reference to the colorbuffer, typically from a + different Android process than the one which created it. + +void rcCloseColorBuffer(uint32_t colorbuffer); + Removes a reference to the colorbuffer. When the reference count drops + to zero the colorbuffer is automatically destroyed. + +void rcFlushWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer); + This flushes the current window color buffer + +void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer); + This set the target color buffer for a windowSurface, when set the + previous target colorBuffer gets updated before switching to the new + colorBuffer. + +EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf); + Binds a windowSurface(s) and current rendering context for the + calling thread. + +void rcFBPost(uint32_t colorBuffer); + This function causes the content of the colorBuffer object to be + displayed on the host framebuffer window. The function returns + immediatly, the buffer will be displayed at the next swap interval. + +void rcFBSetSwapInterval(EGLint interval); + Sets the swap interval for the host framebuffer window. + +void rcBindTexture(uint32_t colorBuffer); + This function instruct the host to bind the content of the specified + colorBuffer to the current binded texture object of the calling thread. + This function should be used to implement eglBindTexImage. + +EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead); + This function returns only after all rendering requests for the specified + colorBuffer rendering target has been processed and after all 'postCount' + posts for the buffer requested previously through rcFBPost has been + processed. + if 'forRead' is not-zero, the function returns positive value in case + there was rendering done to the buffer since the last CacheFlush request + with non-zero 'forRead' value, otherwise the function returns zero or + negative value on failure. + +void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, + GLint width, GLint height, GLenum format, + GLenum type, void* pixels); + This function queries the host for the pixel content of a colorBuffer's + subregion. It act the same as OpenGL glReadPixels however pixels + are always packed with alignment of 1. + +void rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, + GLint width, GLint height, GLenum format, + GLenum type, void* pixels); + Updates the content of a subregion of a colorBuffer object. + pixels are always unpacked with alignment of 1. + +uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buffer) + Create an EGLImage from a client object. + +int rcDestroyClientImage(uint32_t image) + Destroy an EGLImage object. diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.attrib b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.attrib new file mode 100644 index 0000000..0fa0469 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.attrib @@ -0,0 +1,45 @@ +GLOBAL + base_opcode 10000 + encoder_headers "glUtils.h" + +rcGetEGLVersion + dir major out + len major sizeof(EGLint) + dir minor out + len minor sizeof(EGLint) + +rcQueryEGLString + dir buffer out + len buffer bufferSize + +rcGetGLString + dir buffer out + len buffer bufferSize + +rcGetNumConfigs + dir numAttribs out + len numAttribs sizeof(uint32_t) + +rcGetConfigs + dir buffer out + len buffer bufSize + +rcChooseConfig + dir attribs in + len attribs attribs_size + dir configs out + var_flag configs nullAllowed + len configs configs_size*sizeof(uint32_t) + +rcReadColorBuffer + dir pixels out + len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height) + +rcUpdateColorBuffer + dir pixels in + len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height) + var_flag pixels isLarge + +rcCloseColorBuffer + flag flushOnEncode + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.in b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.in new file mode 100644 index 0000000..47b8533 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.in @@ -0,0 +1,35 @@ +GL_ENRTY(GLint, rcGetRendererVersion) +GL_ENTRY(EGLint, rcGetEGLVersion, EGLint *major, EGLint *minor) +GL_ENTRY(EGLint, rcQueryEGLString, EGLenum name, void *buffer, EGLint bufferSize) +GL_ENTRY(EGLint, rcGetGLString, EGLenum name, void *buffer, EGLint bufferSize) +GL_ENTRY(EGLint, rcGetNumConfigs, uint32_t *numAttribs) +GL_ENTRY(EGLint, rcGetConfigs, uint32_t bufSize, GLuint *buffer) +GL_ENTRY(EGLint, rcChooseConfig, EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size) +GL_ENTRY(EGLint, rcGetFBParam, EGLint param) +GL_ENTRY(uint32_t, rcCreateContext, uint32_t config, uint32_t share, uint32_t glVersion) +GL_ENTRY(void, rcDestroyContext, uint32_t context) +GL_ENTRY(uint32_t, rcCreateWindowSurface, uint32_t config, uint32_t width, uint32_t height) +GL_ENTRY(void, rcDestroyWindowSurface, uint32_t windowSurface) +GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat) +GL_ENTRY(void, rcOpenColorBuffer, uint32_t colorbuffer) +GL_ENTRY(void, rcCloseColorBuffer, uint32_t colorbuffer) +GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer) +GL_ENTRY(int, rcFlushWindowColorBuffer, uint32_t windowSurface) +GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf) +GL_ENTRY(void, rcFBPost, uint32_t colorBuffer) +GL_ENTRY(void, rcFBSetSwapInterval, EGLint interval) +GL_ENTRY(void, rcBindTexture, uint32_t colorBuffer) +GL_ENTRY(void, rcBindRenderbuffer, uint32_t colorBuffer) +GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead) +GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels) +GL_ENTRY(int, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels) +GL_ENTRY(int, rcOpenColorBuffer2, uint32_t colorbuffer) +GL_ENTRY(uint32_t, rcCreateClientImage, uint32_t context, EGLenum target, GLuint buffer) +GL_ENTRY(int, rcDestroyClientImage, uint32_t image) +GL_ENTRY(void, rcSelectChecksumHelper, uint32_t newProtocol, uint32_t reserved) +GL_ENTRY(int, rcGetNumDisplays) +GL_ENTRY(int, rcGetDisplayWidth, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayHeight, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayDpiX, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayDpiY, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayVsyncPeriod, uint32_t displayId) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.types b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.types new file mode 100644 index 0000000..a7d96ab --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl.types @@ -0,0 +1,11 @@ +uint32_t 32 0x%08x false +EGLint 32 0x%08x false +GLint 32 0x%08x false +GLuint 32 0x%08x false +GLenum 32 0x%08x false +EGLenum 32 0x%08x false +uint32_t* 32 0x%08x true +EGLint* 32 0x%08x true +GLint* 32 0x%08x true +GLuint* 32 0x%08x true +void* 32 0x%08x true diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_base.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_base.h new file mode 100644 index 0000000..4fb5d76 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_base.h @@ -0,0 +1,41 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __renderControl_client_base_t_h +#define __renderControl_client_base_t_h + +#include "renderControl_client_proc.h" + + +struct renderControl_client_base_t { + + rcGetRendererVersion_client_proc_t rcGetRendererVersion; + rcGetEGLVersion_client_proc_t rcGetEGLVersion; + rcQueryEGLString_client_proc_t rcQueryEGLString; + rcGetGLString_client_proc_t rcGetGLString; + rcGetNumConfigs_client_proc_t rcGetNumConfigs; + rcGetConfigs_client_proc_t rcGetConfigs; + rcChooseConfig_client_proc_t rcChooseConfig; + rcGetFBParam_client_proc_t rcGetFBParam; + rcCreateContext_client_proc_t rcCreateContext; + rcDestroyContext_client_proc_t rcDestroyContext; + rcCreateWindowSurface_client_proc_t rcCreateWindowSurface; + rcDestroyWindowSurface_client_proc_t rcDestroyWindowSurface; + rcCreateColorBuffer_client_proc_t rcCreateColorBuffer; + rcOpenColorBuffer_client_proc_t rcOpenColorBuffer; + rcCloseColorBuffer_client_proc_t rcCloseColorBuffer; + rcSetWindowColorBuffer_client_proc_t rcSetWindowColorBuffer; + rcFlushWindowColorBuffer_client_proc_t rcFlushWindowColorBuffer; + rcMakeCurrent_client_proc_t rcMakeCurrent; + rcFBPost_client_proc_t rcFBPost; + rcFBSetSwapInterval_client_proc_t rcFBSetSwapInterval; + rcBindTexture_client_proc_t rcBindTexture; + rcBindRenderbuffer_client_proc_t rcBindRenderbuffer; + rcColorBufferCacheFlush_client_proc_t rcColorBufferCacheFlush; + rcReadColorBuffer_client_proc_t rcReadColorBuffer; + rcUpdateColorBuffer_client_proc_t rcUpdateColorBuffer; + rcOpenColorBuffer2_client_proc_t rcOpenColorBuffer2; + rcCreateClientImage_client_proc_t rcCreateClientImage; + rcDestroyClientImage_client_proc_t rcDestroyClientImage; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.cpp new file mode 100644 index 0000000..34ae4f8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.cpp @@ -0,0 +1,52 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include "renderControl_client_context.h" + + +#include + +int renderControl_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + rcGetRendererVersion = (rcGetRendererVersion_client_proc_t) getProc("rcGetRendererVersion", userData); + rcGetEGLVersion = (rcGetEGLVersion_client_proc_t) getProc("rcGetEGLVersion", userData); + rcQueryEGLString = (rcQueryEGLString_client_proc_t) getProc("rcQueryEGLString", userData); + rcGetGLString = (rcGetGLString_client_proc_t) getProc("rcGetGLString", userData); + rcGetNumConfigs = (rcGetNumConfigs_client_proc_t) getProc("rcGetNumConfigs", userData); + rcGetConfigs = (rcGetConfigs_client_proc_t) getProc("rcGetConfigs", userData); + rcChooseConfig = (rcChooseConfig_client_proc_t) getProc("rcChooseConfig", userData); + rcGetFBParam = (rcGetFBParam_client_proc_t) getProc("rcGetFBParam", userData); + rcCreateContext = (rcCreateContext_client_proc_t) getProc("rcCreateContext", userData); + rcDestroyContext = (rcDestroyContext_client_proc_t) getProc("rcDestroyContext", userData); + rcCreateWindowSurface = (rcCreateWindowSurface_client_proc_t) getProc("rcCreateWindowSurface", userData); + rcDestroyWindowSurface = (rcDestroyWindowSurface_client_proc_t) getProc("rcDestroyWindowSurface", userData); + rcCreateColorBuffer = (rcCreateColorBuffer_client_proc_t) getProc("rcCreateColorBuffer", userData); + rcOpenColorBuffer = (rcOpenColorBuffer_client_proc_t) getProc("rcOpenColorBuffer", userData); + rcCloseColorBuffer = (rcCloseColorBuffer_client_proc_t) getProc("rcCloseColorBuffer", userData); + rcSetWindowColorBuffer = (rcSetWindowColorBuffer_client_proc_t) getProc("rcSetWindowColorBuffer", userData); + rcFlushWindowColorBuffer = (rcFlushWindowColorBuffer_client_proc_t) getProc("rcFlushWindowColorBuffer", userData); + rcMakeCurrent = (rcMakeCurrent_client_proc_t) getProc("rcMakeCurrent", userData); + rcFBPost = (rcFBPost_client_proc_t) getProc("rcFBPost", userData); + rcFBSetSwapInterval = (rcFBSetSwapInterval_client_proc_t) getProc("rcFBSetSwapInterval", userData); + rcBindTexture = (rcBindTexture_client_proc_t) getProc("rcBindTexture", userData); + rcBindRenderbuffer = (rcBindRenderbuffer_client_proc_t) getProc("rcBindRenderbuffer", userData); + rcColorBufferCacheFlush = (rcColorBufferCacheFlush_client_proc_t) getProc("rcColorBufferCacheFlush", userData); + rcReadColorBuffer = (rcReadColorBuffer_client_proc_t) getProc("rcReadColorBuffer", userData); + rcUpdateColorBuffer = (rcUpdateColorBuffer_client_proc_t) getProc("rcUpdateColorBuffer", userData); + rcOpenColorBuffer2 = (rcOpenColorBuffer2_client_proc_t) getProc("rcOpenColorBuffer2", userData); + rcCreateClientImage = (rcCreateClientImage_client_proc_t) getProc("rcCreateClientImage", userData); + rcDestroyClientImage = (rcDestroyClientImage_client_proc_t) getProc("rcDestroyClientImage", userData); + rcSelectChecksumCalculator = (rcSelectChecksumCalculator_client_proc_t) getProc("rcSelectChecksumCalculator", userData); + rcGetNumDisplays = (rcGetNumDisplays_client_proc_t) getProc("rcGetNumDisplays", userData); + rcGetDisplayWidth = (rcGetDisplayWidth_client_proc_t) getProc("rcGetDisplayWidth", userData); + rcGetDisplayHeight = (rcGetDisplayHeight_client_proc_t) getProc("rcGetDisplayHeight", userData); + rcGetDisplayDpiX = (rcGetDisplayDpiX_client_proc_t) getProc("rcGetDisplayDpiX", userData); + rcGetDisplayDpiY = (rcGetDisplayDpiY_client_proc_t) getProc("rcGetDisplayDpiY", userData); + rcGetDisplayVsyncPeriod = (rcGetDisplayVsyncPeriod_client_proc_t) getProc("rcGetDisplayVsyncPeriod", userData); + rcPostLayer = (rcPostLayer_client_proc_t) getProc("rcPostLayer", userData); + rcPostAllLayersDone = (rcPostAllLayersDone_client_proc_t) getProc("rcPostAllLayersDone", userData); + return 0; +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.h new file mode 100644 index 0000000..a6408c1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_context.h @@ -0,0 +1,59 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __renderControl_client_context_t_h +#define __renderControl_client_context_t_h + +#include "renderControl_client_proc.h" + +#include "renderControl_types.h" + + +struct renderControl_client_context_t { + + rcGetRendererVersion_client_proc_t rcGetRendererVersion; + rcGetEGLVersion_client_proc_t rcGetEGLVersion; + rcQueryEGLString_client_proc_t rcQueryEGLString; + rcGetGLString_client_proc_t rcGetGLString; + rcGetNumConfigs_client_proc_t rcGetNumConfigs; + rcGetConfigs_client_proc_t rcGetConfigs; + rcChooseConfig_client_proc_t rcChooseConfig; + rcGetFBParam_client_proc_t rcGetFBParam; + rcCreateContext_client_proc_t rcCreateContext; + rcDestroyContext_client_proc_t rcDestroyContext; + rcCreateWindowSurface_client_proc_t rcCreateWindowSurface; + rcDestroyWindowSurface_client_proc_t rcDestroyWindowSurface; + rcCreateColorBuffer_client_proc_t rcCreateColorBuffer; + rcOpenColorBuffer_client_proc_t rcOpenColorBuffer; + rcCloseColorBuffer_client_proc_t rcCloseColorBuffer; + rcSetWindowColorBuffer_client_proc_t rcSetWindowColorBuffer; + rcFlushWindowColorBuffer_client_proc_t rcFlushWindowColorBuffer; + rcMakeCurrent_client_proc_t rcMakeCurrent; + rcFBPost_client_proc_t rcFBPost; + rcFBSetSwapInterval_client_proc_t rcFBSetSwapInterval; + rcBindTexture_client_proc_t rcBindTexture; + rcBindRenderbuffer_client_proc_t rcBindRenderbuffer; + rcColorBufferCacheFlush_client_proc_t rcColorBufferCacheFlush; + rcReadColorBuffer_client_proc_t rcReadColorBuffer; + rcUpdateColorBuffer_client_proc_t rcUpdateColorBuffer; + rcOpenColorBuffer2_client_proc_t rcOpenColorBuffer2; + rcCreateClientImage_client_proc_t rcCreateClientImage; + rcDestroyClientImage_client_proc_t rcDestroyClientImage; + rcSelectChecksumCalculator_client_proc_t rcSelectChecksumCalculator; + rcGetNumDisplays_client_proc_t rcGetNumDisplays; + rcGetDisplayWidth_client_proc_t rcGetDisplayWidth; + rcGetDisplayHeight_client_proc_t rcGetDisplayHeight; + rcGetDisplayDpiX_client_proc_t rcGetDisplayDpiX; + rcGetDisplayDpiY_client_proc_t rcGetDisplayDpiY; + rcGetDisplayVsyncPeriod_client_proc_t rcGetDisplayVsyncPeriod; + rcPostLayer_client_proc_t rcPostLayer; + rcPostAllLayersDone_client_proc_t rcPostAllLayersDone; + virtual ~renderControl_client_context_t() {} + + typedef renderControl_client_context_t *CONTEXT_ACCESSOR_TYPE(void); + static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); + virtual void setError(unsigned int error){ (void)error; }; + virtual unsigned int getError(){ return 0; }; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_proc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_proc.h new file mode 100644 index 0000000..565fd12 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_client_proc.h @@ -0,0 +1,51 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __renderControl_client_proc_t_h +#define __renderControl_client_proc_t_h + + + +#include "renderControl_types.h" +#ifndef renderControl_APIENTRY +#define renderControl_APIENTRY +#endif +typedef GLint (renderControl_APIENTRY *rcGetRendererVersion_client_proc_t) (void * ctx); +typedef EGLint (renderControl_APIENTRY *rcGetEGLVersion_client_proc_t) (void * ctx, EGLint*, EGLint*); +typedef EGLint (renderControl_APIENTRY *rcQueryEGLString_client_proc_t) (void * ctx, EGLenum, void*, EGLint); +typedef EGLint (renderControl_APIENTRY *rcGetGLString_client_proc_t) (void * ctx, EGLenum, void*, EGLint); +typedef EGLint (renderControl_APIENTRY *rcGetNumConfigs_client_proc_t) (void * ctx, uint32_t*); +typedef EGLint (renderControl_APIENTRY *rcGetConfigs_client_proc_t) (void * ctx, uint32_t, GLuint*); +typedef EGLint (renderControl_APIENTRY *rcChooseConfig_client_proc_t) (void * ctx, EGLint*, uint32_t, uint32_t*, uint32_t); +typedef EGLint (renderControl_APIENTRY *rcGetFBParam_client_proc_t) (void * ctx, EGLint); +typedef uint32_t (renderControl_APIENTRY *rcCreateContext_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t); +typedef void (renderControl_APIENTRY *rcDestroyContext_client_proc_t) (void * ctx, uint32_t); +typedef uint32_t (renderControl_APIENTRY *rcCreateWindowSurface_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t); +typedef void (renderControl_APIENTRY *rcDestroyWindowSurface_client_proc_t) (void * ctx, uint32_t); +typedef uint32_t (renderControl_APIENTRY *rcCreateColorBuffer_client_proc_t) (void * ctx, uint32_t, uint32_t, GLenum); +typedef void (renderControl_APIENTRY *rcOpenColorBuffer_client_proc_t) (void * ctx, uint32_t); +typedef void (renderControl_APIENTRY *rcCloseColorBuffer_client_proc_t) (void * ctx, uint32_t); +typedef void (renderControl_APIENTRY *rcSetWindowColorBuffer_client_proc_t) (void * ctx, uint32_t, uint32_t); +typedef int (renderControl_APIENTRY *rcFlushWindowColorBuffer_client_proc_t) (void * ctx, uint32_t); +typedef EGLint (renderControl_APIENTRY *rcMakeCurrent_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t); +typedef void (renderControl_APIENTRY *rcFBPost_client_proc_t) (void * ctx, uint32_t); +typedef void (renderControl_APIENTRY *rcFBSetSwapInterval_client_proc_t) (void * ctx, EGLint); +typedef void (renderControl_APIENTRY *rcBindTexture_client_proc_t) (void * ctx, uint32_t); +typedef void (renderControl_APIENTRY *rcBindRenderbuffer_client_proc_t) (void * ctx, uint32_t); +typedef EGLint (renderControl_APIENTRY *rcColorBufferCacheFlush_client_proc_t) (void * ctx, uint32_t, EGLint, int); +typedef void (renderControl_APIENTRY *rcReadColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*); +typedef int (renderControl_APIENTRY *rcUpdateColorBuffer_client_proc_t) (void * ctx, uint32_t, GLint, GLint, GLint, GLint, GLenum, GLenum, void*); +typedef int (renderControl_APIENTRY *rcOpenColorBuffer2_client_proc_t) (void * ctx, uint32_t); +typedef uint32_t (renderControl_APIENTRY *rcCreateClientImage_client_proc_t) (void * ctx, uint32_t, EGLenum, GLuint); +typedef int (renderControl_APIENTRY *rcDestroyClientImage_client_proc_t) (void * ctx, uint32_t); +typedef void (renderControl_APIENTRY *rcSelectChecksumCalculator_client_proc_t) (void * ctx, uint32_t, uint32_t); +typedef int (renderControl_APIENTRY *rcGetNumDisplays_client_proc_t) (void * ctx); +typedef int (renderControl_APIENTRY *rcGetDisplayWidth_client_proc_t) (void * ctx, uint32_t); +typedef int (renderControl_APIENTRY *rcGetDisplayHeight_client_proc_t) (void * ctx, uint32_t); +typedef int (renderControl_APIENTRY *rcGetDisplayDpiX_client_proc_t) (void * ctx, uint32_t); +typedef int (renderControl_APIENTRY *rcGetDisplayDpiY_client_proc_t) (void * ctx, uint32_t); +typedef int (renderControl_APIENTRY *rcGetDisplayVsyncPeriod_client_proc_t) (void * ctx, uint32_t); +typedef void (renderControl_APIENTRY *rcPostLayer_client_proc_t) (void * ctx, const char*, uint32_t, float, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t); +typedef void (renderControl_APIENTRY *rcPostAllLayersDone_client_proc_t) (void * ctx); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.cpp new file mode 100644 index 0000000..4a22b54 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.cpp @@ -0,0 +1,1392 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include +#include "renderControl_opcodes.h" + +#include "renderControl_enc.h" + + +#include + +namespace { + +void enc_unsupported() +{ + ALOGE("Function is unsupported\n"); +} + +GLint rcGetRendererVersion_enc(void *self ) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetRendererVersion;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + GLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetRendererVersion: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcGetEGLVersion_enc(void *self , EGLint* major, EGLint* minor) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_major = sizeof(EGLint); + const unsigned int __size_minor = sizeof(EGLint); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_major + __size_minor + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetEGLVersion;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_major; ptr += 4; + *(unsigned int *)(ptr) = __size_minor; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(major, __size_major); + if (useChecksum) checksumCalculator->addBuffer(major, __size_major); + stream->readback(minor, __size_minor); + if (useChecksum) checksumCalculator->addBuffer(minor, __size_minor); + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetEGLVersion: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcQueryEGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffer = bufferSize; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_buffer + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcQueryEGLString;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &name, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_buffer; ptr += 4; + memcpy(ptr, &bufferSize, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(buffer, __size_buffer); + if (useChecksum) checksumCalculator->addBuffer(buffer, __size_buffer); + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcQueryEGLString: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcGetGLString_enc(void *self , EGLenum name, void* buffer, EGLint bufferSize) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffer = bufferSize; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_buffer + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetGLString;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &name, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_buffer; ptr += 4; + memcpy(ptr, &bufferSize, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(buffer, __size_buffer); + if (useChecksum) checksumCalculator->addBuffer(buffer, __size_buffer); + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetGLString: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcGetNumConfigs_enc(void *self , uint32_t* numAttribs) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_numAttribs = sizeof(uint32_t); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_numAttribs + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetNumConfigs;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_numAttribs; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(numAttribs, __size_numAttribs); + if (useChecksum) checksumCalculator->addBuffer(numAttribs, __size_numAttribs); + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetNumConfigs: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcGetConfigs_enc(void *self , uint32_t bufSize, GLuint* buffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_buffer = bufSize; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + __size_buffer + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetConfigs;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &bufSize, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_buffer; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(buffer, __size_buffer); + if (useChecksum) checksumCalculator->addBuffer(buffer, __size_buffer); + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetConfigs: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcChooseConfig_enc(void *self , EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_attribs = attribs_size; + const unsigned int __size_configs = ((configs != NULL) ? configs_size*sizeof(uint32_t) : 0); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_attribs + 4 + __size_configs + 4 + 2*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcChooseConfig;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_attribs; ptr += 4; + memcpy(ptr, attribs, __size_attribs);ptr += __size_attribs; + memcpy(ptr, &attribs_size, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_configs; ptr += 4; + memcpy(ptr, &configs_size, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + if (configs != NULL) { + stream->readback(configs, __size_configs); + if (useChecksum) checksumCalculator->addBuffer(configs, __size_configs); + } + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcChooseConfig: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcGetFBParam_enc(void *self , EGLint param) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetFBParam;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetFBParam: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +uint32_t rcCreateContext_enc(void *self , uint32_t config, uint32_t share, uint32_t glVersion) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcCreateContext;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &config, 4); ptr += 4; + memcpy(ptr, &share, 4); ptr += 4; + memcpy(ptr, &glVersion, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + uint32_t retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcCreateContext: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void rcDestroyContext_enc(void *self , uint32_t context) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcDestroyContext;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &context, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +uint32_t rcCreateWindowSurface_enc(void *self , uint32_t config, uint32_t width, uint32_t height) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcCreateWindowSurface;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &config, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + uint32_t retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcCreateWindowSurface: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void rcDestroyWindowSurface_enc(void *self , uint32_t windowSurface) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcDestroyWindowSurface;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &windowSurface, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +uint32_t rcCreateColorBuffer_enc(void *self , uint32_t width, uint32_t height, GLenum internalFormat) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcCreateColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &internalFormat, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + uint32_t retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcCreateColorBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void rcOpenColorBuffer_enc(void *self , uint32_t colorbuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcOpenColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void rcCloseColorBuffer_enc(void *self , uint32_t colorbuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcCloseColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->flush(); +} + +void rcSetWindowColorBuffer_enc(void *self , uint32_t windowSurface, uint32_t colorBuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcSetWindowColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &windowSurface, 4); ptr += 4; + memcpy(ptr, &colorBuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +int rcFlushWindowColorBuffer_enc(void *self , uint32_t windowSurface) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcFlushWindowColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &windowSurface, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcFlushWindowColorBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +EGLint rcMakeCurrent_enc(void *self , uint32_t context, uint32_t drawSurf, uint32_t readSurf) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcMakeCurrent;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &context, 4); ptr += 4; + memcpy(ptr, &drawSurf, 4); ptr += 4; + memcpy(ptr, &readSurf, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcMakeCurrent: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void rcFBPost_enc(void *self , uint32_t colorBuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcFBPost;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorBuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void rcFBSetSwapInterval_enc(void *self , EGLint interval) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcFBSetSwapInterval;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &interval, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void rcBindTexture_enc(void *self , uint32_t colorBuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcBindTexture;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorBuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void rcBindRenderbuffer_enc(void *self , uint32_t colorBuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcBindRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorBuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +EGLint rcColorBufferCacheFlush_enc(void *self , uint32_t colorbuffer, EGLint postCount, int forRead) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcColorBufferCacheFlush;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorbuffer, 4); ptr += 4; + memcpy(ptr, &postCount, 4); ptr += 4; + memcpy(ptr, &forRead, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + EGLint retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcColorBufferCacheFlush: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void rcReadColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = (((glUtilsPixelBitSize(format, type) * width) >> 3) * height); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcReadColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorbuffer, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + *(unsigned int *)(ptr) = __size_pixels; ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->readback(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcReadColorBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } +} + +int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_pixels = (((glUtilsPixelBitSize(format, type) * width) >> 3) * height); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4); + ptr = buf; + int tmp = OP_rcUpdateColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorbuffer, 4); ptr += 4; + memcpy(ptr, &x, 4); ptr += 4; + memcpy(ptr, &y, 4); ptr += 4; + memcpy(ptr, &width, 4); ptr += 4; + memcpy(ptr, &height, 4); ptr += 4; + memcpy(ptr, &format, 4); ptr += 4; + memcpy(ptr, &type, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + stream->flush(); + stream->writeFully(&__size_pixels,4); + if (useChecksum) checksumCalculator->addBuffer(&__size_pixels,4); + stream->writeFully(pixels, __size_pixels); + if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels); + buf = stream->alloc(checksumSize); + if (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize); + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcUpdateColorBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +int rcOpenColorBuffer2_enc(void *self , uint32_t colorbuffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcOpenColorBuffer2;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &colorbuffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcOpenColorBuffer2: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +uint32_t rcCreateClientImage_enc(void *self , uint32_t context, EGLenum target, GLuint buffer) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcCreateClientImage;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &context, 4); ptr += 4; + memcpy(ptr, &target, 4); ptr += 4; + memcpy(ptr, &buffer, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + uint32_t retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcCreateClientImage: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +int rcDestroyClientImage_enc(void *self , uint32_t image) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcDestroyClientImage;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &image, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcDestroyClientImage: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void rcSelectChecksumCalculator_enc(void *self , uint32_t newProtocol, uint32_t reserved) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcSelectChecksumCalculator;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &newProtocol, 4); ptr += 4; + memcpy(ptr, &reserved, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +int rcGetNumDisplays_enc(void *self ) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetNumDisplays;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetNumDisplays: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +int rcGetDisplayWidth_enc(void *self , uint32_t displayId) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetDisplayWidth;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &displayId, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetDisplayWidth: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +int rcGetDisplayHeight_enc(void *self , uint32_t displayId) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetDisplayHeight;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &displayId, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetDisplayHeight: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +int rcGetDisplayDpiX_enc(void *self , uint32_t displayId) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetDisplayDpiX;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &displayId, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetDisplayDpiX: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +int rcGetDisplayDpiY_enc(void *self , uint32_t displayId) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetDisplayDpiY;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &displayId, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetDisplayDpiY: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +int rcGetDisplayVsyncPeriod_enc(void *self , uint32_t displayId) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcGetDisplayVsyncPeriod;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &displayId, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + int retval; + stream->readback(&retval, 4); + if (useChecksum) checksumCalculator->addBuffer(&retval, 4); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("rcGetDisplayVsyncPeriod: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void rcPostLayer_enc(void *self , const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_name = (strlen(name) + 1); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_name + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcPostLayer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_name; ptr += 4; + memcpy(ptr, name, __size_name);ptr += __size_name; + memcpy(ptr, &colorBuffer, 4); ptr += 4; + memcpy(ptr, &alpha, 4); ptr += 4; + memcpy(ptr, &sourceCropLeft, 4); ptr += 4; + memcpy(ptr, &sourceCropTop, 4); ptr += 4; + memcpy(ptr, &sourceCropRight, 4); ptr += 4; + memcpy(ptr, &sourceCropBottom, 4); ptr += 4; + memcpy(ptr, &displayFrameLeft, 4); ptr += 4; + memcpy(ptr, &displayFrameTop, 4); ptr += 4; + memcpy(ptr, &displayFrameRight, 4); ptr += 4; + memcpy(ptr, &displayFrameBottom, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +void rcPostAllLayersDone_enc(void *self ) +{ + + renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_rcPostAllLayersDone;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +} // namespace + +renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator) +{ + m_stream = stream; + m_checksumCalculator = checksumCalculator; + + this->rcGetRendererVersion = &rcGetRendererVersion_enc; + this->rcGetEGLVersion = &rcGetEGLVersion_enc; + this->rcQueryEGLString = &rcQueryEGLString_enc; + this->rcGetGLString = &rcGetGLString_enc; + this->rcGetNumConfigs = &rcGetNumConfigs_enc; + this->rcGetConfigs = &rcGetConfigs_enc; + this->rcChooseConfig = &rcChooseConfig_enc; + this->rcGetFBParam = &rcGetFBParam_enc; + this->rcCreateContext = &rcCreateContext_enc; + this->rcDestroyContext = &rcDestroyContext_enc; + this->rcCreateWindowSurface = &rcCreateWindowSurface_enc; + this->rcDestroyWindowSurface = &rcDestroyWindowSurface_enc; + this->rcCreateColorBuffer = &rcCreateColorBuffer_enc; + this->rcOpenColorBuffer = &rcOpenColorBuffer_enc; + this->rcCloseColorBuffer = &rcCloseColorBuffer_enc; + this->rcSetWindowColorBuffer = &rcSetWindowColorBuffer_enc; + this->rcFlushWindowColorBuffer = &rcFlushWindowColorBuffer_enc; + this->rcMakeCurrent = &rcMakeCurrent_enc; + this->rcFBPost = &rcFBPost_enc; + this->rcFBSetSwapInterval = &rcFBSetSwapInterval_enc; + this->rcBindTexture = &rcBindTexture_enc; + this->rcBindRenderbuffer = &rcBindRenderbuffer_enc; + this->rcColorBufferCacheFlush = &rcColorBufferCacheFlush_enc; + this->rcReadColorBuffer = &rcReadColorBuffer_enc; + this->rcUpdateColorBuffer = &rcUpdateColorBuffer_enc; + this->rcOpenColorBuffer2 = &rcOpenColorBuffer2_enc; + this->rcCreateClientImage = &rcCreateClientImage_enc; + this->rcDestroyClientImage = &rcDestroyClientImage_enc; + this->rcSelectChecksumCalculator = &rcSelectChecksumCalculator_enc; + this->rcGetNumDisplays = &rcGetNumDisplays_enc; + this->rcGetDisplayWidth = &rcGetDisplayWidth_enc; + this->rcGetDisplayHeight = &rcGetDisplayHeight_enc; + this->rcGetDisplayDpiX = &rcGetDisplayDpiX_enc; + this->rcGetDisplayDpiY = &rcGetDisplayDpiY_enc; + this->rcGetDisplayVsyncPeriod = &rcGetDisplayVsyncPeriod_enc; + this->rcPostLayer = &rcPostLayer_enc; + this->rcPostAllLayersDone = &rcPostAllLayersDone_enc; +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.h new file mode 100644 index 0000000..628cff3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_enc.h @@ -0,0 +1,24 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + +#ifndef GUARD_renderControl_encoder_context_t +#define GUARD_renderControl_encoder_context_t + +#include "IOStream.h" +#include "ChecksumCalculator.h" +#include "renderControl_client_context.h" + + +#include +#include +#include "glUtils.h" + +struct renderControl_encoder_context_t : public renderControl_client_context_t { + + IOStream *m_stream; + ChecksumCalculator *m_checksumCalculator; + + renderControl_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator); +}; + +#endif // GUARD_renderControl_encoder_context_t \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_entry.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_entry.cpp new file mode 100644 index 0000000..822bb80 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_entry.cpp @@ -0,0 +1,276 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#include +#include +#include "renderControl_client_context.h" + +#ifndef GL_TRUE +extern "C" { + GLint rcGetRendererVersion(); + EGLint rcGetEGLVersion(EGLint* major, EGLint* minor); + EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize); + EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize); + EGLint rcGetNumConfigs(uint32_t* numAttribs); + EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer); + EGLint rcChooseConfig(EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size); + EGLint rcGetFBParam(EGLint param); + uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion); + void rcDestroyContext(uint32_t context); + uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height); + void rcDestroyWindowSurface(uint32_t windowSurface); + uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat); + void rcOpenColorBuffer(uint32_t colorbuffer); + void rcCloseColorBuffer(uint32_t colorbuffer); + void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer); + int rcFlushWindowColorBuffer(uint32_t windowSurface); + EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf); + void rcFBPost(uint32_t colorBuffer); + void rcFBSetSwapInterval(EGLint interval); + void rcBindTexture(uint32_t colorBuffer); + void rcBindRenderbuffer(uint32_t colorBuffer); + EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead); + void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels); + int rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels); + int rcOpenColorBuffer2(uint32_t colorbuffer); + uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buffer); + int rcDestroyClientImage(uint32_t image); + void rcSelectChecksumCalculator(uint32_t newProtocol, uint32_t reserved); + int rcGetNumDisplays(); + int rcGetDisplayWidth(uint32_t displayId); + int rcGetDisplayHeight(uint32_t displayId); + int rcGetDisplayDpiX(uint32_t displayId); + int rcGetDisplayDpiY(uint32_t displayId); + int rcGetDisplayVsyncPeriod(uint32_t displayId); + void rcPostLayer(const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom); + void rcPostAllLayersDone(); +}; + +#endif +#ifndef GET_CONTEXT +static renderControl_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; +void renderControl_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } +#define GET_CONTEXT renderControl_client_context_t * ctx = getCurrentContext() +#endif + +GLint rcGetRendererVersion() +{ + GET_CONTEXT; + return ctx->rcGetRendererVersion(ctx); +} + +EGLint rcGetEGLVersion(EGLint* major, EGLint* minor) +{ + GET_CONTEXT; + return ctx->rcGetEGLVersion(ctx, major, minor); +} + +EGLint rcQueryEGLString(EGLenum name, void* buffer, EGLint bufferSize) +{ + GET_CONTEXT; + return ctx->rcQueryEGLString(ctx, name, buffer, bufferSize); +} + +EGLint rcGetGLString(EGLenum name, void* buffer, EGLint bufferSize) +{ + GET_CONTEXT; + return ctx->rcGetGLString(ctx, name, buffer, bufferSize); +} + +EGLint rcGetNumConfigs(uint32_t* numAttribs) +{ + GET_CONTEXT; + return ctx->rcGetNumConfigs(ctx, numAttribs); +} + +EGLint rcGetConfigs(uint32_t bufSize, GLuint* buffer) +{ + GET_CONTEXT; + return ctx->rcGetConfigs(ctx, bufSize, buffer); +} + +EGLint rcChooseConfig(EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size) +{ + GET_CONTEXT; + return ctx->rcChooseConfig(ctx, attribs, attribs_size, configs, configs_size); +} + +EGLint rcGetFBParam(EGLint param) +{ + GET_CONTEXT; + return ctx->rcGetFBParam(ctx, param); +} + +uint32_t rcCreateContext(uint32_t config, uint32_t share, uint32_t glVersion) +{ + GET_CONTEXT; + return ctx->rcCreateContext(ctx, config, share, glVersion); +} + +void rcDestroyContext(uint32_t context) +{ + GET_CONTEXT; + ctx->rcDestroyContext(ctx, context); +} + +uint32_t rcCreateWindowSurface(uint32_t config, uint32_t width, uint32_t height) +{ + GET_CONTEXT; + return ctx->rcCreateWindowSurface(ctx, config, width, height); +} + +void rcDestroyWindowSurface(uint32_t windowSurface) +{ + GET_CONTEXT; + ctx->rcDestroyWindowSurface(ctx, windowSurface); +} + +uint32_t rcCreateColorBuffer(uint32_t width, uint32_t height, GLenum internalFormat) +{ + GET_CONTEXT; + return ctx->rcCreateColorBuffer(ctx, width, height, internalFormat); +} + +void rcOpenColorBuffer(uint32_t colorbuffer) +{ + GET_CONTEXT; + ctx->rcOpenColorBuffer(ctx, colorbuffer); +} + +void rcCloseColorBuffer(uint32_t colorbuffer) +{ + GET_CONTEXT; + ctx->rcCloseColorBuffer(ctx, colorbuffer); +} + +void rcSetWindowColorBuffer(uint32_t windowSurface, uint32_t colorBuffer) +{ + GET_CONTEXT; + ctx->rcSetWindowColorBuffer(ctx, windowSurface, colorBuffer); +} + +int rcFlushWindowColorBuffer(uint32_t windowSurface) +{ + GET_CONTEXT; + return ctx->rcFlushWindowColorBuffer(ctx, windowSurface); +} + +EGLint rcMakeCurrent(uint32_t context, uint32_t drawSurf, uint32_t readSurf) +{ + GET_CONTEXT; + return ctx->rcMakeCurrent(ctx, context, drawSurf, readSurf); +} + +void rcFBPost(uint32_t colorBuffer) +{ + GET_CONTEXT; + ctx->rcFBPost(ctx, colorBuffer); +} + +void rcFBSetSwapInterval(EGLint interval) +{ + GET_CONTEXT; + ctx->rcFBSetSwapInterval(ctx, interval); +} + +void rcBindTexture(uint32_t colorBuffer) +{ + GET_CONTEXT; + ctx->rcBindTexture(ctx, colorBuffer); +} + +void rcBindRenderbuffer(uint32_t colorBuffer) +{ + GET_CONTEXT; + ctx->rcBindRenderbuffer(ctx, colorBuffer); +} + +EGLint rcColorBufferCacheFlush(uint32_t colorbuffer, EGLint postCount, int forRead) +{ + GET_CONTEXT; + return ctx->rcColorBufferCacheFlush(ctx, colorbuffer, postCount, forRead); +} + +void rcReadColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels) +{ + GET_CONTEXT; + ctx->rcReadColorBuffer(ctx, colorbuffer, x, y, width, height, format, type, pixels); +} + +int rcUpdateColorBuffer(uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels) +{ + GET_CONTEXT; + return ctx->rcUpdateColorBuffer(ctx, colorbuffer, x, y, width, height, format, type, pixels); +} + +int rcOpenColorBuffer2(uint32_t colorbuffer) +{ + GET_CONTEXT; + return ctx->rcOpenColorBuffer2(ctx, colorbuffer); +} + +uint32_t rcCreateClientImage(uint32_t context, EGLenum target, GLuint buffer) +{ + GET_CONTEXT; + return ctx->rcCreateClientImage(ctx, context, target, buffer); +} + +int rcDestroyClientImage(uint32_t image) +{ + GET_CONTEXT; + return ctx->rcDestroyClientImage(ctx, image); +} + +void rcSelectChecksumCalculator(uint32_t newProtocol, uint32_t reserved) +{ + GET_CONTEXT; + ctx->rcSelectChecksumCalculator(ctx, newProtocol, reserved); +} + +int rcGetNumDisplays() +{ + GET_CONTEXT; + return ctx->rcGetNumDisplays(ctx); +} + +int rcGetDisplayWidth(uint32_t displayId) +{ + GET_CONTEXT; + return ctx->rcGetDisplayWidth(ctx, displayId); +} + +int rcGetDisplayHeight(uint32_t displayId) +{ + GET_CONTEXT; + return ctx->rcGetDisplayHeight(ctx, displayId); +} + +int rcGetDisplayDpiX(uint32_t displayId) +{ + GET_CONTEXT; + return ctx->rcGetDisplayDpiX(ctx, displayId); +} + +int rcGetDisplayDpiY(uint32_t displayId) +{ + GET_CONTEXT; + return ctx->rcGetDisplayDpiY(ctx, displayId); +} + +int rcGetDisplayVsyncPeriod(uint32_t displayId) +{ + GET_CONTEXT; + return ctx->rcGetDisplayVsyncPeriod(ctx, displayId); +} + +void rcPostLayer(const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom) +{ + GET_CONTEXT; + ctx->rcPostLayer(ctx, name, colorBuffer, alpha, sourceCropLeft, sourceCropTop, sourceCropRight, sourceCropBottom, displayFrameLeft, displayFrameTop, displayFrameRight, displayFrameBottom); +} + +void rcPostAllLayersDone() +{ + GET_CONTEXT; + ctx->rcPostAllLayersDone(ctx); +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_ftable.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_ftable.h new file mode 100644 index 0000000..da81858 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_ftable.h @@ -0,0 +1,52 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __renderControl_client_ftable_t_h +#define __renderControl_client_ftable_t_h + + +static const struct _renderControl_funcs_by_name { + const char *name; + void *proc; +} renderControl_funcs_by_name[] = { + {"rcGetRendererVersion", (void*)rcGetRendererVersion}, + {"rcGetEGLVersion", (void*)rcGetEGLVersion}, + {"rcQueryEGLString", (void*)rcQueryEGLString}, + {"rcGetGLString", (void*)rcGetGLString}, + {"rcGetNumConfigs", (void*)rcGetNumConfigs}, + {"rcGetConfigs", (void*)rcGetConfigs}, + {"rcChooseConfig", (void*)rcChooseConfig}, + {"rcGetFBParam", (void*)rcGetFBParam}, + {"rcCreateContext", (void*)rcCreateContext}, + {"rcDestroyContext", (void*)rcDestroyContext}, + {"rcCreateWindowSurface", (void*)rcCreateWindowSurface}, + {"rcDestroyWindowSurface", (void*)rcDestroyWindowSurface}, + {"rcCreateColorBuffer", (void*)rcCreateColorBuffer}, + {"rcOpenColorBuffer", (void*)rcOpenColorBuffer}, + {"rcCloseColorBuffer", (void*)rcCloseColorBuffer}, + {"rcSetWindowColorBuffer", (void*)rcSetWindowColorBuffer}, + {"rcFlushWindowColorBuffer", (void*)rcFlushWindowColorBuffer}, + {"rcMakeCurrent", (void*)rcMakeCurrent}, + {"rcFBPost", (void*)rcFBPost}, + {"rcFBSetSwapInterval", (void*)rcFBSetSwapInterval}, + {"rcBindTexture", (void*)rcBindTexture}, + {"rcBindRenderbuffer", (void*)rcBindRenderbuffer}, + {"rcColorBufferCacheFlush", (void*)rcColorBufferCacheFlush}, + {"rcReadColorBuffer", (void*)rcReadColorBuffer}, + {"rcUpdateColorBuffer", (void*)rcUpdateColorBuffer}, + {"rcOpenColorBuffer2", (void*)rcOpenColorBuffer2}, + {"rcCreateClientImage", (void*)rcCreateClientImage}, + {"rcDestroyClientImage", (void*)rcDestroyClientImage}, + {"rcSelectChecksumCalculator", (void*)rcSelectChecksumCalculator}, + {"rcGetNumDisplays", (void*)rcGetNumDisplays}, + {"rcGetDisplayWidth", (void*)rcGetDisplayWidth}, + {"rcGetDisplayHeight", (void*)rcGetDisplayHeight}, + {"rcGetDisplayDpiX", (void*)rcGetDisplayDpiX}, + {"rcGetDisplayDpiY", (void*)rcGetDisplayDpiY}, + {"rcGetDisplayVsyncPeriod", (void*)rcGetDisplayVsyncPeriod}, + {"rcPostLayer", (void*)rcPostLayer}, + {"rcPostAllLayersDone", (void*)rcPostAllLayersDone}, +}; +static const int renderControl_num_funcs = sizeof(renderControl_funcs_by_name) / sizeof(struct _renderControl_funcs_by_name); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_opcodes.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_opcodes.h new file mode 100644 index 0000000..e7cf12d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_opcodes.h @@ -0,0 +1,46 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __GUARD_renderControl_opcodes_h_ +#define __GUARD_renderControl_opcodes_h_ + +#define OP_rcGetRendererVersion 10000 +#define OP_rcGetEGLVersion 10001 +#define OP_rcQueryEGLString 10002 +#define OP_rcGetGLString 10003 +#define OP_rcGetNumConfigs 10004 +#define OP_rcGetConfigs 10005 +#define OP_rcChooseConfig 10006 +#define OP_rcGetFBParam 10007 +#define OP_rcCreateContext 10008 +#define OP_rcDestroyContext 10009 +#define OP_rcCreateWindowSurface 10010 +#define OP_rcDestroyWindowSurface 10011 +#define OP_rcCreateColorBuffer 10012 +#define OP_rcOpenColorBuffer 10013 +#define OP_rcCloseColorBuffer 10014 +#define OP_rcSetWindowColorBuffer 10015 +#define OP_rcFlushWindowColorBuffer 10016 +#define OP_rcMakeCurrent 10017 +#define OP_rcFBPost 10018 +#define OP_rcFBSetSwapInterval 10019 +#define OP_rcBindTexture 10020 +#define OP_rcBindRenderbuffer 10021 +#define OP_rcColorBufferCacheFlush 10022 +#define OP_rcReadColorBuffer 10023 +#define OP_rcUpdateColorBuffer 10024 +#define OP_rcOpenColorBuffer2 10025 +#define OP_rcCreateClientImage 10026 +#define OP_rcDestroyClientImage 10027 +#define OP_rcSelectChecksumCalculator 10028 +#define OP_rcGetNumDisplays 10029 +#define OP_rcGetDisplayWidth 10030 +#define OP_rcGetDisplayHeight 10031 +#define OP_rcGetDisplayDpiX 10032 +#define OP_rcGetDisplayDpiY 10033 +#define OP_rcGetDisplayVsyncPeriod 10034 +#define OP_rcPostLayer 10035 +#define OP_rcPostAllLayersDone 10036 +#define OP_last 10037 + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_types.h b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_types.h new file mode 100644 index 0000000..da215bb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/system/renderControl_enc/renderControl_types.h @@ -0,0 +1,28 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include "glUtils.h" + +// values for 'param' argument of rcGetFBParam +#define FB_WIDTH 1 +#define FB_HEIGHT 2 +#define FB_XDPI 3 +#define FB_YDPI 4 +#define FB_FPS 5 +#define FB_MIN_SWAP_INTERVAL 6 +#define FB_MAX_SWAP_INTERVAL 7 diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/Android.mk new file mode 100644 index 0000000..d97212d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/Android.mk @@ -0,0 +1,74 @@ +LOCAL_PATH := $(call my-dir) + +#### libGLESv1_CM_emul.so +$(call emugl-begin-shared-library,libGLESv1_CM_emul) +$(call emugl-import,libGLESv1_enc) +$(call emugl-gen-wrapper,$(EMUGL_PATH)/system/GLESv1_enc,gl) +$(call emugl-set-shared-library-subpath,egl) + +LOCAL_SRC_FILES += glesv1_emul_ifc.cpp + +$(call emugl-end-module) + +emulatorOpengl := $(LOCAL_PATH)/../.. +logTag := -DLOG_TAG=\"eglWrapper\" +EMUGEN = $(BUILD_OUT_EXECUTABLES)/emugen +## comment for no debug +#debugFlags = -g -O0 + +#### libGLESv2_CM_emul.so +$(call emugl-begin-shared-library, libGLESv2_emul) +$(call emugl-import,libGLESv2_enc) +$(call emugl-gen-wrapper,$(EMUGL_PATH)/system/GLESv2_enc,gl2) +LOCAL_SRC_FILES += glesv2_emul_ifc.cpp +$(call emugl-set-shared-library-subpath,egl) +$(call emugl-end-module) + +##### libEGL_emul.so ########### + +# THE FOLLOWING DOESN'T WORK YET +# +$(call emugl-begin-shared-library,libEGL_emul) +$(call emugl-import,libut_rendercontrol_enc libGLESv1_CM_emul libGLESv2_emul libOpenglSystemCommon) + +$(call emugl-set-shared-library-subpath,egl) +LOCAL_CFLAGS += $(logTag) + +LOCAL_SRC_FILES := \ + egl.cpp \ + egl_dispatch.cpp \ + ServerConnection.cpp \ + ThreadInfo.cpp + +$(call emugl-end-module) + +#### egl.cfg #### + +# Ensure that this file is only copied to emulator-specific builds. +# Other builds are device-specific and will provide their own +# version of this file to point to the appropriate HW EGL libraries. +# +ifneq (,$(filter full full_x86 full_mips sdk sdk_x86 sdk_mips,$(TARGET_PRODUCT))) +ifeq (,$(BUILD_EMULATOR_OPENGL_DRIVER)) +include $(CLEAR_VARS) + +LOCAL_MODULE := egl.cfg +LOCAL_SRC_FILES := $(LOCAL_MODULE) + +LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/egl +LOCAL_MODULE_CLASS := ETC + +include $(BUILD_PREBUILT) +endif # building 'real' driver BUILD_EMULATOR_OPENGL_DRIVER +endif # TARGET_PRODUCT in 'full sdk full_x86 sdk_x86 full_mips sdk_mips' + +#### gles_emul.cfg #### +include $(CLEAR_VARS) + +LOCAL_MODULE := gles_emul.cfg +LOCAL_SRC_FILES := $(LOCAL_MODULE) + +LOCAL_MODULE_PATH := $(TARGET_OUT)/etc +LOCAL_MODULE_CLASS := ETC + +include $(BUILD_PREBUILT) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ApiInitializer.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ApiInitializer.h new file mode 100644 index 0000000..793c735 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ApiInitializer.h @@ -0,0 +1,42 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef _API_INITIALIZER_H_ +#define _API_INITIALIZER_H_ +#include +#include + +class ApiInitializer { +public: + ApiInitializer(void *dso) : + m_dso(dso) { + } + static void *s_getProc(const char *name, void *userData) { + ApiInitializer *self = (ApiInitializer *)userData; + return self->getProc(name); + } +private: + void *m_dso; + void *getProc(const char *name) { + void *symbol = NULL; + if (m_dso) { + symbol = dlsym(m_dso, name); + } + return symbol; + } +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/CleanSpec.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/CleanSpec.mk new file mode 100644 index 0000000..f56383a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/CleanSpec.mk @@ -0,0 +1,50 @@ +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# If you don't need to do a full clean build but would like to touch +# a file or delete some intermediate files, add a clean step to the end +# of the list. These steps will only be run once, if they haven't been +# run before. +# +# E.g.: +# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) +# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) +# +# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with +# files that are missing or have been moved. +# +# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. +# Use $(OUT_DIR) to refer to the "out" directory. +# +# If you need to re-do something that's already mentioned, just copy +# the command and add it to the bottom of the list. E.g., if a change +# that you made last week required touching a file and a change you +# made today requires touching the same file, just copy the old +# touch step and add it to the end of the list. +# +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +# For example: +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) +#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) +#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) + +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/SHARED_LIBRARIES/libGLES_emul_intermediates) diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.cpp new file mode 100644 index 0000000..ff4e390 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.cpp @@ -0,0 +1,125 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include "ServerConnection.h" +#include "TcpStream.h" +#include "QemuPipeStream.h" +#include +#include "ThreadInfo.h" + +gl_client_context_t *ServerConnection::s_getGlContext() +{ + EGLThreadInfo *ti = getEGLThreadInfo(); + if (ti->serverConn) { + return ti->serverConn->m_glEnc; + } + return NULL; +} + +gl2_client_context_t *ServerConnection::s_getGl2Context() +{ + EGLThreadInfo *ti = getEGLThreadInfo(); + if (ti->serverConn) { + return ti->serverConn->m_gl2Enc; + } + return NULL; +} + +ServerConnection *ServerConnection::s_getServerConnection() +{ + EGLThreadInfo *ti = getEGLThreadInfo(); + if (!ti->serverConn) + { + ti->serverConn = new ServerConnection(); + if (ti->serverConn->create() < 0) { + delete ti->serverConn; + ti->serverConn = NULL; + } + } + + return ti->serverConn; +} + + +ServerConnection::ServerConnection() : + m_stream(NULL), + m_glEnc(NULL), + m_ut_enc(NULL) +{ +} + +ServerConnection::~ServerConnection() +{ + delete m_ut_enc; + delete m_glEnc; + delete m_stream; +} + + + +int ServerConnection::create(size_t bufsize, + const char *defaultServer) +{ + /* XXX: Make configurable through system property */ + int useQemuPipe = 1; + + if (m_stream != NULL) delete(m_stream); + + if (useQemuPipe) { + QemuPipeStream* pipeStream = new QemuPipeStream(bufsize); + + if (pipeStream->connect() < 0) { + ALOGE("couldn't connect to host server\n"); + delete pipeStream; + return -1; + } + m_stream = pipeStream; + } + else /* !useQemuPipe */ + { + TcpStream* tcpStream = new TcpStream(bufsize); + + char *s = getenv(ENV_RGL_SERVER); + char *hostname; + if (s == NULL) { + hostname = strdup(defaultServer); + } else { + hostname = strdup(s); + } + + if (tcpStream->connect(hostname, CODEC_SERVER_PORT) < 0) { + ALOGE("couldn't connect to %s\n", hostname); + free(hostname); + delete tcpStream; + return -1; + } + LOGI("connecting to server %s\n", hostname); + free(hostname); + + m_stream = tcpStream; + } + + m_glEnc = new GLEncoder(m_stream); + m_glEnc->setContextAccessor(s_getGlContext); + + m_gl2Enc = new GL2Encoder(m_stream); + m_gl2Enc->setContextAccessor(s_getGl2Context); + + m_ut_enc = new ut_rendercontrol_encoder_context_t(m_stream); + return 0; +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.h new file mode 100644 index 0000000..84f40d8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ServerConnection.h @@ -0,0 +1,55 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _SERVER_CONNECTION_H +#define _SERVER_CONNECTION_H + +#include "GLEncoder.h" +#include "GL2Encoder.h" +#include "IOStream.h" +#include "codec_defs.h" +#include "ut_rendercontrol_enc.h" +#include + +#define ENV_RGL_SERVER "RGL_SERVER" +#define RGL_DEFAULT_SERVER "10.0.2.2" + +class ServerConnection { +public: + ~ServerConnection(); + int create(size_t buf_size = 4 * 1024 * 1024, const char *defaultServer = RGL_DEFAULT_SERVER); + static gl_client_context_t *s_getGlContext(); + static ServerConnection *s_getServerConnection(); + static gl2_client_context_t *s_getGl2Context(); + GLEncoder *glEncoder() { return m_glEnc; } + GL2Encoder *gl2Encoder() { return m_gl2Enc; } + ut_rendercontrol_encoder_context_t * utEnc() { return m_ut_enc; } + +private: + ServerConnection(); + +private: + static pthread_key_t s_glKey; + static pthread_key_t s_connectionKey; + static void s_initKeys(); + IOStream *m_stream; + GLEncoder *m_glEnc; + GL2Encoder *m_gl2Enc; + ut_rendercontrol_encoder_context_t *m_ut_enc; + +}; + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.cpp new file mode 100644 index 0000000..5bf6a7d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.cpp @@ -0,0 +1,39 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "ThreadInfo.h" +#include "cutils/threads.h" + +thread_store_t s_tls = THREAD_STORE_INITIALIZER; + +static void tlsDestruct(void *ptr) +{ + if (ptr) { + EGLThreadInfo *ti = (EGLThreadInfo *)ptr; + delete ti->serverConn; + delete ti; + } +} + +EGLThreadInfo *getEGLThreadInfo() +{ + EGLThreadInfo *ti = (EGLThreadInfo *)thread_store_get(&s_tls); + if (ti) return ti; + + ti = new EGLThreadInfo(); + thread_store_set(&s_tls, ti, tlsDestruct); + + return ti; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.h new file mode 100644 index 0000000..f748a39 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/ThreadInfo.h @@ -0,0 +1,49 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _THREAD_INFO_H +#define _THREAD_INFO_H + +#include "ServerConnection.h" +#include + +struct EGLWrapperContext +{ + EGLWrapperContext(EGLContext p_aglContext, int _version) { + aglContext = p_aglContext; + clientState = NULL; + version = _version; + } + + ~EGLWrapperContext() { + delete clientState; + } + + EGLContext aglContext; + GLClientState *clientState; + int version; +}; + +struct EGLThreadInfo +{ + EGLThreadInfo() : currentContext(NULL), serverConn(NULL) {} + + EGLWrapperContext *currentContext; + ServerConnection *serverConn; +}; + + +EGLThreadInfo *getEGLThreadInfo(); +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cfg b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cfg new file mode 100644 index 0000000..891b07d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cfg @@ -0,0 +1 @@ +0 0 emul \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cpp new file mode 100644 index 0000000..1e2e456 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl.cpp @@ -0,0 +1,663 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// +// WARNING -------------------------- WARNING +// This code meant to be used for testing purposes only. It is not production +// level quality. +// Use on your own risk !! +// + +#include +#include +#include +#include +#include "egl_dispatch.h" +#include "egl_ftable.h" +#include +#include +#include "ServerConnection.h" +#include "ThreadInfo.h" +#include +#include "gl_wrapper_context.h" +#include "gl2_wrapper_context.h" + +#define GLES_EMUL_TARGETS_FILE "/system/etc/gles_emul.cfg" +// implementation libraries; +#define GLESv1_enc_LIB "/system/lib/libGLESv1_enc.so" +#define GLESv2_enc_LIB "/system/lib/libGLESv2_enc.so" +#define GLES_android_LIB "/system/lib/egl/libGLES_android.so" +// driver libraries; +#define GLESv1_DRIVER "/system/lib/egl/libGLESv1_CM_emul.so" +#define GLESv2_DRIVER "/system/lib/egl/libGLESv2_emul.so" + + +static struct egl_dispatch *s_dispatch = NULL; +pthread_once_t dispatchTablesInitialized = PTHREAD_ONCE_INIT; + +static bool s_needEncode = false; + +static gl_wrapper_context_t *g_gl_dispatch = NULL; +static gl2_wrapper_context_t *g_gl2_dispatch = NULL; + +template +int initApi(const char *driverLibName, const char *implLibName, T **dispatchTable, T *(*accessor)()) +{ + void *driverLib = dlopen(driverLibName, RTLD_NOW | RTLD_LOCAL); + if (driverLib == NULL) { + ALOGE("failed to load %s : %s\n", driverLibName, dlerror()); + return -1; + } + + typedef T *(*createFcn_t)(void *, T *(*accessor)()); + createFcn_t createFcn; + createFcn = (createFcn_t) dlsym(driverLib, "createFromLib"); + if (createFcn == NULL) { + ALOGE("failed to load createFromLib constructor function\n"); + return -1; + } + + void *implLib = dlopen(implLibName, RTLD_NOW | RTLD_LOCAL); + if (implLib == NULL) { + ALOGE("couldn't open %s", implLibName); + return -2; + } + *dispatchTable = createFcn(implLib, accessor); + if (*dispatchTable == NULL) { + return -3; + } + + // XXX - we do close the impl library since it doesn't have data, as far as we concern. + dlclose(implLib); + + // XXX - we do not dlclose the driver library, so its not initialized when + // later loaded by android - is this required? + ALOGD("loading %s into %s complete\n", implLibName, driverLibName); + return 0; + +} + +static gl_wrapper_context_t *getGLContext() +{ + return g_gl_dispatch; +} + +static gl2_wrapper_context_t *getGL2Context() +{ + return g_gl2_dispatch; +} + +const char *getProcName() +{ + static const char *procname = NULL; + + if (procname == NULL) { + const char *str = get_process_name(); + if (strcmp(str, "unknown") != 0) { + procname = str; + } else { + // we need to obtain our process name from the command line; + FILE *fp = fopen("/proc/self/cmdline", "rt"); + if (fp == NULL) { + ALOGE("couldn't open /proc/self/cmdline\n"); + return NULL; + } + + char line[1000]; + if (fgets(line, sizeof(line), fp) == NULL) { + ALOGE("couldn't read the self cmdline from \n"); + fclose(fp); + return NULL; + } + fclose(fp); + + if (line[0] == '\0') { + ALOGE("cmdline is empty\n"); + return NULL; + } + + //obtain the basename; + line[sizeof(line) - 1] = '\0'; + char *p = line; + while (*p != '\0' && + *p != '\t' && + *p != ' ' && + *p != '\n') { + p++; + } + + *p = '\0'; p--; + while (p > line && *p != '/') p--; + if (*p == '/') p++; + procname = strdup(p); + } + } + + return procname; +} + + + +bool isNeedEncode() +{ + const char *procname = getProcName(); + if (procname == NULL) return false; + ALOGD("isNeedEncode? for %s\n", procname); + // check on our whitelist + FILE *fp = fopen(GLES_EMUL_TARGETS_FILE, "rt"); + if (fp == NULL) { + ALOGE("couldn't open %s\n", GLES_EMUL_TARGETS_FILE); + return false; + } + + char line[100]; + bool found = false; + size_t procnameLen = strlen(procname); + + while (fgets(line, sizeof(line), fp) != NULL) { + if (strlen(line) >= procnameLen && + !strncmp(procname, line, procnameLen)) { + char c = line[procnameLen]; + if (c == '\0' || c == ' ' || c == '\t' || c == '\n') { + found = true; + ALOGD("should use encoder for %s\n", procname); + break; + } + } + } + fclose(fp); + return found; +} + +void initDispatchTables() +{ + // + // Load our back-end implementation of EGL/GLES + // + ALOGD("Loading egl dispatch for %s\n", getProcName()); + + void *gles_android = dlopen("/system/lib/egl/libGLES_android.so", RTLD_NOW | RTLD_LOCAL); + if (!gles_android) { + fprintf(stderr,"FATAL ERROR: Could not load libGLES_android lib\n"); + exit(-1); + } + + // + // Load back-end EGL implementation library + // + s_dispatch = create_egl_dispatch( gles_android ); + if (!s_dispatch) { + fprintf(stderr,"FATAL ERROR: Could not create egl dispatch\n"); + exit(-1); + } + + // + // initialize gles + // + s_needEncode = isNeedEncode(); + void *gles_encoder = NULL; + if (s_needEncode) { + // initialize a connection to the server, and the GLESv1/v2 encoders; + ServerConnection * connection = ServerConnection::s_getServerConnection(); + if (connection == NULL) { + ALOGE("couldn't create server connection\n"); + s_needEncode = false; + } + } + + // init dispatch tabels for GLESv1 & GLESv2 + if (s_needEncode) { + // XXX - we do not check the retrun value because there isn't much we can do here on failure. + + if (initApi(GLESv1_DRIVER, GLESv1_enc_LIB, &g_gl_dispatch, getGLContext) < 0) { + // fallback to android on faluire + s_needEncode = false; + } else { + initApi(GLESv2_DRIVER, GLESv2_enc_LIB, &g_gl2_dispatch, getGL2Context); + } + } + + if (!s_needEncode) { + ALOGD("Initializing native opengl for %s\n", getProcName()); + initApi(GLESv1_DRIVER, GLES_android_LIB, &g_gl_dispatch, getGLContext); + // try to initialize gl2 from GLES, though its probably going to fail + initApi(GLESv2_DRIVER, GLES_android_LIB, &g_gl2_dispatch, getGL2Context); + } +} + +static struct egl_dispatch *getDispatch() +{ + pthread_once(&dispatchTablesInitialized, initDispatchTables); + return s_dispatch; +} + +__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname) +{ + + // search in EGL function table + for (int i=0; ieglGetError(); +} + +EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) +{ + return getDispatch()->eglGetDisplay(display_id); +} + +EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) +{ + return getDispatch()->eglInitialize(dpy, major, minor); +} + +EGLBoolean eglTerminate(EGLDisplay dpy) +{ + return getDispatch()->eglTerminate(dpy); +} + +const char* eglQueryString(EGLDisplay dpy, EGLint name) +{ + return getDispatch()->eglQueryString(dpy, name); +} + +EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) +{ + return getDispatch()->eglGetConfigs(dpy, configs, config_size, num_config); +} + +static EGLint * filter_es2_bit(const EGLint *attrib_list, bool *isES2) +{ + if (attrib_list == NULL) { + if (isES2 != NULL) *isES2 = false; + return NULL; + } + + EGLint *attribs = NULL; + int nAttribs = 0; + while(attrib_list[nAttribs] != EGL_NONE) nAttribs++; + nAttribs++; + + attribs = new EGLint[nAttribs]; + memcpy(attribs, attrib_list, nAttribs * sizeof(EGLint)); + if (isES2 != NULL) *isES2 = false; + + // scan the attribute list for ES2 request and replace with ES1. + for (int i = 0; i < nAttribs; i++) { + if (attribs[i] == EGL_RENDERABLE_TYPE) { + if (attribs[i + 1] & EGL_OPENGL_ES2_BIT) { + attribs[i + 1] &= ~EGL_OPENGL_ES2_BIT; + attribs[i + 1] |= EGL_OPENGL_ES_BIT; + ALOGD("removing ES2 bit 0x%x\n", attribs[i + 1]); + if (isES2 != NULL) *isES2 = true; + } + } + } + return attribs; +} + +EGLBoolean eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) +{ + EGLBoolean res; + if (s_needEncode) { + EGLint *attribs = filter_es2_bit(attrib_list, NULL); + res = getDispatch()->eglChooseConfig(dpy, + attribs, + configs, + config_size, + num_config); + ALOGD("eglChooseConfig: %d configs found\n", *num_config); + if (*num_config == 0 && attribs != NULL) { + ALOGD("requested attributes:\n"); + for (int i = 0; attribs[i] != EGL_NONE; i++) { + ALOGD("%d: 0x%x\n", i, attribs[i]); + } + } + + delete attribs; + } else { + res = getDispatch()->eglChooseConfig(dpy, attrib_list, configs, config_size, num_config); + } + return res; +} + +EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) +{ + if (s_needEncode && attribute == EGL_RENDERABLE_TYPE) { + *value = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; + return EGL_TRUE; + } else { + return getDispatch()->eglGetConfigAttrib(dpy, config, attribute, value); + } +} + +EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list) +{ + EGLSurface surface = getDispatch()->eglCreateWindowSurface(dpy, config, win, attrib_list); + if (surface != EGL_NO_SURFACE) { + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { + server->utEnc()->createSurface(server->utEnc(), getpid(), (uint32_t)surface); + } + } + return surface; +} + +EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) +{ + EGLSurface surface = getDispatch()->eglCreatePbufferSurface(dpy, config, attrib_list); + if (surface != EGL_NO_SURFACE) { + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { + server->utEnc()->createSurface(server->utEnc(), getpid(), (uint32_t)surface); + } + } + return surface; +} + +EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) +{ + EGLSurface surface = getDispatch()->eglCreatePixmapSurface(dpy, config, pixmap, attrib_list); + if (surface != EGL_NO_SURFACE) { + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { + server->utEnc()->createSurface(server->utEnc(), getpid(), (uint32_t)surface); + } + } + return surface; +} + +EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) +{ + EGLBoolean res = getDispatch()->eglDestroySurface(dpy, surface); + if (res && surface != EGL_NO_SURFACE) { + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { + server->utEnc()->destroySurface(server->utEnc(), getpid(), (uint32_t)surface); + } + } + return res; +} + +EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) +{ + EGLBoolean res = getDispatch()->eglQuerySurface(dpy, surface, attribute, value); + if (res && attribute == EGL_RENDERABLE_TYPE) { + *value |= EGL_OPENGL_ES2_BIT; + } + return res; +} + +EGLBoolean eglBindAPI(EGLenum api) +{ + return getDispatch()->eglBindAPI(api); +} + +EGLenum eglQueryAPI() +{ + return getDispatch()->eglQueryAPI(); +} + +EGLBoolean eglWaitClient() +{ + return getDispatch()->eglWaitClient(); +} + +EGLBoolean eglReleaseThread() +{ + return getDispatch()->eglReleaseThread(); +} + +EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list) +{ + return getDispatch()->eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list); +} + +EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) +{ + return getDispatch()->eglSurfaceAttrib(dpy, surface, attribute, value); +} + +EGLBoolean eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +{ + return getDispatch()->eglBindTexImage(dpy, surface, buffer); +} + +EGLBoolean eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) +{ + return getDispatch()->eglReleaseTexImage(dpy, surface, buffer); +} + +EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) +{ + return getDispatch()->eglSwapInterval(dpy, interval); +} + +EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) +{ + + EGLContext share = share_context; + if (share) share = ((EGLWrapperContext *)share_context)->aglContext; + + // check if are ES2, and convert it to ES1. + int nAttribs = 0; + if (attrib_list != NULL) { + while(attrib_list[nAttribs] != EGL_NONE) { + nAttribs++; + } + nAttribs++; + } + + EGLint *attrib = NULL; + if (nAttribs > 0) { + attrib = new EGLint[nAttribs]; + memcpy(attrib, attrib_list, nAttribs * sizeof(EGLint)); + } + + int version = 1; + for (int i = 0; i < nAttribs; i++) { + if (attrib[i] == EGL_CONTEXT_CLIENT_VERSION && + attrib[i + 1] == 2) { + version = 2; + attrib[i + 1] = 1; // replace to version 1 + } + } + + EGLContext ctx = getDispatch()->eglCreateContext(dpy, config, share, attrib); + delete attrib; + EGLWrapperContext *wctx = new EGLWrapperContext(ctx, version); + if (ctx != EGL_NO_CONTEXT) { + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { + wctx->clientState = new GLClientState(); + server->utEnc()->createContext(server->utEnc(), getpid(), + (uint32_t)wctx, + (uint32_t)(share_context == EGL_NO_CONTEXT ? 0 : share_context), wctx->version); + } + } + return (EGLContext)wctx; +} + +EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) +{ + EGLWrapperContext *wctx = (EGLWrapperContext *)ctx; + EGLBoolean res = EGL_FALSE; + + if (ctx && ctx != EGL_NO_CONTEXT) { + res = getDispatch()->eglDestroyContext(dpy, wctx->aglContext); + if (res) { + EGLThreadInfo *ti = getEGLThreadInfo(); + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection())) { + server->utEnc()->destroyContext(ti->serverConn->utEnc(), getpid(), (uint32_t)ctx); + } + if (ti->currentContext == wctx) ti->currentContext = NULL; + delete wctx; + } + } + + return res; +} + +EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) +{ + EGLWrapperContext *wctx = (EGLWrapperContext *)ctx; + EGLContext aglContext = (ctx == EGL_NO_CONTEXT ? EGL_NO_CONTEXT : wctx->aglContext); + EGLThreadInfo *ti = getEGLThreadInfo(); + EGLBoolean res = getDispatch()->eglMakeCurrent(dpy, draw, read, aglContext); + if (res ) { + // NOTE - we do get a pointer to the server connection, (rather then using ti->serverConn) + // for cases that this is the first egl call of the current thread. + + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection())) { + server->utEnc()->makeCurrentContext(server->utEnc(), getpid(), + (uint32_t) (draw == EGL_NO_SURFACE ? 0 : draw), + (uint32_t) (read == EGL_NO_SURFACE ? 0 : read), + (uint32_t) (ctx == EGL_NO_CONTEXT ? 0 : ctx)); + server->glEncoder()->setClientState( wctx ? wctx->clientState : NULL ); + server->gl2Encoder()->setClientState( wctx ? wctx->clientState : NULL ); + } + + // set current context in our thread info + ti->currentContext = wctx; + } + return res; + +} + +EGLContext eglGetCurrentContext() +{ + EGLThreadInfo *ti = getEGLThreadInfo(); + return (ti->currentContext ? ti->currentContext : EGL_NO_CONTEXT); +} + +EGLSurface eglGetCurrentSurface(EGLint readdraw) +{ + return getDispatch()->eglGetCurrentSurface(readdraw); +} + +EGLDisplay eglGetCurrentDisplay() +{ + return getDispatch()->eglGetCurrentDisplay(); +} + +EGLBoolean eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value) +{ + EGLWrapperContext *wctx = (EGLWrapperContext *)ctx; + if (wctx) { + if (attribute == EGL_CONTEXT_CLIENT_VERSION) { + *value = wctx->version; + return EGL_TRUE; + } else { + return getDispatch()->eglQueryContext(dpy, wctx->aglContext, attribute, value); + } + } + else { + return EGL_BAD_CONTEXT; + } +} + +EGLBoolean eglWaitGL() +{ + return getDispatch()->eglWaitGL(); +} + +EGLBoolean eglWaitNative(EGLint engine) +{ + return getDispatch()->eglWaitNative(engine); +} + +EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) +{ + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection()) != NULL) { + server->utEnc()->swapBuffers(server->utEnc(), getpid(), (uint32_t)surface); + server->glEncoder()->flush(); + server->gl2Encoder()->flush(); + return 1; + } + return getDispatch()->eglSwapBuffers(dpy, surface); +} + +EGLBoolean eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) +{ + return getDispatch()->eglCopyBuffers(dpy, surface, target); +} + +EGLBoolean eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list) +{ + return getDispatch()->eglLockSurfaceKHR(display, surface, attrib_list); +} + +EGLBoolean eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface) +{ + return getDispatch()->eglUnlockSurfaceKHR(display, surface); +} + +EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list) +{ + EGLWrapperContext *wctx = (EGLWrapperContext *)ctx; + EGLContext aglContext = (wctx ? wctx->aglContext : EGL_NO_CONTEXT); + return getDispatch()->eglCreateImageKHR(dpy, aglContext, target, buffer, attrib_list); +} + +EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) +{ + return getDispatch()->eglDestroyImageKHR(dpy, image); +} + +EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) +{ + return getDispatch()->eglCreateSyncKHR(dpy, type, attrib_list); +} + +EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) +{ + return getDispatch()->eglDestroySyncKHR(dpy, sync); +} + +EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) +{ + return getDispatch()->eglClientWaitSyncKHR(dpy, sync, flags, timeout); +} + +EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) +{ + return getDispatch()->eglSignalSyncKHR(dpy, sync, mode); +} + +EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) +{ + return getDispatch()->eglGetSyncAttribKHR(dpy, sync, attribute, value); +} + +EGLBoolean eglSetSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw, EGLint left, EGLint top, EGLint width, EGLint height) +{ + return getDispatch()->eglSetSwapRectangleANDROID(dpy, draw, left, top, width, height); +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.cpp new file mode 100644 index 0000000..f69ca61 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.cpp @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include "egl_dispatch.h" +#include + +egl_dispatch *create_egl_dispatch(void *gles_android) +{ + egl_dispatch *disp = new egl_dispatch; + + void *ptr; + ptr = dlsym(gles_android,"eglGetError"); disp->set_eglGetError((eglGetError_t)ptr); + ptr = dlsym(gles_android,"eglGetDisplay"); disp->set_eglGetDisplay((eglGetDisplay_t)ptr); + ptr = dlsym(gles_android,"eglInitialize"); disp->set_eglInitialize((eglInitialize_t)ptr); + ptr = dlsym(gles_android,"eglTerminate"); disp->set_eglTerminate((eglTerminate_t)ptr); + ptr = dlsym(gles_android,"eglQueryString"); disp->set_eglQueryString((eglQueryString_t)ptr); + ptr = dlsym(gles_android,"eglGetConfigs"); disp->set_eglGetConfigs((eglGetConfigs_t)ptr); + ptr = dlsym(gles_android,"eglChooseConfig"); disp->set_eglChooseConfig((eglChooseConfig_t)ptr); + ptr = dlsym(gles_android,"eglGetConfigAttrib"); disp->set_eglGetConfigAttrib((eglGetConfigAttrib_t)ptr); + ptr = dlsym(gles_android,"eglCreateWindowSurface"); disp->set_eglCreateWindowSurface((eglCreateWindowSurface_t)ptr); + ptr = dlsym(gles_android,"eglCreatePbufferSurface"); disp->set_eglCreatePbufferSurface((eglCreatePbufferSurface_t)ptr); + ptr = dlsym(gles_android,"eglCreatePixmapSurface"); disp->set_eglCreatePixmapSurface((eglCreatePixmapSurface_t)ptr); + ptr = dlsym(gles_android,"eglDestroySurface"); disp->set_eglDestroySurface((eglDestroySurface_t)ptr); + ptr = dlsym(gles_android,"eglQuerySurface"); disp->set_eglQuerySurface((eglQuerySurface_t)ptr); + ptr = dlsym(gles_android,"eglBindAPI"); disp->set_eglBindAPI((eglBindAPI_t)ptr); + ptr = dlsym(gles_android,"eglQueryAPI"); disp->set_eglQueryAPI((eglQueryAPI_t)ptr); + ptr = dlsym(gles_android,"eglWaitClient"); disp->set_eglWaitClient((eglWaitClient_t)ptr); + ptr = dlsym(gles_android,"eglReleaseThread"); disp->set_eglReleaseThread((eglReleaseThread_t)ptr); + ptr = dlsym(gles_android,"eglCreatePbufferFromClientBuffer"); disp->set_eglCreatePbufferFromClientBuffer((eglCreatePbufferFromClientBuffer_t)ptr); + ptr = dlsym(gles_android,"eglSurfaceAttrib"); disp->set_eglSurfaceAttrib((eglSurfaceAttrib_t)ptr); + ptr = dlsym(gles_android,"eglBindTexImage"); disp->set_eglBindTexImage((eglBindTexImage_t)ptr); + ptr = dlsym(gles_android,"eglReleaseTexImage"); disp->set_eglReleaseTexImage((eglReleaseTexImage_t)ptr); + ptr = dlsym(gles_android,"eglSwapInterval"); disp->set_eglSwapInterval((eglSwapInterval_t)ptr); + ptr = dlsym(gles_android,"eglCreateContext"); disp->set_eglCreateContext((eglCreateContext_t)ptr); + ptr = dlsym(gles_android,"eglDestroyContext"); disp->set_eglDestroyContext((eglDestroyContext_t)ptr); + ptr = dlsym(gles_android,"eglMakeCurrent"); disp->set_eglMakeCurrent((eglMakeCurrent_t)ptr); + ptr = dlsym(gles_android,"eglGetCurrentContext"); disp->set_eglGetCurrentContext((eglGetCurrentContext_t)ptr); + ptr = dlsym(gles_android,"eglGetCurrentSurface"); disp->set_eglGetCurrentSurface((eglGetCurrentSurface_t)ptr); + ptr = dlsym(gles_android,"eglGetCurrentDisplay"); disp->set_eglGetCurrentDisplay((eglGetCurrentDisplay_t)ptr); + ptr = dlsym(gles_android,"eglQueryContext"); disp->set_eglQueryContext((eglQueryContext_t)ptr); + ptr = dlsym(gles_android,"eglWaitGL"); disp->set_eglWaitGL((eglWaitGL_t)ptr); + ptr = dlsym(gles_android,"eglWaitNative"); disp->set_eglWaitNative((eglWaitNative_t)ptr); + ptr = dlsym(gles_android,"eglSwapBuffers"); disp->set_eglSwapBuffers((eglSwapBuffers_t)ptr); + ptr = dlsym(gles_android,"eglCopyBuffers"); disp->set_eglCopyBuffers((eglCopyBuffers_t)ptr); + ptr = dlsym(gles_android,"eglGetProcAddress"); disp->set_eglGetProcAddress((eglGetProcAddress_t)ptr); + ptr = dlsym(gles_android,"eglLockSurfaceKHR"); disp->set_eglLockSurfaceKHR((eglLockSurfaceKHR_t)ptr); + ptr = dlsym(gles_android,"eglUnlockSurfaceKHR"); disp->set_eglUnlockSurfaceKHR((eglUnlockSurfaceKHR_t)ptr); + ptr = dlsym(gles_android,"eglCreateImageKHR"); disp->set_eglCreateImageKHR((eglCreateImageKHR_t)ptr); + ptr = dlsym(gles_android,"eglDestroyImageKHR"); disp->set_eglDestroyImageKHR((eglDestroyImageKHR_t)ptr); + ptr = dlsym(gles_android,"eglCreateSyncKHR"); disp->set_eglCreateSyncKHR((eglCreateSyncKHR_t)ptr); + ptr = dlsym(gles_android,"eglDestroySyncKHR"); disp->set_eglDestroySyncKHR((eglDestroySyncKHR_t)ptr); + ptr = dlsym(gles_android,"eglClientWaitSyncKHR"); disp->set_eglClientWaitSyncKHR((eglClientWaitSyncKHR_t)ptr); + ptr = dlsym(gles_android,"eglSignalSyncKHR"); disp->set_eglSignalSyncKHR((eglSignalSyncKHR_t)ptr); + ptr = dlsym(gles_android,"eglGetSyncAttribKHR"); disp->set_eglGetSyncAttribKHR((eglGetSyncAttribKHR_t)ptr); + ptr = dlsym(gles_android,"eglSetSwapRectangleANDROID"); disp->set_eglSetSwapRectangleANDROID((eglSetSwapRectangleANDROID_t)ptr); + + return disp; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.h new file mode 100644 index 0000000..1b8de0d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_dispatch.h @@ -0,0 +1,115 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _EGL_DISPATCH_H +#define _EGL_DISPATCH_H + +#include "egl_proc.h" + +struct egl_dispatch { + eglGetError_t eglGetError; + eglGetDisplay_t eglGetDisplay; + eglInitialize_t eglInitialize; + eglTerminate_t eglTerminate; + eglQueryString_t eglQueryString; + eglGetConfigs_t eglGetConfigs; + eglChooseConfig_t eglChooseConfig; + eglGetConfigAttrib_t eglGetConfigAttrib; + eglCreateWindowSurface_t eglCreateWindowSurface; + eglCreatePbufferSurface_t eglCreatePbufferSurface; + eglCreatePixmapSurface_t eglCreatePixmapSurface; + eglDestroySurface_t eglDestroySurface; + eglQuerySurface_t eglQuerySurface; + eglBindAPI_t eglBindAPI; + eglQueryAPI_t eglQueryAPI; + eglWaitClient_t eglWaitClient; + eglReleaseThread_t eglReleaseThread; + eglCreatePbufferFromClientBuffer_t eglCreatePbufferFromClientBuffer; + eglSurfaceAttrib_t eglSurfaceAttrib; + eglBindTexImage_t eglBindTexImage; + eglReleaseTexImage_t eglReleaseTexImage; + eglSwapInterval_t eglSwapInterval; + eglCreateContext_t eglCreateContext; + eglDestroyContext_t eglDestroyContext; + eglMakeCurrent_t eglMakeCurrent; + eglGetCurrentContext_t eglGetCurrentContext; + eglGetCurrentSurface_t eglGetCurrentSurface; + eglGetCurrentDisplay_t eglGetCurrentDisplay; + eglQueryContext_t eglQueryContext; + eglWaitGL_t eglWaitGL; + eglWaitNative_t eglWaitNative; + eglSwapBuffers_t eglSwapBuffers; + eglCopyBuffers_t eglCopyBuffers; + eglGetProcAddress_t eglGetProcAddress; + eglLockSurfaceKHR_t eglLockSurfaceKHR; + eglUnlockSurfaceKHR_t eglUnlockSurfaceKHR; + eglCreateImageKHR_t eglCreateImageKHR; + eglDestroyImageKHR_t eglDestroyImageKHR; + eglCreateSyncKHR_t eglCreateSyncKHR; + eglDestroySyncKHR_t eglDestroySyncKHR; + eglClientWaitSyncKHR_t eglClientWaitSyncKHR; + eglSignalSyncKHR_t eglSignalSyncKHR; + eglGetSyncAttribKHR_t eglGetSyncAttribKHR; + eglSetSwapRectangleANDROID_t eglSetSwapRectangleANDROID; + //Accessors + eglGetError_t set_eglGetError(eglGetError_t f) { eglGetError_t retval = eglGetError; eglGetError = f; return retval;} + eglGetDisplay_t set_eglGetDisplay(eglGetDisplay_t f) { eglGetDisplay_t retval = eglGetDisplay; eglGetDisplay = f; return retval;} + eglInitialize_t set_eglInitialize(eglInitialize_t f) { eglInitialize_t retval = eglInitialize; eglInitialize = f; return retval;} + eglTerminate_t set_eglTerminate(eglTerminate_t f) { eglTerminate_t retval = eglTerminate; eglTerminate = f; return retval;} + eglQueryString_t set_eglQueryString(eglQueryString_t f) { eglQueryString_t retval = eglQueryString; eglQueryString = f; return retval;} + eglGetConfigs_t set_eglGetConfigs(eglGetConfigs_t f) { eglGetConfigs_t retval = eglGetConfigs; eglGetConfigs = f; return retval;} + eglChooseConfig_t set_eglChooseConfig(eglChooseConfig_t f) { eglChooseConfig_t retval = eglChooseConfig; eglChooseConfig = f; return retval;} + eglGetConfigAttrib_t set_eglGetConfigAttrib(eglGetConfigAttrib_t f) { eglGetConfigAttrib_t retval = eglGetConfigAttrib; eglGetConfigAttrib = f; return retval;} + eglCreateWindowSurface_t set_eglCreateWindowSurface(eglCreateWindowSurface_t f) { eglCreateWindowSurface_t retval = eglCreateWindowSurface; eglCreateWindowSurface = f; return retval;} + eglCreatePbufferSurface_t set_eglCreatePbufferSurface(eglCreatePbufferSurface_t f) { eglCreatePbufferSurface_t retval = eglCreatePbufferSurface; eglCreatePbufferSurface = f; return retval;} + eglCreatePixmapSurface_t set_eglCreatePixmapSurface(eglCreatePixmapSurface_t f) { eglCreatePixmapSurface_t retval = eglCreatePixmapSurface; eglCreatePixmapSurface = f; return retval;} + eglDestroySurface_t set_eglDestroySurface(eglDestroySurface_t f) { eglDestroySurface_t retval = eglDestroySurface; eglDestroySurface = f; return retval;} + eglQuerySurface_t set_eglQuerySurface(eglQuerySurface_t f) { eglQuerySurface_t retval = eglQuerySurface; eglQuerySurface = f; return retval;} + eglBindAPI_t set_eglBindAPI(eglBindAPI_t f) { eglBindAPI_t retval = eglBindAPI; eglBindAPI = f; return retval;} + eglQueryAPI_t set_eglQueryAPI(eglQueryAPI_t f) { eglQueryAPI_t retval = eglQueryAPI; eglQueryAPI = f; return retval;} + eglWaitClient_t set_eglWaitClient(eglWaitClient_t f) { eglWaitClient_t retval = eglWaitClient; eglWaitClient = f; return retval;} + eglReleaseThread_t set_eglReleaseThread(eglReleaseThread_t f) { eglReleaseThread_t retval = eglReleaseThread; eglReleaseThread = f; return retval;} + eglCreatePbufferFromClientBuffer_t set_eglCreatePbufferFromClientBuffer(eglCreatePbufferFromClientBuffer_t f) { eglCreatePbufferFromClientBuffer_t retval = eglCreatePbufferFromClientBuffer; eglCreatePbufferFromClientBuffer = f; return retval;} + eglSurfaceAttrib_t set_eglSurfaceAttrib(eglSurfaceAttrib_t f) { eglSurfaceAttrib_t retval = eglSurfaceAttrib; eglSurfaceAttrib = f; return retval;} + eglBindTexImage_t set_eglBindTexImage(eglBindTexImage_t f) { eglBindTexImage_t retval = eglBindTexImage; eglBindTexImage = f; return retval;} + eglReleaseTexImage_t set_eglReleaseTexImage(eglReleaseTexImage_t f) { eglReleaseTexImage_t retval = eglReleaseTexImage; eglReleaseTexImage = f; return retval;} + eglSwapInterval_t set_eglSwapInterval(eglSwapInterval_t f) { eglSwapInterval_t retval = eglSwapInterval; eglSwapInterval = f; return retval;} + eglCreateContext_t set_eglCreateContext(eglCreateContext_t f) { eglCreateContext_t retval = eglCreateContext; eglCreateContext = f; return retval;} + eglDestroyContext_t set_eglDestroyContext(eglDestroyContext_t f) { eglDestroyContext_t retval = eglDestroyContext; eglDestroyContext = f; return retval;} + eglMakeCurrent_t set_eglMakeCurrent(eglMakeCurrent_t f) { eglMakeCurrent_t retval = eglMakeCurrent; eglMakeCurrent = f; return retval;} + eglGetCurrentContext_t set_eglGetCurrentContext(eglGetCurrentContext_t f) { eglGetCurrentContext_t retval = eglGetCurrentContext; eglGetCurrentContext = f; return retval;} + eglGetCurrentSurface_t set_eglGetCurrentSurface(eglGetCurrentSurface_t f) { eglGetCurrentSurface_t retval = eglGetCurrentSurface; eglGetCurrentSurface = f; return retval;} + eglGetCurrentDisplay_t set_eglGetCurrentDisplay(eglGetCurrentDisplay_t f) { eglGetCurrentDisplay_t retval = eglGetCurrentDisplay; eglGetCurrentDisplay = f; return retval;} + eglQueryContext_t set_eglQueryContext(eglQueryContext_t f) { eglQueryContext_t retval = eglQueryContext; eglQueryContext = f; return retval;} + eglWaitGL_t set_eglWaitGL(eglWaitGL_t f) { eglWaitGL_t retval = eglWaitGL; eglWaitGL = f; return retval;} + eglWaitNative_t set_eglWaitNative(eglWaitNative_t f) { eglWaitNative_t retval = eglWaitNative; eglWaitNative = f; return retval;} + eglSwapBuffers_t set_eglSwapBuffers(eglSwapBuffers_t f) { eglSwapBuffers_t retval = eglSwapBuffers; eglSwapBuffers = f; return retval;} + eglCopyBuffers_t set_eglCopyBuffers(eglCopyBuffers_t f) { eglCopyBuffers_t retval = eglCopyBuffers; eglCopyBuffers = f; return retval;} + eglGetProcAddress_t set_eglGetProcAddress(eglGetProcAddress_t f) { eglGetProcAddress_t retval = eglGetProcAddress; eglGetProcAddress = f; return retval;} + eglLockSurfaceKHR_t set_eglLockSurfaceKHR(eglLockSurfaceKHR_t f) { eglLockSurfaceKHR_t retval = eglLockSurfaceKHR; eglLockSurfaceKHR = f; return retval;} + eglUnlockSurfaceKHR_t set_eglUnlockSurfaceKHR(eglUnlockSurfaceKHR_t f) { eglUnlockSurfaceKHR_t retval = eglUnlockSurfaceKHR; eglUnlockSurfaceKHR = f; return retval;} + eglCreateImageKHR_t set_eglCreateImageKHR(eglCreateImageKHR_t f) { eglCreateImageKHR_t retval = eglCreateImageKHR; eglCreateImageKHR = f; return retval;} + eglDestroyImageKHR_t set_eglDestroyImageKHR(eglDestroyImageKHR_t f) { eglDestroyImageKHR_t retval = eglDestroyImageKHR; eglDestroyImageKHR = f; return retval;} + eglCreateSyncKHR_t set_eglCreateSyncKHR(eglCreateSyncKHR_t f) { eglCreateSyncKHR_t retval = eglCreateSyncKHR; eglCreateSyncKHR = f; return retval;} + eglDestroySyncKHR_t set_eglDestroySyncKHR(eglDestroySyncKHR_t f) { eglDestroySyncKHR_t retval = eglDestroySyncKHR; eglDestroySyncKHR = f; return retval;} + eglClientWaitSyncKHR_t set_eglClientWaitSyncKHR(eglClientWaitSyncKHR_t f) { eglClientWaitSyncKHR_t retval = eglClientWaitSyncKHR; eglClientWaitSyncKHR = f; return retval;} + eglSignalSyncKHR_t set_eglSignalSyncKHR(eglSignalSyncKHR_t f) { eglSignalSyncKHR_t retval = eglSignalSyncKHR; eglSignalSyncKHR = f; return retval;} + eglGetSyncAttribKHR_t set_eglGetSyncAttribKHR(eglGetSyncAttribKHR_t f) { eglGetSyncAttribKHR_t retval = eglGetSyncAttribKHR; eglGetSyncAttribKHR = f; return retval;} + eglSetSwapRectangleANDROID_t set_eglSetSwapRectangleANDROID(eglSetSwapRectangleANDROID_t f) { eglSetSwapRectangleANDROID_t retval = eglSetSwapRectangleANDROID; eglSetSwapRectangleANDROID = f; return retval;} +}; + +egl_dispatch *create_egl_dispatch(void *gles_andorid); + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_ftable.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_ftable.h new file mode 100644 index 0000000..ee40585 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_ftable.h @@ -0,0 +1,66 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +static struct _egl_funcs_by_name { + const char *name; + void *proc; +} egl_funcs_by_name[] = { + {"eglGetError", (void *)eglGetError}, + {"eglGetDisplay", (void *)eglGetDisplay}, + {"eglInitialize", (void *)eglInitialize}, + {"eglTerminate", (void *)eglTerminate}, + {"eglQueryString", (void *)eglQueryString}, + {"eglGetConfigs", (void *)eglGetConfigs}, + {"eglChooseConfig", (void *)eglChooseConfig}, + {"eglGetConfigAttrib", (void *)eglGetConfigAttrib}, + {"eglCreateWindowSurface", (void *)eglCreateWindowSurface}, + {"eglCreatePbufferSurface", (void *)eglCreatePbufferSurface}, + {"eglCreatePixmapSurface", (void *)eglCreatePixmapSurface}, + {"eglDestroySurface", (void *)eglDestroySurface}, + {"eglQuerySurface", (void *)eglQuerySurface}, + {"eglBindAPI", (void *)eglBindAPI}, + {"eglQueryAPI", (void *)eglQueryAPI}, + {"eglWaitClient", (void *)eglWaitClient}, + {"eglReleaseThread", (void *)eglReleaseThread}, + {"eglCreatePbufferFromClientBuffer", (void *)eglCreatePbufferFromClientBuffer}, + {"eglSurfaceAttrib", (void *)eglSurfaceAttrib}, + {"eglBindTexImage", (void *)eglBindTexImage}, + {"eglReleaseTexImage", (void *)eglReleaseTexImage}, + {"eglSwapInterval", (void *)eglSwapInterval}, + {"eglCreateContext", (void *)eglCreateContext}, + {"eglDestroyContext", (void *)eglDestroyContext}, + {"eglMakeCurrent", (void *)eglMakeCurrent}, + {"eglGetCurrentContext", (void *)eglGetCurrentContext}, + {"eglGetCurrentSurface", (void *)eglGetCurrentSurface}, + {"eglGetCurrentDisplay", (void *)eglGetCurrentDisplay}, + {"eglQueryContext", (void *)eglQueryContext}, + {"eglWaitGL", (void *)eglWaitGL}, + {"eglWaitNative", (void *)eglWaitNative}, + {"eglSwapBuffers", (void *)eglSwapBuffers}, + {"eglCopyBuffers", (void *)eglCopyBuffers}, + {"eglGetProcAddress", (void *)eglGetProcAddress}, + {"eglLockSurfaceKHR", (void *)eglLockSurfaceKHR}, + {"eglUnlockSurfaceKHR", (void *)eglUnlockSurfaceKHR}, + {"eglCreateImageKHR", (void *)eglCreateImageKHR}, + {"eglDestroyImageKHR", (void *)eglDestroyImageKHR}, + {"eglCreateSyncKHR", (void *)eglCreateSyncKHR}, + {"eglDestroySyncKHR", (void *)eglDestroySyncKHR}, + {"eglClientWaitSyncKHR", (void *)eglClientWaitSyncKHR}, + {"eglSignalSyncKHR", (void *)eglSignalSyncKHR}, + {"eglGetSyncAttribKHR", (void *)eglGetSyncAttribKHR}, + {"eglSetSwapRectangleANDROID", (void *)eglSetSwapRectangleANDROID} +}; + +static int egl_num_funcs = sizeof(egl_funcs_by_name) / sizeof(struct _egl_funcs_by_name); diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_proc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_proc.h new file mode 100644 index 0000000..140c030 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/egl_proc.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _EGL_PROC_H +#define _EGL_PROC_H + +#include +#define EGL_EGLEXT_PROTOTYPES +#include + +typedef EGLint (* eglGetError_t) (); +typedef EGLDisplay (* eglGetDisplay_t) (EGLNativeDisplayType); +typedef EGLBoolean (* eglInitialize_t) (EGLDisplay, EGLint*, EGLint*); +typedef EGLBoolean (* eglTerminate_t) (EGLDisplay); +typedef char* (* eglQueryString_t) (EGLDisplay, EGLint); +typedef EGLBoolean (* eglGetConfigs_t) (EGLDisplay, EGLConfig*, EGLint, EGLint*); +typedef EGLBoolean (* eglChooseConfig_t) (EGLDisplay, const EGLint*, EGLConfig*, EGLint, EGLint*); +typedef EGLBoolean (* eglGetConfigAttrib_t) (EGLDisplay, EGLConfig, EGLint, EGLint*); +typedef EGLSurface (* eglCreateWindowSurface_t) (EGLDisplay, EGLConfig, EGLNativeWindowType, const EGLint*); +typedef EGLSurface (* eglCreatePbufferSurface_t) (EGLDisplay, EGLConfig, const EGLint*); +typedef EGLSurface (* eglCreatePixmapSurface_t) (EGLDisplay, EGLConfig, EGLNativePixmapType, const EGLint*); +typedef EGLBoolean (* eglDestroySurface_t) (EGLDisplay, EGLSurface); +typedef EGLBoolean (* eglQuerySurface_t) (EGLDisplay, EGLSurface, EGLint, EGLint*); +typedef EGLBoolean (* eglBindAPI_t) (EGLenum); +typedef EGLenum (* eglQueryAPI_t) (); +typedef EGLBoolean (* eglWaitClient_t) (); +typedef EGLBoolean (* eglReleaseThread_t) (); +typedef EGLSurface (* eglCreatePbufferFromClientBuffer_t) (EGLDisplay, EGLenum, EGLClientBuffer, EGLConfig, const EGLint*); +typedef EGLBoolean (* eglSurfaceAttrib_t) (EGLDisplay, EGLSurface, EGLint, EGLint); +typedef EGLBoolean (* eglBindTexImage_t) (EGLDisplay, EGLSurface, EGLint); +typedef EGLBoolean (* eglReleaseTexImage_t) (EGLDisplay, EGLSurface, EGLint); +typedef EGLBoolean (* eglSwapInterval_t) (EGLDisplay, EGLint); +typedef EGLContext (* eglCreateContext_t) (EGLDisplay, EGLConfig, EGLContext, const EGLint*); +typedef EGLBoolean (* eglDestroyContext_t) (EGLDisplay, EGLContext); +typedef EGLBoolean (* eglMakeCurrent_t) (EGLDisplay, EGLSurface, EGLSurface, EGLContext); +typedef EGLContext (* eglGetCurrentContext_t) (); +typedef EGLSurface (* eglGetCurrentSurface_t) (EGLint); +typedef EGLDisplay (* eglGetCurrentDisplay_t) (); +typedef EGLBoolean (* eglQueryContext_t) (EGLDisplay, EGLContext, EGLint, EGLint*); +typedef EGLBoolean (* eglWaitGL_t) (); +typedef EGLBoolean (* eglWaitNative_t) (EGLint); +typedef EGLBoolean (* eglSwapBuffers_t) (EGLDisplay, EGLSurface); +typedef EGLBoolean (* eglCopyBuffers_t) (EGLDisplay, EGLSurface, EGLNativePixmapType); +typedef __eglMustCastToProperFunctionPointerType (* eglGetProcAddress_t) (const char*); +typedef EGLBoolean (* eglLockSurfaceKHR_t) (EGLDisplay, EGLSurface, const EGLint*); +typedef EGLBoolean (* eglUnlockSurfaceKHR_t) (EGLDisplay, EGLSurface); +typedef EGLImageKHR (* eglCreateImageKHR_t) (EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*); +typedef EGLBoolean (* eglDestroyImageKHR_t) (EGLDisplay, EGLImageKHR image); +typedef EGLSyncKHR (* eglCreateSyncKHR_t) (EGLDisplay, EGLenum, const EGLint*); +typedef EGLBoolean (* eglDestroySyncKHR_t) (EGLDisplay, EGLSyncKHR sync); +typedef EGLint (* eglClientWaitSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR timeout); +typedef EGLBoolean (* eglSignalSyncKHR_t) (EGLDisplay, EGLSyncKHR, EGLenum); +typedef EGLBoolean (* eglGetSyncAttribKHR_t) (EGLDisplay, EGLSyncKHR, EGLint, EGLint*); +typedef EGLBoolean (* eglSetSwapRectangleANDROID_t) (EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint); + +#endif // of _EGL_PROC_H diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles.cpp new file mode 100644 index 0000000..c0949c8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles.cpp @@ -0,0 +1,1410 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include +#include "gles_dispatch.h" +#include "gles_ftable.h" +#include +#include + +static struct gles_dispatch *s_dispatch = NULL; + +void init_gles(void *gles_android) +{ + s_dispatch = create_gles_dispatch(gles_android); + if (s_dispatch == NULL) { + ALOGE("failed to create gles dispatch\n"); + } +} + +static struct gles_dispatch *getDispatch() +{ + if (!s_dispatch) { + fprintf(stderr,"FATAL ERROR: GLES has not been initialized\n"); + exit(-1); + } + + return s_dispatch; +} + +__eglMustCastToProperFunctionPointerType gles_getProcAddress(const char *procname) +{ + for (int i=0; iglAlphaFunc(func, ref); +} + +void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + getDispatch()->glClearColor(red, green, blue, alpha); +} + +void glClearDepthf(GLclampf depth) +{ + getDispatch()->glClearDepthf(depth); +} + +void glClipPlanef(GLenum plane, const GLfloat *equation) +{ + getDispatch()->glClipPlanef(plane, equation); +} + +void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + getDispatch()->glColor4f(red, green, blue, alpha); +} + +void glDepthRangef(GLclampf zNear, GLclampf zFar) +{ + getDispatch()->glDepthRangef(zNear, zFar); +} + +void glFogf(GLenum pname, GLfloat param) +{ + getDispatch()->glFogf(pname, param); +} + +void glFogfv(GLenum pname, const GLfloat *params) +{ + getDispatch()->glFogfv(pname, params); +} + +void glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + getDispatch()->glFrustumf(left, right, bottom, top, zNear, zFar); +} + +void glGetClipPlanef(GLenum pname, GLfloat eqn[4]) +{ + getDispatch()->glGetClipPlanef(pname, eqn); +} + +void glGetFloatv(GLenum pname, GLfloat *params) +{ + getDispatch()->glGetFloatv(pname, params); +} + +void glGetLightfv(GLenum light, GLenum pname, GLfloat *params) +{ + getDispatch()->glGetLightfv(light, pname, params); +} + +void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +{ + getDispatch()->glGetMaterialfv(face, pname, params); +} + +void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params) +{ + getDispatch()->glGetTexEnvfv(env, pname, params); +} + +void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + getDispatch()->glGetTexParameterfv(target, pname, params); +} + +void glLightModelf(GLenum pname, GLfloat param) +{ + getDispatch()->glLightModelf(pname, param); +} + +void glLightModelfv(GLenum pname, const GLfloat *params) +{ + getDispatch()->glLightModelfv(pname, params); +} + +void glLightf(GLenum light, GLenum pname, GLfloat param) +{ + getDispatch()->glLightf(light, pname, param); +} + +void glLightfv(GLenum light, GLenum pname, const GLfloat *params) +{ + getDispatch()->glLightfv(light, pname, params); +} + +void glLineWidth(GLfloat width) +{ + getDispatch()->glLineWidth(width); +} + +void glLoadMatrixf(const GLfloat *m) +{ + getDispatch()->glLoadMatrixf(m); +} + +void glMaterialf(GLenum face, GLenum pname, GLfloat param) +{ + getDispatch()->glMaterialf(face, pname, param); +} + +void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) +{ + getDispatch()->glMaterialfv(face, pname, params); +} + +void glMultMatrixf(const GLfloat *m) +{ + getDispatch()->glMultMatrixf(m); +} + +void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + getDispatch()->glMultiTexCoord4f(target, s, t, r, q); +} + +void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) +{ + getDispatch()->glNormal3f(nx, ny, nz); +} + +void glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + getDispatch()->glOrthof(left, right, bottom, top, zNear, zFar); +} + +void glPointParameterf(GLenum pname, GLfloat param) +{ + getDispatch()->glPointParameterf(pname, param); +} + +void glPointParameterfv(GLenum pname, const GLfloat *params) +{ + getDispatch()->glPointParameterfv(pname, params); +} + +void glPointSize(GLfloat size) +{ + getDispatch()->glPointSize(size); +} + +void glPolygonOffset(GLfloat factor, GLfloat units) +{ + getDispatch()->glPolygonOffset(factor, units); +} + +void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + getDispatch()->glRotatef(angle, x, y, z); +} + +void glScalef(GLfloat x, GLfloat y, GLfloat z) +{ + getDispatch()->glScalef(x, y, z); +} + +void glTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + getDispatch()->glTexEnvf(target, pname, param); +} + +void glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ + getDispatch()->glTexEnvfv(target, pname, params); +} + +void glTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + getDispatch()->glTexParameterf(target, pname, param); +} + +void glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + getDispatch()->glTexParameterfv(target, pname, params); +} + +void glTranslatef(GLfloat x, GLfloat y, GLfloat z) +{ + getDispatch()->glTranslatef(x, y, z); +} + +void glActiveTexture(GLenum texture) +{ + getDispatch()->glActiveTexture(texture); +} + +void glAlphaFuncx(GLenum func, GLclampx ref) +{ + getDispatch()->glAlphaFuncx(func, ref); +} + +void glBindBuffer(GLenum target, GLuint buffer) +{ + getDispatch()->glBindBuffer(target, buffer); +} + +void glBindTexture(GLenum target, GLuint texture) +{ + getDispatch()->glBindTexture(target, texture); +} + +void glBlendFunc(GLenum sfactor, GLenum dfactor) +{ + getDispatch()->glBlendFunc(sfactor, dfactor); +} + +void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) +{ + getDispatch()->glBufferData(target, size, data, usage); +} + +void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) +{ + getDispatch()->glBufferSubData(target, offset, size, data); +} + +void glClear(GLbitfield mask) +{ + getDispatch()->glClear(mask); +} + +void glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + getDispatch()->glClearColorx(red, green, blue, alpha); +} + +void glClearDepthx(GLclampx depth) +{ + getDispatch()->glClearDepthx(depth); +} + +void glClearStencil(GLint s) +{ + getDispatch()->glClearStencil(s); +} + +void glClientActiveTexture(GLenum texture) +{ + getDispatch()->glClientActiveTexture(texture); +} + +void glClipPlanex(GLenum plane, const GLfixed *equation) +{ + getDispatch()->glClipPlanex(plane, equation); +} + +void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + getDispatch()->glColor4ub(red, green, blue, alpha); +} + +void glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + getDispatch()->glColor4x(red, green, blue, alpha); +} + +void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + getDispatch()->glColorMask(red, green, blue, alpha); +} + +void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + getDispatch()->glColorPointer(size, type, stride, pointer); +} + +void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) +{ + getDispatch()->glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +} + +void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) +{ + getDispatch()->glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); +} + +void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + getDispatch()->glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); +} + +void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + getDispatch()->glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +} + +void glCullFace(GLenum mode) +{ + getDispatch()->glCullFace(mode); +} + +void glDeleteBuffers(GLsizei n, const GLuint *buffers) +{ + getDispatch()->glDeleteBuffers(n, buffers); +} + +void glDeleteTextures(GLsizei n, const GLuint *textures) +{ + getDispatch()->glDeleteTextures(n, textures); +} + +void glDepthFunc(GLenum func) +{ + getDispatch()->glDepthFunc(func); +} + +void glDepthMask(GLboolean flag) +{ + getDispatch()->glDepthMask(flag); +} + +void glDepthRangex(GLclampx zNear, GLclampx zFar) +{ + getDispatch()->glDepthRangex(zNear, zFar); +} + +void glDisable(GLenum cap) +{ + getDispatch()->glDisable(cap); +} + +void glDisableClientState(GLenum array) +{ + getDispatch()->glDisableClientState(array); +} + +void glDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + getDispatch()->glDrawArrays(mode, first, count); +} + +void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +{ + getDispatch()->glDrawElements(mode, count, type, indices); +} + +void glEnable(GLenum cap) +{ + getDispatch()->glEnable(cap); +} + +void glEnableClientState(GLenum array) +{ + getDispatch()->glEnableClientState(array); +} + +void glFinish() +{ + getDispatch()->glFinish(); +} + +void glFlush() +{ + getDispatch()->glFlush(); +} + +void glFogx(GLenum pname, GLfixed param) +{ + getDispatch()->glFogx(pname, param); +} + +void glFogxv(GLenum pname, const GLfixed *params) +{ + getDispatch()->glFogxv(pname, params); +} + +void glFrontFace(GLenum mode) +{ + getDispatch()->glFrontFace(mode); +} + +void glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + getDispatch()->glFrustumx(left, right, bottom, top, zNear, zFar); +} + +void glGetBooleanv(GLenum pname, GLboolean *params) +{ + getDispatch()->glGetBooleanv(pname, params); +} + +void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ + getDispatch()->glGetBufferParameteriv(target, pname, params); +} + +void glGetClipPlanex(GLenum pname, GLfixed eqn[4]) +{ + getDispatch()->glGetClipPlanex(pname, eqn); +} + +void glGenBuffers(GLsizei n, GLuint *buffers) +{ + getDispatch()->glGenBuffers(n, buffers); +} + +void glGenTextures(GLsizei n, GLuint *textures) +{ + getDispatch()->glGenTextures(n, textures); +} + +GLenum glGetError() +{ + return getDispatch()->glGetError(); +} + +void glGetFixedv(GLenum pname, GLfixed *params) +{ + getDispatch()->glGetFixedv(pname, params); +} + +void glGetIntegerv(GLenum pname, GLint *params) +{ + getDispatch()->glGetIntegerv(pname, params); +} + +void glGetLightxv(GLenum light, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetLightxv(light, pname, params); +} + +void glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetMaterialxv(face, pname, params); +} + +void glGetPointerv(GLenum pname, GLvoid **params) +{ + getDispatch()->glGetPointerv(pname, params); +} + +const GLubyte* glGetString(GLenum name) +{ + return getDispatch()->glGetString(name); +} + +void glGetTexEnviv(GLenum env, GLenum pname, GLint *params) +{ + getDispatch()->glGetTexEnviv(env, pname, params); +} + +void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetTexEnvxv(env, pname, params); +} + +void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ + getDispatch()->glGetTexParameteriv(target, pname, params); +} + +void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetTexParameterxv(target, pname, params); +} + +void glHint(GLenum target, GLenum mode) +{ + getDispatch()->glHint(target, mode); +} + +GLboolean glIsBuffer(GLuint buffer) +{ + return getDispatch()->glIsBuffer(buffer); +} + +GLboolean glIsEnabled(GLenum cap) +{ + return getDispatch()->glIsEnabled(cap); +} + +GLboolean glIsTexture(GLuint texture) +{ + return getDispatch()->glIsTexture(texture); +} + +void glLightModelx(GLenum pname, GLfixed param) +{ + getDispatch()->glLightModelx(pname, param); +} + +void glLightModelxv(GLenum pname, const GLfixed *params) +{ + getDispatch()->glLightModelxv(pname, params); +} + +void glLightx(GLenum light, GLenum pname, GLfixed param) +{ + getDispatch()->glLightx(light, pname, param); +} + +void glLightxv(GLenum light, GLenum pname, const GLfixed *params) +{ + getDispatch()->glLightxv(light, pname, params); +} + +void glLineWidthx(GLfixed width) +{ + getDispatch()->glLineWidthx(width); +} + +void glLoadIdentity() +{ + getDispatch()->glLoadIdentity(); +} + +void glLoadMatrixx(const GLfixed *m) +{ + getDispatch()->glLoadMatrixx(m); +} + +void glLogicOp(GLenum opcode) +{ + getDispatch()->glLogicOp(opcode); +} + +void glMaterialx(GLenum face, GLenum pname, GLfixed param) +{ + getDispatch()->glMaterialx(face, pname, param); +} + +void glMaterialxv(GLenum face, GLenum pname, const GLfixed *params) +{ + getDispatch()->glMaterialxv(face, pname, params); +} + +void glMatrixMode(GLenum mode) +{ + getDispatch()->glMatrixMode(mode); +} + +void glMultMatrixx(const GLfixed *m) +{ + getDispatch()->glMultMatrixx(m); +} + +void glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + getDispatch()->glMultiTexCoord4x(target, s, t, r, q); +} + +void glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz) +{ + getDispatch()->glNormal3x(nx, ny, nz); +} + +void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) +{ + getDispatch()->glNormalPointer(type, stride, pointer); +} + +void glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + getDispatch()->glOrthox(left, right, bottom, top, zNear, zFar); +} + +void glPixelStorei(GLenum pname, GLint param) +{ + getDispatch()->glPixelStorei(pname, param); +} + +void glPointParameterx(GLenum pname, GLfixed param) +{ + getDispatch()->glPointParameterx(pname, param); +} + +void glPointParameterxv(GLenum pname, const GLfixed *params) +{ + getDispatch()->glPointParameterxv(pname, params); +} + +void glPointSizex(GLfixed size) +{ + getDispatch()->glPointSizex(size); +} + +void glPolygonOffsetx(GLfixed factor, GLfixed units) +{ + getDispatch()->glPolygonOffsetx(factor, units); +} + +void glPopMatrix() +{ + getDispatch()->glPopMatrix(); +} + +void glPushMatrix() +{ + getDispatch()->glPushMatrix(); +} + +void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +{ + getDispatch()->glReadPixels(x, y, width, height, format, type, pixels); +} + +void glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + getDispatch()->glRotatex(angle, x, y, z); +} + +void glSampleCoverage(GLclampf value, GLboolean invert) +{ + getDispatch()->glSampleCoverage(value, invert); +} + +void glSampleCoveragex(GLclampx value, GLboolean invert) +{ + getDispatch()->glSampleCoveragex(value, invert); +} + +void glScalex(GLfixed x, GLfixed y, GLfixed z) +{ + getDispatch()->glScalex(x, y, z); +} + +void glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + getDispatch()->glScissor(x, y, width, height); +} + +void glShadeModel(GLenum mode) +{ + getDispatch()->glShadeModel(mode); +} + +void glStencilFunc(GLenum func, GLint ref, GLuint mask) +{ + getDispatch()->glStencilFunc(func, ref, mask); +} + +void glStencilMask(GLuint mask) +{ + getDispatch()->glStencilMask(mask); +} + +void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + getDispatch()->glStencilOp(fail, zfail, zpass); +} + +void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + getDispatch()->glTexCoordPointer(size, type, stride, pointer); +} + +void glTexEnvi(GLenum target, GLenum pname, GLint param) +{ + getDispatch()->glTexEnvi(target, pname, param); +} + +void glTexEnvx(GLenum target, GLenum pname, GLfixed param) +{ + getDispatch()->glTexEnvx(target, pname, param); +} + +void glTexEnviv(GLenum target, GLenum pname, const GLint *params) +{ + getDispatch()->glTexEnviv(target, pname, params); +} + +void glTexEnvxv(GLenum target, GLenum pname, const GLfixed *params) +{ + getDispatch()->glTexEnvxv(target, pname, params); +} + +void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +{ + getDispatch()->glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); +} + +void glTexParameteri(GLenum target, GLenum pname, GLint param) +{ + getDispatch()->glTexParameteri(target, pname, param); +} + +void glTexParameterx(GLenum target, GLenum pname, GLfixed param) +{ + getDispatch()->glTexParameterx(target, pname, param); +} + +void glTexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + getDispatch()->glTexParameteriv(target, pname, params); +} + +void glTexParameterxv(GLenum target, GLenum pname, const GLfixed *params) +{ + getDispatch()->glTexParameterxv(target, pname, params); +} + +void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +{ + getDispatch()->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); +} + +void glTranslatex(GLfixed x, GLfixed y, GLfixed z) +{ + getDispatch()->glTranslatex(x, y, z); +} + +void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + getDispatch()->glVertexPointer(size, type, stride, pointer); +} + +void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + getDispatch()->glViewport(x, y, width, height); +} + +void glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer) +{ + getDispatch()->glPointSizePointerOES(type, stride, pointer); +} + +void glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha) +{ + getDispatch()->glBlendEquationSeparateOES(modeRGB, modeAlpha); +} + +void glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + getDispatch()->glBlendFuncSeparateOES(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void glBlendEquationOES(GLenum mode) +{ + getDispatch()->glBlendEquationOES(mode); +} + +void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ + getDispatch()->glDrawTexsOES(x, y, z, width, height); +} + +void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + getDispatch()->glDrawTexiOES(x, y, z, width, height); +} + +void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ + getDispatch()->glDrawTexxOES(x, y, z, width, height); +} + +void glDrawTexsvOES(const GLshort *coords) +{ + getDispatch()->glDrawTexsvOES(coords); +} + +void glDrawTexivOES(const GLint *coords) +{ + getDispatch()->glDrawTexivOES(coords); +} + +void glDrawTexxvOES(const GLfixed *coords) +{ + getDispatch()->glDrawTexxvOES(coords); +} + +void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ + getDispatch()->glDrawTexfOES(x, y, z, width, height); +} + +void glDrawTexfvOES(const GLfloat *coords) +{ + getDispatch()->glDrawTexfvOES(coords); +} + +void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +{ + getDispatch()->glEGLImageTargetTexture2DOES(target, image); +} + +void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + getDispatch()->glEGLImageTargetRenderbufferStorageOES(target, image); +} + +void glAlphaFuncxOES(GLenum func, GLclampx ref) +{ + getDispatch()->glAlphaFuncxOES(func, ref); +} + +void glClearColorxOES(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + getDispatch()->glClearColorxOES(red, green, blue, alpha); +} + +void glClearDepthxOES(GLclampx depth) +{ + getDispatch()->glClearDepthxOES(depth); +} + +void glClipPlanexOES(GLenum plane, const GLfixed *equation) +{ + getDispatch()->glClipPlanexOES(plane, equation); +} + +void glColor4xOES(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + getDispatch()->glColor4xOES(red, green, blue, alpha); +} + +void glDepthRangexOES(GLclampx zNear, GLclampx zFar) +{ + getDispatch()->glDepthRangexOES(zNear, zFar); +} + +void glFogxOES(GLenum pname, GLfixed param) +{ + getDispatch()->glFogxOES(pname, param); +} + +void glFogxvOES(GLenum pname, const GLfixed *params) +{ + getDispatch()->glFogxvOES(pname, params); +} + +void glFrustumxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + getDispatch()->glFrustumxOES(left, right, bottom, top, zNear, zFar); +} + +void glGetClipPlanexOES(GLenum pname, GLfixed eqn[4]) +{ + getDispatch()->glGetClipPlanexOES(pname, eqn); +} + +void glGetFixedvOES(GLenum pname, GLfixed *params) +{ + getDispatch()->glGetFixedvOES(pname, params); +} + +void glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetLightxvOES(light, pname, params); +} + +void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetMaterialxvOES(face, pname, params); +} + +void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetTexEnvxvOES(env, pname, params); +} + +void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetTexParameterxvOES(target, pname, params); +} + +void glLightModelxOES(GLenum pname, GLfixed param) +{ + getDispatch()->glLightModelxOES(pname, param); +} + +void glLightModelxvOES(GLenum pname, const GLfixed *params) +{ + getDispatch()->glLightModelxvOES(pname, params); +} + +void glLightxOES(GLenum light, GLenum pname, GLfixed param) +{ + getDispatch()->glLightxOES(light, pname, param); +} + +void glLightxvOES(GLenum light, GLenum pname, const GLfixed *params) +{ + getDispatch()->glLightxvOES(light, pname, params); +} + +void glLineWidthxOES(GLfixed width) +{ + getDispatch()->glLineWidthxOES(width); +} + +void glLoadMatrixxOES(const GLfixed *m) +{ + getDispatch()->glLoadMatrixxOES(m); +} + +void glMaterialxOES(GLenum face, GLenum pname, GLfixed param) +{ + getDispatch()->glMaterialxOES(face, pname, param); +} + +void glMaterialxvOES(GLenum face, GLenum pname, const GLfixed *params) +{ + getDispatch()->glMaterialxvOES(face, pname, params); +} + +void glMultMatrixxOES(const GLfixed *m) +{ + getDispatch()->glMultMatrixxOES(m); +} + +void glMultiTexCoord4xOES(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + getDispatch()->glMultiTexCoord4xOES(target, s, t, r, q); +} + +void glNormal3xOES(GLfixed nx, GLfixed ny, GLfixed nz) +{ + getDispatch()->glNormal3xOES(nx, ny, nz); +} + +void glOrthoxOES(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + getDispatch()->glOrthoxOES(left, right, bottom, top, zNear, zFar); +} + +void glPointParameterxOES(GLenum pname, GLfixed param) +{ + getDispatch()->glPointParameterxOES(pname, param); +} + +void glPointParameterxvOES(GLenum pname, const GLfixed *params) +{ + getDispatch()->glPointParameterxvOES(pname, params); +} + +void glPointSizexOES(GLfixed size) +{ + getDispatch()->glPointSizexOES(size); +} + +void glPolygonOffsetxOES(GLfixed factor, GLfixed units) +{ + getDispatch()->glPolygonOffsetxOES(factor, units); +} + +void glRotatexOES(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + getDispatch()->glRotatexOES(angle, x, y, z); +} + +void glSampleCoveragexOES(GLclampx value, GLboolean invert) +{ + getDispatch()->glSampleCoveragexOES(value, invert); +} + +void glScalexOES(GLfixed x, GLfixed y, GLfixed z) +{ + getDispatch()->glScalexOES(x, y, z); +} + +void glTexEnvxOES(GLenum target, GLenum pname, GLfixed param) +{ + getDispatch()->glTexEnvxOES(target, pname, param); +} + +void glTexEnvxvOES(GLenum target, GLenum pname, const GLfixed *params) +{ + getDispatch()->glTexEnvxvOES(target, pname, params); +} + +void glTexParameterxOES(GLenum target, GLenum pname, GLfixed param) +{ + getDispatch()->glTexParameterxOES(target, pname, param); +} + +void glTexParameterxvOES(GLenum target, GLenum pname, const GLfixed *params) +{ + getDispatch()->glTexParameterxvOES(target, pname, params); +} + +void glTranslatexOES(GLfixed x, GLfixed y, GLfixed z) +{ + getDispatch()->glTranslatexOES(x, y, z); +} + +GLboolean glIsRenderbufferOES(GLuint renderbuffer) +{ + return getDispatch()->glIsRenderbufferOES(renderbuffer); +} + +void glBindRenderbufferOES(GLenum target, GLuint renderbuffer) +{ + getDispatch()->glBindRenderbufferOES(target, renderbuffer); +} + +void glDeleteRenderbuffersOES(GLsizei n, const GLuint *renderbuffers) +{ + getDispatch()->glDeleteRenderbuffersOES(n, renderbuffers); +} + +void glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers) +{ + getDispatch()->glGenRenderbuffersOES(n, renderbuffers); +} + +void glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + getDispatch()->glRenderbufferStorageOES(target, internalformat, width, height); +} + +void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint *params) +{ + getDispatch()->glGetRenderbufferParameterivOES(target, pname, params); +} + +GLboolean glIsFramebufferOES(GLuint framebuffer) +{ + return getDispatch()->glIsFramebufferOES(framebuffer); +} + +void glBindFramebufferOES(GLenum target, GLuint framebuffer) +{ + getDispatch()->glBindFramebufferOES(target, framebuffer); +} + +void glDeleteFramebuffersOES(GLsizei n, const GLuint *framebuffers) +{ + getDispatch()->glDeleteFramebuffersOES(n, framebuffers); +} + +void glGenFramebuffersOES(GLsizei n, GLuint *framebuffers) +{ + getDispatch()->glGenFramebuffersOES(n, framebuffers); +} + +GLenum glCheckFramebufferStatusOES(GLenum target) +{ + return getDispatch()->glCheckFramebufferStatusOES(target); +} + +void glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + getDispatch()->glFramebufferRenderbufferOES(target, attachment, renderbuffertarget, renderbuffer); +} + +void glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + getDispatch()->glFramebufferTexture2DOES(target, attachment, textarget, texture, level); +} + +void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params) +{ + getDispatch()->glGetFramebufferAttachmentParameterivOES(target, attachment, pname, params); +} + +void glGenerateMipmapOES(GLenum target) +{ + getDispatch()->glGenerateMipmapOES(target); +} + +void* glMapBufferOES(GLenum target, GLenum access) +{ + return getDispatch()->glMapBufferOES(target, access); +} + +GLboolean glUnmapBufferOES(GLenum target) +{ + return getDispatch()->glUnmapBufferOES(target); +} + +void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid **ptr) +{ + getDispatch()->glGetBufferPointervOES(target, pname, ptr); +} + +void glCurrentPaletteMatrixOES(GLuint matrixpaletteindex) +{ + getDispatch()->glCurrentPaletteMatrixOES(matrixpaletteindex); +} + +void glLoadPaletteFromModelViewMatrixOES() +{ + getDispatch()->glLoadPaletteFromModelViewMatrixOES(); +} + +void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + getDispatch()->glMatrixIndexPointerOES(size, type, stride, pointer); +} + +void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + getDispatch()->glWeightPointerOES(size, type, stride, pointer); +} + +GLbitfield glQueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) +{ + return getDispatch()->glQueryMatrixxOES(mantissa, exponent); +} + +void glDepthRangefOES(GLclampf zNear, GLclampf zFar) +{ + getDispatch()->glDepthRangefOES(zNear, zFar); +} + +void glFrustumfOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + getDispatch()->glFrustumfOES(left, right, bottom, top, zNear, zFar); +} + +void glOrthofOES(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + getDispatch()->glOrthofOES(left, right, bottom, top, zNear, zFar); +} + +void glClipPlanefOES(GLenum plane, const GLfloat *equation) +{ + getDispatch()->glClipPlanefOES(plane, equation); +} + +void glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]) +{ + getDispatch()->glGetClipPlanefOES(pname, eqn); +} + +void glClearDepthfOES(GLclampf depth) +{ + getDispatch()->glClearDepthfOES(depth); +} + +void glTexGenfOES(GLenum coord, GLenum pname, GLfloat param) +{ + getDispatch()->glTexGenfOES(coord, pname, param); +} + +void glTexGenfvOES(GLenum coord, GLenum pname, const GLfloat *params) +{ + getDispatch()->glTexGenfvOES(coord, pname, params); +} + +void glTexGeniOES(GLenum coord, GLenum pname, GLint param) +{ + getDispatch()->glTexGeniOES(coord, pname, param); +} + +void glTexGenivOES(GLenum coord, GLenum pname, const GLint *params) +{ + getDispatch()->glTexGenivOES(coord, pname, params); +} + +void glTexGenxOES(GLenum coord, GLenum pname, GLfixed param) +{ + getDispatch()->glTexGenxOES(coord, pname, param); +} + +void glTexGenxvOES(GLenum coord, GLenum pname, const GLfixed *params) +{ + getDispatch()->glTexGenxvOES(coord, pname, params); +} + +void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params) +{ + getDispatch()->glGetTexGenfvOES(coord, pname, params); +} + +void glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params) +{ + getDispatch()->glGetTexGenivOES(coord, pname, params); +} + +void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params) +{ + getDispatch()->glGetTexGenxvOES(coord, pname, params); +} + +void glBindVertexArrayOES(GLuint array) +{ + getDispatch()->glBindVertexArrayOES(array); +} + +void glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays) +{ + getDispatch()->glDeleteVertexArraysOES(n, arrays); +} + +void glGenVertexArraysOES(GLsizei n, GLuint *arrays) +{ + getDispatch()->glGenVertexArraysOES(n, arrays); +} + +GLboolean glIsVertexArrayOES(GLuint array) +{ + return getDispatch()->glIsVertexArrayOES(array); +} + +void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments) +{ + getDispatch()->glDiscardFramebufferEXT(target, numAttachments, attachments); +} + +void glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) +{ + getDispatch()->glMultiDrawArraysEXT(mode, first, count, primcount); +} + +void glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount) +{ + getDispatch()->glMultiDrawElementsEXT(mode, count, type, indices, primcount); +} + +void glClipPlanefIMG(GLenum p, const GLfloat *eqn) +{ + getDispatch()->glClipPlanefIMG(p, eqn); +} + +void glClipPlanexIMG(GLenum p, const GLfixed *eqn) +{ + getDispatch()->glClipPlanexIMG(p, eqn); +} + +void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +{ + getDispatch()->glRenderbufferStorageMultisampleIMG(target, samples, internalformat, width, height); +} + +void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +{ + getDispatch()->glFramebufferTexture2DMultisampleIMG(target, attachment, textarget, texture, level, samples); +} + +void glDeleteFencesNV(GLsizei n, const GLuint *fences) +{ + getDispatch()->glDeleteFencesNV(n, fences); +} + +void glGenFencesNV(GLsizei n, GLuint *fences) +{ + getDispatch()->glGenFencesNV(n, fences); +} + +GLboolean glIsFenceNV(GLuint fence) +{ + return getDispatch()->glIsFenceNV(fence); +} + +GLboolean glTestFenceNV(GLuint fence) +{ + return getDispatch()->glTestFenceNV(fence); +} + +void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) +{ + getDispatch()->glGetFenceivNV(fence, pname, params); +} + +void glFinishFenceNV(GLuint fence) +{ + getDispatch()->glFinishFenceNV(fence); +} + +void glSetFenceNV(GLuint fence, GLenum condition) +{ + getDispatch()->glSetFenceNV(fence, condition); +} + +void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls) +{ + getDispatch()->glGetDriverControlsQCOM(num, size, driverControls); +} + +void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) +{ + getDispatch()->glGetDriverControlStringQCOM(driverControl, bufSize, length, driverControlString); +} + +void glEnableDriverControlQCOM(GLuint driverControl) +{ + getDispatch()->glEnableDriverControlQCOM(driverControl); +} + +void glDisableDriverControlQCOM(GLuint driverControl) +{ + getDispatch()->glDisableDriverControlQCOM(driverControl); +} + +void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures) +{ + getDispatch()->glExtGetTexturesQCOM(textures, maxTextures, numTextures); +} + +void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) +{ + getDispatch()->glExtGetBuffersQCOM(buffers, maxBuffers, numBuffers); +} + +void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) +{ + getDispatch()->glExtGetRenderbuffersQCOM(renderbuffers, maxRenderbuffers, numRenderbuffers); +} + +void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) +{ + getDispatch()->glExtGetFramebuffersQCOM(framebuffers, maxFramebuffers, numFramebuffers); +} + +void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) +{ + getDispatch()->glExtGetTexLevelParameterivQCOM(texture, face, level, pname, params); +} + +void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param) +{ + getDispatch()->glExtTexObjectStateOverrideiQCOM(target, pname, param); +} + +void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) +{ + getDispatch()->glExtGetTexSubImageQCOM(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, texels); +} + +void glExtGetBufferPointervQCOM(GLenum target, GLvoid **params) +{ + getDispatch()->glExtGetBufferPointervQCOM(target, params); +} + +void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders) +{ + getDispatch()->glExtGetShadersQCOM(shaders, maxShaders, numShaders); +} + +void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms) +{ + getDispatch()->glExtGetProgramsQCOM(programs, maxPrograms, numPrograms); +} + +GLboolean glExtIsProgramBinaryQCOM(GLuint program) +{ + return getDispatch()->glExtIsProgramBinaryQCOM(program); +} + +void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length) +{ + getDispatch()->glExtGetProgramBinarySourceQCOM(program, shadertype, source, length); +} + +void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) +{ + getDispatch()->glStartTilingQCOM(x, y, width, height, preserveMask); +} + +void glEndTilingQCOM(GLbitfield preserveMask) +{ + getDispatch()->glEndTilingQCOM(preserveMask); +} + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.cpp new file mode 100644 index 0000000..0a17624 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.cpp @@ -0,0 +1,298 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "gles_dispatch.h" +#include +#include + +gles_dispatch *create_gles_dispatch(void *gles_android) +{ + gles_dispatch *disp = new gles_dispatch; + + void *ptr; + ptr = dlsym(gles_android,"glAlphaFunc"); disp->set_glAlphaFunc((glAlphaFunc_t)ptr); + ptr = dlsym(gles_android,"glClearColor"); disp->set_glClearColor((glClearColor_t)ptr); + ptr = dlsym(gles_android,"glClearDepthf"); disp->set_glClearDepthf((glClearDepthf_t)ptr); + ptr = dlsym(gles_android,"glClipPlanef"); disp->set_glClipPlanef((glClipPlanef_t)ptr); + ptr = dlsym(gles_android,"glColor4f"); disp->set_glColor4f((glColor4f_t)ptr); + ptr = dlsym(gles_android,"glDepthRangef"); disp->set_glDepthRangef((glDepthRangef_t)ptr); + ptr = dlsym(gles_android,"glFogf"); disp->set_glFogf((glFogf_t)ptr); + ptr = dlsym(gles_android,"glFogfv"); disp->set_glFogfv((glFogfv_t)ptr); + ptr = dlsym(gles_android,"glFrustumf"); disp->set_glFrustumf((glFrustumf_t)ptr); + ptr = dlsym(gles_android,"glGetClipPlanef"); disp->set_glGetClipPlanef((glGetClipPlanef_t)ptr); + ptr = dlsym(gles_android,"glGetFloatv"); disp->set_glGetFloatv((glGetFloatv_t)ptr); + ptr = dlsym(gles_android,"glGetLightfv"); disp->set_glGetLightfv((glGetLightfv_t)ptr); + ptr = dlsym(gles_android,"glGetMaterialfv"); disp->set_glGetMaterialfv((glGetMaterialfv_t)ptr); + ptr = dlsym(gles_android,"glGetTexEnvfv"); disp->set_glGetTexEnvfv((glGetTexEnvfv_t)ptr); + ptr = dlsym(gles_android,"glGetTexParameterfv"); disp->set_glGetTexParameterfv((glGetTexParameterfv_t)ptr); + ptr = dlsym(gles_android,"glLightModelf"); disp->set_glLightModelf((glLightModelf_t)ptr); + ptr = dlsym(gles_android,"glLightModelfv"); disp->set_glLightModelfv((glLightModelfv_t)ptr); + ptr = dlsym(gles_android,"glLightf"); disp->set_glLightf((glLightf_t)ptr); + ptr = dlsym(gles_android,"glLightfv"); disp->set_glLightfv((glLightfv_t)ptr); + ptr = dlsym(gles_android,"glLineWidth"); disp->set_glLineWidth((glLineWidth_t)ptr); + ptr = dlsym(gles_android,"glLoadMatrixf"); disp->set_glLoadMatrixf((glLoadMatrixf_t)ptr); + ptr = dlsym(gles_android,"glMaterialf"); disp->set_glMaterialf((glMaterialf_t)ptr); + ptr = dlsym(gles_android,"glMaterialfv"); disp->set_glMaterialfv((glMaterialfv_t)ptr); + ptr = dlsym(gles_android,"glMultMatrixf"); disp->set_glMultMatrixf((glMultMatrixf_t)ptr); + ptr = dlsym(gles_android,"glMultiTexCoord4f"); disp->set_glMultiTexCoord4f((glMultiTexCoord4f_t)ptr); + ptr = dlsym(gles_android,"glNormal3f"); disp->set_glNormal3f((glNormal3f_t)ptr); + ptr = dlsym(gles_android,"glOrthof"); disp->set_glOrthof((glOrthof_t)ptr); + ptr = dlsym(gles_android,"glPointParameterf"); disp->set_glPointParameterf((glPointParameterf_t)ptr); + ptr = dlsym(gles_android,"glPointParameterfv"); disp->set_glPointParameterfv((glPointParameterfv_t)ptr); + ptr = dlsym(gles_android,"glPointSize"); disp->set_glPointSize((glPointSize_t)ptr); + ptr = dlsym(gles_android,"glPolygonOffset"); disp->set_glPolygonOffset((glPolygonOffset_t)ptr); + ptr = dlsym(gles_android,"glRotatef"); disp->set_glRotatef((glRotatef_t)ptr); + ptr = dlsym(gles_android,"glScalef"); disp->set_glScalef((glScalef_t)ptr); + ptr = dlsym(gles_android,"glTexEnvf"); disp->set_glTexEnvf((glTexEnvf_t)ptr); + ptr = dlsym(gles_android,"glTexEnvfv"); disp->set_glTexEnvfv((glTexEnvfv_t)ptr); + ptr = dlsym(gles_android,"glTexParameterf"); disp->set_glTexParameterf((glTexParameterf_t)ptr); + ptr = dlsym(gles_android,"glTexParameterfv"); disp->set_glTexParameterfv((glTexParameterfv_t)ptr); + ptr = dlsym(gles_android,"glTranslatef"); disp->set_glTranslatef((glTranslatef_t)ptr); + ptr = dlsym(gles_android,"glActiveTexture"); disp->set_glActiveTexture((glActiveTexture_t)ptr); + ptr = dlsym(gles_android,"glAlphaFuncx"); disp->set_glAlphaFuncx((glAlphaFuncx_t)ptr); + ptr = dlsym(gles_android,"glBindBuffer"); disp->set_glBindBuffer((glBindBuffer_t)ptr); + ptr = dlsym(gles_android,"glBindTexture"); disp->set_glBindTexture((glBindTexture_t)ptr); + ptr = dlsym(gles_android,"glBlendFunc"); disp->set_glBlendFunc((glBlendFunc_t)ptr); + ptr = dlsym(gles_android,"glBufferData"); disp->set_glBufferData((glBufferData_t)ptr); + ptr = dlsym(gles_android,"glBufferSubData"); disp->set_glBufferSubData((glBufferSubData_t)ptr); + ptr = dlsym(gles_android,"glClear"); disp->set_glClear((glClear_t)ptr); + ptr = dlsym(gles_android,"glClearColorx"); disp->set_glClearColorx((glClearColorx_t)ptr); + ptr = dlsym(gles_android,"glClearDepthx"); disp->set_glClearDepthx((glClearDepthx_t)ptr); + ptr = dlsym(gles_android,"glClearStencil"); disp->set_glClearStencil((glClearStencil_t)ptr); + ptr = dlsym(gles_android,"glClientActiveTexture"); disp->set_glClientActiveTexture((glClientActiveTexture_t)ptr); + ptr = dlsym(gles_android,"glClipPlanex"); disp->set_glClipPlanex((glClipPlanex_t)ptr); + ptr = dlsym(gles_android,"glColor4ub"); disp->set_glColor4ub((glColor4ub_t)ptr); + ptr = dlsym(gles_android,"glColor4x"); disp->set_glColor4x((glColor4x_t)ptr); + ptr = dlsym(gles_android,"glColorMask"); disp->set_glColorMask((glColorMask_t)ptr); + ptr = dlsym(gles_android,"glColorPointer"); disp->set_glColorPointer((glColorPointer_t)ptr); + ptr = dlsym(gles_android,"glCompressedTexImage2D"); disp->set_glCompressedTexImage2D((glCompressedTexImage2D_t)ptr); + ptr = dlsym(gles_android,"glCompressedTexSubImage2D"); disp->set_glCompressedTexSubImage2D((glCompressedTexSubImage2D_t)ptr); + ptr = dlsym(gles_android,"glCopyTexImage2D"); disp->set_glCopyTexImage2D((glCopyTexImage2D_t)ptr); + ptr = dlsym(gles_android,"glCopyTexSubImage2D"); disp->set_glCopyTexSubImage2D((glCopyTexSubImage2D_t)ptr); + ptr = dlsym(gles_android,"glCullFace"); disp->set_glCullFace((glCullFace_t)ptr); + ptr = dlsym(gles_android,"glDeleteBuffers"); disp->set_glDeleteBuffers((glDeleteBuffers_t)ptr); + ptr = dlsym(gles_android,"glDeleteTextures"); disp->set_glDeleteTextures((glDeleteTextures_t)ptr); + ptr = dlsym(gles_android,"glDepthFunc"); disp->set_glDepthFunc((glDepthFunc_t)ptr); + ptr = dlsym(gles_android,"glDepthMask"); disp->set_glDepthMask((glDepthMask_t)ptr); + ptr = dlsym(gles_android,"glDepthRangex"); disp->set_glDepthRangex((glDepthRangex_t)ptr); + ptr = dlsym(gles_android,"glDisable"); disp->set_glDisable((glDisable_t)ptr); + ptr = dlsym(gles_android,"glDisableClientState"); disp->set_glDisableClientState((glDisableClientState_t)ptr); + ptr = dlsym(gles_android,"glDrawArrays"); disp->set_glDrawArrays((glDrawArrays_t)ptr); + ptr = dlsym(gles_android,"glDrawElements"); disp->set_glDrawElements((glDrawElements_t)ptr); + ptr = dlsym(gles_android,"glEnable"); disp->set_glEnable((glEnable_t)ptr); + ptr = dlsym(gles_android,"glEnableClientState"); disp->set_glEnableClientState((glEnableClientState_t)ptr); + ptr = dlsym(gles_android,"glFinish"); disp->set_glFinish((glFinish_t)ptr); + ptr = dlsym(gles_android,"glFlush"); disp->set_glFlush((glFlush_t)ptr); + ptr = dlsym(gles_android,"glFogx"); disp->set_glFogx((glFogx_t)ptr); + ptr = dlsym(gles_android,"glFogxv"); disp->set_glFogxv((glFogxv_t)ptr); + ptr = dlsym(gles_android,"glFrontFace"); disp->set_glFrontFace((glFrontFace_t)ptr); + ptr = dlsym(gles_android,"glFrustumx"); disp->set_glFrustumx((glFrustumx_t)ptr); + ptr = dlsym(gles_android,"glGetBooleanv"); disp->set_glGetBooleanv((glGetBooleanv_t)ptr); + ptr = dlsym(gles_android,"glGetBufferParameteriv"); disp->set_glGetBufferParameteriv((glGetBufferParameteriv_t)ptr); + ptr = dlsym(gles_android,"glGetClipPlanex"); disp->set_glGetClipPlanex((glGetClipPlanex_t)ptr); + ptr = dlsym(gles_android,"glGenBuffers"); disp->set_glGenBuffers((glGenBuffers_t)ptr); + ptr = dlsym(gles_android,"glGenTextures"); disp->set_glGenTextures((glGenTextures_t)ptr); + ptr = dlsym(gles_android,"glGetError"); disp->set_glGetError((glGetError_t)ptr); + ptr = dlsym(gles_android,"glGetFixedv"); disp->set_glGetFixedv((glGetFixedv_t)ptr); + ptr = dlsym(gles_android,"glGetIntegerv"); disp->set_glGetIntegerv((glGetIntegerv_t)ptr); + ptr = dlsym(gles_android,"glGetLightxv"); disp->set_glGetLightxv((glGetLightxv_t)ptr); + ptr = dlsym(gles_android,"glGetMaterialxv"); disp->set_glGetMaterialxv((glGetMaterialxv_t)ptr); + ptr = dlsym(gles_android,"glGetPointerv"); disp->set_glGetPointerv((glGetPointerv_t)ptr); + ptr = dlsym(gles_android,"glGetString"); disp->set_glGetString((glGetString_t)ptr); + ptr = dlsym(gles_android,"glGetTexEnviv"); disp->set_glGetTexEnviv((glGetTexEnviv_t)ptr); + ptr = dlsym(gles_android,"glGetTexEnvxv"); disp->set_glGetTexEnvxv((glGetTexEnvxv_t)ptr); + ptr = dlsym(gles_android,"glGetTexParameteriv"); disp->set_glGetTexParameteriv((glGetTexParameteriv_t)ptr); + ptr = dlsym(gles_android,"glGetTexParameterxv"); disp->set_glGetTexParameterxv((glGetTexParameterxv_t)ptr); + ptr = dlsym(gles_android,"glHint"); disp->set_glHint((glHint_t)ptr); + ptr = dlsym(gles_android,"glIsBuffer"); disp->set_glIsBuffer((glIsBuffer_t)ptr); + ptr = dlsym(gles_android,"glIsEnabled"); disp->set_glIsEnabled((glIsEnabled_t)ptr); + ptr = dlsym(gles_android,"glIsTexture"); disp->set_glIsTexture((glIsTexture_t)ptr); + ptr = dlsym(gles_android,"glLightModelx"); disp->set_glLightModelx((glLightModelx_t)ptr); + ptr = dlsym(gles_android,"glLightModelxv"); disp->set_glLightModelxv((glLightModelxv_t)ptr); + ptr = dlsym(gles_android,"glLightx"); disp->set_glLightx((glLightx_t)ptr); + ptr = dlsym(gles_android,"glLightxv"); disp->set_glLightxv((glLightxv_t)ptr); + ptr = dlsym(gles_android,"glLineWidthx"); disp->set_glLineWidthx((glLineWidthx_t)ptr); + ptr = dlsym(gles_android,"glLoadIdentity"); disp->set_glLoadIdentity((glLoadIdentity_t)ptr); + ptr = dlsym(gles_android,"glLoadMatrixx"); disp->set_glLoadMatrixx((glLoadMatrixx_t)ptr); + ptr = dlsym(gles_android,"glLogicOp"); disp->set_glLogicOp((glLogicOp_t)ptr); + ptr = dlsym(gles_android,"glMaterialx"); disp->set_glMaterialx((glMaterialx_t)ptr); + ptr = dlsym(gles_android,"glMaterialxv"); disp->set_glMaterialxv((glMaterialxv_t)ptr); + ptr = dlsym(gles_android,"glMatrixMode"); disp->set_glMatrixMode((glMatrixMode_t)ptr); + ptr = dlsym(gles_android,"glMultMatrixx"); disp->set_glMultMatrixx((glMultMatrixx_t)ptr); + ptr = dlsym(gles_android,"glMultiTexCoord4x"); disp->set_glMultiTexCoord4x((glMultiTexCoord4x_t)ptr); + ptr = dlsym(gles_android,"glNormal3x"); disp->set_glNormal3x((glNormal3x_t)ptr); + ptr = dlsym(gles_android,"glNormalPointer"); disp->set_glNormalPointer((glNormalPointer_t)ptr); + ptr = dlsym(gles_android,"glOrthox"); disp->set_glOrthox((glOrthox_t)ptr); + ptr = dlsym(gles_android,"glPixelStorei"); disp->set_glPixelStorei((glPixelStorei_t)ptr); + ptr = dlsym(gles_android,"glPointParameterx"); disp->set_glPointParameterx((glPointParameterx_t)ptr); + ptr = dlsym(gles_android,"glPointParameterxv"); disp->set_glPointParameterxv((glPointParameterxv_t)ptr); + ptr = dlsym(gles_android,"glPointSizex"); disp->set_glPointSizex((glPointSizex_t)ptr); + ptr = dlsym(gles_android,"glPolygonOffsetx"); disp->set_glPolygonOffsetx((glPolygonOffsetx_t)ptr); + ptr = dlsym(gles_android,"glPopMatrix"); disp->set_glPopMatrix((glPopMatrix_t)ptr); + ptr = dlsym(gles_android,"glPushMatrix"); disp->set_glPushMatrix((glPushMatrix_t)ptr); + ptr = dlsym(gles_android,"glReadPixels"); disp->set_glReadPixels((glReadPixels_t)ptr); + ptr = dlsym(gles_android,"glRotatex"); disp->set_glRotatex((glRotatex_t)ptr); + ptr = dlsym(gles_android,"glSampleCoverage"); disp->set_glSampleCoverage((glSampleCoverage_t)ptr); + ptr = dlsym(gles_android,"glSampleCoveragex"); disp->set_glSampleCoveragex((glSampleCoveragex_t)ptr); + ptr = dlsym(gles_android,"glScalex"); disp->set_glScalex((glScalex_t)ptr); + ptr = dlsym(gles_android,"glScissor"); disp->set_glScissor((glScissor_t)ptr); + ptr = dlsym(gles_android,"glShadeModel"); disp->set_glShadeModel((glShadeModel_t)ptr); + ptr = dlsym(gles_android,"glStencilFunc"); disp->set_glStencilFunc((glStencilFunc_t)ptr); + ptr = dlsym(gles_android,"glStencilMask"); disp->set_glStencilMask((glStencilMask_t)ptr); + ptr = dlsym(gles_android,"glStencilOp"); disp->set_glStencilOp((glStencilOp_t)ptr); + ptr = dlsym(gles_android,"glTexCoordPointer"); disp->set_glTexCoordPointer((glTexCoordPointer_t)ptr); + ptr = dlsym(gles_android,"glTexEnvi"); disp->set_glTexEnvi((glTexEnvi_t)ptr); + ptr = dlsym(gles_android,"glTexEnvx"); disp->set_glTexEnvx((glTexEnvx_t)ptr); + ptr = dlsym(gles_android,"glTexEnviv"); disp->set_glTexEnviv((glTexEnviv_t)ptr); + ptr = dlsym(gles_android,"glTexEnvxv"); disp->set_glTexEnvxv((glTexEnvxv_t)ptr); + ptr = dlsym(gles_android,"glTexImage2D"); disp->set_glTexImage2D((glTexImage2D_t)ptr); + ptr = dlsym(gles_android,"glTexParameteri"); disp->set_glTexParameteri((glTexParameteri_t)ptr); + ptr = dlsym(gles_android,"glTexParameterx"); disp->set_glTexParameterx((glTexParameterx_t)ptr); + ptr = dlsym(gles_android,"glTexParameteriv"); disp->set_glTexParameteriv((glTexParameteriv_t)ptr); + ptr = dlsym(gles_android,"glTexParameterxv"); disp->set_glTexParameterxv((glTexParameterxv_t)ptr); + ptr = dlsym(gles_android,"glTexSubImage2D"); disp->set_glTexSubImage2D((glTexSubImage2D_t)ptr); + ptr = dlsym(gles_android,"glTranslatex"); disp->set_glTranslatex((glTranslatex_t)ptr); + ptr = dlsym(gles_android,"glVertexPointer"); disp->set_glVertexPointer((glVertexPointer_t)ptr); + ptr = dlsym(gles_android,"glViewport"); disp->set_glViewport((glViewport_t)ptr); + ptr = dlsym(gles_android,"glPointSizePointerOES"); disp->set_glPointSizePointerOES((glPointSizePointerOES_t)ptr); + ptr = dlsym(gles_android,"glBlendEquationSeparateOES"); disp->set_glBlendEquationSeparateOES((glBlendEquationSeparateOES_t)ptr); + ptr = dlsym(gles_android,"glBlendFuncSeparateOES"); disp->set_glBlendFuncSeparateOES((glBlendFuncSeparateOES_t)ptr); + ptr = dlsym(gles_android,"glBlendEquationOES"); disp->set_glBlendEquationOES((glBlendEquationOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexsOES"); disp->set_glDrawTexsOES((glDrawTexsOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexiOES"); disp->set_glDrawTexiOES((glDrawTexiOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexxOES"); disp->set_glDrawTexxOES((glDrawTexxOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexsvOES"); disp->set_glDrawTexsvOES((glDrawTexsvOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexivOES"); disp->set_glDrawTexivOES((glDrawTexivOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexxvOES"); disp->set_glDrawTexxvOES((glDrawTexxvOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexfOES"); disp->set_glDrawTexfOES((glDrawTexfOES_t)ptr); + ptr = dlsym(gles_android,"glDrawTexfvOES"); disp->set_glDrawTexfvOES((glDrawTexfvOES_t)ptr); + ptr = dlsym(gles_android,"glEGLImageTargetTexture2DOES"); disp->set_glEGLImageTargetTexture2DOES((glEGLImageTargetTexture2DOES_t)ptr); + ptr = dlsym(gles_android,"glEGLImageTargetRenderbufferStorageOES"); disp->set_glEGLImageTargetRenderbufferStorageOES((glEGLImageTargetRenderbufferStorageOES_t)ptr); + ptr = dlsym(gles_android,"glAlphaFuncxOES"); disp->set_glAlphaFuncxOES((glAlphaFuncxOES_t)ptr); + ptr = dlsym(gles_android,"glClearColorxOES"); disp->set_glClearColorxOES((glClearColorxOES_t)ptr); + ptr = dlsym(gles_android,"glClearDepthxOES"); disp->set_glClearDepthxOES((glClearDepthxOES_t)ptr); + ptr = dlsym(gles_android,"glClipPlanexOES"); disp->set_glClipPlanexOES((glClipPlanexOES_t)ptr); + ptr = dlsym(gles_android,"glColor4xOES"); disp->set_glColor4xOES((glColor4xOES_t)ptr); + ptr = dlsym(gles_android,"glDepthRangexOES"); disp->set_glDepthRangexOES((glDepthRangexOES_t)ptr); + ptr = dlsym(gles_android,"glFogxOES"); disp->set_glFogxOES((glFogxOES_t)ptr); + ptr = dlsym(gles_android,"glFogxvOES"); disp->set_glFogxvOES((glFogxvOES_t)ptr); + ptr = dlsym(gles_android,"glFrustumxOES"); disp->set_glFrustumxOES((glFrustumxOES_t)ptr); + ptr = dlsym(gles_android,"glGetClipPlanexOES"); disp->set_glGetClipPlanexOES((glGetClipPlanexOES_t)ptr); + ptr = dlsym(gles_android,"glGetFixedvOES"); disp->set_glGetFixedvOES((glGetFixedvOES_t)ptr); + ptr = dlsym(gles_android,"glGetLightxvOES"); disp->set_glGetLightxvOES((glGetLightxvOES_t)ptr); + ptr = dlsym(gles_android,"glGetMaterialxvOES"); disp->set_glGetMaterialxvOES((glGetMaterialxvOES_t)ptr); + ptr = dlsym(gles_android,"glGetTexEnvxvOES"); disp->set_glGetTexEnvxvOES((glGetTexEnvxvOES_t)ptr); + ptr = dlsym(gles_android,"glGetTexParameterxvOES"); disp->set_glGetTexParameterxvOES((glGetTexParameterxvOES_t)ptr); + ptr = dlsym(gles_android,"glLightModelxOES"); disp->set_glLightModelxOES((glLightModelxOES_t)ptr); + ptr = dlsym(gles_android,"glLightModelxvOES"); disp->set_glLightModelxvOES((glLightModelxvOES_t)ptr); + ptr = dlsym(gles_android,"glLightxOES"); disp->set_glLightxOES((glLightxOES_t)ptr); + ptr = dlsym(gles_android,"glLightxvOES"); disp->set_glLightxvOES((glLightxvOES_t)ptr); + ptr = dlsym(gles_android,"glLineWidthxOES"); disp->set_glLineWidthxOES((glLineWidthxOES_t)ptr); + ptr = dlsym(gles_android,"glLoadMatrixxOES"); disp->set_glLoadMatrixxOES((glLoadMatrixxOES_t)ptr); + ptr = dlsym(gles_android,"glMaterialxOES"); disp->set_glMaterialxOES((glMaterialxOES_t)ptr); + ptr = dlsym(gles_android,"glMaterialxvOES"); disp->set_glMaterialxvOES((glMaterialxvOES_t)ptr); + ptr = dlsym(gles_android,"glMultMatrixxOES"); disp->set_glMultMatrixxOES((glMultMatrixxOES_t)ptr); + ptr = dlsym(gles_android,"glMultiTexCoord4xOES"); disp->set_glMultiTexCoord4xOES((glMultiTexCoord4xOES_t)ptr); + ptr = dlsym(gles_android,"glNormal3xOES"); disp->set_glNormal3xOES((glNormal3xOES_t)ptr); + ptr = dlsym(gles_android,"glOrthoxOES"); disp->set_glOrthoxOES((glOrthoxOES_t)ptr); + ptr = dlsym(gles_android,"glPointParameterxOES"); disp->set_glPointParameterxOES((glPointParameterxOES_t)ptr); + ptr = dlsym(gles_android,"glPointParameterxvOES"); disp->set_glPointParameterxvOES((glPointParameterxvOES_t)ptr); + ptr = dlsym(gles_android,"glPointSizexOES"); disp->set_glPointSizexOES((glPointSizexOES_t)ptr); + ptr = dlsym(gles_android,"glPolygonOffsetxOES"); disp->set_glPolygonOffsetxOES((glPolygonOffsetxOES_t)ptr); + ptr = dlsym(gles_android,"glRotatexOES"); disp->set_glRotatexOES((glRotatexOES_t)ptr); + ptr = dlsym(gles_android,"glSampleCoveragexOES"); disp->set_glSampleCoveragexOES((glSampleCoveragexOES_t)ptr); + ptr = dlsym(gles_android,"glScalexOES"); disp->set_glScalexOES((glScalexOES_t)ptr); + ptr = dlsym(gles_android,"glTexEnvxOES"); disp->set_glTexEnvxOES((glTexEnvxOES_t)ptr); + ptr = dlsym(gles_android,"glTexEnvxvOES"); disp->set_glTexEnvxvOES((glTexEnvxvOES_t)ptr); + ptr = dlsym(gles_android,"glTexParameterxOES"); disp->set_glTexParameterxOES((glTexParameterxOES_t)ptr); + ptr = dlsym(gles_android,"glTexParameterxvOES"); disp->set_glTexParameterxvOES((glTexParameterxvOES_t)ptr); + ptr = dlsym(gles_android,"glTranslatexOES"); disp->set_glTranslatexOES((glTranslatexOES_t)ptr); + ptr = dlsym(gles_android,"glIsRenderbufferOES"); disp->set_glIsRenderbufferOES((glIsRenderbufferOES_t)ptr); + ptr = dlsym(gles_android,"glBindRenderbufferOES"); disp->set_glBindRenderbufferOES((glBindRenderbufferOES_t)ptr); + ptr = dlsym(gles_android,"glDeleteRenderbuffersOES"); disp->set_glDeleteRenderbuffersOES((glDeleteRenderbuffersOES_t)ptr); + ptr = dlsym(gles_android,"glGenRenderbuffersOES"); disp->set_glGenRenderbuffersOES((glGenRenderbuffersOES_t)ptr); + ptr = dlsym(gles_android,"glRenderbufferStorageOES"); disp->set_glRenderbufferStorageOES((glRenderbufferStorageOES_t)ptr); + ptr = dlsym(gles_android,"glGetRenderbufferParameterivOES"); disp->set_glGetRenderbufferParameterivOES((glGetRenderbufferParameterivOES_t)ptr); + ptr = dlsym(gles_android,"glIsFramebufferOES"); disp->set_glIsFramebufferOES((glIsFramebufferOES_t)ptr); + ptr = dlsym(gles_android,"glBindFramebufferOES"); disp->set_glBindFramebufferOES((glBindFramebufferOES_t)ptr); + ptr = dlsym(gles_android,"glDeleteFramebuffersOES"); disp->set_glDeleteFramebuffersOES((glDeleteFramebuffersOES_t)ptr); + ptr = dlsym(gles_android,"glGenFramebuffersOES"); disp->set_glGenFramebuffersOES((glGenFramebuffersOES_t)ptr); + ptr = dlsym(gles_android,"glCheckFramebufferStatusOES"); disp->set_glCheckFramebufferStatusOES((glCheckFramebufferStatusOES_t)ptr); + ptr = dlsym(gles_android,"glFramebufferRenderbufferOES"); disp->set_glFramebufferRenderbufferOES((glFramebufferRenderbufferOES_t)ptr); + ptr = dlsym(gles_android,"glFramebufferTexture2DOES"); disp->set_glFramebufferTexture2DOES((glFramebufferTexture2DOES_t)ptr); + ptr = dlsym(gles_android,"glGetFramebufferAttachmentParameterivOES"); disp->set_glGetFramebufferAttachmentParameterivOES((glGetFramebufferAttachmentParameterivOES_t)ptr); + ptr = dlsym(gles_android,"glGenerateMipmapOES"); disp->set_glGenerateMipmapOES((glGenerateMipmapOES_t)ptr); + ptr = dlsym(gles_android,"glMapBufferOES"); disp->set_glMapBufferOES((glMapBufferOES_t)ptr); + ptr = dlsym(gles_android,"glUnmapBufferOES"); disp->set_glUnmapBufferOES((glUnmapBufferOES_t)ptr); + ptr = dlsym(gles_android,"glGetBufferPointervOES"); disp->set_glGetBufferPointervOES((glGetBufferPointervOES_t)ptr); + ptr = dlsym(gles_android,"glCurrentPaletteMatrixOES"); disp->set_glCurrentPaletteMatrixOES((glCurrentPaletteMatrixOES_t)ptr); + ptr = dlsym(gles_android,"glLoadPaletteFromModelViewMatrixOES"); disp->set_glLoadPaletteFromModelViewMatrixOES((glLoadPaletteFromModelViewMatrixOES_t)ptr); + ptr = dlsym(gles_android,"glMatrixIndexPointerOES"); disp->set_glMatrixIndexPointerOES((glMatrixIndexPointerOES_t)ptr); + ptr = dlsym(gles_android,"glWeightPointerOES"); disp->set_glWeightPointerOES((glWeightPointerOES_t)ptr); + ptr = dlsym(gles_android,"glQueryMatrixxOES"); disp->set_glQueryMatrixxOES((glQueryMatrixxOES_t)ptr); + ptr = dlsym(gles_android,"glDepthRangefOES"); disp->set_glDepthRangefOES((glDepthRangefOES_t)ptr); + ptr = dlsym(gles_android,"glFrustumfOES"); disp->set_glFrustumfOES((glFrustumfOES_t)ptr); + ptr = dlsym(gles_android,"glOrthofOES"); disp->set_glOrthofOES((glOrthofOES_t)ptr); + ptr = dlsym(gles_android,"glClipPlanefOES"); disp->set_glClipPlanefOES((glClipPlanefOES_t)ptr); + ptr = dlsym(gles_android,"glGetClipPlanefOES"); disp->set_glGetClipPlanefOES((glGetClipPlanefOES_t)ptr); + ptr = dlsym(gles_android,"glClearDepthfOES"); disp->set_glClearDepthfOES((glClearDepthfOES_t)ptr); + ptr = dlsym(gles_android,"glTexGenfOES"); disp->set_glTexGenfOES((glTexGenfOES_t)ptr); + ptr = dlsym(gles_android,"glTexGenfvOES"); disp->set_glTexGenfvOES((glTexGenfvOES_t)ptr); + ptr = dlsym(gles_android,"glTexGeniOES"); disp->set_glTexGeniOES((glTexGeniOES_t)ptr); + ptr = dlsym(gles_android,"glTexGenivOES"); disp->set_glTexGenivOES((glTexGenivOES_t)ptr); + ptr = dlsym(gles_android,"glTexGenxOES"); disp->set_glTexGenxOES((glTexGenxOES_t)ptr); + ptr = dlsym(gles_android,"glTexGenxvOES"); disp->set_glTexGenxvOES((glTexGenxvOES_t)ptr); + ptr = dlsym(gles_android,"glGetTexGenfvOES"); disp->set_glGetTexGenfvOES((glGetTexGenfvOES_t)ptr); + ptr = dlsym(gles_android,"glGetTexGenivOES"); disp->set_glGetTexGenivOES((glGetTexGenivOES_t)ptr); + ptr = dlsym(gles_android,"glGetTexGenxvOES"); disp->set_glGetTexGenxvOES((glGetTexGenxvOES_t)ptr); + ptr = dlsym(gles_android,"glBindVertexArrayOES"); disp->set_glBindVertexArrayOES((glBindVertexArrayOES_t)ptr); + ptr = dlsym(gles_android,"glDeleteVertexArraysOES"); disp->set_glDeleteVertexArraysOES((glDeleteVertexArraysOES_t)ptr); + ptr = dlsym(gles_android,"glGenVertexArraysOES"); disp->set_glGenVertexArraysOES((glGenVertexArraysOES_t)ptr); + ptr = dlsym(gles_android,"glIsVertexArrayOES"); disp->set_glIsVertexArrayOES((glIsVertexArrayOES_t)ptr); + ptr = dlsym(gles_android,"glDiscardFramebufferEXT"); disp->set_glDiscardFramebufferEXT((glDiscardFramebufferEXT_t)ptr); + ptr = dlsym(gles_android,"glMultiDrawArraysEXT"); disp->set_glMultiDrawArraysEXT((glMultiDrawArraysEXT_t)ptr); + ptr = dlsym(gles_android,"glMultiDrawElementsEXT"); disp->set_glMultiDrawElementsEXT((glMultiDrawElementsEXT_t)ptr); + ptr = dlsym(gles_android,"glClipPlanefIMG"); disp->set_glClipPlanefIMG((glClipPlanefIMG_t)ptr); + ptr = dlsym(gles_android,"glClipPlanexIMG"); disp->set_glClipPlanexIMG((glClipPlanexIMG_t)ptr); + ptr = dlsym(gles_android,"glRenderbufferStorageMultisampleIMG"); disp->set_glRenderbufferStorageMultisampleIMG((glRenderbufferStorageMultisampleIMG_t)ptr); + ptr = dlsym(gles_android,"glFramebufferTexture2DMultisampleIMG"); disp->set_glFramebufferTexture2DMultisampleIMG((glFramebufferTexture2DMultisampleIMG_t)ptr); + ptr = dlsym(gles_android,"glDeleteFencesNV"); disp->set_glDeleteFencesNV((glDeleteFencesNV_t)ptr); + ptr = dlsym(gles_android,"glGenFencesNV"); disp->set_glGenFencesNV((glGenFencesNV_t)ptr); + ptr = dlsym(gles_android,"glIsFenceNV"); disp->set_glIsFenceNV((glIsFenceNV_t)ptr); + ptr = dlsym(gles_android,"glTestFenceNV"); disp->set_glTestFenceNV((glTestFenceNV_t)ptr); + ptr = dlsym(gles_android,"glGetFenceivNV"); disp->set_glGetFenceivNV((glGetFenceivNV_t)ptr); + ptr = dlsym(gles_android,"glFinishFenceNV"); disp->set_glFinishFenceNV((glFinishFenceNV_t)ptr); + ptr = dlsym(gles_android,"glSetFenceNV"); disp->set_glSetFenceNV((glSetFenceNV_t)ptr); + ptr = dlsym(gles_android,"glGetDriverControlsQCOM"); disp->set_glGetDriverControlsQCOM((glGetDriverControlsQCOM_t)ptr); + ptr = dlsym(gles_android,"glGetDriverControlStringQCOM"); disp->set_glGetDriverControlStringQCOM((glGetDriverControlStringQCOM_t)ptr); + ptr = dlsym(gles_android,"glEnableDriverControlQCOM"); disp->set_glEnableDriverControlQCOM((glEnableDriverControlQCOM_t)ptr); + ptr = dlsym(gles_android,"glDisableDriverControlQCOM"); disp->set_glDisableDriverControlQCOM((glDisableDriverControlQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetTexturesQCOM"); disp->set_glExtGetTexturesQCOM((glExtGetTexturesQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetBuffersQCOM"); disp->set_glExtGetBuffersQCOM((glExtGetBuffersQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetRenderbuffersQCOM"); disp->set_glExtGetRenderbuffersQCOM((glExtGetRenderbuffersQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetFramebuffersQCOM"); disp->set_glExtGetFramebuffersQCOM((glExtGetFramebuffersQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetTexLevelParameterivQCOM"); disp->set_glExtGetTexLevelParameterivQCOM((glExtGetTexLevelParameterivQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtTexObjectStateOverrideiQCOM"); disp->set_glExtTexObjectStateOverrideiQCOM((glExtTexObjectStateOverrideiQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetTexSubImageQCOM"); disp->set_glExtGetTexSubImageQCOM((glExtGetTexSubImageQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetBufferPointervQCOM"); disp->set_glExtGetBufferPointervQCOM((glExtGetBufferPointervQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetShadersQCOM"); disp->set_glExtGetShadersQCOM((glExtGetShadersQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetProgramsQCOM"); disp->set_glExtGetProgramsQCOM((glExtGetProgramsQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtIsProgramBinaryQCOM"); disp->set_glExtIsProgramBinaryQCOM((glExtIsProgramBinaryQCOM_t)ptr); + ptr = dlsym(gles_android,"glExtGetProgramBinarySourceQCOM"); disp->set_glExtGetProgramBinarySourceQCOM((glExtGetProgramBinarySourceQCOM_t)ptr); + ptr = dlsym(gles_android,"glStartTilingQCOM"); disp->set_glStartTilingQCOM((glStartTilingQCOM_t)ptr); + ptr = dlsym(gles_android,"glEndTilingQCOM"); disp->set_glEndTilingQCOM((glEndTilingQCOM_t)ptr); + + return disp; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.h new file mode 100644 index 0000000..98a4fca --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_dispatch.h @@ -0,0 +1,570 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GLES_DISPATCH_H +#define _GLES_DISPATCH_H + +#include "gles_proc.h" + + +struct gles_dispatch { + glAlphaFunc_t glAlphaFunc; + glClearColor_t glClearColor; + glClearDepthf_t glClearDepthf; + glClipPlanef_t glClipPlanef; + glColor4f_t glColor4f; + glDepthRangef_t glDepthRangef; + glFogf_t glFogf; + glFogfv_t glFogfv; + glFrustumf_t glFrustumf; + glGetClipPlanef_t glGetClipPlanef; + glGetFloatv_t glGetFloatv; + glGetLightfv_t glGetLightfv; + glGetMaterialfv_t glGetMaterialfv; + glGetTexEnvfv_t glGetTexEnvfv; + glGetTexParameterfv_t glGetTexParameterfv; + glLightModelf_t glLightModelf; + glLightModelfv_t glLightModelfv; + glLightf_t glLightf; + glLightfv_t glLightfv; + glLineWidth_t glLineWidth; + glLoadMatrixf_t glLoadMatrixf; + glMaterialf_t glMaterialf; + glMaterialfv_t glMaterialfv; + glMultMatrixf_t glMultMatrixf; + glMultiTexCoord4f_t glMultiTexCoord4f; + glNormal3f_t glNormal3f; + glOrthof_t glOrthof; + glPointParameterf_t glPointParameterf; + glPointParameterfv_t glPointParameterfv; + glPointSize_t glPointSize; + glPolygonOffset_t glPolygonOffset; + glRotatef_t glRotatef; + glScalef_t glScalef; + glTexEnvf_t glTexEnvf; + glTexEnvfv_t glTexEnvfv; + glTexParameterf_t glTexParameterf; + glTexParameterfv_t glTexParameterfv; + glTranslatef_t glTranslatef; + glActiveTexture_t glActiveTexture; + glAlphaFuncx_t glAlphaFuncx; + glBindBuffer_t glBindBuffer; + glBindTexture_t glBindTexture; + glBlendFunc_t glBlendFunc; + glBufferData_t glBufferData; + glBufferSubData_t glBufferSubData; + glClear_t glClear; + glClearColorx_t glClearColorx; + glClearDepthx_t glClearDepthx; + glClearStencil_t glClearStencil; + glClientActiveTexture_t glClientActiveTexture; + glClipPlanex_t glClipPlanex; + glColor4ub_t glColor4ub; + glColor4x_t glColor4x; + glColorMask_t glColorMask; + glColorPointer_t glColorPointer; + glCompressedTexImage2D_t glCompressedTexImage2D; + glCompressedTexSubImage2D_t glCompressedTexSubImage2D; + glCopyTexImage2D_t glCopyTexImage2D; + glCopyTexSubImage2D_t glCopyTexSubImage2D; + glCullFace_t glCullFace; + glDeleteBuffers_t glDeleteBuffers; + glDeleteTextures_t glDeleteTextures; + glDepthFunc_t glDepthFunc; + glDepthMask_t glDepthMask; + glDepthRangex_t glDepthRangex; + glDisable_t glDisable; + glDisableClientState_t glDisableClientState; + glDrawArrays_t glDrawArrays; + glDrawElements_t glDrawElements; + glEnable_t glEnable; + glEnableClientState_t glEnableClientState; + glFinish_t glFinish; + glFlush_t glFlush; + glFogx_t glFogx; + glFogxv_t glFogxv; + glFrontFace_t glFrontFace; + glFrustumx_t glFrustumx; + glGetBooleanv_t glGetBooleanv; + glGetBufferParameteriv_t glGetBufferParameteriv; + glGetClipPlanex_t glGetClipPlanex; + glGenBuffers_t glGenBuffers; + glGenTextures_t glGenTextures; + glGetError_t glGetError; + glGetFixedv_t glGetFixedv; + glGetIntegerv_t glGetIntegerv; + glGetLightxv_t glGetLightxv; + glGetMaterialxv_t glGetMaterialxv; + glGetPointerv_t glGetPointerv; + glGetString_t glGetString; + glGetTexEnviv_t glGetTexEnviv; + glGetTexEnvxv_t glGetTexEnvxv; + glGetTexParameteriv_t glGetTexParameteriv; + glGetTexParameterxv_t glGetTexParameterxv; + glHint_t glHint; + glIsBuffer_t glIsBuffer; + glIsEnabled_t glIsEnabled; + glIsTexture_t glIsTexture; + glLightModelx_t glLightModelx; + glLightModelxv_t glLightModelxv; + glLightx_t glLightx; + glLightxv_t glLightxv; + glLineWidthx_t glLineWidthx; + glLoadIdentity_t glLoadIdentity; + glLoadMatrixx_t glLoadMatrixx; + glLogicOp_t glLogicOp; + glMaterialx_t glMaterialx; + glMaterialxv_t glMaterialxv; + glMatrixMode_t glMatrixMode; + glMultMatrixx_t glMultMatrixx; + glMultiTexCoord4x_t glMultiTexCoord4x; + glNormal3x_t glNormal3x; + glNormalPointer_t glNormalPointer; + glOrthox_t glOrthox; + glPixelStorei_t glPixelStorei; + glPointParameterx_t glPointParameterx; + glPointParameterxv_t glPointParameterxv; + glPointSizex_t glPointSizex; + glPolygonOffsetx_t glPolygonOffsetx; + glPopMatrix_t glPopMatrix; + glPushMatrix_t glPushMatrix; + glReadPixels_t glReadPixels; + glRotatex_t glRotatex; + glSampleCoverage_t glSampleCoverage; + glSampleCoveragex_t glSampleCoveragex; + glScalex_t glScalex; + glScissor_t glScissor; + glShadeModel_t glShadeModel; + glStencilFunc_t glStencilFunc; + glStencilMask_t glStencilMask; + glStencilOp_t glStencilOp; + glTexCoordPointer_t glTexCoordPointer; + glTexEnvi_t glTexEnvi; + glTexEnvx_t glTexEnvx; + glTexEnviv_t glTexEnviv; + glTexEnvxv_t glTexEnvxv; + glTexImage2D_t glTexImage2D; + glTexParameteri_t glTexParameteri; + glTexParameterx_t glTexParameterx; + glTexParameteriv_t glTexParameteriv; + glTexParameterxv_t glTexParameterxv; + glTexSubImage2D_t glTexSubImage2D; + glTranslatex_t glTranslatex; + glVertexPointer_t glVertexPointer; + glViewport_t glViewport; + glPointSizePointerOES_t glPointSizePointerOES; + glBlendEquationSeparateOES_t glBlendEquationSeparateOES; + glBlendFuncSeparateOES_t glBlendFuncSeparateOES; + glBlendEquationOES_t glBlendEquationOES; + glDrawTexsOES_t glDrawTexsOES; + glDrawTexiOES_t glDrawTexiOES; + glDrawTexxOES_t glDrawTexxOES; + glDrawTexsvOES_t glDrawTexsvOES; + glDrawTexivOES_t glDrawTexivOES; + glDrawTexxvOES_t glDrawTexxvOES; + glDrawTexfOES_t glDrawTexfOES; + glDrawTexfvOES_t glDrawTexfvOES; + glEGLImageTargetTexture2DOES_t glEGLImageTargetTexture2DOES; + glEGLImageTargetRenderbufferStorageOES_t glEGLImageTargetRenderbufferStorageOES; + glAlphaFuncxOES_t glAlphaFuncxOES; + glClearColorxOES_t glClearColorxOES; + glClearDepthxOES_t glClearDepthxOES; + glClipPlanexOES_t glClipPlanexOES; + glColor4xOES_t glColor4xOES; + glDepthRangexOES_t glDepthRangexOES; + glFogxOES_t glFogxOES; + glFogxvOES_t glFogxvOES; + glFrustumxOES_t glFrustumxOES; + glGetClipPlanexOES_t glGetClipPlanexOES; + glGetFixedvOES_t glGetFixedvOES; + glGetLightxvOES_t glGetLightxvOES; + glGetMaterialxvOES_t glGetMaterialxvOES; + glGetTexEnvxvOES_t glGetTexEnvxvOES; + glGetTexParameterxvOES_t glGetTexParameterxvOES; + glLightModelxOES_t glLightModelxOES; + glLightModelxvOES_t glLightModelxvOES; + glLightxOES_t glLightxOES; + glLightxvOES_t glLightxvOES; + glLineWidthxOES_t glLineWidthxOES; + glLoadMatrixxOES_t glLoadMatrixxOES; + glMaterialxOES_t glMaterialxOES; + glMaterialxvOES_t glMaterialxvOES; + glMultMatrixxOES_t glMultMatrixxOES; + glMultiTexCoord4xOES_t glMultiTexCoord4xOES; + glNormal3xOES_t glNormal3xOES; + glOrthoxOES_t glOrthoxOES; + glPointParameterxOES_t glPointParameterxOES; + glPointParameterxvOES_t glPointParameterxvOES; + glPointSizexOES_t glPointSizexOES; + glPolygonOffsetxOES_t glPolygonOffsetxOES; + glRotatexOES_t glRotatexOES; + glSampleCoveragexOES_t glSampleCoveragexOES; + glScalexOES_t glScalexOES; + glTexEnvxOES_t glTexEnvxOES; + glTexEnvxvOES_t glTexEnvxvOES; + glTexParameterxOES_t glTexParameterxOES; + glTexParameterxvOES_t glTexParameterxvOES; + glTranslatexOES_t glTranslatexOES; + glIsRenderbufferOES_t glIsRenderbufferOES; + glBindRenderbufferOES_t glBindRenderbufferOES; + glDeleteRenderbuffersOES_t glDeleteRenderbuffersOES; + glGenRenderbuffersOES_t glGenRenderbuffersOES; + glRenderbufferStorageOES_t glRenderbufferStorageOES; + glGetRenderbufferParameterivOES_t glGetRenderbufferParameterivOES; + glIsFramebufferOES_t glIsFramebufferOES; + glBindFramebufferOES_t glBindFramebufferOES; + glDeleteFramebuffersOES_t glDeleteFramebuffersOES; + glGenFramebuffersOES_t glGenFramebuffersOES; + glCheckFramebufferStatusOES_t glCheckFramebufferStatusOES; + glFramebufferRenderbufferOES_t glFramebufferRenderbufferOES; + glFramebufferTexture2DOES_t glFramebufferTexture2DOES; + glGetFramebufferAttachmentParameterivOES_t glGetFramebufferAttachmentParameterivOES; + glGenerateMipmapOES_t glGenerateMipmapOES; + glMapBufferOES_t glMapBufferOES; + glUnmapBufferOES_t glUnmapBufferOES; + glGetBufferPointervOES_t glGetBufferPointervOES; + glCurrentPaletteMatrixOES_t glCurrentPaletteMatrixOES; + glLoadPaletteFromModelViewMatrixOES_t glLoadPaletteFromModelViewMatrixOES; + glMatrixIndexPointerOES_t glMatrixIndexPointerOES; + glWeightPointerOES_t glWeightPointerOES; + glQueryMatrixxOES_t glQueryMatrixxOES; + glDepthRangefOES_t glDepthRangefOES; + glFrustumfOES_t glFrustumfOES; + glOrthofOES_t glOrthofOES; + glClipPlanefOES_t glClipPlanefOES; + glGetClipPlanefOES_t glGetClipPlanefOES; + glClearDepthfOES_t glClearDepthfOES; + glTexGenfOES_t glTexGenfOES; + glTexGenfvOES_t glTexGenfvOES; + glTexGeniOES_t glTexGeniOES; + glTexGenivOES_t glTexGenivOES; + glTexGenxOES_t glTexGenxOES; + glTexGenxvOES_t glTexGenxvOES; + glGetTexGenfvOES_t glGetTexGenfvOES; + glGetTexGenivOES_t glGetTexGenivOES; + glGetTexGenxvOES_t glGetTexGenxvOES; + glBindVertexArrayOES_t glBindVertexArrayOES; + glDeleteVertexArraysOES_t glDeleteVertexArraysOES; + glGenVertexArraysOES_t glGenVertexArraysOES; + glIsVertexArrayOES_t glIsVertexArrayOES; + glDiscardFramebufferEXT_t glDiscardFramebufferEXT; + glMultiDrawArraysEXT_t glMultiDrawArraysEXT; + glMultiDrawElementsEXT_t glMultiDrawElementsEXT; + glClipPlanefIMG_t glClipPlanefIMG; + glClipPlanexIMG_t glClipPlanexIMG; + glRenderbufferStorageMultisampleIMG_t glRenderbufferStorageMultisampleIMG; + glFramebufferTexture2DMultisampleIMG_t glFramebufferTexture2DMultisampleIMG; + glDeleteFencesNV_t glDeleteFencesNV; + glGenFencesNV_t glGenFencesNV; + glIsFenceNV_t glIsFenceNV; + glTestFenceNV_t glTestFenceNV; + glGetFenceivNV_t glGetFenceivNV; + glFinishFenceNV_t glFinishFenceNV; + glSetFenceNV_t glSetFenceNV; + glGetDriverControlsQCOM_t glGetDriverControlsQCOM; + glGetDriverControlStringQCOM_t glGetDriverControlStringQCOM; + glEnableDriverControlQCOM_t glEnableDriverControlQCOM; + glDisableDriverControlQCOM_t glDisableDriverControlQCOM; + glExtGetTexturesQCOM_t glExtGetTexturesQCOM; + glExtGetBuffersQCOM_t glExtGetBuffersQCOM; + glExtGetRenderbuffersQCOM_t glExtGetRenderbuffersQCOM; + glExtGetFramebuffersQCOM_t glExtGetFramebuffersQCOM; + glExtGetTexLevelParameterivQCOM_t glExtGetTexLevelParameterivQCOM; + glExtTexObjectStateOverrideiQCOM_t glExtTexObjectStateOverrideiQCOM; + glExtGetTexSubImageQCOM_t glExtGetTexSubImageQCOM; + glExtGetBufferPointervQCOM_t glExtGetBufferPointervQCOM; + glExtGetShadersQCOM_t glExtGetShadersQCOM; + glExtGetProgramsQCOM_t glExtGetProgramsQCOM; + glExtIsProgramBinaryQCOM_t glExtIsProgramBinaryQCOM; + glExtGetProgramBinarySourceQCOM_t glExtGetProgramBinarySourceQCOM; + glStartTilingQCOM_t glStartTilingQCOM; + glEndTilingQCOM_t glEndTilingQCOM; + //Accessors + glAlphaFunc_t set_glAlphaFunc(glAlphaFunc_t f) { glAlphaFunc_t retval = glAlphaFunc; glAlphaFunc = f; return retval;} + glClearColor_t set_glClearColor(glClearColor_t f) { glClearColor_t retval = glClearColor; glClearColor = f; return retval;} + glClearDepthf_t set_glClearDepthf(glClearDepthf_t f) { glClearDepthf_t retval = glClearDepthf; glClearDepthf = f; return retval;} + glClipPlanef_t set_glClipPlanef(glClipPlanef_t f) { glClipPlanef_t retval = glClipPlanef; glClipPlanef = f; return retval;} + glColor4f_t set_glColor4f(glColor4f_t f) { glColor4f_t retval = glColor4f; glColor4f = f; return retval;} + glDepthRangef_t set_glDepthRangef(glDepthRangef_t f) { glDepthRangef_t retval = glDepthRangef; glDepthRangef = f; return retval;} + glFogf_t set_glFogf(glFogf_t f) { glFogf_t retval = glFogf; glFogf = f; return retval;} + glFogfv_t set_glFogfv(glFogfv_t f) { glFogfv_t retval = glFogfv; glFogfv = f; return retval;} + glFrustumf_t set_glFrustumf(glFrustumf_t f) { glFrustumf_t retval = glFrustumf; glFrustumf = f; return retval;} + glGetClipPlanef_t set_glGetClipPlanef(glGetClipPlanef_t f) { glGetClipPlanef_t retval = glGetClipPlanef; glGetClipPlanef = f; return retval;} + glGetFloatv_t set_glGetFloatv(glGetFloatv_t f) { glGetFloatv_t retval = glGetFloatv; glGetFloatv = f; return retval;} + glGetLightfv_t set_glGetLightfv(glGetLightfv_t f) { glGetLightfv_t retval = glGetLightfv; glGetLightfv = f; return retval;} + glGetMaterialfv_t set_glGetMaterialfv(glGetMaterialfv_t f) { glGetMaterialfv_t retval = glGetMaterialfv; glGetMaterialfv = f; return retval;} + glGetTexEnvfv_t set_glGetTexEnvfv(glGetTexEnvfv_t f) { glGetTexEnvfv_t retval = glGetTexEnvfv; glGetTexEnvfv = f; return retval;} + glGetTexParameterfv_t set_glGetTexParameterfv(glGetTexParameterfv_t f) { glGetTexParameterfv_t retval = glGetTexParameterfv; glGetTexParameterfv = f; return retval;} + glLightModelf_t set_glLightModelf(glLightModelf_t f) { glLightModelf_t retval = glLightModelf; glLightModelf = f; return retval;} + glLightModelfv_t set_glLightModelfv(glLightModelfv_t f) { glLightModelfv_t retval = glLightModelfv; glLightModelfv = f; return retval;} + glLightf_t set_glLightf(glLightf_t f) { glLightf_t retval = glLightf; glLightf = f; return retval;} + glLightfv_t set_glLightfv(glLightfv_t f) { glLightfv_t retval = glLightfv; glLightfv = f; return retval;} + glLineWidth_t set_glLineWidth(glLineWidth_t f) { glLineWidth_t retval = glLineWidth; glLineWidth = f; return retval;} + glLoadMatrixf_t set_glLoadMatrixf(glLoadMatrixf_t f) { glLoadMatrixf_t retval = glLoadMatrixf; glLoadMatrixf = f; return retval;} + glMaterialf_t set_glMaterialf(glMaterialf_t f) { glMaterialf_t retval = glMaterialf; glMaterialf = f; return retval;} + glMaterialfv_t set_glMaterialfv(glMaterialfv_t f) { glMaterialfv_t retval = glMaterialfv; glMaterialfv = f; return retval;} + glMultMatrixf_t set_glMultMatrixf(glMultMatrixf_t f) { glMultMatrixf_t retval = glMultMatrixf; glMultMatrixf = f; return retval;} + glMultiTexCoord4f_t set_glMultiTexCoord4f(glMultiTexCoord4f_t f) { glMultiTexCoord4f_t retval = glMultiTexCoord4f; glMultiTexCoord4f = f; return retval;} + glNormal3f_t set_glNormal3f(glNormal3f_t f) { glNormal3f_t retval = glNormal3f; glNormal3f = f; return retval;} + glOrthof_t set_glOrthof(glOrthof_t f) { glOrthof_t retval = glOrthof; glOrthof = f; return retval;} + glPointParameterf_t set_glPointParameterf(glPointParameterf_t f) { glPointParameterf_t retval = glPointParameterf; glPointParameterf = f; return retval;} + glPointParameterfv_t set_glPointParameterfv(glPointParameterfv_t f) { glPointParameterfv_t retval = glPointParameterfv; glPointParameterfv = f; return retval;} + glPointSize_t set_glPointSize(glPointSize_t f) { glPointSize_t retval = glPointSize; glPointSize = f; return retval;} + glPolygonOffset_t set_glPolygonOffset(glPolygonOffset_t f) { glPolygonOffset_t retval = glPolygonOffset; glPolygonOffset = f; return retval;} + glRotatef_t set_glRotatef(glRotatef_t f) { glRotatef_t retval = glRotatef; glRotatef = f; return retval;} + glScalef_t set_glScalef(glScalef_t f) { glScalef_t retval = glScalef; glScalef = f; return retval;} + glTexEnvf_t set_glTexEnvf(glTexEnvf_t f) { glTexEnvf_t retval = glTexEnvf; glTexEnvf = f; return retval;} + glTexEnvfv_t set_glTexEnvfv(glTexEnvfv_t f) { glTexEnvfv_t retval = glTexEnvfv; glTexEnvfv = f; return retval;} + glTexParameterf_t set_glTexParameterf(glTexParameterf_t f) { glTexParameterf_t retval = glTexParameterf; glTexParameterf = f; return retval;} + glTexParameterfv_t set_glTexParameterfv(glTexParameterfv_t f) { glTexParameterfv_t retval = glTexParameterfv; glTexParameterfv = f; return retval;} + glTranslatef_t set_glTranslatef(glTranslatef_t f) { glTranslatef_t retval = glTranslatef; glTranslatef = f; return retval;} + glActiveTexture_t set_glActiveTexture(glActiveTexture_t f) { glActiveTexture_t retval = glActiveTexture; glActiveTexture = f; return retval;} + glAlphaFuncx_t set_glAlphaFuncx(glAlphaFuncx_t f) { glAlphaFuncx_t retval = glAlphaFuncx; glAlphaFuncx = f; return retval;} + glBindBuffer_t set_glBindBuffer(glBindBuffer_t f) { glBindBuffer_t retval = glBindBuffer; glBindBuffer = f; return retval;} + glBindTexture_t set_glBindTexture(glBindTexture_t f) { glBindTexture_t retval = glBindTexture; glBindTexture = f; return retval;} + glBlendFunc_t set_glBlendFunc(glBlendFunc_t f) { glBlendFunc_t retval = glBlendFunc; glBlendFunc = f; return retval;} + glBufferData_t set_glBufferData(glBufferData_t f) { glBufferData_t retval = glBufferData; glBufferData = f; return retval;} + glBufferSubData_t set_glBufferSubData(glBufferSubData_t f) { glBufferSubData_t retval = glBufferSubData; glBufferSubData = f; return retval;} + glClear_t set_glClear(glClear_t f) { glClear_t retval = glClear; glClear = f; return retval;} + glClearColorx_t set_glClearColorx(glClearColorx_t f) { glClearColorx_t retval = glClearColorx; glClearColorx = f; return retval;} + glClearDepthx_t set_glClearDepthx(glClearDepthx_t f) { glClearDepthx_t retval = glClearDepthx; glClearDepthx = f; return retval;} + glClearStencil_t set_glClearStencil(glClearStencil_t f) { glClearStencil_t retval = glClearStencil; glClearStencil = f; return retval;} + glClientActiveTexture_t set_glClientActiveTexture(glClientActiveTexture_t f) { glClientActiveTexture_t retval = glClientActiveTexture; glClientActiveTexture = f; return retval;} + glClipPlanex_t set_glClipPlanex(glClipPlanex_t f) { glClipPlanex_t retval = glClipPlanex; glClipPlanex = f; return retval;} + glColor4ub_t set_glColor4ub(glColor4ub_t f) { glColor4ub_t retval = glColor4ub; glColor4ub = f; return retval;} + glColor4x_t set_glColor4x(glColor4x_t f) { glColor4x_t retval = glColor4x; glColor4x = f; return retval;} + glColorMask_t set_glColorMask(glColorMask_t f) { glColorMask_t retval = glColorMask; glColorMask = f; return retval;} + glColorPointer_t set_glColorPointer(glColorPointer_t f) { glColorPointer_t retval = glColorPointer; glColorPointer = f; return retval;} + glCompressedTexImage2D_t set_glCompressedTexImage2D(glCompressedTexImage2D_t f) { glCompressedTexImage2D_t retval = glCompressedTexImage2D; glCompressedTexImage2D = f; return retval;} + glCompressedTexSubImage2D_t set_glCompressedTexSubImage2D(glCompressedTexSubImage2D_t f) { glCompressedTexSubImage2D_t retval = glCompressedTexSubImage2D; glCompressedTexSubImage2D = f; return retval;} + glCopyTexImage2D_t set_glCopyTexImage2D(glCopyTexImage2D_t f) { glCopyTexImage2D_t retval = glCopyTexImage2D; glCopyTexImage2D = f; return retval;} + glCopyTexSubImage2D_t set_glCopyTexSubImage2D(glCopyTexSubImage2D_t f) { glCopyTexSubImage2D_t retval = glCopyTexSubImage2D; glCopyTexSubImage2D = f; return retval;} + glCullFace_t set_glCullFace(glCullFace_t f) { glCullFace_t retval = glCullFace; glCullFace = f; return retval;} + glDeleteBuffers_t set_glDeleteBuffers(glDeleteBuffers_t f) { glDeleteBuffers_t retval = glDeleteBuffers; glDeleteBuffers = f; return retval;} + glDeleteTextures_t set_glDeleteTextures(glDeleteTextures_t f) { glDeleteTextures_t retval = glDeleteTextures; glDeleteTextures = f; return retval;} + glDepthFunc_t set_glDepthFunc(glDepthFunc_t f) { glDepthFunc_t retval = glDepthFunc; glDepthFunc = f; return retval;} + glDepthMask_t set_glDepthMask(glDepthMask_t f) { glDepthMask_t retval = glDepthMask; glDepthMask = f; return retval;} + glDepthRangex_t set_glDepthRangex(glDepthRangex_t f) { glDepthRangex_t retval = glDepthRangex; glDepthRangex = f; return retval;} + glDisable_t set_glDisable(glDisable_t f) { glDisable_t retval = glDisable; glDisable = f; return retval;} + glDisableClientState_t set_glDisableClientState(glDisableClientState_t f) { glDisableClientState_t retval = glDisableClientState; glDisableClientState = f; return retval;} + glDrawArrays_t set_glDrawArrays(glDrawArrays_t f) { glDrawArrays_t retval = glDrawArrays; glDrawArrays = f; return retval;} + glDrawElements_t set_glDrawElements(glDrawElements_t f) { glDrawElements_t retval = glDrawElements; glDrawElements = f; return retval;} + glEnable_t set_glEnable(glEnable_t f) { glEnable_t retval = glEnable; glEnable = f; return retval;} + glEnableClientState_t set_glEnableClientState(glEnableClientState_t f) { glEnableClientState_t retval = glEnableClientState; glEnableClientState = f; return retval;} + glFinish_t set_glFinish(glFinish_t f) { glFinish_t retval = glFinish; glFinish = f; return retval;} + glFlush_t set_glFlush(glFlush_t f) { glFlush_t retval = glFlush; glFlush = f; return retval;} + glFogx_t set_glFogx(glFogx_t f) { glFogx_t retval = glFogx; glFogx = f; return retval;} + glFogxv_t set_glFogxv(glFogxv_t f) { glFogxv_t retval = glFogxv; glFogxv = f; return retval;} + glFrontFace_t set_glFrontFace(glFrontFace_t f) { glFrontFace_t retval = glFrontFace; glFrontFace = f; return retval;} + glFrustumx_t set_glFrustumx(glFrustumx_t f) { glFrustumx_t retval = glFrustumx; glFrustumx = f; return retval;} + glGetBooleanv_t set_glGetBooleanv(glGetBooleanv_t f) { glGetBooleanv_t retval = glGetBooleanv; glGetBooleanv = f; return retval;} + glGetBufferParameteriv_t set_glGetBufferParameteriv(glGetBufferParameteriv_t f) { glGetBufferParameteriv_t retval = glGetBufferParameteriv; glGetBufferParameteriv = f; return retval;} + glGetClipPlanex_t set_glGetClipPlanex(glGetClipPlanex_t f) { glGetClipPlanex_t retval = glGetClipPlanex; glGetClipPlanex = f; return retval;} + glGenBuffers_t set_glGenBuffers(glGenBuffers_t f) { glGenBuffers_t retval = glGenBuffers; glGenBuffers = f; return retval;} + glGenTextures_t set_glGenTextures(glGenTextures_t f) { glGenTextures_t retval = glGenTextures; glGenTextures = f; return retval;} + glGetError_t set_glGetError(glGetError_t f) { glGetError_t retval = glGetError; glGetError = f; return retval;} + glGetFixedv_t set_glGetFixedv(glGetFixedv_t f) { glGetFixedv_t retval = glGetFixedv; glGetFixedv = f; return retval;} + glGetIntegerv_t set_glGetIntegerv(glGetIntegerv_t f) { glGetIntegerv_t retval = glGetIntegerv; glGetIntegerv = f; return retval;} + glGetLightxv_t set_glGetLightxv(glGetLightxv_t f) { glGetLightxv_t retval = glGetLightxv; glGetLightxv = f; return retval;} + glGetMaterialxv_t set_glGetMaterialxv(glGetMaterialxv_t f) { glGetMaterialxv_t retval = glGetMaterialxv; glGetMaterialxv = f; return retval;} + glGetPointerv_t set_glGetPointerv(glGetPointerv_t f) { glGetPointerv_t retval = glGetPointerv; glGetPointerv = f; return retval;} + glGetString_t set_glGetString(glGetString_t f) { glGetString_t retval = glGetString; glGetString = f; return retval;} + glGetTexEnviv_t set_glGetTexEnviv(glGetTexEnviv_t f) { glGetTexEnviv_t retval = glGetTexEnviv; glGetTexEnviv = f; return retval;} + glGetTexEnvxv_t set_glGetTexEnvxv(glGetTexEnvxv_t f) { glGetTexEnvxv_t retval = glGetTexEnvxv; glGetTexEnvxv = f; return retval;} + glGetTexParameteriv_t set_glGetTexParameteriv(glGetTexParameteriv_t f) { glGetTexParameteriv_t retval = glGetTexParameteriv; glGetTexParameteriv = f; return retval;} + glGetTexParameterxv_t set_glGetTexParameterxv(glGetTexParameterxv_t f) { glGetTexParameterxv_t retval = glGetTexParameterxv; glGetTexParameterxv = f; return retval;} + glHint_t set_glHint(glHint_t f) { glHint_t retval = glHint; glHint = f; return retval;} + glIsBuffer_t set_glIsBuffer(glIsBuffer_t f) { glIsBuffer_t retval = glIsBuffer; glIsBuffer = f; return retval;} + glIsEnabled_t set_glIsEnabled(glIsEnabled_t f) { glIsEnabled_t retval = glIsEnabled; glIsEnabled = f; return retval;} + glIsTexture_t set_glIsTexture(glIsTexture_t f) { glIsTexture_t retval = glIsTexture; glIsTexture = f; return retval;} + glLightModelx_t set_glLightModelx(glLightModelx_t f) { glLightModelx_t retval = glLightModelx; glLightModelx = f; return retval;} + glLightModelxv_t set_glLightModelxv(glLightModelxv_t f) { glLightModelxv_t retval = glLightModelxv; glLightModelxv = f; return retval;} + glLightx_t set_glLightx(glLightx_t f) { glLightx_t retval = glLightx; glLightx = f; return retval;} + glLightxv_t set_glLightxv(glLightxv_t f) { glLightxv_t retval = glLightxv; glLightxv = f; return retval;} + glLineWidthx_t set_glLineWidthx(glLineWidthx_t f) { glLineWidthx_t retval = glLineWidthx; glLineWidthx = f; return retval;} + glLoadIdentity_t set_glLoadIdentity(glLoadIdentity_t f) { glLoadIdentity_t retval = glLoadIdentity; glLoadIdentity = f; return retval;} + glLoadMatrixx_t set_glLoadMatrixx(glLoadMatrixx_t f) { glLoadMatrixx_t retval = glLoadMatrixx; glLoadMatrixx = f; return retval;} + glLogicOp_t set_glLogicOp(glLogicOp_t f) { glLogicOp_t retval = glLogicOp; glLogicOp = f; return retval;} + glMaterialx_t set_glMaterialx(glMaterialx_t f) { glMaterialx_t retval = glMaterialx; glMaterialx = f; return retval;} + glMaterialxv_t set_glMaterialxv(glMaterialxv_t f) { glMaterialxv_t retval = glMaterialxv; glMaterialxv = f; return retval;} + glMatrixMode_t set_glMatrixMode(glMatrixMode_t f) { glMatrixMode_t retval = glMatrixMode; glMatrixMode = f; return retval;} + glMultMatrixx_t set_glMultMatrixx(glMultMatrixx_t f) { glMultMatrixx_t retval = glMultMatrixx; glMultMatrixx = f; return retval;} + glMultiTexCoord4x_t set_glMultiTexCoord4x(glMultiTexCoord4x_t f) { glMultiTexCoord4x_t retval = glMultiTexCoord4x; glMultiTexCoord4x = f; return retval;} + glNormal3x_t set_glNormal3x(glNormal3x_t f) { glNormal3x_t retval = glNormal3x; glNormal3x = f; return retval;} + glNormalPointer_t set_glNormalPointer(glNormalPointer_t f) { glNormalPointer_t retval = glNormalPointer; glNormalPointer = f; return retval;} + glOrthox_t set_glOrthox(glOrthox_t f) { glOrthox_t retval = glOrthox; glOrthox = f; return retval;} + glPixelStorei_t set_glPixelStorei(glPixelStorei_t f) { glPixelStorei_t retval = glPixelStorei; glPixelStorei = f; return retval;} + glPointParameterx_t set_glPointParameterx(glPointParameterx_t f) { glPointParameterx_t retval = glPointParameterx; glPointParameterx = f; return retval;} + glPointParameterxv_t set_glPointParameterxv(glPointParameterxv_t f) { glPointParameterxv_t retval = glPointParameterxv; glPointParameterxv = f; return retval;} + glPointSizex_t set_glPointSizex(glPointSizex_t f) { glPointSizex_t retval = glPointSizex; glPointSizex = f; return retval;} + glPolygonOffsetx_t set_glPolygonOffsetx(glPolygonOffsetx_t f) { glPolygonOffsetx_t retval = glPolygonOffsetx; glPolygonOffsetx = f; return retval;} + glPopMatrix_t set_glPopMatrix(glPopMatrix_t f) { glPopMatrix_t retval = glPopMatrix; glPopMatrix = f; return retval;} + glPushMatrix_t set_glPushMatrix(glPushMatrix_t f) { glPushMatrix_t retval = glPushMatrix; glPushMatrix = f; return retval;} + glReadPixels_t set_glReadPixels(glReadPixels_t f) { glReadPixels_t retval = glReadPixels; glReadPixels = f; return retval;} + glRotatex_t set_glRotatex(glRotatex_t f) { glRotatex_t retval = glRotatex; glRotatex = f; return retval;} + glSampleCoverage_t set_glSampleCoverage(glSampleCoverage_t f) { glSampleCoverage_t retval = glSampleCoverage; glSampleCoverage = f; return retval;} + glSampleCoveragex_t set_glSampleCoveragex(glSampleCoveragex_t f) { glSampleCoveragex_t retval = glSampleCoveragex; glSampleCoveragex = f; return retval;} + glScalex_t set_glScalex(glScalex_t f) { glScalex_t retval = glScalex; glScalex = f; return retval;} + glScissor_t set_glScissor(glScissor_t f) { glScissor_t retval = glScissor; glScissor = f; return retval;} + glShadeModel_t set_glShadeModel(glShadeModel_t f) { glShadeModel_t retval = glShadeModel; glShadeModel = f; return retval;} + glStencilFunc_t set_glStencilFunc(glStencilFunc_t f) { glStencilFunc_t retval = glStencilFunc; glStencilFunc = f; return retval;} + glStencilMask_t set_glStencilMask(glStencilMask_t f) { glStencilMask_t retval = glStencilMask; glStencilMask = f; return retval;} + glStencilOp_t set_glStencilOp(glStencilOp_t f) { glStencilOp_t retval = glStencilOp; glStencilOp = f; return retval;} + glTexCoordPointer_t set_glTexCoordPointer(glTexCoordPointer_t f) { glTexCoordPointer_t retval = glTexCoordPointer; glTexCoordPointer = f; return retval;} + glTexEnvi_t set_glTexEnvi(glTexEnvi_t f) { glTexEnvi_t retval = glTexEnvi; glTexEnvi = f; return retval;} + glTexEnvx_t set_glTexEnvx(glTexEnvx_t f) { glTexEnvx_t retval = glTexEnvx; glTexEnvx = f; return retval;} + glTexEnviv_t set_glTexEnviv(glTexEnviv_t f) { glTexEnviv_t retval = glTexEnviv; glTexEnviv = f; return retval;} + glTexEnvxv_t set_glTexEnvxv(glTexEnvxv_t f) { glTexEnvxv_t retval = glTexEnvxv; glTexEnvxv = f; return retval;} + glTexImage2D_t set_glTexImage2D(glTexImage2D_t f) { glTexImage2D_t retval = glTexImage2D; glTexImage2D = f; return retval;} + glTexParameteri_t set_glTexParameteri(glTexParameteri_t f) { glTexParameteri_t retval = glTexParameteri; glTexParameteri = f; return retval;} + glTexParameterx_t set_glTexParameterx(glTexParameterx_t f) { glTexParameterx_t retval = glTexParameterx; glTexParameterx = f; return retval;} + glTexParameteriv_t set_glTexParameteriv(glTexParameteriv_t f) { glTexParameteriv_t retval = glTexParameteriv; glTexParameteriv = f; return retval;} + glTexParameterxv_t set_glTexParameterxv(glTexParameterxv_t f) { glTexParameterxv_t retval = glTexParameterxv; glTexParameterxv = f; return retval;} + glTexSubImage2D_t set_glTexSubImage2D(glTexSubImage2D_t f) { glTexSubImage2D_t retval = glTexSubImage2D; glTexSubImage2D = f; return retval;} + glTranslatex_t set_glTranslatex(glTranslatex_t f) { glTranslatex_t retval = glTranslatex; glTranslatex = f; return retval;} + glVertexPointer_t set_glVertexPointer(glVertexPointer_t f) { glVertexPointer_t retval = glVertexPointer; glVertexPointer = f; return retval;} + glViewport_t set_glViewport(glViewport_t f) { glViewport_t retval = glViewport; glViewport = f; return retval;} + glPointSizePointerOES_t set_glPointSizePointerOES(glPointSizePointerOES_t f) { glPointSizePointerOES_t retval = glPointSizePointerOES; glPointSizePointerOES = f; return retval;} + glBlendEquationSeparateOES_t set_glBlendEquationSeparateOES(glBlendEquationSeparateOES_t f) { glBlendEquationSeparateOES_t retval = glBlendEquationSeparateOES; glBlendEquationSeparateOES = f; return retval;} + glBlendFuncSeparateOES_t set_glBlendFuncSeparateOES(glBlendFuncSeparateOES_t f) { glBlendFuncSeparateOES_t retval = glBlendFuncSeparateOES; glBlendFuncSeparateOES = f; return retval;} + glBlendEquationOES_t set_glBlendEquationOES(glBlendEquationOES_t f) { glBlendEquationOES_t retval = glBlendEquationOES; glBlendEquationOES = f; return retval;} + glDrawTexsOES_t set_glDrawTexsOES(glDrawTexsOES_t f) { glDrawTexsOES_t retval = glDrawTexsOES; glDrawTexsOES = f; return retval;} + glDrawTexiOES_t set_glDrawTexiOES(glDrawTexiOES_t f) { glDrawTexiOES_t retval = glDrawTexiOES; glDrawTexiOES = f; return retval;} + glDrawTexxOES_t set_glDrawTexxOES(glDrawTexxOES_t f) { glDrawTexxOES_t retval = glDrawTexxOES; glDrawTexxOES = f; return retval;} + glDrawTexsvOES_t set_glDrawTexsvOES(glDrawTexsvOES_t f) { glDrawTexsvOES_t retval = glDrawTexsvOES; glDrawTexsvOES = f; return retval;} + glDrawTexivOES_t set_glDrawTexivOES(glDrawTexivOES_t f) { glDrawTexivOES_t retval = glDrawTexivOES; glDrawTexivOES = f; return retval;} + glDrawTexxvOES_t set_glDrawTexxvOES(glDrawTexxvOES_t f) { glDrawTexxvOES_t retval = glDrawTexxvOES; glDrawTexxvOES = f; return retval;} + glDrawTexfOES_t set_glDrawTexfOES(glDrawTexfOES_t f) { glDrawTexfOES_t retval = glDrawTexfOES; glDrawTexfOES = f; return retval;} + glDrawTexfvOES_t set_glDrawTexfvOES(glDrawTexfvOES_t f) { glDrawTexfvOES_t retval = glDrawTexfvOES; glDrawTexfvOES = f; return retval;} + glEGLImageTargetTexture2DOES_t set_glEGLImageTargetTexture2DOES(glEGLImageTargetTexture2DOES_t f) { glEGLImageTargetTexture2DOES_t retval = glEGLImageTargetTexture2DOES; glEGLImageTargetTexture2DOES = f; return retval;} + glEGLImageTargetRenderbufferStorageOES_t set_glEGLImageTargetRenderbufferStorageOES(glEGLImageTargetRenderbufferStorageOES_t f) { glEGLImageTargetRenderbufferStorageOES_t retval = glEGLImageTargetRenderbufferStorageOES; glEGLImageTargetRenderbufferStorageOES = f; return retval;} + glAlphaFuncxOES_t set_glAlphaFuncxOES(glAlphaFuncxOES_t f) { glAlphaFuncxOES_t retval = glAlphaFuncxOES; glAlphaFuncxOES = f; return retval;} + glClearColorxOES_t set_glClearColorxOES(glClearColorxOES_t f) { glClearColorxOES_t retval = glClearColorxOES; glClearColorxOES = f; return retval;} + glClearDepthxOES_t set_glClearDepthxOES(glClearDepthxOES_t f) { glClearDepthxOES_t retval = glClearDepthxOES; glClearDepthxOES = f; return retval;} + glClipPlanexOES_t set_glClipPlanexOES(glClipPlanexOES_t f) { glClipPlanexOES_t retval = glClipPlanexOES; glClipPlanexOES = f; return retval;} + glColor4xOES_t set_glColor4xOES(glColor4xOES_t f) { glColor4xOES_t retval = glColor4xOES; glColor4xOES = f; return retval;} + glDepthRangexOES_t set_glDepthRangexOES(glDepthRangexOES_t f) { glDepthRangexOES_t retval = glDepthRangexOES; glDepthRangexOES = f; return retval;} + glFogxOES_t set_glFogxOES(glFogxOES_t f) { glFogxOES_t retval = glFogxOES; glFogxOES = f; return retval;} + glFogxvOES_t set_glFogxvOES(glFogxvOES_t f) { glFogxvOES_t retval = glFogxvOES; glFogxvOES = f; return retval;} + glFrustumxOES_t set_glFrustumxOES(glFrustumxOES_t f) { glFrustumxOES_t retval = glFrustumxOES; glFrustumxOES = f; return retval;} + glGetClipPlanexOES_t set_glGetClipPlanexOES(glGetClipPlanexOES_t f) { glGetClipPlanexOES_t retval = glGetClipPlanexOES; glGetClipPlanexOES = f; return retval;} + glGetFixedvOES_t set_glGetFixedvOES(glGetFixedvOES_t f) { glGetFixedvOES_t retval = glGetFixedvOES; glGetFixedvOES = f; return retval;} + glGetLightxvOES_t set_glGetLightxvOES(glGetLightxvOES_t f) { glGetLightxvOES_t retval = glGetLightxvOES; glGetLightxvOES = f; return retval;} + glGetMaterialxvOES_t set_glGetMaterialxvOES(glGetMaterialxvOES_t f) { glGetMaterialxvOES_t retval = glGetMaterialxvOES; glGetMaterialxvOES = f; return retval;} + glGetTexEnvxvOES_t set_glGetTexEnvxvOES(glGetTexEnvxvOES_t f) { glGetTexEnvxvOES_t retval = glGetTexEnvxvOES; glGetTexEnvxvOES = f; return retval;} + glGetTexParameterxvOES_t set_glGetTexParameterxvOES(glGetTexParameterxvOES_t f) { glGetTexParameterxvOES_t retval = glGetTexParameterxvOES; glGetTexParameterxvOES = f; return retval;} + glLightModelxOES_t set_glLightModelxOES(glLightModelxOES_t f) { glLightModelxOES_t retval = glLightModelxOES; glLightModelxOES = f; return retval;} + glLightModelxvOES_t set_glLightModelxvOES(glLightModelxvOES_t f) { glLightModelxvOES_t retval = glLightModelxvOES; glLightModelxvOES = f; return retval;} + glLightxOES_t set_glLightxOES(glLightxOES_t f) { glLightxOES_t retval = glLightxOES; glLightxOES = f; return retval;} + glLightxvOES_t set_glLightxvOES(glLightxvOES_t f) { glLightxvOES_t retval = glLightxvOES; glLightxvOES = f; return retval;} + glLineWidthxOES_t set_glLineWidthxOES(glLineWidthxOES_t f) { glLineWidthxOES_t retval = glLineWidthxOES; glLineWidthxOES = f; return retval;} + glLoadMatrixxOES_t set_glLoadMatrixxOES(glLoadMatrixxOES_t f) { glLoadMatrixxOES_t retval = glLoadMatrixxOES; glLoadMatrixxOES = f; return retval;} + glMaterialxOES_t set_glMaterialxOES(glMaterialxOES_t f) { glMaterialxOES_t retval = glMaterialxOES; glMaterialxOES = f; return retval;} + glMaterialxvOES_t set_glMaterialxvOES(glMaterialxvOES_t f) { glMaterialxvOES_t retval = glMaterialxvOES; glMaterialxvOES = f; return retval;} + glMultMatrixxOES_t set_glMultMatrixxOES(glMultMatrixxOES_t f) { glMultMatrixxOES_t retval = glMultMatrixxOES; glMultMatrixxOES = f; return retval;} + glMultiTexCoord4xOES_t set_glMultiTexCoord4xOES(glMultiTexCoord4xOES_t f) { glMultiTexCoord4xOES_t retval = glMultiTexCoord4xOES; glMultiTexCoord4xOES = f; return retval;} + glNormal3xOES_t set_glNormal3xOES(glNormal3xOES_t f) { glNormal3xOES_t retval = glNormal3xOES; glNormal3xOES = f; return retval;} + glOrthoxOES_t set_glOrthoxOES(glOrthoxOES_t f) { glOrthoxOES_t retval = glOrthoxOES; glOrthoxOES = f; return retval;} + glPointParameterxOES_t set_glPointParameterxOES(glPointParameterxOES_t f) { glPointParameterxOES_t retval = glPointParameterxOES; glPointParameterxOES = f; return retval;} + glPointParameterxvOES_t set_glPointParameterxvOES(glPointParameterxvOES_t f) { glPointParameterxvOES_t retval = glPointParameterxvOES; glPointParameterxvOES = f; return retval;} + glPointSizexOES_t set_glPointSizexOES(glPointSizexOES_t f) { glPointSizexOES_t retval = glPointSizexOES; glPointSizexOES = f; return retval;} + glPolygonOffsetxOES_t set_glPolygonOffsetxOES(glPolygonOffsetxOES_t f) { glPolygonOffsetxOES_t retval = glPolygonOffsetxOES; glPolygonOffsetxOES = f; return retval;} + glRotatexOES_t set_glRotatexOES(glRotatexOES_t f) { glRotatexOES_t retval = glRotatexOES; glRotatexOES = f; return retval;} + glSampleCoveragexOES_t set_glSampleCoveragexOES(glSampleCoveragexOES_t f) { glSampleCoveragexOES_t retval = glSampleCoveragexOES; glSampleCoveragexOES = f; return retval;} + glScalexOES_t set_glScalexOES(glScalexOES_t f) { glScalexOES_t retval = glScalexOES; glScalexOES = f; return retval;} + glTexEnvxOES_t set_glTexEnvxOES(glTexEnvxOES_t f) { glTexEnvxOES_t retval = glTexEnvxOES; glTexEnvxOES = f; return retval;} + glTexEnvxvOES_t set_glTexEnvxvOES(glTexEnvxvOES_t f) { glTexEnvxvOES_t retval = glTexEnvxvOES; glTexEnvxvOES = f; return retval;} + glTexParameterxOES_t set_glTexParameterxOES(glTexParameterxOES_t f) { glTexParameterxOES_t retval = glTexParameterxOES; glTexParameterxOES = f; return retval;} + glTexParameterxvOES_t set_glTexParameterxvOES(glTexParameterxvOES_t f) { glTexParameterxvOES_t retval = glTexParameterxvOES; glTexParameterxvOES = f; return retval;} + glTranslatexOES_t set_glTranslatexOES(glTranslatexOES_t f) { glTranslatexOES_t retval = glTranslatexOES; glTranslatexOES = f; return retval;} + glIsRenderbufferOES_t set_glIsRenderbufferOES(glIsRenderbufferOES_t f) { glIsRenderbufferOES_t retval = glIsRenderbufferOES; glIsRenderbufferOES = f; return retval;} + glBindRenderbufferOES_t set_glBindRenderbufferOES(glBindRenderbufferOES_t f) { glBindRenderbufferOES_t retval = glBindRenderbufferOES; glBindRenderbufferOES = f; return retval;} + glDeleteRenderbuffersOES_t set_glDeleteRenderbuffersOES(glDeleteRenderbuffersOES_t f) { glDeleteRenderbuffersOES_t retval = glDeleteRenderbuffersOES; glDeleteRenderbuffersOES = f; return retval;} + glGenRenderbuffersOES_t set_glGenRenderbuffersOES(glGenRenderbuffersOES_t f) { glGenRenderbuffersOES_t retval = glGenRenderbuffersOES; glGenRenderbuffersOES = f; return retval;} + glRenderbufferStorageOES_t set_glRenderbufferStorageOES(glRenderbufferStorageOES_t f) { glRenderbufferStorageOES_t retval = glRenderbufferStorageOES; glRenderbufferStorageOES = f; return retval;} + glGetRenderbufferParameterivOES_t set_glGetRenderbufferParameterivOES(glGetRenderbufferParameterivOES_t f) { glGetRenderbufferParameterivOES_t retval = glGetRenderbufferParameterivOES; glGetRenderbufferParameterivOES = f; return retval;} + glIsFramebufferOES_t set_glIsFramebufferOES(glIsFramebufferOES_t f) { glIsFramebufferOES_t retval = glIsFramebufferOES; glIsFramebufferOES = f; return retval;} + glBindFramebufferOES_t set_glBindFramebufferOES(glBindFramebufferOES_t f) { glBindFramebufferOES_t retval = glBindFramebufferOES; glBindFramebufferOES = f; return retval;} + glDeleteFramebuffersOES_t set_glDeleteFramebuffersOES(glDeleteFramebuffersOES_t f) { glDeleteFramebuffersOES_t retval = glDeleteFramebuffersOES; glDeleteFramebuffersOES = f; return retval;} + glGenFramebuffersOES_t set_glGenFramebuffersOES(glGenFramebuffersOES_t f) { glGenFramebuffersOES_t retval = glGenFramebuffersOES; glGenFramebuffersOES = f; return retval;} + glCheckFramebufferStatusOES_t set_glCheckFramebufferStatusOES(glCheckFramebufferStatusOES_t f) { glCheckFramebufferStatusOES_t retval = glCheckFramebufferStatusOES; glCheckFramebufferStatusOES = f; return retval;} + glFramebufferRenderbufferOES_t set_glFramebufferRenderbufferOES(glFramebufferRenderbufferOES_t f) { glFramebufferRenderbufferOES_t retval = glFramebufferRenderbufferOES; glFramebufferRenderbufferOES = f; return retval;} + glFramebufferTexture2DOES_t set_glFramebufferTexture2DOES(glFramebufferTexture2DOES_t f) { glFramebufferTexture2DOES_t retval = glFramebufferTexture2DOES; glFramebufferTexture2DOES = f; return retval;} + glGetFramebufferAttachmentParameterivOES_t set_glGetFramebufferAttachmentParameterivOES(glGetFramebufferAttachmentParameterivOES_t f) { glGetFramebufferAttachmentParameterivOES_t retval = glGetFramebufferAttachmentParameterivOES; glGetFramebufferAttachmentParameterivOES = f; return retval;} + glGenerateMipmapOES_t set_glGenerateMipmapOES(glGenerateMipmapOES_t f) { glGenerateMipmapOES_t retval = glGenerateMipmapOES; glGenerateMipmapOES = f; return retval;} + glMapBufferOES_t set_glMapBufferOES(glMapBufferOES_t f) { glMapBufferOES_t retval = glMapBufferOES; glMapBufferOES = f; return retval;} + glUnmapBufferOES_t set_glUnmapBufferOES(glUnmapBufferOES_t f) { glUnmapBufferOES_t retval = glUnmapBufferOES; glUnmapBufferOES = f; return retval;} + glGetBufferPointervOES_t set_glGetBufferPointervOES(glGetBufferPointervOES_t f) { glGetBufferPointervOES_t retval = glGetBufferPointervOES; glGetBufferPointervOES = f; return retval;} + glCurrentPaletteMatrixOES_t set_glCurrentPaletteMatrixOES(glCurrentPaletteMatrixOES_t f) { glCurrentPaletteMatrixOES_t retval = glCurrentPaletteMatrixOES; glCurrentPaletteMatrixOES = f; return retval;} + glLoadPaletteFromModelViewMatrixOES_t set_glLoadPaletteFromModelViewMatrixOES(glLoadPaletteFromModelViewMatrixOES_t f) { glLoadPaletteFromModelViewMatrixOES_t retval = glLoadPaletteFromModelViewMatrixOES; glLoadPaletteFromModelViewMatrixOES = f; return retval;} + glMatrixIndexPointerOES_t set_glMatrixIndexPointerOES(glMatrixIndexPointerOES_t f) { glMatrixIndexPointerOES_t retval = glMatrixIndexPointerOES; glMatrixIndexPointerOES = f; return retval;} + glWeightPointerOES_t set_glWeightPointerOES(glWeightPointerOES_t f) { glWeightPointerOES_t retval = glWeightPointerOES; glWeightPointerOES = f; return retval;} + glQueryMatrixxOES_t set_glQueryMatrixxOES(glQueryMatrixxOES_t f) { glQueryMatrixxOES_t retval = glQueryMatrixxOES; glQueryMatrixxOES = f; return retval;} + glDepthRangefOES_t set_glDepthRangefOES(glDepthRangefOES_t f) { glDepthRangefOES_t retval = glDepthRangefOES; glDepthRangefOES = f; return retval;} + glFrustumfOES_t set_glFrustumfOES(glFrustumfOES_t f) { glFrustumfOES_t retval = glFrustumfOES; glFrustumfOES = f; return retval;} + glOrthofOES_t set_glOrthofOES(glOrthofOES_t f) { glOrthofOES_t retval = glOrthofOES; glOrthofOES = f; return retval;} + glClipPlanefOES_t set_glClipPlanefOES(glClipPlanefOES_t f) { glClipPlanefOES_t retval = glClipPlanefOES; glClipPlanefOES = f; return retval;} + glGetClipPlanefOES_t set_glGetClipPlanefOES(glGetClipPlanefOES_t f) { glGetClipPlanefOES_t retval = glGetClipPlanefOES; glGetClipPlanefOES = f; return retval;} + glClearDepthfOES_t set_glClearDepthfOES(glClearDepthfOES_t f) { glClearDepthfOES_t retval = glClearDepthfOES; glClearDepthfOES = f; return retval;} + glTexGenfOES_t set_glTexGenfOES(glTexGenfOES_t f) { glTexGenfOES_t retval = glTexGenfOES; glTexGenfOES = f; return retval;} + glTexGenfvOES_t set_glTexGenfvOES(glTexGenfvOES_t f) { glTexGenfvOES_t retval = glTexGenfvOES; glTexGenfvOES = f; return retval;} + glTexGeniOES_t set_glTexGeniOES(glTexGeniOES_t f) { glTexGeniOES_t retval = glTexGeniOES; glTexGeniOES = f; return retval;} + glTexGenivOES_t set_glTexGenivOES(glTexGenivOES_t f) { glTexGenivOES_t retval = glTexGenivOES; glTexGenivOES = f; return retval;} + glTexGenxOES_t set_glTexGenxOES(glTexGenxOES_t f) { glTexGenxOES_t retval = glTexGenxOES; glTexGenxOES = f; return retval;} + glTexGenxvOES_t set_glTexGenxvOES(glTexGenxvOES_t f) { glTexGenxvOES_t retval = glTexGenxvOES; glTexGenxvOES = f; return retval;} + glGetTexGenfvOES_t set_glGetTexGenfvOES(glGetTexGenfvOES_t f) { glGetTexGenfvOES_t retval = glGetTexGenfvOES; glGetTexGenfvOES = f; return retval;} + glGetTexGenivOES_t set_glGetTexGenivOES(glGetTexGenivOES_t f) { glGetTexGenivOES_t retval = glGetTexGenivOES; glGetTexGenivOES = f; return retval;} + glGetTexGenxvOES_t set_glGetTexGenxvOES(glGetTexGenxvOES_t f) { glGetTexGenxvOES_t retval = glGetTexGenxvOES; glGetTexGenxvOES = f; return retval;} + glBindVertexArrayOES_t set_glBindVertexArrayOES(glBindVertexArrayOES_t f) { glBindVertexArrayOES_t retval = glBindVertexArrayOES; glBindVertexArrayOES = f; return retval;} + glDeleteVertexArraysOES_t set_glDeleteVertexArraysOES(glDeleteVertexArraysOES_t f) { glDeleteVertexArraysOES_t retval = glDeleteVertexArraysOES; glDeleteVertexArraysOES = f; return retval;} + glGenVertexArraysOES_t set_glGenVertexArraysOES(glGenVertexArraysOES_t f) { glGenVertexArraysOES_t retval = glGenVertexArraysOES; glGenVertexArraysOES = f; return retval;} + glIsVertexArrayOES_t set_glIsVertexArrayOES(glIsVertexArrayOES_t f) { glIsVertexArrayOES_t retval = glIsVertexArrayOES; glIsVertexArrayOES = f; return retval;} + glDiscardFramebufferEXT_t set_glDiscardFramebufferEXT(glDiscardFramebufferEXT_t f) { glDiscardFramebufferEXT_t retval = glDiscardFramebufferEXT; glDiscardFramebufferEXT = f; return retval;} + glMultiDrawArraysEXT_t set_glMultiDrawArraysEXT(glMultiDrawArraysEXT_t f) { glMultiDrawArraysEXT_t retval = glMultiDrawArraysEXT; glMultiDrawArraysEXT = f; return retval;} + glMultiDrawElementsEXT_t set_glMultiDrawElementsEXT(glMultiDrawElementsEXT_t f) { glMultiDrawElementsEXT_t retval = glMultiDrawElementsEXT; glMultiDrawElementsEXT = f; return retval;} + glClipPlanefIMG_t set_glClipPlanefIMG(glClipPlanefIMG_t f) { glClipPlanefIMG_t retval = glClipPlanefIMG; glClipPlanefIMG = f; return retval;} + glClipPlanexIMG_t set_glClipPlanexIMG(glClipPlanexIMG_t f) { glClipPlanexIMG_t retval = glClipPlanexIMG; glClipPlanexIMG = f; return retval;} + glRenderbufferStorageMultisampleIMG_t set_glRenderbufferStorageMultisampleIMG(glRenderbufferStorageMultisampleIMG_t f) { glRenderbufferStorageMultisampleIMG_t retval = glRenderbufferStorageMultisampleIMG; glRenderbufferStorageMultisampleIMG = f; return retval;} + glFramebufferTexture2DMultisampleIMG_t set_glFramebufferTexture2DMultisampleIMG(glFramebufferTexture2DMultisampleIMG_t f) { glFramebufferTexture2DMultisampleIMG_t retval = glFramebufferTexture2DMultisampleIMG; glFramebufferTexture2DMultisampleIMG = f; return retval;} + glDeleteFencesNV_t set_glDeleteFencesNV(glDeleteFencesNV_t f) { glDeleteFencesNV_t retval = glDeleteFencesNV; glDeleteFencesNV = f; return retval;} + glGenFencesNV_t set_glGenFencesNV(glGenFencesNV_t f) { glGenFencesNV_t retval = glGenFencesNV; glGenFencesNV = f; return retval;} + glIsFenceNV_t set_glIsFenceNV(glIsFenceNV_t f) { glIsFenceNV_t retval = glIsFenceNV; glIsFenceNV = f; return retval;} + glTestFenceNV_t set_glTestFenceNV(glTestFenceNV_t f) { glTestFenceNV_t retval = glTestFenceNV; glTestFenceNV = f; return retval;} + glGetFenceivNV_t set_glGetFenceivNV(glGetFenceivNV_t f) { glGetFenceivNV_t retval = glGetFenceivNV; glGetFenceivNV = f; return retval;} + glFinishFenceNV_t set_glFinishFenceNV(glFinishFenceNV_t f) { glFinishFenceNV_t retval = glFinishFenceNV; glFinishFenceNV = f; return retval;} + glSetFenceNV_t set_glSetFenceNV(glSetFenceNV_t f) { glSetFenceNV_t retval = glSetFenceNV; glSetFenceNV = f; return retval;} + glGetDriverControlsQCOM_t set_glGetDriverControlsQCOM(glGetDriverControlsQCOM_t f) { glGetDriverControlsQCOM_t retval = glGetDriverControlsQCOM; glGetDriverControlsQCOM = f; return retval;} + glGetDriverControlStringQCOM_t set_glGetDriverControlStringQCOM(glGetDriverControlStringQCOM_t f) { glGetDriverControlStringQCOM_t retval = glGetDriverControlStringQCOM; glGetDriverControlStringQCOM = f; return retval;} + glEnableDriverControlQCOM_t set_glEnableDriverControlQCOM(glEnableDriverControlQCOM_t f) { glEnableDriverControlQCOM_t retval = glEnableDriverControlQCOM; glEnableDriverControlQCOM = f; return retval;} + glDisableDriverControlQCOM_t set_glDisableDriverControlQCOM(glDisableDriverControlQCOM_t f) { glDisableDriverControlQCOM_t retval = glDisableDriverControlQCOM; glDisableDriverControlQCOM = f; return retval;} + glExtGetTexturesQCOM_t set_glExtGetTexturesQCOM(glExtGetTexturesQCOM_t f) { glExtGetTexturesQCOM_t retval = glExtGetTexturesQCOM; glExtGetTexturesQCOM = f; return retval;} + glExtGetBuffersQCOM_t set_glExtGetBuffersQCOM(glExtGetBuffersQCOM_t f) { glExtGetBuffersQCOM_t retval = glExtGetBuffersQCOM; glExtGetBuffersQCOM = f; return retval;} + glExtGetRenderbuffersQCOM_t set_glExtGetRenderbuffersQCOM(glExtGetRenderbuffersQCOM_t f) { glExtGetRenderbuffersQCOM_t retval = glExtGetRenderbuffersQCOM; glExtGetRenderbuffersQCOM = f; return retval;} + glExtGetFramebuffersQCOM_t set_glExtGetFramebuffersQCOM(glExtGetFramebuffersQCOM_t f) { glExtGetFramebuffersQCOM_t retval = glExtGetFramebuffersQCOM; glExtGetFramebuffersQCOM = f; return retval;} + glExtGetTexLevelParameterivQCOM_t set_glExtGetTexLevelParameterivQCOM(glExtGetTexLevelParameterivQCOM_t f) { glExtGetTexLevelParameterivQCOM_t retval = glExtGetTexLevelParameterivQCOM; glExtGetTexLevelParameterivQCOM = f; return retval;} + glExtTexObjectStateOverrideiQCOM_t set_glExtTexObjectStateOverrideiQCOM(glExtTexObjectStateOverrideiQCOM_t f) { glExtTexObjectStateOverrideiQCOM_t retval = glExtTexObjectStateOverrideiQCOM; glExtTexObjectStateOverrideiQCOM = f; return retval;} + glExtGetTexSubImageQCOM_t set_glExtGetTexSubImageQCOM(glExtGetTexSubImageQCOM_t f) { glExtGetTexSubImageQCOM_t retval = glExtGetTexSubImageQCOM; glExtGetTexSubImageQCOM = f; return retval;} + glExtGetBufferPointervQCOM_t set_glExtGetBufferPointervQCOM(glExtGetBufferPointervQCOM_t f) { glExtGetBufferPointervQCOM_t retval = glExtGetBufferPointervQCOM; glExtGetBufferPointervQCOM = f; return retval;} + glExtGetShadersQCOM_t set_glExtGetShadersQCOM(glExtGetShadersQCOM_t f) { glExtGetShadersQCOM_t retval = glExtGetShadersQCOM; glExtGetShadersQCOM = f; return retval;} + glExtGetProgramsQCOM_t set_glExtGetProgramsQCOM(glExtGetProgramsQCOM_t f) { glExtGetProgramsQCOM_t retval = glExtGetProgramsQCOM; glExtGetProgramsQCOM = f; return retval;} + glExtIsProgramBinaryQCOM_t set_glExtIsProgramBinaryQCOM(glExtIsProgramBinaryQCOM_t f) { glExtIsProgramBinaryQCOM_t retval = glExtIsProgramBinaryQCOM; glExtIsProgramBinaryQCOM = f; return retval;} + glExtGetProgramBinarySourceQCOM_t set_glExtGetProgramBinarySourceQCOM(glExtGetProgramBinarySourceQCOM_t f) { glExtGetProgramBinarySourceQCOM_t retval = glExtGetProgramBinarySourceQCOM; glExtGetProgramBinarySourceQCOM = f; return retval;} + glStartTilingQCOM_t set_glStartTilingQCOM(glStartTilingQCOM_t f) { glStartTilingQCOM_t retval = glStartTilingQCOM; glStartTilingQCOM = f; return retval;} + glEndTilingQCOM_t set_glEndTilingQCOM(glEndTilingQCOM_t f) { glEndTilingQCOM_t retval = glEndTilingQCOM; glEndTilingQCOM = f; return retval;} +}; + +gles_dispatch *create_gles_dispatch(void *gles_andorid); + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_emul.cfg b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_emul.cfg new file mode 100644 index 0000000..a837807 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_emul.cfg @@ -0,0 +1,7 @@ +angeles +my-tritex +org.zeroxlab.benchmark +com.cooliris.media +com.polarbit.waveblazerlite +test-opengl-gl2_basic +com.trendy.ddapp diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_ftable.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_ftable.h new file mode 100644 index 0000000..1895b18 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_ftable.h @@ -0,0 +1,292 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +static struct _gles_funcs_by_name { + const char *name; + void *proc; +} gles_funcs_by_name[] = { + {"glAlphaFunc", (void *)glAlphaFunc}, + {"glClearColor", (void *)glClearColor}, + {"glClearDepthf", (void *)glClearDepthf}, + {"glClipPlanef", (void *)glClipPlanef}, + {"glColor4f", (void *)glColor4f}, + {"glDepthRangef", (void *)glDepthRangef}, + {"glFogf", (void *)glFogf}, + {"glFogfv", (void *)glFogfv}, + {"glFrustumf", (void *)glFrustumf}, + {"glGetClipPlanef", (void *)glGetClipPlanef}, + {"glGetFloatv", (void *)glGetFloatv}, + {"glGetLightfv", (void *)glGetLightfv}, + {"glGetMaterialfv", (void *)glGetMaterialfv}, + {"glGetTexEnvfv", (void *)glGetTexEnvfv}, + {"glGetTexParameterfv", (void *)glGetTexParameterfv}, + {"glLightModelf", (void *)glLightModelf}, + {"glLightModelfv", (void *)glLightModelfv}, + {"glLightf", (void *)glLightf}, + {"glLightfv", (void *)glLightfv}, + {"glLineWidth", (void *)glLineWidth}, + {"glLoadMatrixf", (void *)glLoadMatrixf}, + {"glMaterialf", (void *)glMaterialf}, + {"glMaterialfv", (void *)glMaterialfv}, + {"glMultMatrixf", (void *)glMultMatrixf}, + {"glMultiTexCoord4f", (void *)glMultiTexCoord4f}, + {"glNormal3f", (void *)glNormal3f}, + {"glOrthof", (void *)glOrthof}, + {"glPointParameterf", (void *)glPointParameterf}, + {"glPointParameterfv", (void *)glPointParameterfv}, + {"glPointSize", (void *)glPointSize}, + {"glPolygonOffset", (void *)glPolygonOffset}, + {"glRotatef", (void *)glRotatef}, + {"glScalef", (void *)glScalef}, + {"glTexEnvf", (void *)glTexEnvf}, + {"glTexEnvfv", (void *)glTexEnvfv}, + {"glTexParameterf", (void *)glTexParameterf}, + {"glTexParameterfv", (void *)glTexParameterfv}, + {"glTranslatef", (void *)glTranslatef}, + {"glActiveTexture", (void *)glActiveTexture}, + {"glAlphaFuncx", (void *)glAlphaFuncx}, + {"glBindBuffer", (void *)glBindBuffer}, + {"glBindTexture", (void *)glBindTexture}, + {"glBlendFunc", (void *)glBlendFunc}, + {"glBufferData", (void *)glBufferData}, + {"glBufferSubData", (void *)glBufferSubData}, + {"glClear", (void *)glClear}, + {"glClearColorx", (void *)glClearColorx}, + {"glClearDepthx", (void *)glClearDepthx}, + {"glClearStencil", (void *)glClearStencil}, + {"glClientActiveTexture", (void *)glClientActiveTexture}, + {"glClipPlanex", (void *)glClipPlanex}, + {"glColor4ub", (void *)glColor4ub}, + {"glColor4x", (void *)glColor4x}, + {"glColorMask", (void *)glColorMask}, + {"glColorPointer", (void *)glColorPointer}, + {"glCompressedTexImage2D", (void *)glCompressedTexImage2D}, + {"glCompressedTexSubImage2D", (void *)glCompressedTexSubImage2D}, + {"glCopyTexImage2D", (void *)glCopyTexImage2D}, + {"glCopyTexSubImage2D", (void *)glCopyTexSubImage2D}, + {"glCullFace", (void *)glCullFace}, + {"glDeleteBuffers", (void *)glDeleteBuffers}, + {"glDeleteTextures", (void *)glDeleteTextures}, + {"glDepthFunc", (void *)glDepthFunc}, + {"glDepthMask", (void *)glDepthMask}, + {"glDepthRangex", (void *)glDepthRangex}, + {"glDisable", (void *)glDisable}, + {"glDisableClientState", (void *)glDisableClientState}, + {"glDrawArrays", (void *)glDrawArrays}, + {"glDrawElements", (void *)glDrawElements}, + {"glEnable", (void *)glEnable}, + {"glEnableClientState", (void *)glEnableClientState}, + {"glFinish", (void *)glFinish}, + {"glFlush", (void *)glFlush}, + {"glFogx", (void *)glFogx}, + {"glFogxv", (void *)glFogxv}, + {"glFrontFace", (void *)glFrontFace}, + {"glFrustumx", (void *)glFrustumx}, + {"glGetBooleanv", (void *)glGetBooleanv}, + {"glGetBufferParameteriv", (void *)glGetBufferParameteriv}, + {"glGetClipPlanex", (void *)glGetClipPlanex}, + {"glGenBuffers", (void *)glGenBuffers}, + {"glGenTextures", (void *)glGenTextures}, + {"glGetError", (void *)glGetError}, + {"glGetFixedv", (void *)glGetFixedv}, + {"glGetIntegerv", (void *)glGetIntegerv}, + {"glGetLightxv", (void *)glGetLightxv}, + {"glGetMaterialxv", (void *)glGetMaterialxv}, + {"glGetPointerv", (void *)glGetPointerv}, + {"glGetString", (void *)glGetString}, + {"glGetTexEnviv", (void *)glGetTexEnviv}, + {"glGetTexEnvxv", (void *)glGetTexEnvxv}, + {"glGetTexParameteriv", (void *)glGetTexParameteriv}, + {"glGetTexParameterxv", (void *)glGetTexParameterxv}, + {"glHint", (void *)glHint}, + {"glIsBuffer", (void *)glIsBuffer}, + {"glIsEnabled", (void *)glIsEnabled}, + {"glIsTexture", (void *)glIsTexture}, + {"glLightModelx", (void *)glLightModelx}, + {"glLightModelxv", (void *)glLightModelxv}, + {"glLightx", (void *)glLightx}, + {"glLightxv", (void *)glLightxv}, + {"glLineWidthx", (void *)glLineWidthx}, + {"glLoadIdentity", (void *)glLoadIdentity}, + {"glLoadMatrixx", (void *)glLoadMatrixx}, + {"glLogicOp", (void *)glLogicOp}, + {"glMaterialx", (void *)glMaterialx}, + {"glMaterialxv", (void *)glMaterialxv}, + {"glMatrixMode", (void *)glMatrixMode}, + {"glMultMatrixx", (void *)glMultMatrixx}, + {"glMultiTexCoord4x", (void *)glMultiTexCoord4x}, + {"glNormal3x", (void *)glNormal3x}, + {"glNormalPointer", (void *)glNormalPointer}, + {"glOrthox", (void *)glOrthox}, + {"glPixelStorei", (void *)glPixelStorei}, + {"glPointParameterx", (void *)glPointParameterx}, + {"glPointParameterxv", (void *)glPointParameterxv}, + {"glPointSizex", (void *)glPointSizex}, + {"glPolygonOffsetx", (void *)glPolygonOffsetx}, + {"glPopMatrix", (void *)glPopMatrix}, + {"glPushMatrix", (void *)glPushMatrix}, + {"glReadPixels", (void *)glReadPixels}, + {"glRotatex", (void *)glRotatex}, + {"glSampleCoverage", (void *)glSampleCoverage}, + {"glSampleCoveragex", (void *)glSampleCoveragex}, + {"glScalex", (void *)glScalex}, + {"glScissor", (void *)glScissor}, + {"glShadeModel", (void *)glShadeModel}, + {"glStencilFunc", (void *)glStencilFunc}, + {"glStencilMask", (void *)glStencilMask}, + {"glStencilOp", (void *)glStencilOp}, + {"glTexCoordPointer", (void *)glTexCoordPointer}, + {"glTexEnvi", (void *)glTexEnvi}, + {"glTexEnvx", (void *)glTexEnvx}, + {"glTexEnviv", (void *)glTexEnviv}, + {"glTexEnvxv", (void *)glTexEnvxv}, + {"glTexImage2D", (void *)glTexImage2D}, + {"glTexParameteri", (void *)glTexParameteri}, + {"glTexParameterx", (void *)glTexParameterx}, + {"glTexParameteriv", (void *)glTexParameteriv}, + {"glTexParameterxv", (void *)glTexParameterxv}, + {"glTexSubImage2D", (void *)glTexSubImage2D}, + {"glTranslatex", (void *)glTranslatex}, + {"glVertexPointer", (void *)glVertexPointer}, + {"glViewport", (void *)glViewport}, + {"glPointSizePointerOES", (void *)glPointSizePointerOES}, + {"glBlendEquationSeparateOES", (void *)glBlendEquationSeparateOES}, + {"glBlendFuncSeparateOES", (void *)glBlendFuncSeparateOES}, + {"glBlendEquationOES", (void *)glBlendEquationOES}, + {"glDrawTexsOES", (void *)glDrawTexsOES}, + {"glDrawTexiOES", (void *)glDrawTexiOES}, + {"glDrawTexxOES", (void *)glDrawTexxOES}, + {"glDrawTexsvOES", (void *)glDrawTexsvOES}, + {"glDrawTexivOES", (void *)glDrawTexivOES}, + {"glDrawTexxvOES", (void *)glDrawTexxvOES}, + {"glDrawTexfOES", (void *)glDrawTexfOES}, + {"glDrawTexfvOES", (void *)glDrawTexfvOES}, + {"glEGLImageTargetTexture2DOES", (void *)glEGLImageTargetTexture2DOES}, + {"glEGLImageTargetRenderbufferStorageOES", (void *)glEGLImageTargetRenderbufferStorageOES}, + {"glAlphaFuncxOES", (void *)glAlphaFuncxOES}, + {"glClearColorxOES", (void *)glClearColorxOES}, + {"glClearDepthxOES", (void *)glClearDepthxOES}, + {"glClipPlanexOES", (void *)glClipPlanexOES}, + {"glColor4xOES", (void *)glColor4xOES}, + {"glDepthRangexOES", (void *)glDepthRangexOES}, + {"glFogxOES", (void *)glFogxOES}, + {"glFogxvOES", (void *)glFogxvOES}, + {"glFrustumxOES", (void *)glFrustumxOES}, + {"glGetClipPlanexOES", (void *)glGetClipPlanexOES}, + {"glGetFixedvOES", (void *)glGetFixedvOES}, + {"glGetLightxvOES", (void *)glGetLightxvOES}, + {"glGetMaterialxvOES", (void *)glGetMaterialxvOES}, + {"glGetTexEnvxvOES", (void *)glGetTexEnvxvOES}, + {"glGetTexParameterxvOES", (void *)glGetTexParameterxvOES}, + {"glLightModelxOES", (void *)glLightModelxOES}, + {"glLightModelxvOES", (void *)glLightModelxvOES}, + {"glLightxOES", (void *)glLightxOES}, + {"glLightxvOES", (void *)glLightxvOES}, + {"glLineWidthxOES", (void *)glLineWidthxOES}, + {"glLoadMatrixxOES", (void *)glLoadMatrixxOES}, + {"glMaterialxOES", (void *)glMaterialxOES}, + {"glMaterialxvOES", (void *)glMaterialxvOES}, + {"glMultMatrixxOES", (void *)glMultMatrixxOES}, + {"glMultiTexCoord4xOES", (void *)glMultiTexCoord4xOES}, + {"glNormal3xOES", (void *)glNormal3xOES}, + {"glOrthoxOES", (void *)glOrthoxOES}, + {"glPointParameterxOES", (void *)glPointParameterxOES}, + {"glPointParameterxvOES", (void *)glPointParameterxvOES}, + {"glPointSizexOES", (void *)glPointSizexOES}, + {"glPolygonOffsetxOES", (void *)glPolygonOffsetxOES}, + {"glRotatexOES", (void *)glRotatexOES}, + {"glSampleCoveragexOES", (void *)glSampleCoveragexOES}, + {"glScalexOES", (void *)glScalexOES}, + {"glTexEnvxOES", (void *)glTexEnvxOES}, + {"glTexEnvxvOES", (void *)glTexEnvxvOES}, + {"glTexParameterxOES", (void *)glTexParameterxOES}, + {"glTexParameterxvOES", (void *)glTexParameterxvOES}, + {"glTranslatexOES", (void *)glTranslatexOES}, + {"glIsRenderbufferOES", (void *)glIsRenderbufferOES}, + {"glBindRenderbufferOES", (void *)glBindRenderbufferOES}, + {"glDeleteRenderbuffersOES", (void *)glDeleteRenderbuffersOES}, + {"glGenRenderbuffersOES", (void *)glGenRenderbuffersOES}, + {"glRenderbufferStorageOES", (void *)glRenderbufferStorageOES}, + {"glGetRenderbufferParameterivOES", (void *)glGetRenderbufferParameterivOES}, + {"glIsFramebufferOES", (void *)glIsFramebufferOES}, + {"glBindFramebufferOES", (void *)glBindFramebufferOES}, + {"glDeleteFramebuffersOES", (void *)glDeleteFramebuffersOES}, + {"glGenFramebuffersOES", (void *)glGenFramebuffersOES}, + {"glCheckFramebufferStatusOES", (void *)glCheckFramebufferStatusOES}, + {"glFramebufferRenderbufferOES", (void *)glFramebufferRenderbufferOES}, + {"glFramebufferTexture2DOES", (void *)glFramebufferTexture2DOES}, + {"glGetFramebufferAttachmentParameterivOES", (void *)glGetFramebufferAttachmentParameterivOES}, + {"glGenerateMipmapOES", (void *)glGenerateMipmapOES}, + {"glMapBufferOES", (void *)glMapBufferOES}, + {"glUnmapBufferOES", (void *)glUnmapBufferOES}, + {"glGetBufferPointervOES", (void *)glGetBufferPointervOES}, + {"glCurrentPaletteMatrixOES", (void *)glCurrentPaletteMatrixOES}, + {"glLoadPaletteFromModelViewMatrixOES", (void *)glLoadPaletteFromModelViewMatrixOES}, + {"glMatrixIndexPointerOES", (void *)glMatrixIndexPointerOES}, + {"glWeightPointerOES", (void *)glWeightPointerOES}, + {"glQueryMatrixxOES", (void *)glQueryMatrixxOES}, + {"glDepthRangefOES", (void *)glDepthRangefOES}, + {"glFrustumfOES", (void *)glFrustumfOES}, + {"glOrthofOES", (void *)glOrthofOES}, + {"glClipPlanefOES", (void *)glClipPlanefOES}, + {"glGetClipPlanefOES", (void *)glGetClipPlanefOES}, + {"glClearDepthfOES", (void *)glClearDepthfOES}, + {"glTexGenfOES", (void *)glTexGenfOES}, + {"glTexGenfvOES", (void *)glTexGenfvOES}, + {"glTexGeniOES", (void *)glTexGeniOES}, + {"glTexGenivOES", (void *)glTexGenivOES}, + {"glTexGenxOES", (void *)glTexGenxOES}, + {"glTexGenxvOES", (void *)glTexGenxvOES}, + {"glGetTexGenfvOES", (void *)glGetTexGenfvOES}, + {"glGetTexGenivOES", (void *)glGetTexGenivOES}, + {"glGetTexGenxvOES", (void *)glGetTexGenxvOES}, + {"glBindVertexArrayOES", (void *)glBindVertexArrayOES}, + {"glDeleteVertexArraysOES", (void *)glDeleteVertexArraysOES}, + {"glGenVertexArraysOES", (void *)glGenVertexArraysOES}, + {"glIsVertexArrayOES", (void *)glIsVertexArrayOES}, + {"glDiscardFramebufferEXT", (void *)glDiscardFramebufferEXT}, + {"glMultiDrawArraysEXT", (void *)glMultiDrawArraysEXT}, + {"glMultiDrawElementsEXT", (void *)glMultiDrawElementsEXT}, + {"glClipPlanefIMG", (void *)glClipPlanefIMG}, + {"glClipPlanexIMG", (void *)glClipPlanexIMG}, + {"glRenderbufferStorageMultisampleIMG", (void *)glRenderbufferStorageMultisampleIMG}, + {"glFramebufferTexture2DMultisampleIMG", (void *)glFramebufferTexture2DMultisampleIMG}, + {"glDeleteFencesNV", (void *)glDeleteFencesNV}, + {"glGenFencesNV", (void *)glGenFencesNV}, + {"glIsFenceNV", (void *)glIsFenceNV}, + {"glTestFenceNV", (void *)glTestFenceNV}, + {"glGetFenceivNV", (void *)glGetFenceivNV}, + {"glFinishFenceNV", (void *)glFinishFenceNV}, + {"glSetFenceNV", (void *)glSetFenceNV}, + {"glGetDriverControlsQCOM", (void *)glGetDriverControlsQCOM}, + {"glGetDriverControlStringQCOM", (void *)glGetDriverControlStringQCOM}, + {"glEnableDriverControlQCOM", (void *)glEnableDriverControlQCOM}, + {"glDisableDriverControlQCOM", (void *)glDisableDriverControlQCOM}, + {"glExtGetTexturesQCOM", (void *)glExtGetTexturesQCOM}, + {"glExtGetBuffersQCOM", (void *)glExtGetBuffersQCOM}, + {"glExtGetRenderbuffersQCOM", (void *)glExtGetRenderbuffersQCOM}, + {"glExtGetFramebuffersQCOM", (void *)glExtGetFramebuffersQCOM}, + {"glExtGetTexLevelParameterivQCOM", (void *)glExtGetTexLevelParameterivQCOM}, + {"glExtTexObjectStateOverrideiQCOM", (void *)glExtTexObjectStateOverrideiQCOM}, + {"glExtGetTexSubImageQCOM", (void *)glExtGetTexSubImageQCOM}, + {"glExtGetBufferPointervQCOM", (void *)glExtGetBufferPointervQCOM}, + {"glExtGetShadersQCOM", (void *)glExtGetShadersQCOM}, + {"glExtGetProgramsQCOM", (void *)glExtGetProgramsQCOM}, + {"glExtIsProgramBinaryQCOM", (void *)glExtIsProgramBinaryQCOM}, + {"glExtGetProgramBinarySourceQCOM", (void *)glExtGetProgramBinarySourceQCOM}, + {"glStartTilingQCOM", (void *)glStartTilingQCOM}, + {"glEndTilingQCOM", (void *)glEndTilingQCOM} +}; +static int gles_num_funcs = sizeof(gles_funcs_by_name) / sizeof(struct _gles_funcs_by_name); diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_proc.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_proc.h new file mode 100644 index 0000000..afd94b9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/gles_proc.h @@ -0,0 +1,296 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GLES_PROC_H +#define _GLES_PROC_H + +#include +#define GL_GLEXT_PROTOTYPES +#include + +typedef void (* glAlphaFunc_t) (GLenum, GLclampf); +typedef void (* glClearColor_t) (GLclampf, GLclampf, GLclampf, GLclampf); +typedef void (* glClearDepthf_t) (GLclampf); +typedef void (* glClipPlanef_t) (GLenum, const GLfloat*); +typedef void (* glColor4f_t) (GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glDepthRangef_t) (GLclampf, GLclampf); +typedef void (* glFogf_t) (GLenum, GLfloat); +typedef void (* glFogfv_t) (GLenum, const GLfloat*); +typedef void (* glFrustumf_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glGetClipPlanef_t) (GLenum, GLfloat*); +typedef void (* glGetFloatv_t) (GLenum, GLfloat*); +typedef void (* glGetLightfv_t) (GLenum, GLenum, GLfloat*); +typedef void (* glGetMaterialfv_t) (GLenum, GLenum, GLfloat*); +typedef void (* glGetTexEnvfv_t) (GLenum, GLenum, GLfloat*); +typedef void (* glGetTexParameterfv_t) (GLenum, GLenum, GLfloat*); +typedef void (* glLightModelf_t) (GLenum, GLfloat); +typedef void (* glLightModelfv_t) (GLenum, const GLfloat*); +typedef void (* glLightf_t) (GLenum, GLenum, GLfloat); +typedef void (* glLightfv_t) (GLenum, GLenum, const GLfloat*); +typedef void (* glLineWidth_t) (GLfloat); +typedef void (* glLoadMatrixf_t) (const GLfloat*); +typedef void (* glMaterialf_t) (GLenum, GLenum, GLfloat); +typedef void (* glMaterialfv_t) (GLenum, GLenum, const GLfloat*); +typedef void (* glMultMatrixf_t) (const GLfloat*); +typedef void (* glMultiTexCoord4f_t) (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glNormal3f_t) (GLfloat, GLfloat, GLfloat); +typedef void (* glOrthof_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glPointParameterf_t) (GLenum, GLfloat); +typedef void (* glPointParameterfv_t) (GLenum, const GLfloat*); +typedef void (* glPointSize_t) (GLfloat); +typedef void (* glPolygonOffset_t) (GLfloat, GLfloat); +typedef void (* glRotatef_t) (GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glScalef_t) (GLfloat, GLfloat, GLfloat); +typedef void (* glTexEnvf_t) (GLenum, GLenum, GLfloat); +typedef void (* glTexEnvfv_t) (GLenum, GLenum, const GLfloat*); +typedef void (* glTexParameterf_t) (GLenum, GLenum, GLfloat); +typedef void (* glTexParameterfv_t) (GLenum, GLenum, const GLfloat*); +typedef void (* glTranslatef_t) (GLfloat, GLfloat, GLfloat); +typedef void (* glActiveTexture_t) (GLenum); +typedef void (* glAlphaFuncx_t) (GLenum, GLclampx); +typedef void (* glBindBuffer_t) (GLenum, GLuint); +typedef void (* glBindTexture_t) (GLenum, GLuint); +typedef void (* glBlendFunc_t) (GLenum, GLenum); +typedef void (* glBufferData_t) (GLenum, GLsizeiptr, const GLvoid*, GLenum); +typedef void (* glBufferSubData_t) (GLenum, GLintptr, GLsizeiptr, const GLvoid*); +typedef void (* glClear_t) (GLbitfield); +typedef void (* glClearColorx_t) (GLclampx, GLclampx, GLclampx, GLclampx); +typedef void (* glClearDepthx_t) (GLclampx); +typedef void (* glClearStencil_t) (GLint); +typedef void (* glClientActiveTexture_t) (GLenum); +typedef void (* glClipPlanex_t) (GLenum, const GLfixed*); +typedef void (* glColor4ub_t) (GLubyte, GLubyte, GLubyte, GLubyte); +typedef void (* glColor4x_t) (GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glColorMask_t) (GLboolean, GLboolean, GLboolean, GLboolean); +typedef void (* glColorPointer_t) (GLint, GLenum, GLsizei, const GLvoid*); +typedef void (* glCompressedTexImage2D_t) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*); +typedef void (* glCompressedTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*); +typedef void (* glCopyTexImage2D_t) (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +typedef void (* glCopyTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +typedef void (* glCullFace_t) (GLenum); +typedef void (* glDeleteBuffers_t) (GLsizei, const GLuint*); +typedef void (* glDeleteTextures_t) (GLsizei, const GLuint*); +typedef void (* glDepthFunc_t) (GLenum); +typedef void (* glDepthMask_t) (GLboolean); +typedef void (* glDepthRangex_t) (GLclampx, GLclampx); +typedef void (* glDisable_t) (GLenum); +typedef void (* glDisableClientState_t) (GLenum); +typedef void (* glDrawArrays_t) (GLenum, GLint, GLsizei); +typedef void (* glDrawElements_t) (GLenum, GLsizei, GLenum, const GLvoid*); +typedef void (* glEnable_t) (GLenum); +typedef void (* glEnableClientState_t) (GLenum); +typedef void (* glFinish_t) (); +typedef void (* glFlush_t) (); +typedef void (* glFogx_t) (GLenum, GLfixed); +typedef void (* glFogxv_t) (GLenum, const GLfixed*); +typedef void (* glFrontFace_t) (GLenum); +typedef void (* glFrustumx_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glGetBooleanv_t) (GLenum, GLboolean*); +typedef void (* glGetBufferParameteriv_t) (GLenum, GLenum, GLint*); +typedef void (* glGetClipPlanex_t) (GLenum, GLfixed*); +typedef void (* glGenBuffers_t) (GLsizei, GLuint*); +typedef void (* glGenTextures_t) (GLsizei, GLuint*); +typedef GLenum (* glGetError_t) (); +typedef void (* glGetFixedv_t) (GLenum, GLfixed*); +typedef void (* glGetIntegerv_t) (GLenum, GLint*); +typedef void (* glGetLightxv_t) (GLenum, GLenum, GLfixed*); +typedef void (* glGetMaterialxv_t) (GLenum, GLenum, GLfixed*); +typedef void (* glGetPointerv_t) (GLenum, GLvoid**); +typedef const GLubyte* (* glGetString_t) (GLenum); +typedef void (* glGetTexEnviv_t) (GLenum, GLenum, GLint*); +typedef void (* glGetTexEnvxv_t) (GLenum, GLenum, GLfixed*); +typedef void (* glGetTexParameteriv_t) (GLenum, GLenum, GLint*); +typedef void (* glGetTexParameterxv_t) (GLenum, GLenum, GLfixed*); +typedef void (* glHint_t) (GLenum, GLenum); +typedef GLboolean (* glIsBuffer_t) (GLuint); +typedef GLboolean (* glIsEnabled_t) (GLenum); +typedef GLboolean (* glIsTexture_t) (GLuint); +typedef void (* glLightModelx_t) (GLenum, GLfixed); +typedef void (* glLightModelxv_t) (GLenum, const GLfixed*); +typedef void (* glLightx_t) (GLenum, GLenum, GLfixed); +typedef void (* glLightxv_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glLineWidthx_t) (GLfixed); +typedef void (* glLoadIdentity_t) (); +typedef void (* glLoadMatrixx_t) (const GLfixed*); +typedef void (* glLogicOp_t) (GLenum); +typedef void (* glMaterialx_t) (GLenum, GLenum, GLfixed); +typedef void (* glMaterialxv_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glMatrixMode_t) (GLenum); +typedef void (* glMultMatrixx_t) (const GLfixed*); +typedef void (* glMultiTexCoord4x_t) (GLenum, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glNormal3x_t) (GLfixed, GLfixed, GLfixed); +typedef void (* glNormalPointer_t) (GLenum, GLsizei, const GLvoid*); +typedef void (* glOrthox_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glPixelStorei_t) (GLenum, GLint); +typedef void (* glPointParameterx_t) (GLenum, GLfixed); +typedef void (* glPointParameterxv_t) (GLenum, const GLfixed*); +typedef void (* glPointSizex_t) (GLfixed); +typedef void (* glPolygonOffsetx_t) (GLfixed, GLfixed); +typedef void (* glPopMatrix_t) (); +typedef void (* glPushMatrix_t) (); +typedef void (* glReadPixels_t) (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); +typedef void (* glRotatex_t) (GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glSampleCoverage_t) (GLclampf, GLboolean); +typedef void (* glSampleCoveragex_t) (GLclampx, GLboolean); +typedef void (* glScalex_t) (GLfixed, GLfixed, GLfixed); +typedef void (* glScissor_t) (GLint, GLint, GLsizei, GLsizei); +typedef void (* glShadeModel_t) (GLenum); +typedef void (* glStencilFunc_t) (GLenum, GLint, GLuint); +typedef void (* glStencilMask_t) (GLuint); +typedef void (* glStencilOp_t) (GLenum, GLenum, GLenum); +typedef void (* glTexCoordPointer_t) (GLint, GLenum, GLsizei, const GLvoid*); +typedef void (* glTexEnvi_t) (GLenum, GLenum, GLint); +typedef void (* glTexEnvx_t) (GLenum, GLenum, GLfixed); +typedef void (* glTexEnviv_t) (GLenum, GLenum, const GLint*); +typedef void (* glTexEnvxv_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glTexImage2D_t) (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); +typedef void (* glTexParameteri_t) (GLenum, GLenum, GLint); +typedef void (* glTexParameterx_t) (GLenum, GLenum, GLfixed); +typedef void (* glTexParameteriv_t) (GLenum, GLenum, const GLint*); +typedef void (* glTexParameterxv_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glTexSubImage2D_t) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*); +typedef void (* glTranslatex_t) (GLfixed, GLfixed, GLfixed); +typedef void (* glVertexPointer_t) (GLint, GLenum, GLsizei, const GLvoid*); +typedef void (* glViewport_t) (GLint, GLint, GLsizei, GLsizei); +typedef void (* glPointSizePointerOES_t) (GLenum, GLsizei, const GLvoid*); +typedef void (* glBlendEquationSeparateOES_t) (GLenum, GLenum); +typedef void (* glBlendFuncSeparateOES_t) (GLenum, GLenum, GLenum, GLenum); +typedef void (* glBlendEquationOES_t) (GLenum); +typedef void (* glDrawTexsOES_t) (GLshort, GLshort, GLshort, GLshort, GLshort); +typedef void (* glDrawTexiOES_t) (GLint, GLint, GLint, GLint, GLint); +typedef void (* glDrawTexxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glDrawTexsvOES_t) (const GLshort*); +typedef void (* glDrawTexivOES_t) (const GLint*); +typedef void (* glDrawTexxvOES_t) (const GLfixed*); +typedef void (* glDrawTexfOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glDrawTexfvOES_t) (const GLfloat*); +typedef void (* glEGLImageTargetTexture2DOES_t) (GLenum, GLeglImageOES); +typedef void (* glEGLImageTargetRenderbufferStorageOES_t) (GLenum, GLeglImageOES); +typedef void (* glAlphaFuncxOES_t) (GLenum, GLclampx); +typedef void (* glClearColorxOES_t) (GLclampx, GLclampx, GLclampx, GLclampx); +typedef void (* glClearDepthxOES_t) (GLclampx); +typedef void (* glClipPlanexOES_t) (GLenum, const GLfixed*); +typedef void (* glColor4xOES_t) (GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glDepthRangexOES_t) (GLclampx, GLclampx); +typedef void (* glFogxOES_t) (GLenum, GLfixed); +typedef void (* glFogxvOES_t) (GLenum, const GLfixed*); +typedef void (* glFrustumxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glGetClipPlanexOES_t) (GLenum, GLfixed*); +typedef void (* glGetFixedvOES_t) (GLenum, GLfixed*); +typedef void (* glGetLightxvOES_t) (GLenum, GLenum, GLfixed*); +typedef void (* glGetMaterialxvOES_t) (GLenum, GLenum, GLfixed*); +typedef void (* glGetTexEnvxvOES_t) (GLenum, GLenum, GLfixed*); +typedef void (* glGetTexParameterxvOES_t) (GLenum, GLenum, GLfixed*); +typedef void (* glLightModelxOES_t) (GLenum, GLfixed); +typedef void (* glLightModelxvOES_t) (GLenum, const GLfixed*); +typedef void (* glLightxOES_t) (GLenum, GLenum, GLfixed); +typedef void (* glLightxvOES_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glLineWidthxOES_t) (GLfixed); +typedef void (* glLoadMatrixxOES_t) (const GLfixed*); +typedef void (* glMaterialxOES_t) (GLenum, GLenum, GLfixed); +typedef void (* glMaterialxvOES_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glMultMatrixxOES_t) (const GLfixed*); +typedef void (* glMultiTexCoord4xOES_t) (GLenum, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glNormal3xOES_t) (GLfixed, GLfixed, GLfixed); +typedef void (* glOrthoxOES_t) (GLfixed, GLfixed, GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glPointParameterxOES_t) (GLenum, GLfixed); +typedef void (* glPointParameterxvOES_t) (GLenum, const GLfixed*); +typedef void (* glPointSizexOES_t) (GLfixed); +typedef void (* glPolygonOffsetxOES_t) (GLfixed, GLfixed); +typedef void (* glRotatexOES_t) (GLfixed, GLfixed, GLfixed, GLfixed); +typedef void (* glSampleCoveragexOES_t) (GLclampx, GLboolean); +typedef void (* glScalexOES_t) (GLfixed, GLfixed, GLfixed); +typedef void (* glTexEnvxOES_t) (GLenum, GLenum, GLfixed); +typedef void (* glTexEnvxvOES_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glTexParameterxOES_t) (GLenum, GLenum, GLfixed); +typedef void (* glTexParameterxvOES_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glTranslatexOES_t) (GLfixed, GLfixed, GLfixed); +typedef GLboolean (* glIsRenderbufferOES_t) (GLuint); +typedef void (* glBindRenderbufferOES_t) (GLenum, GLuint); +typedef void (* glDeleteRenderbuffersOES_t) (GLsizei, const GLuint*); +typedef void (* glGenRenderbuffersOES_t) (GLsizei, GLuint*); +typedef void (* glRenderbufferStorageOES_t) (GLenum, GLenum, GLsizei, GLsizei); +typedef void (* glGetRenderbufferParameterivOES_t) (GLenum, GLenum, GLint*); +typedef GLboolean (* glIsFramebufferOES_t) (GLuint); +typedef void (* glBindFramebufferOES_t) (GLenum, GLuint); +typedef void (* glDeleteFramebuffersOES_t) (GLsizei, const GLuint*); +typedef void (* glGenFramebuffersOES_t) (GLsizei, GLuint*); +typedef GLenum (* glCheckFramebufferStatusOES_t) (GLenum); +typedef void (* glFramebufferRenderbufferOES_t) (GLenum, GLenum, GLenum, GLuint); +typedef void (* glFramebufferTexture2DOES_t) (GLenum, GLenum, GLenum, GLuint, GLint); +typedef void (* glGetFramebufferAttachmentParameterivOES_t) (GLenum, GLenum, GLenum, GLint*); +typedef void (* glGenerateMipmapOES_t) (GLenum); +typedef void* (* glMapBufferOES_t) (GLenum, GLenum); +typedef GLboolean (* glUnmapBufferOES_t) (GLenum); +typedef void (* glGetBufferPointervOES_t) (GLenum, GLenum, GLvoid*); +typedef void (* glCurrentPaletteMatrixOES_t) (GLuint); +typedef void (* glLoadPaletteFromModelViewMatrixOES_t) (); +typedef void (* glMatrixIndexPointerOES_t) (GLint, GLenum, GLsizei, const GLvoid*); +typedef void (* glWeightPointerOES_t) (GLint, GLenum, GLsizei, const GLvoid*); +typedef GLbitfield (* glQueryMatrixxOES_t) (GLfixed*, GLint*); +typedef void (* glDepthRangefOES_t) (GLclampf, GLclampf); +typedef void (* glFrustumfOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glOrthofOES_t) (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +typedef void (* glClipPlanefOES_t) (GLenum, const GLfloat*); +typedef void (* glGetClipPlanefOES_t) (GLenum, GLfloat*); +typedef void (* glClearDepthfOES_t) (GLclampf); +typedef void (* glTexGenfOES_t) (GLenum, GLenum, GLfloat); +typedef void (* glTexGenfvOES_t) (GLenum, GLenum, const GLfloat*); +typedef void (* glTexGeniOES_t) (GLenum, GLenum, GLint); +typedef void (* glTexGenivOES_t) (GLenum, GLenum, const GLint*); +typedef void (* glTexGenxOES_t) (GLenum, GLenum, GLfixed); +typedef void (* glTexGenxvOES_t) (GLenum, GLenum, const GLfixed*); +typedef void (* glGetTexGenfvOES_t) (GLenum, GLenum, GLfloat*); +typedef void (* glGetTexGenivOES_t) (GLenum, GLenum, GLint*); +typedef void (* glGetTexGenxvOES_t) (GLenum, GLenum, GLfixed*); +typedef void (* glBindVertexArrayOES_t) (GLuint); +typedef void (* glDeleteVertexArraysOES_t) (GLsizei, const GLuint*); +typedef void (* glGenVertexArraysOES_t) (GLsizei, GLuint*); +typedef GLboolean (* glIsVertexArrayOES_t) (GLuint); +typedef void (* glDiscardFramebufferEXT_t) (GLenum, GLsizei, const GLenum*); +typedef void (* glMultiDrawArraysEXT_t) (GLenum, GLint*, GLsizei*, GLsizei); +typedef void (* glMultiDrawElementsEXT_t) (GLenum, const GLsizei*, GLenum, const GLvoid**, GLsizei); +typedef void (* glClipPlanefIMG_t) (GLenum, const GLfloat*); +typedef void (* glClipPlanexIMG_t) (GLenum, const GLfixed*); +typedef void (* glRenderbufferStorageMultisampleIMG_t) (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +typedef void (* glFramebufferTexture2DMultisampleIMG_t) (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); +typedef void (* glDeleteFencesNV_t) (GLsizei, const GLuint*); +typedef void (* glGenFencesNV_t) (GLsizei, GLuint*); +typedef GLboolean (* glIsFenceNV_t) (GLuint); +typedef GLboolean (* glTestFenceNV_t) (GLuint); +typedef void (* glGetFenceivNV_t) (GLuint, GLenum, GLint*); +typedef void (* glFinishFenceNV_t) (GLuint); +typedef void (* glSetFenceNV_t) (GLuint, GLenum); +typedef void (* glGetDriverControlsQCOM_t) (GLint*, GLsizei, GLuint*); +typedef void (* glGetDriverControlStringQCOM_t) (GLuint, GLsizei, GLsizei*, GLchar*); +typedef void (* glEnableDriverControlQCOM_t) (GLuint); +typedef void (* glDisableDriverControlQCOM_t) (GLuint); +typedef void (* glExtGetTexturesQCOM_t) (GLuint*, GLint, GLint*); +typedef void (* glExtGetBuffersQCOM_t) (GLuint*, GLint, GLint*); +typedef void (* glExtGetRenderbuffersQCOM_t) (GLuint*, GLint, GLint*); +typedef void (* glExtGetFramebuffersQCOM_t) (GLuint*, GLint, GLint*); +typedef void (* glExtGetTexLevelParameterivQCOM_t) (GLuint, GLenum, GLint, GLenum, GLint*); +typedef void (* glExtTexObjectStateOverrideiQCOM_t) (GLenum, GLenum, GLint); +typedef void (* glExtGetTexSubImageQCOM_t) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); +typedef void (* glExtGetBufferPointervQCOM_t) (GLenum, GLvoid**); +typedef void (* glExtGetShadersQCOM_t) (GLuint*, GLint, GLint*); +typedef void (* glExtGetProgramsQCOM_t) (GLuint*, GLint, GLint*); +typedef GLboolean (* glExtIsProgramBinaryQCOM_t) (GLuint); +typedef void (* glExtGetProgramBinarySourceQCOM_t) (GLuint, GLenum, GLchar*, GLint*); +typedef void (* glStartTilingQCOM_t) (GLuint, GLuint, GLuint, GLuint, GLbitfield); +typedef void (* glEndTilingQCOM_t) (GLbitfield); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp new file mode 100644 index 0000000..26c98a8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv1_emul_ifc.cpp @@ -0,0 +1,39 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include "ApiInitializer.h" +#include +#include "gl_wrapper_context.h" + +extern "C" { + gl_wrapper_context_t *createFromLib(void *solib, gl_wrapper_context_t *(*accessor)()); +} + +gl_wrapper_context_t * createFromLib(void *solib, gl_wrapper_context_t *(accessor)()) +{ + gl_wrapper_context_t *ctx = new gl_wrapper_context_t; + if (ctx == NULL) { + return NULL; + } + ApiInitializer *initializer = new ApiInitializer(solib); + ctx->initDispatchByName(ApiInitializer::s_getProc, initializer); + gl_wrapper_context_t::setContextAccessor(accessor); + delete initializer; + return ctx; +} + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp new file mode 100644 index 0000000..4ae13dd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/gles_android_wrapper/glesv2_emul_ifc.cpp @@ -0,0 +1,40 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include "ApiInitializer.h" +#include +#include "gl2_wrapper_context.h" + +extern "C" { + gl2_wrapper_context_t *createFromLib(void *solib, gl2_wrapper_context_t *(*accessor)()); +} + +gl2_wrapper_context_t * createFromLib(void *solib, gl2_wrapper_context_t *(*accessor)()) +{ + gl2_wrapper_context_t *ctx = new gl2_wrapper_context_t; + if (ctx == NULL) { + return NULL; + } + ApiInitializer *initializer = new ApiInitializer(solib); + ctx->initDispatchByName(ApiInitializer::s_getProc, initializer); + gl2_wrapper_context_t::setContextAccessor(accessor); + delete initializer; + return ctx; +} + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/Android.mk b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/Android.mk new file mode 100644 index 0000000..ae234b2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/Android.mk @@ -0,0 +1,8 @@ +LOCAL_PATH := $(call my-dir) + +$(call emugl-begin-shared-library,libut_rendercontrol_enc) +$(call emugl-import,libOpenglCodecCommon) +$(call emugl-gen-encoder,$(LOCAL_PATH),ut_rendercontrol) +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +$(call emugl-end-module) + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib new file mode 100644 index 0000000..c47a9f9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.attrib @@ -0,0 +1,4 @@ +GLOBAL + base_opcode 10000 + encoder_headers + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.in b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.in new file mode 100644 index 0000000..0d5942f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.in @@ -0,0 +1,11 @@ +GL_ENTRY(int, createContext, uint32_t pid, uint32_t handle, uint32_t shareCtx, int version) +GL_ENTRY(int, createSurface, uint32_t pid, uint32_t handle) +GL_ENTRY(int, makeCurrentContext, uint32_t pid, uint32_t drawSurface, uint32_t readSurface, uint32_t ctxHandle) +GL_ENTRY(void, swapBuffers, uint32_t pid, uint32_t surface) +GL_ENTRY(int, destroyContext, uint32_t pid, uint32_t handle) +GL_ENTRY(int, destroySurface, uint32_t pid, uint32_t handle) + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types new file mode 100644 index 0000000..9d945ab --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol.types @@ -0,0 +1,2 @@ +uint32_t 32 0x%08x false + diff --git a/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol_types.h b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol_types.h new file mode 100644 index 0000000..9b7864d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/opengl/tests/ut_rendercontrol_enc/ut_rendercontrol_types.h @@ -0,0 +1,17 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include diff --git a/src/type3_AndroidCloud/anbox-master/android/power/Android.mk b/src/type3_AndroidCloud/anbox-master/android/power/Android.mk new file mode 100644 index 0000000..0273f04 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/power/Android.mk @@ -0,0 +1,28 @@ +# Copyright (C) 2012 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +LOCAL_PATH := $(call my-dir) + +# HAL module implemenation stored in +# hw/..so +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_CFLAGS += -DQEMU_HARDWARE +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_SRC_FILES := power_qemu.c +LOCAL_MODULE := power.goldfish +LOCAL_MODULE_TAGS := optional +include $(BUILD_SHARED_LIBRARY) diff --git a/src/type3_AndroidCloud/anbox-master/android/power/power_qemu.c b/src/type3_AndroidCloud/anbox-master/android/power/power_qemu.c new file mode 100644 index 0000000..d4251e0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/power/power_qemu.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "emulator PowerHAL" +#include + +#include +#include +#include +#include +#include + +static int qemud_fd; + +static void power_qemu_init(struct power_module *module) +{ + qemud_fd = qemud_channel_open("hw-control"); + + if (qemud_fd < 0) + ALOGE("Error connecting to qemud hw-control service\n"); +} + +static void power_qemu_set_interactive(struct power_module *module, int on) +{ + int r; + + r = qemud_channel_send(qemud_fd, on ? "power:screen_state:wake" + : "power:screen_state:standby", -1); + + if (r < 0) + ALOGE("Error sending power command to qemud hw-control service\n"); +} + +static struct hw_module_methods_t power_qemu_module_methods = { + .open = NULL, +}; + +struct power_module HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .version_major = 1, + .version_minor = 0, + .id = POWER_HARDWARE_MODULE_ID, + .name = "Emulator Power HAL", + .author = "The Android Open Source Project", + .methods = &power_qemu_module_methods, + }, + + .init = power_qemu_init, + .setInteractive = power_qemu_set_interactive, +}; diff --git a/src/type3_AndroidCloud/anbox-master/android/qemu-props/Android.mk b/src/type3_AndroidCloud/anbox-master/android/qemu-props/Android.mk new file mode 100644 index 0000000..78ab1d5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/qemu-props/Android.mk @@ -0,0 +1,28 @@ +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# this file is used to build emulator-specific program tools +# that should only run in the emulator. +# + +LOCAL_PATH := $(call my-dir) + +# The 'qemu-props' program is run from /system/etc/init.goldfish.rc +# to setup various system properties sent by the emulator program. +# +include $(CLEAR_VARS) +LOCAL_MODULE := qemu-props +LOCAL_SRC_FILES := qemu-props.c +LOCAL_SHARED_LIBRARIES := libcutils liblog +include $(BUILD_EXECUTABLE) diff --git a/src/type3_AndroidCloud/anbox-master/android/qemu-props/qemu-props.c b/src/type3_AndroidCloud/anbox-master/android/qemu-props/qemu-props.c new file mode 100644 index 0000000..56d510f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/qemu-props/qemu-props.c @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* this program is used to read a set of system properties and their values + * from the emulator program and set them in the currently-running emulated + * system. It does so by connecting to the 'boot-properties' qemud service. + * + * This program should be run as root and called from + * /system/etc/init.goldfish.rc exclusively. + */ + +#define LOG_TAG "qemu-props" + +#define DEBUG 1 + +#if DEBUG +# include +# define DD(...) ALOGI(__VA_ARGS__) +#else +# define DD(...) ((void)0) +#endif + +#include +#include +#include + +/* Name of the qemud service we want to connect to. + */ +#define QEMUD_SERVICE "boot-properties" + +#define MAX_TRIES 5 + +int main(void) +{ + int qemud_fd, count = 0; + + /* try to connect to the qemud service */ + { + int tries = MAX_TRIES; + + while (1) { + qemud_fd = qemud_channel_open( "boot-properties" ); + if (qemud_fd >= 0) + break; + + if (--tries <= 0) { + DD("Could not connect after too many tries. Aborting"); + return 1; + } + + DD("waiting 1s to wait for qemud."); + sleep(1); + } + } + + DD("connected to '%s' qemud service.", QEMUD_SERVICE); + + /* send the 'list' command to the service */ + if (qemud_channel_send(qemud_fd, "list", -1) < 0) { + DD("could not send command to '%s' service", QEMUD_SERVICE); + return 1; + } + + /* read each system property as a single line from the service, + * until exhaustion. + */ + for (;;) + { +#define BUFF_SIZE (PROPERTY_KEY_MAX + PROPERTY_VALUE_MAX + 2) + DD("receiving.."); + char* q; + char temp[BUFF_SIZE]; + int len = qemud_channel_recv(qemud_fd, temp, sizeof temp - 1); + + /* lone NUL-byte signals end of properties */ + if (len < 0 || len > BUFF_SIZE-1 || temp[0] == '\0') + break; + + temp[len] = '\0'; /* zero-terminate string */ + + DD("received: %.*s", len, temp); + + /* separate propery name from value */ + q = strchr(temp, '='); + if (q == NULL) { + DD("invalid format, ignored."); + continue; + } + *q++ = '\0'; + + if (property_set(temp, q) < 0) { + DD("could not set property '%s' to '%s'", temp, q); + } else { + count += 1; + } + } + + + /* finally, close the channel and exit */ + close(qemud_fd); + DD("exiting (%d properties set).", count); + return 0; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/qemud/Android.mk b/src/type3_AndroidCloud/anbox-master/android/qemud/Android.mk new file mode 100644 index 0000000..30ee5eb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/qemud/Android.mk @@ -0,0 +1,20 @@ +# Copyright 2008 The Android Open Source Project + +# We're moving the emulator-specific platform libs to +# development.git/tools/emulator/. The following test is to ensure +# smooth builds even if the tree contains both versions. +# + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES:= \ + qemud.c + + +LOCAL_SHARED_LIBRARIES := \ + libcutils liblog + +LOCAL_MODULE:= qemud + +include $(BUILD_EXECUTABLE) diff --git a/src/type3_AndroidCloud/anbox-master/android/qemud/qemud.c b/src/type3_AndroidCloud/anbox-master/android/qemud/qemud.c new file mode 100644 index 0000000..a9185ba --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/qemud/qemud.c @@ -0,0 +1,1683 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * the qemud daemon program is only used within Android as a bridge + * between the emulator program and the emulated system. it really works as + * a simple stream multiplexer that works as follows: + * + * - qemud is started by init following instructions in + * /system/etc/init.goldfish.rc (i.e. it is never started on real devices) + * + * - qemud communicates with the emulator program through a single serial + * port, whose name is passed through a kernel boot parameter + * (e.g. android.qemud=ttyS1) + * + * - qemud binds one unix local stream socket (/dev/socket/qemud, created + * by init through /system/etc/init.goldfish.rc). + * + * + * emulator <==serial==> qemud <---> /dev/socket/qemud <-+--> client1 + * | + * +--> client2 + * + * - the special channel index 0 is used by the emulator and qemud only. + * other channel numbers correspond to clients. More specifically, + * connection are created like this: + * + * * the client connects to /dev/socket/qemud + * + * * the client sends the service name through the socket, as + * + * + * * qemud creates a "Client" object internally, assigns it an + * internal unique channel number > 0, then sends a connection + * initiation request to the emulator (i.e. through channel 0): + * + * connect:: + * + * where is the service name, and is a 2-hexchar + * number corresponding to the channel number. + * + * * in case of success, the emulator responds through channel 0 + * with: + * + * ok:connect: + * + * after this, all messages between the client and the emulator + * are passed in pass-through mode. + * + * * if the emulator refuses the service connection, it will + * send the following through channel 0: + * + * ko:connect::reason-for-failure + * + * * If the client closes the connection, qemud sends the following + * to the emulator: + * + * disconnect: + * + * The same message is the opposite direction if the emulator + * chooses to close the connection. + * + * * any command sent through channel 0 to the emulator that is + * not properly recognized will be answered by: + * + * ko:unknown command + * + * + * Internally, the daemon maintains a "Client" object for each client + * connection (i.e. accepting socket connection). + */ + +/* name of the single control socket used by the daemon */ +#define CONTROL_SOCKET_NAME "qemud" + +#define DEBUG 0 +#define T_ACTIVE 0 /* set to 1 to dump traffic */ + +#if DEBUG +# define LOG_TAG "qemud" +# include +# define D(...) ALOGD(__VA_ARGS__) +#else +# define D(...) ((void)0) +# define T(...) ((void)0) +#endif + +#if T_ACTIVE +# define T(...) D(__VA_ARGS__) +#else +# define T(...) ((void)0) +#endif + +/** UTILITIES + **/ + +static void +fatal( const char* fmt, ... ) +{ + va_list args; + va_start(args, fmt); + fprintf(stderr, "PANIC: "); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n" ); + va_end(args); + exit(1); +} + +static void* +xalloc( size_t sz ) +{ + void* p; + + if (sz == 0) + return NULL; + + p = malloc(sz); + if (p == NULL) + fatal( "not enough memory" ); + + return p; +} + +#define xnew(p) (p) = xalloc(sizeof(*(p))) + +static void* +xalloc0( size_t sz ) +{ + void* p = xalloc(sz); + memset( p, 0, sz ); + return p; +} + +#define xnew0(p) (p) = xalloc0(sizeof(*(p))) + +#define xfree(p) (free((p)), (p) = NULL) + +static void* +xrealloc( void* block, size_t size ) +{ + void* p = realloc( block, size ); + + if (p == NULL && size > 0) + fatal( "not enough memory" ); + + return p; +} + +#define xrenew(p,count) (p) = xrealloc((p),sizeof(*(p))*(count)) + +static int +hex2int( const uint8_t* data, int len ) +{ + int result = 0; + while (len > 0) { + int c = *data++; + unsigned d; + + result <<= 4; + do { + d = (unsigned)(c - '0'); + if (d < 10) + break; + + d = (unsigned)(c - 'a'); + if (d < 6) { + d += 10; + break; + } + + d = (unsigned)(c - 'A'); + if (d < 6) { + d += 10; + break; + } + + return -1; + } + while (0); + + result |= d; + len -= 1; + } + return result; +} + + +static void +int2hex( int value, uint8_t* to, int width ) +{ + int nn = 0; + static const char hexchars[16] = "0123456789abcdef"; + + for ( --width; width >= 0; width--, nn++ ) { + to[nn] = hexchars[(value >> (width*4)) & 15]; + } +} + +static int +fd_read(int fd, void* to, int len) +{ + int ret; + + do { + ret = read(fd, to, len); + } while (ret < 0 && errno == EINTR); + + return ret; +} + +static int +fd_write(int fd, const void* from, int len) +{ + int ret; + + do { + ret = write(fd, from, len); + } while (ret < 0 && errno == EINTR); + + return ret; +} + +static void +fd_setnonblock(int fd) +{ + int ret, flags; + + do { + flags = fcntl(fd, F_GETFD); + } while (flags < 0 && errno == EINTR); + + if (flags < 0) { + fatal( "%s: could not get flags for fd %d: %s", + __FUNCTION__, fd, strerror(errno) ); + } + + do { + ret = fcntl(fd, F_SETFD, flags | O_NONBLOCK); + } while (ret < 0 && errno == EINTR); + + if (ret < 0) { + fatal( "%s: could not set fd %d to non-blocking: %s", + __FUNCTION__, fd, strerror(errno) ); + } +} + + +static int +fd_accept(int fd) +{ + struct sockaddr from; + socklen_t fromlen = sizeof(from); + int ret; + + do { + ret = accept(fd, &from, &fromlen); + } while (ret < 0 && errno == EINTR); + + return ret; +} + +/** FD EVENT LOOP + **/ + +/* A Looper object is used to monitor activity on one or more + * file descriptors (e.g sockets). + * + * - call looper_add() to register a function that will be + * called when events happen on the file descriptor. + * + * - call looper_enable() or looper_disable() to enable/disable + * the set of monitored events for a given file descriptor. + * + * - call looper_del() to unregister a file descriptor. + * this does *not* close the file descriptor. + * + * Note that you can only provide a single function to handle + * all events related to a given file descriptor. + + * You can call looper_enable/_disable/_del within a function + * callback. + */ + +/* the current implementation uses Linux's epoll facility + * the event mask we use are simply combinations of EPOLLIN + * EPOLLOUT, EPOLLHUP and EPOLLERR + */ +#include + +#define MAX_CHANNELS 16 +#define MAX_EVENTS (MAX_CHANNELS+1) /* each channel + the serial fd */ + +/* the event handler function type, 'user' is a user-specific + * opaque pointer passed to looper_add(). + */ +typedef void (*EventFunc)( void* user, int events ); + +/* bit flags for the LoopHook structure. + * + * HOOK_PENDING means that an event happened on the + * corresponding file descriptor. + * + * HOOK_CLOSING is used to delay-close monitored + * file descriptors. + */ +enum { + HOOK_PENDING = (1 << 0), + HOOK_CLOSING = (1 << 1), +}; + +/* A LoopHook structure is used to monitor a given + * file descriptor and record its event handler. + */ +typedef struct { + int fd; + int wanted; /* events we are monitoring */ + int events; /* events that occured */ + int state; /* see HOOK_XXX constants */ + void* ev_user; /* user-provided handler parameter */ + EventFunc ev_func; /* event handler callback */ +} LoopHook; + +/* Looper is the main object modeling a looper object + */ +typedef struct { + int epoll_fd; + int num_fds; + int max_fds; + struct epoll_event* events; + LoopHook* hooks; +} Looper; + +/* initialize a looper object */ +static void +looper_init( Looper* l ) +{ + l->epoll_fd = epoll_create(4); + l->num_fds = 0; + l->max_fds = 0; + l->events = NULL; + l->hooks = NULL; +} + +/* finalize a looper object */ +static void +looper_done( Looper* l ) +{ + xfree(l->events); + xfree(l->hooks); + l->max_fds = 0; + l->num_fds = 0; + + close(l->epoll_fd); + l->epoll_fd = -1; +} + +/* return the LoopHook corresponding to a given + * monitored file descriptor, or NULL if not found + */ +static LoopHook* +looper_find( Looper* l, int fd ) +{ + LoopHook* hook = l->hooks; + LoopHook* end = hook + l->num_fds; + + for ( ; hook < end; hook++ ) { + if (hook->fd == fd) + return hook; + } + return NULL; +} + +/* grow the arrays in the looper object */ +static void +looper_grow( Looper* l ) +{ + int old_max = l->max_fds; + int new_max = old_max + (old_max >> 1) + 4; + int n; + + xrenew( l->events, new_max ); + xrenew( l->hooks, new_max ); + l->max_fds = new_max; + + /* now change the handles to all events */ + for (n = 0; n < l->num_fds; n++) { + struct epoll_event ev; + LoopHook* hook = l->hooks + n; + + ev.events = hook->wanted; + ev.data.ptr = hook; + epoll_ctl( l->epoll_fd, EPOLL_CTL_MOD, hook->fd, &ev ); + } +} + +/* register a file descriptor and its event handler. + * no event mask will be enabled + */ +static void +looper_add( Looper* l, int fd, EventFunc func, void* user ) +{ + struct epoll_event ev; + LoopHook* hook; + + if (l->num_fds >= l->max_fds) + looper_grow(l); + + hook = l->hooks + l->num_fds; + + hook->fd = fd; + hook->ev_user = user; + hook->ev_func = func; + hook->state = 0; + hook->wanted = 0; + hook->events = 0; + + fd_setnonblock(fd); + + ev.events = 0; + ev.data.ptr = hook; + epoll_ctl( l->epoll_fd, EPOLL_CTL_ADD, fd, &ev ); + + l->num_fds += 1; +} + +/* unregister a file descriptor and its event handler + */ +static void +looper_del( Looper* l, int fd ) +{ + LoopHook* hook = looper_find( l, fd ); + + if (!hook) { + D( "%s: invalid fd: %d", __FUNCTION__, fd ); + return; + } + /* don't remove the hook yet */ + hook->state |= HOOK_CLOSING; + + epoll_ctl( l->epoll_fd, EPOLL_CTL_DEL, fd, NULL ); +} + +/* enable monitoring of certain events for a file + * descriptor. This adds 'events' to the current + * event mask + */ +static void +looper_enable( Looper* l, int fd, int events ) +{ + LoopHook* hook = looper_find( l, fd ); + + if (!hook) { + D("%s: invalid fd: %d", __FUNCTION__, fd ); + return; + } + + if (events & ~hook->wanted) { + struct epoll_event ev; + + hook->wanted |= events; + ev.events = hook->wanted; + ev.data.ptr = hook; + + epoll_ctl( l->epoll_fd, EPOLL_CTL_MOD, fd, &ev ); + } +} + +/* disable monitoring of certain events for a file + * descriptor. This ignores events that are not + * currently enabled. + */ +static void +looper_disable( Looper* l, int fd, int events ) +{ + LoopHook* hook = looper_find( l, fd ); + + if (!hook) { + D("%s: invalid fd: %d", __FUNCTION__, fd ); + return; + } + + if (events & hook->wanted) { + struct epoll_event ev; + + hook->wanted &= ~events; + ev.events = hook->wanted; + ev.data.ptr = hook; + + epoll_ctl( l->epoll_fd, EPOLL_CTL_MOD, fd, &ev ); + } +} + +/* wait until an event occurs on one of the registered file + * descriptors. Only returns in case of error !! + */ +static void +looper_loop( Looper* l ) +{ + for (;;) { + int n, count; + + do { + count = epoll_wait( l->epoll_fd, l->events, l->num_fds, -1 ); + } while (count < 0 && errno == EINTR); + + if (count < 0) { + D("%s: error: %s", __FUNCTION__, strerror(errno) ); + return; + } + + if (count == 0) { + D("%s: huh ? epoll returned count=0", __FUNCTION__); + continue; + } + + /* mark all pending hooks */ + for (n = 0; n < count; n++) { + LoopHook* hook = l->events[n].data.ptr; + hook->state = HOOK_PENDING; + hook->events = l->events[n].events; + } + + /* execute hook callbacks. this may change the 'hooks' + * and 'events' array, as well as l->num_fds, so be careful */ + for (n = 0; n < l->num_fds; n++) { + LoopHook* hook = l->hooks + n; + if (hook->state & HOOK_PENDING) { + hook->state &= ~HOOK_PENDING; + hook->ev_func( hook->ev_user, hook->events ); + } + } + + /* now remove all the hooks that were closed by + * the callbacks */ + for (n = 0; n < l->num_fds;) { + struct epoll_event ev; + LoopHook* hook = l->hooks + n; + + if (!(hook->state & HOOK_CLOSING)) { + n++; + continue; + } + + hook[0] = l->hooks[l->num_fds-1]; + l->num_fds -= 1; + ev.events = hook->wanted; + ev.data.ptr = hook; + epoll_ctl( l->epoll_fd, EPOLL_CTL_MOD, hook->fd, &ev ); + } + } +} + +#if T_ACTIVE +char* +quote( const void* data, int len ) +{ + const char* p = data; + const char* end = p + len; + int count = 0; + int phase = 0; + static char* buff = NULL; + + for (phase = 0; phase < 2; phase++) { + if (phase != 0) { + xfree(buff); + buff = xalloc(count+1); + } + count = 0; + for (p = data; p < end; p++) { + int c = *p; + + if (c == '\\') { + if (phase != 0) { + buff[count] = buff[count+1] = '\\'; + } + count += 2; + continue; + } + + if (c >= 32 && c < 127) { + if (phase != 0) + buff[count] = c; + count += 1; + continue; + } + + + if (c == '\t') { + if (phase != 0) { + memcpy(buff+count, "", 5); + } + count += 5; + continue; + } + if (c == '\n') { + if (phase != 0) { + memcpy(buff+count, "", 4); + } + count += 4; + continue; + } + if (c == '\r') { + if (phase != 0) { + memcpy(buff+count, "", 4); + } + count += 4; + continue; + } + + if (phase != 0) { + buff[count+0] = '\\'; + buff[count+1] = 'x'; + buff[count+2] = "0123456789abcdef"[(c >> 4) & 15]; + buff[count+3] = "0123456789abcdef"[ (c) & 15]; + } + count += 4; + } + } + buff[count] = 0; + return buff; +} +#endif /* T_ACTIVE */ + +/** PACKETS + ** + ** We need a way to buffer data before it can be sent to the + ** corresponding file descriptor. We use linked list of Packet + ** objects to do this. + **/ + +typedef struct Packet Packet; + +#define MAX_PAYLOAD 4000 + +struct Packet { + Packet* next; + int len; + int channel; + uint8_t data[ MAX_PAYLOAD ]; +}; + +/* we expect to alloc/free a lot of packets during + * operations so use a single linked list of free packets + * to keep things speedy and simple. + */ +static Packet* _free_packets; + +/* Allocate a packet */ +static Packet* +packet_alloc(void) +{ + Packet* p = _free_packets; + if (p != NULL) { + _free_packets = p->next; + } else { + xnew(p); + } + p->next = NULL; + p->len = 0; + p->channel = -1; + return p; +} + +/* Release a packet. This takes the address of a packet + * pointer that will be set to NULL on exit (avoids + * referencing dangling pointers in case of bugs) + */ +static void +packet_free( Packet* *ppacket ) +{ + Packet* p = *ppacket; + if (p) { + p->next = _free_packets; + _free_packets = p; + *ppacket = NULL; + } +} + +/** PACKET RECEIVER + ** + ** Simple abstraction for something that can receive a packet + ** from a FDHandler (see below) or something else. + ** + ** Send a packet to it with 'receiver_post' + ** + ** Call 'receiver_close' to indicate that the corresponding + ** packet source was closed. + **/ + +typedef void (*PostFunc) ( void* user, Packet* p ); +typedef void (*CloseFunc)( void* user ); + +typedef struct { + PostFunc post; + CloseFunc close; + void* user; +} Receiver; + +/* post a packet to a receiver. Note that this transfers + * ownership of the packet to the receiver. + */ +static __inline__ void +receiver_post( Receiver* r, Packet* p ) +{ + if (r->post) + r->post( r->user, p ); + else + packet_free(&p); +} + +/* tell a receiver the packet source was closed. + * this will also prevent further posting to the + * receiver. + */ +static __inline__ void +receiver_close( Receiver* r ) +{ + if (r->close) { + r->close( r->user ); + r->close = NULL; + } + r->post = NULL; +} + + +/** FD HANDLERS + ** + ** these are smart listeners that send incoming packets to a receiver + ** and can queue one or more outgoing packets and send them when + ** possible to the FD. + ** + ** note that we support clean shutdown of file descriptors, + ** i.e. we try to send all outgoing packets before destroying + ** the FDHandler. + **/ + +typedef struct FDHandler FDHandler; +typedef struct FDHandlerList FDHandlerList; + +struct FDHandler { + int fd; + FDHandlerList* list; + char closing; + Receiver receiver[1]; + + /* queue of outgoing packets */ + int out_pos; + Packet* out_first; + Packet** out_ptail; + + FDHandler* next; + FDHandler** pref; + +}; + +struct FDHandlerList { + /* the looper that manages the fds */ + Looper* looper; + + /* list of active FDHandler objects */ + FDHandler* active; + + /* list of closing FDHandler objects. + * these are waiting to push their + * queued packets to the fd before + * freeing themselves. + */ + FDHandler* closing; + +}; + +/* remove a FDHandler from its current list */ +static void +fdhandler_remove( FDHandler* f ) +{ + f->pref[0] = f->next; + if (f->next) + f->next->pref = f->pref; +} + +/* add a FDHandler to a given list */ +static void +fdhandler_prepend( FDHandler* f, FDHandler** list ) +{ + f->next = list[0]; + f->pref = list; + list[0] = f; + if (f->next) + f->next->pref = &f->next; +} + +/* initialize a FDHandler list */ +static void +fdhandler_list_init( FDHandlerList* list, Looper* looper ) +{ + list->looper = looper; + list->active = NULL; + list->closing = NULL; +} + + +/* close a FDHandler (and free it). Note that this will not + * perform a graceful shutdown, i.e. all packets in the + * outgoing queue will be immediately free. + * + * this *will* notify the receiver that the file descriptor + * was closed. + * + * you should call fdhandler_shutdown() if you want to + * notify the FDHandler that its packet source is closed. + */ +static void +fdhandler_close( FDHandler* f ) +{ + /* notify receiver */ + receiver_close(f->receiver); + + /* remove the handler from its list */ + fdhandler_remove(f); + + /* get rid of outgoing packet queue */ + if (f->out_first != NULL) { + Packet* p; + while ((p = f->out_first) != NULL) { + f->out_first = p->next; + packet_free(&p); + } + } + + /* get rid of file descriptor */ + if (f->fd >= 0) { + looper_del( f->list->looper, f->fd ); + close(f->fd); + f->fd = -1; + } + + f->list = NULL; + xfree(f); +} + +/* Ask the FDHandler to cleanly shutdown the connection, + * i.e. send any pending outgoing packets then auto-free + * itself. + */ +static void +fdhandler_shutdown( FDHandler* f ) +{ + /* prevent later fdhandler_close() to + * call the receiver's close. + */ + f->receiver->close = NULL; + + if (f->out_first != NULL && !f->closing) + { + /* move the handler to the 'closing' list */ + f->closing = 1; + fdhandler_remove(f); + fdhandler_prepend(f, &f->list->closing); + return; + } + + fdhandler_close(f); +} + +/* Enqueue a new packet that the FDHandler will + * send through its file descriptor. + */ +static void +fdhandler_enqueue( FDHandler* f, Packet* p ) +{ + Packet* first = f->out_first; + + p->next = NULL; + f->out_ptail[0] = p; + f->out_ptail = &p->next; + + if (first == NULL) { + f->out_pos = 0; + looper_enable( f->list->looper, f->fd, EPOLLOUT ); + } +} + + +/* FDHandler file descriptor event callback for read/write ops */ +static void +fdhandler_event( FDHandler* f, int events ) +{ + int len; + + /* in certain cases, it's possible to have both EPOLLIN and + * EPOLLHUP at the same time. This indicates that there is incoming + * data to read, but that the connection was nonetheless closed + * by the sender. Be sure to read the data before closing + * the receiver to avoid packet loss. + */ + + if (events & EPOLLIN) { + Packet* p = packet_alloc(); + int len; + + if ((len = fd_read(f->fd, p->data, MAX_PAYLOAD)) < 0) { + D("%s: can't recv: %s", __FUNCTION__, strerror(errno)); + packet_free(&p); + } else if (len > 0) { + p->len = len; + p->channel = -101; /* special debug value, not used */ + receiver_post( f->receiver, p ); + } + } + + if (events & (EPOLLHUP|EPOLLERR)) { + /* disconnection */ + D("%s: disconnect on fd %d", __FUNCTION__, f->fd); + fdhandler_close(f); + return; + } + + if (events & EPOLLOUT && f->out_first) { + Packet* p = f->out_first; + int avail, len; + + avail = p->len - f->out_pos; + if ((len = fd_write(f->fd, p->data + f->out_pos, avail)) < 0) { + D("%s: can't send: %s", __FUNCTION__, strerror(errno)); + } else { + f->out_pos += len; + if (f->out_pos >= p->len) { + f->out_pos = 0; + f->out_first = p->next; + packet_free(&p); + if (f->out_first == NULL) { + f->out_ptail = &f->out_first; + looper_disable( f->list->looper, f->fd, EPOLLOUT ); + } + } + } + } +} + + +/* Create a new FDHandler that monitors read/writes */ +static FDHandler* +fdhandler_new( int fd, + FDHandlerList* list, + Receiver* receiver ) +{ + FDHandler* f = xalloc0(sizeof(*f)); + + f->fd = fd; + f->list = list; + f->receiver[0] = receiver[0]; + f->out_first = NULL; + f->out_ptail = &f->out_first; + f->out_pos = 0; + + fdhandler_prepend(f, &list->active); + + looper_add( list->looper, fd, (EventFunc) fdhandler_event, f ); + looper_enable( list->looper, fd, EPOLLIN ); + + return f; +} + + +/* event callback function to monitor accepts() on server sockets. + * the convention used here is that the receiver will receive a + * dummy packet with the new client socket in p->channel + */ +static void +fdhandler_accept_event( FDHandler* f, int events ) +{ + if (events & EPOLLIN) { + /* this is an accept - send a dummy packet to the receiver */ + Packet* p = packet_alloc(); + + D("%s: accepting on fd %d", __FUNCTION__, f->fd); + p->data[0] = 1; + p->len = 1; + p->channel = fd_accept(f->fd); + if (p->channel < 0) { + D("%s: accept failed ?: %s", __FUNCTION__, strerror(errno)); + packet_free(&p); + return; + } + receiver_post( f->receiver, p ); + } + + if (events & (EPOLLHUP|EPOLLERR)) { + /* disconnecting !! */ + D("%s: closing accept fd %d", __FUNCTION__, f->fd); + fdhandler_close(f); + return; + } +} + + +/* Create a new FDHandler used to monitor new connections on a + * server socket. The receiver must expect the new connection + * fd in the 'channel' field of a dummy packet. + */ +static FDHandler* +fdhandler_new_accept( int fd, + FDHandlerList* list, + Receiver* receiver ) +{ + FDHandler* f = xalloc0(sizeof(*f)); + + f->fd = fd; + f->list = list; + f->receiver[0] = receiver[0]; + + fdhandler_prepend(f, &list->active); + + looper_add( list->looper, fd, (EventFunc) fdhandler_accept_event, f ); + looper_enable( list->looper, fd, EPOLLIN ); + listen( fd, 5 ); + + return f; +} + +/** SERIAL CONNECTION STATE + ** + ** The following is used to handle the framing protocol + ** used on the serial port connection. + **/ + +/* each packet is made of a 6 byte header followed by a payload + * the header looks like: + * + * offset size description + * 0 2 a 2-byte hex string for the channel number + * 4 4 a 4-char hex string for the size of the payload + * 6 n the payload itself + */ +#define HEADER_SIZE 6 +#define CHANNEL_OFFSET 0 +#define LENGTH_OFFSET 2 +#define CHANNEL_SIZE 2 +#define LENGTH_SIZE 4 + +#define CHANNEL_CONTROL 0 + +/* The Serial object receives data from the serial port, + * extracts the payload size and channel index, then sends + * the resulting messages as a packet to a generic receiver. + * + * You can also use serial_send to send a packet through + * the serial port. + */ +typedef struct Serial { + FDHandler* fdhandler; /* used to monitor serial port fd */ + Receiver receiver[1]; /* send payload there */ + int in_len; /* current bytes in input packet */ + int in_datalen; /* payload size, or 0 when reading header */ + int in_channel; /* extracted channel number */ + Packet* in_packet; /* used to read incoming packets */ +} Serial; + + +/* a callback called when the serial port's fd is closed */ +static void +serial_fd_close( Serial* s ) +{ + fatal("unexpected serial port close !!"); +} + +static void +serial_dump( Packet* p, const char* funcname ) +{ + T("%s: %03d bytes: '%s'", + funcname, p->len, quote(p->data, p->len)); +} + +/* a callback called when a packet arrives from the serial port's FDHandler. + * + * This will essentially parse the header, extract the channel number and + * the payload size and store them in 'in_datalen' and 'in_channel'. + * + * After that, the payload is sent to the receiver once completed. + */ +static void +serial_fd_receive( Serial* s, Packet* p ) +{ + int rpos = 0, rcount = p->len; + Packet* inp = s->in_packet; + int inpos = s->in_len; + + serial_dump( p, __FUNCTION__ ); + + while (rpos < rcount) + { + int avail = rcount - rpos; + + /* first, try to read the header */ + if (s->in_datalen == 0) { + int wanted = HEADER_SIZE - inpos; + if (avail > wanted) + avail = wanted; + + memcpy( inp->data + inpos, p->data + rpos, avail ); + inpos += avail; + rpos += avail; + + if (inpos == HEADER_SIZE) { + s->in_datalen = hex2int( inp->data + LENGTH_OFFSET, LENGTH_SIZE ); + s->in_channel = hex2int( inp->data + CHANNEL_OFFSET, CHANNEL_SIZE ); + + if (s->in_datalen <= 0) { + D("ignoring %s packet from serial port", + s->in_datalen ? "empty" : "malformed"); + s->in_datalen = 0; + } + + //D("received %d bytes packet for channel %d", s->in_datalen, s->in_channel); + inpos = 0; + } + } + else /* then, populate the packet itself */ + { + int wanted = s->in_datalen - inpos; + + if (avail > wanted) + avail = wanted; + + memcpy( inp->data + inpos, p->data + rpos, avail ); + inpos += avail; + rpos += avail; + + if (inpos == s->in_datalen) { + if (s->in_channel < 0) { + D("ignoring %d bytes addressed to channel %d", + inpos, s->in_channel); + } else { + inp->len = inpos; + inp->channel = s->in_channel; + receiver_post( s->receiver, inp ); + s->in_packet = inp = packet_alloc(); + } + s->in_datalen = 0; + inpos = 0; + } + } + } + s->in_len = inpos; + packet_free(&p); +} + + +/* send a packet to the serial port. + * this assumes that p->len and p->channel contain the payload's + * size and channel and will add the appropriate header. + */ +static void +serial_send( Serial* s, Packet* p ) +{ + Packet* h = packet_alloc(); + + //D("sending to serial %d bytes from channel %d: '%.*s'", p->len, p->channel, p->len, p->data); + + /* insert a small header before this packet */ + h->len = HEADER_SIZE; + int2hex( p->len, h->data + LENGTH_OFFSET, LENGTH_SIZE ); + int2hex( p->channel, h->data + CHANNEL_OFFSET, CHANNEL_SIZE ); + + serial_dump( h, __FUNCTION__ ); + serial_dump( p, __FUNCTION__ ); + + fdhandler_enqueue( s->fdhandler, h ); + fdhandler_enqueue( s->fdhandler, p ); +} + + +/* initialize serial reader */ +static void +serial_init( Serial* s, + int fd, + FDHandlerList* list, + Receiver* receiver ) +{ + Receiver recv; + + recv.user = s; + recv.post = (PostFunc) serial_fd_receive; + recv.close = (CloseFunc) serial_fd_close; + + s->receiver[0] = receiver[0]; + + s->fdhandler = fdhandler_new( fd, list, &recv ); + s->in_len = 0; + s->in_datalen = 0; + s->in_channel = 0; + s->in_packet = packet_alloc(); +} + + +/** CLIENTS + **/ + +typedef struct Client Client; +typedef struct Multiplexer Multiplexer; + +/* A Client object models a single qemud client socket + * connection in the emulated system. + * + * the client first sends the name of the system service + * it wants to contact (no framing), then waits for a 2 + * byte answer from qemud. + * + * the answer is either "OK" or "KO" to indicate + * success or failure. + * + * In case of success, the client can send messages + * to the service. + * + * In case of failure, it can disconnect or try sending + * the name of another service. + */ +struct Client { + Client* next; + Client** pref; + int channel; + char registered; + FDHandler* fdhandler; + Multiplexer* multiplexer; +}; + +struct Multiplexer { + Client* clients; + int last_channel; + Serial serial[1]; + Looper looper[1]; + FDHandlerList fdhandlers[1]; +}; + + +static int multiplexer_open_channel( Multiplexer* mult, Packet* p ); +static void multiplexer_close_channel( Multiplexer* mult, int channel ); +static void multiplexer_serial_send( Multiplexer* mult, int channel, Packet* p ); + +static void +client_dump( Client* c, Packet* p, const char* funcname ) +{ + T("%s: client %p (%d): %3d bytes: '%s'", + funcname, c, c->fdhandler->fd, + p->len, quote(p->data, p->len)); +} + +/* destroy a client */ +static void +client_free( Client* c ) +{ + /* remove from list */ + c->pref[0] = c->next; + if (c->next) + c->next->pref = c->pref; + + c->channel = -1; + c->registered = 0; + + /* gently ask the FDHandler to shutdown to + * avoid losing queued outgoing packets */ + if (c->fdhandler != NULL) { + fdhandler_shutdown(c->fdhandler); + c->fdhandler = NULL; + } + + xfree(c); +} + + +/* a function called when a client socket receives data */ +static void +client_fd_receive( Client* c, Packet* p ) +{ + client_dump(c, p, __FUNCTION__); + + if (c->registered) { + /* the client is registered, just send the + * data through the serial port + */ + multiplexer_serial_send(c->multiplexer, c->channel, p); + return; + } + + if (c->channel > 0) { + /* the client is waiting registration results. + * this should not happen because the client + * should wait for our 'ok' or 'ko'. + * close the connection. + */ + D("%s: bad client sending data before end of registration", + __FUNCTION__); + BAD_CLIENT: + packet_free(&p); + client_free(c); + return; + } + + /* the client hasn't registered a service yet, + * so this must be the name of a service, call + * the multiplexer to start registration for + * it. + */ + D("%s: attempting registration for service '%.*s'", + __FUNCTION__, p->len, p->data); + c->channel = multiplexer_open_channel(c->multiplexer, p); + if (c->channel < 0) { + D("%s: service name too long", __FUNCTION__); + goto BAD_CLIENT; + } + D("%s: -> received channel id %d", __FUNCTION__, c->channel); + packet_free(&p); +} + + +/* a function called when the client socket is closed. */ +static void +client_fd_close( Client* c ) +{ + T("%s: client %p (%d)", __FUNCTION__, c, c->fdhandler->fd); + + /* no need to shutdown the FDHandler */ + c->fdhandler = NULL; + + /* tell the emulator we're out */ + if (c->channel > 0) + multiplexer_close_channel(c->multiplexer, c->channel); + + /* free the client */ + client_free(c); +} + +/* a function called when the multiplexer received a registration + * response from the emulator for a given client. + */ +static void +client_registration( Client* c, int registered ) +{ + Packet* p = packet_alloc(); + + /* sends registration status to client */ + if (!registered) { + D("%s: registration failed for client %d", __FUNCTION__, c->channel); + memcpy( p->data, "KO", 2 ); + p->len = 2; + } else { + D("%s: registration succeeded for client %d", __FUNCTION__, c->channel); + memcpy( p->data, "OK", 2 ); + p->len = 2; + } + client_dump(c, p, __FUNCTION__); + fdhandler_enqueue(c->fdhandler, p); + + /* now save registration state + */ + c->registered = registered; + if (!registered) { + /* allow the client to try registering another service */ + c->channel = -1; + } +} + +/* send data to a client */ +static void +client_send( Client* c, Packet* p ) +{ + client_dump(c, p, __FUNCTION__); + fdhandler_enqueue(c->fdhandler, p); +} + + +/* Create new client socket handler */ +static Client* +client_new( Multiplexer* mult, + int fd, + FDHandlerList* pfdhandlers, + Client** pclients ) +{ + Client* c; + Receiver recv; + + xnew(c); + + c->multiplexer = mult; + c->next = NULL; + c->pref = &c->next; + c->channel = -1; + c->registered = 0; + + recv.user = c; + recv.post = (PostFunc) client_fd_receive; + recv.close = (CloseFunc) client_fd_close; + + c->fdhandler = fdhandler_new( fd, pfdhandlers, &recv ); + + /* add to client list */ + c->next = *pclients; + c->pref = pclients; + *pclients = c; + if (c->next) + c->next->pref = &c->next; + + return c; +} + +/** GLOBAL MULTIPLEXER + **/ + +/* find a client by its channel */ +static Client* +multiplexer_find_client( Multiplexer* mult, int channel ) +{ + Client* c = mult->clients; + + for ( ; c != NULL; c = c->next ) { + if (c->channel == channel) + return c; + } + return NULL; +} + +/* handle control messages coming from the serial port + * on CONTROL_CHANNEL. + */ +static void +multiplexer_handle_control( Multiplexer* mult, Packet* p ) +{ + /* connection registration success */ + if (p->len == 13 && !memcmp(p->data, "ok:connect:", 11)) { + int channel = hex2int(p->data+11, 2); + Client* client = multiplexer_find_client(mult, channel); + + /* note that 'client' can be NULL if the corresponding + * socket was closed before the emulator response arrived. + */ + if (client != NULL) { + client_registration(client, 1); + } else { + D("%s: NULL client: '%.*s'", __FUNCTION__, p->len, p->data+11); + } + goto EXIT; + } + + /* connection registration failure */ + if (p->len == 13 && !memcmp(p->data, "ko:connect:",11)) { + int channel = hex2int(p->data+11, 2); + Client* client = multiplexer_find_client(mult, channel); + + if (client != NULL) + client_registration(client, 0); + + goto EXIT; + } + + /* emulator-induced client disconnection */ + if (p->len == 13 && !memcmp(p->data, "disconnect:",11)) { + int channel = hex2int(p->data+11, 2); + Client* client = multiplexer_find_client(mult, channel); + + if (client != NULL) + client_free(client); + + goto EXIT; + } + + /* A message that begins with "X00" is a probe sent by + * the emulator used to detect which version of qemud it runs + * against (in order to detect 1.0/1.1 system images. Just + * silently ignore it there instead of printing an error + * message. + */ + if (p->len >= 3 && !memcmp(p->data,"X00",3)) { + goto EXIT; + } + + D("%s: unknown control message (%d bytes): '%.*s'", + __FUNCTION__, p->len, p->len, p->data); + +EXIT: + packet_free(&p); +} + +/* a function called when an incoming packet comes from the serial port */ +static void +multiplexer_serial_receive( Multiplexer* mult, Packet* p ) +{ + Client* client; + + T("%s: channel=%d '%.*s'", __FUNCTION__, p->channel, p->len, p->data); + + if (p->channel == CHANNEL_CONTROL) { + multiplexer_handle_control(mult, p); + return; + } + + client = multiplexer_find_client(mult, p->channel); + if (client != NULL) { + client_send(client, p); + return; + } + + D("%s: discarding packet for unknown channel %d", __FUNCTION__, p->channel); + packet_free(&p); +} + +/* a function called when the serial reader closes */ +static void +multiplexer_serial_close( Multiplexer* mult ) +{ + fatal("unexpected close of serial reader"); +} + +/* a function called to send a packet to the serial port */ +static void +multiplexer_serial_send( Multiplexer* mult, int channel, Packet* p ) +{ + p->channel = channel; + serial_send( mult->serial, p ); +} + + + +/* a function used by a client to allocate a new channel id and + * ask the emulator to open it. 'service' must be a packet containing + * the name of the service in its payload. + * + * returns -1 if the service name is too long. + * + * notice that client_registration() will be called later when + * the answer arrives. + */ +static int +multiplexer_open_channel( Multiplexer* mult, Packet* service ) +{ + Packet* p = packet_alloc(); + int len, channel; + + /* find a free channel number, assume we don't have many + * clients here. */ + { + Client* c; + TRY_AGAIN: + channel = (++mult->last_channel) & 0xff; + + for (c = mult->clients; c != NULL; c = c->next) + if (c->channel == channel) + goto TRY_AGAIN; + } + + len = snprintf((char*)p->data, sizeof p->data, "connect:%.*s:%02x", service->len, service->data, channel); + if (len >= (int)sizeof(p->data)) { + D("%s: weird, service name too long (%d > %d)", __FUNCTION__, len, sizeof(p->data)); + packet_free(&p); + return -1; + } + p->channel = CHANNEL_CONTROL; + p->len = len; + + serial_send(mult->serial, p); + return channel; +} + +/* used to tell the emulator a channel was closed by a client */ +static void +multiplexer_close_channel( Multiplexer* mult, int channel ) +{ + Packet* p = packet_alloc(); + int len = snprintf((char*)p->data, sizeof(p->data), "disconnect:%02x", channel); + + if (len > (int)sizeof(p->data)) { + /* should not happen */ + return; + } + + p->channel = CHANNEL_CONTROL; + p->len = len; + + serial_send(mult->serial, p); +} + +/* this function is used when a new connection happens on the control + * socket. + */ +static void +multiplexer_control_accept( Multiplexer* m, Packet* p ) +{ + /* the file descriptor for the new socket connection is + * in p->channel. See fdhandler_accept_event() */ + int fd = p->channel; + Client* client = client_new( m, fd, m->fdhandlers, &m->clients ); + + D("created client %p listening on fd %d", client, fd); + + /* free dummy packet */ + packet_free(&p); +} + +static void +multiplexer_control_close( Multiplexer* m ) +{ + fatal("unexpected multiplexer control close"); +} + +static void +multiplexer_init( Multiplexer* m, const char* serial_dev ) +{ + int fd, control_fd; + Receiver recv; + + /* initialize looper and fdhandlers list */ + looper_init( m->looper ); + fdhandler_list_init( m->fdhandlers, m->looper ); + + /* open the serial port */ + do { + fd = socket(AF_LOCAL, SOCK_STREAM, 0); + } while (fd < 0 && errno == EINTR); + + struct sockaddr_un addr; + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, serial_dev, sizeof(addr.sun_path)); + + if (connect(fd, (struct sockaddr*) &addr, sizeof(addr)) < 0) { + close(fd); + fd = -1; + } + + if (fd < 0) { + fatal( "%s: could not open '%s': %s", __FUNCTION__, serial_dev, + strerror(errno) ); + } + + /* initialize the serial reader/writer */ + recv.user = m; + recv.post = (PostFunc) multiplexer_serial_receive; + recv.close = (CloseFunc) multiplexer_serial_close; + + serial_init( m->serial, fd, m->fdhandlers, &recv ); + + /* open the qemud control socket */ + recv.user = m; + recv.post = (PostFunc) multiplexer_control_accept; + recv.close = (CloseFunc) multiplexer_control_close; + + fd = android_get_control_socket(CONTROL_SOCKET_NAME); + if (fd < 0) { + fatal("couldn't get fd for control socket '%s'", CONTROL_SOCKET_NAME); + } + + fdhandler_new_accept( fd, m->fdhandlers, &recv ); + + /* initialize clients list */ + m->clients = NULL; +} + +/** MAIN LOOP + **/ + +static Multiplexer _multiplexer[1]; + +int main( void ) +{ + Multiplexer* m = _multiplexer; + + multiplexer_init(m, "/dev/qemud"); + + D( "entering main loop"); + looper_loop( m->looper ); + D( "unexpected termination !!" ); + return 0; +} diff --git a/src/type3_AndroidCloud/anbox-master/android/sensors/Android.mk b/src/type3_AndroidCloud/anbox-master/android/sensors/Android.mk new file mode 100644 index 0000000..4b935a7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/sensors/Android.mk @@ -0,0 +1,40 @@ +# Copyright (C) 2009 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +LOCAL_PATH := $(call my-dir) + +# HAL module implemenation stored in +# hw/..so +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_SRC_FILES := sensors_qemu.c +ifeq ($(TARGET_PRODUCT),vbox_x86) +LOCAL_MODULE := sensors.vbox_x86 +else +LOCAL_MODULE := sensors.goldfish +endif +include $(BUILD_SHARED_LIBRARY) + + +include $(CLEAR_VARS) + +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_SRC_FILES := sensors_qemu.c +LOCAL_MODULE := sensors.ranchu + +include $(BUILD_SHARED_LIBRARY) diff --git a/src/type3_AndroidCloud/anbox-master/android/sensors/sensors_qemu.c b/src/type3_AndroidCloud/anbox-master/android/sensors/sensors_qemu.c new file mode 100644 index 0000000..b0e858c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/android/sensors/sensors_qemu.c @@ -0,0 +1,751 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* this implements a sensors hardware library for the Android emulator. + * the following code should be built as a shared library that will be + * placed into /system/lib/hw/sensors.goldfish.so + * + * it will be loaded by the code in hardware/libhardware/hardware.c + * which is itself called from com_android_server_SensorService.cpp + */ + + +/* we connect with the emulator through the "sensors" qemud service + */ +#define SENSORS_SERVICE_NAME "sensors" + +#define LOG_TAG "QemuSensors" + +#include +#include +#include +#include +#include +#include +#include + +#if 0 +#define D(...) ALOGD(__VA_ARGS__) +#else +#define D(...) ((void)0) +#endif + +#define E(...) ALOGE(__VA_ARGS__) + +#include + +/** SENSOR IDS AND NAMES + **/ + +#define MAX_NUM_SENSORS 8 + +#define SUPPORTED_SENSORS ((1<"; +} + +static int +_sensorIdFromName( const char* name ) +{ + int nn; + + if (name == NULL) + return -1; + + for (nn = 0; nn < MAX_NUM_SENSORS; nn++) + if (!strcmp(name, _sensorIds[nn].name)) + return _sensorIds[nn].id; + + return -1; +} + +/* return the current time in nanoseconds */ +static int64_t now_ns(void) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec; +} + +/** SENSORS POLL DEVICE + ** + ** This one is used to read sensor data from the hardware. + ** We implement this by simply reading the data from the + ** emulator through the QEMUD channel. + **/ + +typedef struct SensorDevice { + struct sensors_poll_device_1 device; + sensors_event_t sensors[MAX_NUM_SENSORS]; + uint32_t pendingSensors; + int64_t timeStart; + int64_t timeOffset; + uint32_t active_sensors; + int fd; + pthread_mutex_t lock; +} SensorDevice; + +/* Grab the file descriptor to the emulator's sensors service pipe. + * This function returns a file descriptor on success, or -errno on + * failure, and assumes the SensorDevice instance's lock is held. + * + * This is needed because set_delay(), poll() and activate() can be called + * from different threads, and poll() is blocking. + * + * Note that the emulator's sensors service creates a new client for each + * connection through qemud_channel_open(), where each client has its own + * delay and set of activated sensors. This precludes calling + * qemud_channel_open() on each request, because a typical emulated system + * will do something like: + * + * 1) On a first thread, de-activate() all sensors first, then call poll(), + * which results in the thread blocking. + * + * 2) On a second thread, slightly later, call set_delay() then activate() + * to enable the acceleration sensor. + * + * The system expects this to unblock the first thread which will receive + * new sensor events after the activate() call in 2). + * + * This cannot work if both threads don't use the same connection. + * + * TODO(digit): This protocol is brittle, implement another control channel + * for set_delay()/activate()/batch() when supporting HAL 1.3 + */ +static int sensor_device_get_fd_locked(SensorDevice* dev) { + /* Create connection to service on first call */ + if (dev->fd < 0) { + dev->fd = qemud_channel_open(SENSORS_SERVICE_NAME); + if (dev->fd < 0) { + int ret = -errno; + E("%s: Could not open connection to service: %s", __FUNCTION__, + strerror(-ret)); + return ret; + } + } + return dev->fd; +} + +/* Send a command to the sensors virtual device. |dev| is a device instance and + * |cmd| is a zero-terminated command string. Return 0 on success, or -errno + * on failure. */ +static int sensor_device_send_command_locked(SensorDevice* dev, + const char* cmd) { + int fd = sensor_device_get_fd_locked(dev); + if (fd < 0) { + return fd; + } + + int ret = 0; + if (qemud_channel_send(fd, cmd, strlen(cmd)) < 0) { + ret = -errno; + E("%s(fd=%d): ERROR: %s", __FUNCTION__, fd, strerror(errno)); + } + return ret; +} + +/* Pick up one pending sensor event. On success, this returns the sensor + * id, and sets |*event| accordingly. On failure, i.e. if there are no + * pending events, return -EINVAL. + * + * Note: The device's lock must be acquired. + */ +static int sensor_device_pick_pending_event_locked(SensorDevice* d, + sensors_event_t* event) +{ + uint32_t mask = SUPPORTED_SENSORS & d->pendingSensors; + if (mask) { + uint32_t i = 31 - __builtin_clz(mask); + d->pendingSensors &= ~(1U << i); + *event = d->sensors[i]; + event->sensor = i; + event->version = sizeof(*event); + + D("%s: %d [%f, %f, %f]", __FUNCTION__, + i, + event->data[0], + event->data[1], + event->data[2]); + return i; + } + E("No sensor to return!!! pendingSensors=0x%08x", d->pendingSensors); + // we may end-up in a busy loop, slow things down, just in case. + usleep(100000); + return -EINVAL; +} + +/* Block until new sensor events are reported by the emulator, or if a + * 'wake' command is received through the service. On succes, return 0 + * and updates the |pendingEvents| and |sensors| fields of |dev|. + * On failure, return -errno. + * + * Note: The device lock must be acquired when calling this function, and + * will still be held on return. However, the function releases the + * lock temporarily during the blocking wait. + */ +static int sensor_device_poll_event_locked(SensorDevice* dev) +{ + D("%s: dev=%p", __FUNCTION__, dev); + + int fd = sensor_device_get_fd_locked(dev); + if (fd < 0) { + E("%s: Could not get pipe channel: %s", __FUNCTION__, strerror(-fd)); + return fd; + } + + // Accumulate pending events into |events| and |new_sensors| mask + // until a 'sync' or 'wake' command is received. This also simplifies the + // code a bit. + uint32_t new_sensors = 0U; + sensors_event_t* events = dev->sensors; + + int64_t event_time = -1; + int ret = 0; + + for (;;) { + /* Release the lock since we're going to block on recv() */ + pthread_mutex_unlock(&dev->lock); + + /* read the next event */ + char buff[256]; + int len = qemud_channel_recv(fd, buff, sizeof(buff) - 1U); + /* re-acquire the lock to modify the device state. */ + pthread_mutex_lock(&dev->lock); + + if (len < 0) { + ret = -errno; + E("%s(fd=%d): Could not receive event data len=%d, errno=%d: %s", + __FUNCTION__, fd, len, errno, strerror(errno)); + break; + } + buff[len] = 0; + D("%s(fd=%d): received [%s]", __FUNCTION__, fd, buff); + + + /* "wake" is sent from the emulator to exit this loop. */ + /* TODO(digit): Is it still needed? */ + if (!strcmp((const char*)buff, "wake")) { + ret = 0x7FFFFFFF; + break; + } + + float params[3]; + + /* "acceleration:::" corresponds to an acceleration event */ + if (sscanf(buff, "acceleration:%g:%g:%g", params+0, params+1, params+2) + == 3) { + new_sensors |= SENSORS_ACCELERATION; + events[ID_ACCELERATION].acceleration.x = params[0]; + events[ID_ACCELERATION].acceleration.y = params[1]; + events[ID_ACCELERATION].acceleration.z = params[2]; + events[ID_ACCELERATION].type = SENSOR_TYPE_ACCELEROMETER; + continue; + } + + /* "orientation:::" is sent when orientation + * changes */ + if (sscanf(buff, "orientation:%g:%g:%g", params+0, params+1, params+2) + == 3) { + new_sensors |= SENSORS_ORIENTATION; + events[ID_ORIENTATION].orientation.azimuth = params[0]; + events[ID_ORIENTATION].orientation.pitch = params[1]; + events[ID_ORIENTATION].orientation.roll = params[2]; + events[ID_ORIENTATION].orientation.status = + SENSOR_STATUS_ACCURACY_HIGH; + events[ID_ORIENTATION].type = SENSOR_TYPE_ORIENTATION; + continue; + } + + /* "magnetic:::" is sent for the params of the magnetic + * field */ + if (sscanf(buff, "magnetic:%g:%g:%g", params+0, params+1, params+2) + == 3) { + new_sensors |= SENSORS_MAGNETIC_FIELD; + events[ID_MAGNETIC_FIELD].magnetic.x = params[0]; + events[ID_MAGNETIC_FIELD].magnetic.y = params[1]; + events[ID_MAGNETIC_FIELD].magnetic.z = params[2]; + events[ID_MAGNETIC_FIELD].magnetic.status = + SENSOR_STATUS_ACCURACY_HIGH; + events[ID_MAGNETIC_FIELD].type = SENSOR_TYPE_MAGNETIC_FIELD; + continue; + } + + /* "temperature:" */ + if (sscanf(buff, "temperature:%g", params+0) == 1) { + new_sensors |= SENSORS_TEMPERATURE; + events[ID_TEMPERATURE].temperature = params[0]; + events[ID_TEMPERATURE].type = SENSOR_TYPE_TEMPERATURE; + continue; + } + + /* "proximity:" */ + if (sscanf(buff, "proximity:%g", params+0) == 1) { + new_sensors |= SENSORS_PROXIMITY; + events[ID_PROXIMITY].distance = params[0]; + events[ID_PROXIMITY].type = SENSOR_TYPE_PROXIMITY; + continue; + } + /* "light:" */ + if (sscanf(buff, "light:%g", params+0) == 1) { + new_sensors |= SENSORS_LIGHT; + events[ID_LIGHT].light = params[0]; + events[ID_LIGHT].type = SENSOR_TYPE_LIGHT; + continue; + } + + /* "pressure:" */ + if (sscanf(buff, "pressure:%g", params+0) == 1) { + new_sensors |= SENSORS_PRESSURE; + events[ID_PRESSURE].pressure = params[0]; + events[ID_PRESSURE].type = SENSOR_TYPE_PRESSURE; + continue; + } + + /* "humidity:" */ + if (sscanf(buff, "humidity:%g", params+0) == 1) { + new_sensors |= SENSORS_HUMIDITY; + events[ID_HUMIDITY].relative_humidity = params[0]; + events[ID_HUMIDITY].type = SENSOR_TYPE_RELATIVE_HUMIDITY; + continue; + } + + /* "sync:

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 gA%M+IgHrj+WPFZm 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 literal 0 HcmV?d00001 diff --git a/src/type3_AndroidCloud/anbox-master/docs/build-android.md b/src/type3_AndroidCloud/anbox-master/docs/build-android.md new file mode 100644 index 0000000..9f543ee --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/docs/build-android.md @@ -0,0 +1,117 @@ +# Build Android Image + +For Anbox we're using a minimal customized version of Android but otherwise +base all our work of a recent release of the [Android Open Source Project](https://source.android.com/). + +To rebuild the Android image you need first fetch all relevant sources. This +will take quite a huge amount of your disk space (~40GB). AOSP recommends at +least 100GB of free disk space. Have a look at [their](https://source.android.com/source/requirements.html) pages too. + +In general for building the Anbox Andorid image the instructions found on [the pages +from the AOSP project](https://source.android.com/source/requirements.html) apply. +We will not describe again here of how to build the Android system in general but +only focus on the steps required for Anbox. + +## Fetch all relevant sources + +First setup a new workspace where you will download all sources too. + +``` +$ mkdir $HOME/anbox-work +``` + +Now initialize the repository by download the manifest and start fetching +the sources: + +``` +$ cd $HOME/anbox-work +$ repo init -u https://github.com/anbox/platform_manifests.git -b anbox +$ repo sync -j4 +``` + +This will take quite some time depending on the speed of your internet connection. + +## Build Android + +When all sources are successfully downloaded you can start building Android itself. + +Firstly initialize the environment with the ```envsetup.sh``` script. + +``` +$ . build/envsetup.sh +``` + +Then initialize the build using ```lunch```. + +``` +$ lunch anbox_x86_64-userdebug +``` + +The complete list of supported build targets: + + * anbox_x86_64-userdebug + * anbox_armv7a_neon-userdebug + * anbox_arm64-userdebug + +Now build everything with + +``` +$ make -j8 +``` + +Once the build is done we need to take the results and create an image file +suitable for Anbox. + +``` +$ cd $HOME/anbox-work/vendor/anbox +$ scripts/create-package.sh \ + $PWD/../out/target/product/x86_64/ramdisk.img \ + $PWD/../out/target/product/x86_64/system.img +``` + +This will create an *android.img* file in the current directory. + +With this, you are now able to use your custom image within the Anbox runtime. + +## Run Anbox with self build android.img + +If you have Anbox installed on your system you need to stop it first. If you used +the installer script and the snap you can do this via + +``` +$ initctl stop anbox +$ sudo systemctl stop snap.anbox.container-manager +``` + +It is important that you stop both, the container manager and the session manager. + +Once both services are stopped you can start the container manager with your +custom android.img file by running + +``` +$ datadir=$HOME/anbox-data +$ mkdir -p $datadir/rootfs +$ sudo anbox container-manager \ + --android-image=/path/to/android.img \ + --data-path=$datadir +``` + +This will start the container manager and setup the container rootfs inside the +specified data path. + +``` +$ ls -alh $HOME/anbox-data +total 20K +drwxrwxr-x 5 ubuntu ubuntu 4,0K Feb 22 08:04 . +drwxrwxr-x 16 ubuntu ubuntu 4,0K Feb 22 08:04 .. +drwxr-xr-x 2 100000 100000 4,0K Feb 22 08:04 cache +drwxr-xr-x 2 100000 100000 4,0K Feb 22 08:04 data +drwxr-xr-x 2 root root 4,0K Feb 22 08:04 rootfs +``` + +**NOTE:** If you look into the $HOME/anbox-data/rootfs directory you won't see +anything as the container manager spawns up a private mount namespace which +prevents anything from the outside to see its mount points. + +The *cache* and *data* directories are bind-mounted into the rootfs at *rootfs/data* +and *rootfs/cache*. diff --git a/src/type3_AndroidCloud/anbox-master/docs/generate-emugl-source.md b/src/type3_AndroidCloud/anbox-master/docs/generate-emugl-source.md new file mode 100644 index 0000000..6dbb14e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/docs/generate-emugl-source.md @@ -0,0 +1,16 @@ +# Generate Android EmuGL source + +Parts of the EmuGL layer are generated with a tool called emugen (see +external/android-emugl/host/tools/emugen). + +To generate the source again after a modification simply call + +``` +$ scripts/update-emugl-sources.sh --emugen=/emugen +``` + +The definition of the various attributes/types/functions can be found in + + * external/android-emugl/host/libs/renderControl_dec + * external/android-emugl/host/libs/GLESv1_dec + * external/android-emugl/host/libs/GLESv2_dec diff --git a/src/type3_AndroidCloud/anbox-master/docs/install.md b/src/type3_AndroidCloud/anbox-master/docs/install.md new file mode 100644 index 0000000..25f3aa4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/docs/install.md @@ -0,0 +1,130 @@ +# Install Anbox + +To install Anbox your system need to support [snaps](https://snapcraft.io). We +do not officially support any other distribution method of Anbox at the moment +but there are community made packages for various distributions (e.g. Arch Linux). +However please keep in mind that the Anbox project can not give support to them +and its solely in the responsibility of the community packager to keep up with +upstream development and update the packaging to any new changes. Please feel +free to report still any bugs you encounter as they may not be related to the +packaging. + +If you don't know about snaps yet head over to [snapcraft.io](https://snapcraft.io/) +to get an introduction of what snaps are, how to install support for them on your +distribution and how to use them. + +The installation of Anbox consists of two steps. + + 1. Install necessary kernel modules + 2. Install the Anbox snap + +In order to support the mandatory kernel subsystems ashmem and binder for the +Android container you have to install two +[DKMS](https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support) +based kernel modules. The source for the kernel modules is maintained by the +Anbox project [here](https://github.com/anbox/anbox-modules). + +At the moment we only have packages prepared for Ubuntu in a PPA on Launchpad. +If you want to help to get the packages in your favorite distribution please +come and talk to us or submit a PR with the distribution specific packaging. + +The second step will install the Anbox snap from the store and will give you +everything you need to run the full Anbox experience. + +## Install necessary kernel modules + +In order to add the PPA to your Ubuntu system please run the following commands: + +``` + $ sudo add-apt-repository ppa:morphis/anbox-support + $ sudo apt update + $ sudo apt install anbox-modules-dkms +``` +> In case `add-apt-repository` is missing, install it via: +> ``` +> sudo apt install software-properties-common +> ``` + +These will add the PPA to your system and install the `anbox-modules-dkms` +package which contains the ashmem and binder kernel modules. They will be +automatically rebuild everytime the kernel packages on your system update. + +After you installed the `anbox-modules-dkms` package you have to manually +load the kernel modules. The next time your system starts they will be +automatically loaded. + +``` + $ sudo modprobe ashmem_linux + $ sudo modprobe binder_linux +``` + +Now you should have two new nodes in your systems `/dev` directory: + +``` + $ ls -1 /dev/{ashmem,binder} + /dev/ashmem + /dev/binder +``` + +## Install the Anbox snap + +Installing the Anbox snap is very simple: + +``` + $ snap install --devmode --beta anbox +``` + +If you haven't logged into the Ubuntu Store yet, the `snap` command will +ask you to use `sudo snap ...` in order to install the snap: + +``` + $ sudo snap install --devmode --beta anbox +``` + +At the moment we require the use of `--devmode` as the Anbox snap is not +yet fully confined. Work has started with the upstream `snapd` project to +get support for full confinement. + +As a side effect of using `--devmode` the snap will not automatically update. +In order to update to a newer version you can run: + +``` + $ snap refresh --beta --devmode anbox +``` + +Information about the currently available versions of the snap is available +via: + +``` + $ snap info anbox +``` + +## Available snap channels + +Currently we only use the beta and edge channels for the Anbox snap. The edge +channel tracks the latest development is always synced with the state of the +master branch on github. The beta channel is updated less frequently to provide +a more stable and bug free experience. + +Once proper confinement for the Anbox snap exists we will also start using the +candidate and stable channels. + +# Uninstall Anbox + +If you want to remove Anbox from your system you first have to remove the snap: + +**NOTE:** By removing the snap you remove all data you stored within the snap +from your system. There is no way to bring it back. + +``` + $ snap remove anbox +``` + +Once the snap is removed you have to remove the installed kernel modules as well: + +``` + $ sudo apt install ppa-purge + $ sudo ppa-purge ppa:morphis/anbox-support +``` + +Once done Anbox is removed from your system. diff --git a/src/type3_AndroidCloud/anbox-master/docs/runtime-setup.md b/src/type3_AndroidCloud/anbox-master/docs/runtime-setup.md new file mode 100644 index 0000000..8f07eeb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/docs/runtime-setup.md @@ -0,0 +1,35 @@ +# Overview + +The Anbox runtime consists mainly of two separate instances: + + * container manager + * session manager + +The container manager has the job of managing the container setup and maintenance +during its lifetime. It has the responsibility to start the LXC environment we're +using to run the Android system. + +The session manager runs inside the session of a user logged into the Linux system. +It will communicate over several sockets with the Android instance running inside +the container and provide integration with the Linux system. It also acts as a +multiplexer to map Android applications into single windows on the desktop +environment. Currently all application windows are owned by the same process +(the session manager). The application logic itself is still in a separate process +inside the Android container. + +The following picture shows an overview over the architecture: + +![Anbox architecture](architecture.png) + +## Application Mapping + +Android applications are mapped into single windows within the desktop environment. +This is achieved by plugging into the Android hwcomposer HAL module which receives +a set of layers to composite on a screen. Anbox tells SurfaceFlinger through its +hwcomposer implementation to get a layer for each application and combines this with +additional information it receives from the Android WindowManager to map individual +layers to applications. For more details please look into the implementation at + + * android/hwcomposer + * src/anbox/graphics/layer_composer.cpp + * src/anbox/wm/manager.cpp diff --git a/src/type3_AndroidCloud/anbox-master/external/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/CMakeLists.txt new file mode 100644 index 0000000..c40f4e3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(process-cpp-minimal) +add_subdirectory(android-emugl) +add_subdirectory(xdg) +add_subdirectory(backward-cpp) +add_subdirectory(cpu_features) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/CMakeLists.txt new file mode 100644 index 0000000..23173b3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/CMakeLists.txt @@ -0,0 +1,28 @@ +# Don't treat any warnings as error as we take the source directly from +# upstream and just compile it. +set(CMAKE_C_FLAGS "-Wall") +set(CMAKE_CXX_FLAGS "-std=c++11 -Wall") + +# Ensure -fPIC +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +include_directories( + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/external/android-emugl/shared + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/include + ${CMAKE_BINARY_DIR}/external/android-emugl/host/include + ${CMAKE_SOURCE_DIR}/external/android-emugl/shared/OpenglCodecCommon + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/include/libOpenglRender + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/GLESv1_dec + ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/GLESv1_dec + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/GLESv2_dec + ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/GLESv2_dec + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/renderControl_dec + ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/renderControl_dec + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/Translator/ + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/Translator/include + ${MIRCLIENT_INCLUDE_DIRS}) + +add_subdirectory(host) +add_subdirectory(shared) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/DESIGN b/src/type3_AndroidCloud/anbox-master/external/android-emugl/DESIGN new file mode 100644 index 0000000..943a0e4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/DESIGN @@ -0,0 +1,615 @@ +Android Hardware OpenGLES emulation design overview +=================================================== + +Introduction: +------------- + +Hardware GLES emulation in the Android platform is implemented with a mix +of components, which are: + + - Several host "translator" libraries. They implement the EGL, GLES 1.1 and + GLES 2.0 ABIs defined by Khronos, and translate the corresponding function + calls into calls to the appropriate desktop APIs, i.e.: + + - GLX (Linux), AGL (OS X) or WGL (Windows) for EGL + - desktop GL 2.0 for GLES 1.1 and GLES 2.0 + + _________ __________ __________ + | | | | | | + |TRANSLATOR |TRANSLATOR| |TRANSLATOR| HOST + | EGL | | GLES 1.1 | | GLES 2.0 | TRANSLATOR + |_________| |__________| |__________| LIBRARIES + | | | + - - - | - - - - - - - - - | - - - - - - - - - | - - - - - + | | | + ____v____ ____v_____ _____v____ HOST + | | | | | | SYSTEM + | GLX | | GL 2.0 | | GL 2.0 | LIBRARIES + |_________| |__________| |__________| + + + + - Several system libraries inside the emulated guest system that implement + the same EGL / GLES 1.1 and GLES 2.0 ABIs. + + They collect the sequence of EGL/GLES function calls and translate then + into a custom wire protocol stream that is sent to the emulator program + through a high-speed communication channel called a "QEMU Pipe". + + For now, all you need to know is that the pipe is implemented with a + custom kernel driver, and provides for _very_ fast bandwidth. All read() + and writes() from/to the pipes are essentially instantaneous from the + guest's point of view. + + + _________ __________ __________ + | | | | | | + |EMULATION| |EMULATION | |EMULATION | GUEST + | EGL | | GLES 1.1 | | GLES 2.0 | SYSTEM + |_________| |__________| |__________| LIBRARIES + | | | + - - - | - - - - - - - - - | - - - - - - - - - | - - - - - + | | | + ____v____________________v____________________v____ GUEST + | | KERNEL + | QEMU PIPE | + |___________________________________________________| + | + - - - - - - - - - - - - - -|- - - - - - - - - - - - - - - - + | + v + EMULATOR + + - Specific code inside the emulator program that is capable of transmitting + the wire protocol stream to a special rendering library or process (called + the "renderer" here), which understands the format. + + | + | PROTOCOL BYTE STREAM + _____v_____ + | | + | EMULATOR | + |___________| + | + | UNMODIFIED PROTOCOL BYTE STREAM + _____v_____ + | | + | RENDERER | + |___________| + + + - The renderer decodes the EGL/GLES commands from the wire + protocol stream, and dispatches them to the translator libraries + appropriately. + + | + | PROTOCOL BYTE STREAM + _____v_____ + | | + | RENDERER | + |___________| + | | | + +-----------------+ | +-----------------+ + | | | + ____v____ ___v______ ____v_____ + | | | | | | HOST + |TRANSLATOR |TRANSLATOR| |TRANSLATOR| HOST + | EGL | | GLES 1.1 | | GLES 2.0 | TRANSLATOR + |_________| |__________| |__________| LIBRARIES + + + + - In reality, the protocol stream flows in both directions, even though most + of the commands result in data going from the guest to the host. A complete + picture of the emulation would thus be: + + + + + + _________ __________ __________ + | | | | | | + |EMULATION| |EMULATION | |EMULATION | GUEST + | EGL | | GLES 1.1 | | GLES 2.0 | SYSTEM + |_________| |__________| |__________| LIBRARIES + ^ ^ ^ + | | | + - - - | - - - - - - - - - | - - - - - - - - - | - - - - - + | | | + ____v____________________v____________________v____ GUEST + | | KERNEL + | QEMU PIPE | + |___________________________________________________| + ^ + | + - - - - - - - - - - - - - -|- - - - - - - - - - - - - - - - + | + | PROTOCOL BYTE STREAM + _____v_____ + | | + | EMULATOR | + |___________| + ^ + | UNMODIFIED PROTOCOL BYTE STREAM + _____v_____ + | | + | RENDERER | + |___________| + ^ ^ ^ + | | | + +-----------------+ | +-----------------+ + | | | + ____v____ ___v______ ____v_____ + | | | | | | + |TRANSLATOR |TRANSLATOR| |TRANSLATOR| HOST + | EGL | | GLES 1.1 | | GLES 2.0 | TRANSLATOR + |_________| |__________| |__________| LIBRARIES + ^ ^ ^ + | | | + - - - | - - - - - - - - - | - - - - - - - - - | - - - - - + | | | + ____v____ ____v_____ _____v____ HOST + | | | | | | SYSTEM + | GLX | | GL 2.0 | | GL 2.0 | LIBRARIES + |_________| |__________| |__________| + + (NOTE: 'GLX' is for Linux only, replace 'AGL' on OS X, and 'WGL' on Windows). + + +Note that, in the above graphics, only the host system libraries at the bottom +are _not_ provided by Android. + + +Design Requirements: +-------------------- + +The above design comes from several important requirements that were decided +early in the project: + +1 - The ability to run the renderer in a separate process from the emulator + itself is important. + + For various practical reasons, we plan to completely separate the core QEMU + emulation from the UI window by using two distinct processes. As such, the + renderer will be implemented as a library inside the UI program, but will + need to receive protocol bytes from the QEMU process. + + The communication channel will be either a fast Unix socket or a Win32 + named pipe between these two. A shared memory segment with appropriate + synchronization primitives might also be used if performance becomes + an issue. + + This explains why the emulator doesn't alter or even try to parse the + protocol byte stream. It only acts as a dumb proxy between the guest + system and the renderer. This also avoids adding lots of GLES-specific + code inside the QEMU code base which is terribly complex. + +2 - The ability to use vendor-specific desktop EGL/GLES libraries is + important. + + GPU vendors like NVidia, AMD or ARM all provide host versions of the + EGL/GLES libraries that emulate their respectivie embedded graphics + chipset. + + The renderer library can be configured to use these instead of the + translator libraries provided with this project. This can be useful to + more accurately emulate the behaviour of specific devices. + + Moreover, these vendor libraries typically expose vendor-specific + extensions that are not provided by the translator libraries. We cannot + expose them without modifying our code, but it's important to be able + to do so without too much pain. + + +Code organization: +------------------ + +All source code for the components above is spread over multiple directories +in the Android source trees: + + - The emulator sources are under $ANDROID/external/qemu, which we'll + call $QEMU in the rest of this document. + + - The guest libraries are under + $ANDROID/device/generic/goldfish/opengl, which we'll call $EMUGL_GUEST + + - The host renderer and translator libraries are under + $QEMU/distrib/android-emugl, which we'll call $EMUGL_HOST + + - The QEMU Pipe kernel driver is under $KERNEL/drivers/misc/qemupipe (3.4) + or $KERNEL/drivers/platform/goldfish/goldfish_pipe.c (3.10) + +Where $ANDROID is the top of the open-source Android source tree, and +$KERNEL is the top of the qemu-specific kernel source tree (using one +of the android-goldfish-xxxx branches here). + +The emulator sources related to this projects are: + + $QEMU/hw/android/goldfish/pipe.c -> implements QEMU pipe virtual hardware. + $QEMU/android/opengles.c -> implements GLES initialization. + $QEMU/android/hw-pipe-net.c -> implements the communication channel + between the QEMU Pipe and the renderer library + +The other sources are: + + $EMUGL_GUEST/system -> system libraries + $EMUGL_GUEST/shared -> guest copy of shared libraries + $EMUGL_GUEST/tests -> various test programs + + $EMUGL_HOST/host -> host libraries (translator + renderer) + $EMUGL_HOST/shared -> host copy of shared libraries + +The reason the shared libraries aren't actually shared is historical: at one +point both guest and host code lived in the same place. That turned out to be +impractical with the way the Android SDK is branched, and didn't support the +requirement that a single emulator binary be able to run several releases +of Android. + + +Translator libraries: +--------------------- + +There are three translator host libraries provided by this project: + + libEGL_translator -> EGL 1.2 translation + libGLES_CM_translator -> GLES 1.1 translation + libGLES_V2_translator -> GLES 2.0 translation + +The full name of the library will depend on the host system. +For simplicity, only the library name suffix will change (i.e. the +'lib' prefix is not dropped on Windows), i.e.: + + libEGL_translator.so -> for Linux + libEGL_translator.dylib -> for OS X + libEGL_translator.dll -> for Windows + +The source code for these libraries is located under the following +path in the Android source tree: + + $EMUGL_HOST/host/libs/Translator/EGL + $EMUGL_HOST/host/libs/Translator/GLES_CM + $EMUGL_HOST/host/libs/Translator/GLES_V2 + +The translator libraries also use a common routines defined under: + + $EMUGL_HOST/host/libs/Translator/GLcommon + + +Wire Protocol Overiew: +---------------------- + +The "wire protocol" is implemented as follows: + + - EGL/GLES function calls are described through several "specification" + files, which describes the types, function signatures and various + attributes for each one of them. + + - These files are read by a tool called "emugen" which generates C + source files and headers based on the specification. These correspond + to both encoding, decoding and "wrappers" (more on this later). + + - System "encoder" static libraries are built using some of these generated + files. They contain code that can serialize EGL/GLES calls into simple + byte messages and send it through a generic "IOStream" object. + + - Host "decoder" static libraries are also built using some of these + generated files. Their code retrieves byte messages from an "IOStream" + object, and translates them into function callbacks. + +IOStream abstraction: +- - - - - - - - - - - + +The "IOStream" is a very simple abstract class used to send byte messages +both in the guest and host. It is defined through a shared header under +$EMUGL/host/include/libOpenglRender/IOStream.h + +Note that despite the path, this header is included by *both* host and guest +source code. The main idea around IOStream's design is that to send a message, +one does the following: + + 1/ call stream->allocBuffer(size), which returns the address of a + memory buffer of at least 'size' bytes. + + 2/ write the content of the serialized command (usually a header + some + payload) directly into the buffer + + 3/ call stream->commitBuffer() to send it. + +Alternatively, one can also pack several commands into a single buffer with +stream->alloc() and stream->flush(), as in: + + 1/ buf1 = stream->alloc(size1) + 2/ write first command bytes into buf1 + 3/ buf2 = stream->alloc(size2) + 4/ write second command bytes into buf2 + 5/ stream->flush() + +Finally, there are also explict read/write methods like stream->readFully() +or stream->writeFully() which can be used when you don't want an intermediate +buffer. This is used in certain cases by the implementation, e.g. to avoid +an intermediate memory copy when sending texture data from the guest to the +host. + +The host IOStream implementations are under $EMUGL/shared/OpenglCodecCommon/, +see in particular: + + $EMUGL_HOST/shared/OpenglCodecCommon/TcpStream.cpp + -> using local TCP sockets + $EMUGL_HOST/shared/OpenglCodecCommon/UnixStream.cpp + -> using Unix sockets + $EMUGL_HOST/shared/OpenglCodecCommon/Win32PipeStream.cpp + -> using Win32 named pipes + +The guest IOStream implementation uses the TcpStream.cpp above, as well as +an alternative QEMU-specific source: + + $EMUGL_GUEST/system/OpenglSystemCommon/QemuPipeStream.cpp + -> uses QEMU pipe from the guest + +The QEMU Pipe implementation is _significantly_ faster (about 20x) due to +several reasons: + + - all succesful read() and write() operations through it are instantaneous + from the guest's point of view. + + - all buffer/memory copies are performed directly by the emulator, and thus + much faster than performing the same thing inside the kernel with emulated + ARM instructions. + + - it doesn't need to go through a kernel TCP/IP stack that will wrap the + data into TCP/IP/MAC packets, send them to an emulated ethernet device, + which is itself connected to an internal firewall implementation that + will unwrap the packets, re-assemble them, then send them through BSD + sockets to the host kernel. + +However, would it be necessary, you could write a guest IOStream implementation +that uses a different transport. If you do, please look at +$EMUGL_GUEST/system/OpenglCodecCommon/HostConnection.cpp which contains the +code used to connect the guest to the host, on a per-thread basis. + + +Source code auto-generation: +- - - - - - - - - - - - - - + +The 'emugen' tool is located under $EMUGL_HOST/host/tools/emugen. There is a +README file that explains how it works. + +You can also look at the following specifications files: + +For GLES 1.1: + $EMUGL_HOST/host/GLESv1_dec/gl.types + $EMUGL_HOST/host/GLESv1_dec/gl.in + $EMUGL_HOST/host/GLESv1_dec/gl.attrib + +For GLES 2.0: + $EMUGL_HOST/host/GLESv2_dec/gl2.types + $EMUGL_HOST/host/GLESv2_dec/gl2.in + $EMUGL_HOST/host/GLESv2_dec/gl2.attrib + +For EGL: + $EMUGL_HOST/host/renderControl_dec/renderControl.types + $EMUGL_HOST/host/renderControl_dec/renderControl.in + $EMUGL_HOST/host/renderControl_dec/renderControl.attrib + +Note that the EGL specification files are under a directory named +"renderControl_dec" and have filenames that begin with "renderControl" + +This is mainly for historic reasons now, but is also related to the fact that +this part of the wire protocol contains support functions/calls/specifications +that are not part of the EGL specification itself, but add a few features +required to make everything works. For example, they have calls related to +the "gralloc" system library module used to manage graphics surfaces at a +lower level than EGL. + +Generally speaking, guest encoder sources are located under directories +named $EMUGL_GUEST/system/_enc/, while the corresponding host decoder +sources will be under $EMUGL_HOST/host/libs/_dec/ + +However, all these sources use the same spec files located under the +decoding directories. + +The encoder files are built from emugen and spec files located in $EMUGL_HOST +and copied to the encoder directories in $EMUGL_GUEST by the gen-encoder.sh +script. They are checked in, so that a given version of Android supports a +specific version of the protocol, even if newer versions of the renderer (and +future Android versions) support a newer protocol version. This step needs to +be done manually when the protocol changes; these changes also need to be +accompanied by changes in the renderer to handle the old version of the +protocol. + + +System libraries: +----------------- + +Meta EGL/GLES system libraries, and egl.cfg: +- - - - - - - - - - - - - - - - - - - - - - + +It is important to understand that the emulation-specific EGL/GLES libraries +are not directly linked by applications at runtime. Instead, the system +provides a set of "meta" EGL/GLES libraries that will load the appropriate +hardware-specific libraries on first use. + +More specifically, the system libEGL.so contains a "loader" which will try +to load: + + - hardware-specific EGL/GLES libraries + - the software-based rendering libraries (called "libagl") + +The system libEGL.so is also capable of merging the EGL configs of both the +hardware and software libraries transparently to the application. The system +libGLESv1_CM.so and libGLESv2.so, work with it to ensure that the thread's +current context will be linked to either the hardware or software libraries +depending on the config selected. + +For the record, the loader's source code in under +frameworks/base/opengl/libs/EGL/Loader.cpp. It depends on a file named +/system/lib/egl/egl.cfg which must contain two lines that look like: + + 0 1 + 0 0 android + +The first number in each line is a display number, and must be 0 since the +system's EGL/GLES libraries don't support anything else. + +The second number must be 1 to indicate hardware libraries, and 0 to indicate +a software one. The line corresponding to the hardware library, if any, must +always appear before the one for the software library. + +The third field is a name corresponding to a shared library suffix. It really +means that the corresponding libraries will be named libEGL_.so, +libGLESv1_CM_.so and libGLESv2_.so. Moreover these libraries must +be placed under /system/lib/egl/ + +The name "android" is reserved for the system software renderer. + +The egl.cfg that comes with this project uses the name "emulation" for the +hardware libraries. This means that it provides an egl.cfg file that contains +the following lines: + + 0 1 emulation + 0 0 android + +See $EMUGL_GUEST/system/egl/egl.cfg and more generally the following build +files: + + $EMUGL_GUEST/system/egl/Android.mk + $EMUGL_GUEST/system/GLESv1/Android.mk + $EMUGL_GUEST/system/GLESv2/Android.mk + +to see how the libraries are named and placed under /system/lib/egl/ by the +build system. + + +Emulation libraries: +- - - - - - - - - - - + +The emulator-specific libraries are under the following: + + $EMUGL_GUEST/system/egl/ + $EMUGL_GUEST/system/GLESv1/ + $EMUGL_GUEST/system/GLESv2/ + +The code for GLESv1 and GLESv2 is pretty small, since it mostly link against +the static encoding libraries. + +The code for EGL is a bit more complex, because it needs to deal with +extensions dynamically. I.e. if an extension is not available on the host +it shouldn't be exposed by the library at runtime. So the EGL code queries +the host for the list of available extensions in order to return them to +clients. Similarly, it must query the list of valid EGLConfigs for the +current host system. + + +"gralloc" module implementation: +- - - - - - - - - - - - - - - - - + +In addition to EGL/GLES libraries, the Android system requires a +hardware-specific library to manage graphics surfaces at a level lower than +EGL. This library must be what is called in Android land as a "HAL module". + +A "HAL module" must provide interfaces defined by Android's HAL +(Hardware Abstraction Library). These interface definitions can be found +under $ANDROID/hardware/libhardware/include/ + +Of all possible HAL modules, the "gralloc" one is used by the system's +SurfaceFlinger to allocate framebuffers and other graphics memory regions, +as well as eventually lock/unlock/swap them when needed. + +The code under $EMUGL/system/gralloc/ implements the module required by the +GLES emulation project. It's not very long, but there are a few things to +notice here: + +- first, it will probe the guest system to determine if the emulator that + is running the virtual device really supports GPU emulation. In certain + circumstances this may not be possible. + + If this is the case, then the module will redirect all calls to the + "default" gralloc module that is normally used by the system when + software-only rendering is enabled. + + The probing happens in the function "fallback_init" which gets called + when the module is first opened. This initializes the 'sFallback' variable + to a pointer to the default gralloc module when required. + +- second, this module is used by SurfaceFlinger to display "software surfaces", + i.e. those that are backed by system memory pixel buffers, and written to + directly through the Skia graphics library (i.e. the non-accelerated ones). + + the default module simply copies the pixel data from the surface to the + virtual framebuffer i/o memory, but this project's gralloc module sends it + to the renderer through the QEMU Pipe instead. + + It turns out that this results in _faster_ rendering/frame-rates overall, + because memory copies inside the guest are slow, while QEMU pipe transfers + are done directly in the emulator. + + +Host Renderer: +-------------- + +The host renderer library is located under +$EMUGL_HOST/host/libs/libOpenglRender, and it provides an interface described +by the headers under $EMUGL_HOST/host/libs/libOpenglRender/render_api.h +(e.g. for use by the emulator). + +In a nutshell, the rendering library is responsible for the following: + + - Providing a virtual off-screen video surface where everything will get + rendered at runtime. Its dimensions are fixed by the call to + initOpenglRender() that must happen just after the library is + initialized. + + - Provide a way to display the virtual video surface on a host application's + UI. This is done by calling createOpenGLSubWindow() which takes as argument + the window ID or handle of a parent window, some display dimensions and + a rotation angle. This allows the surface to be scaled/rotated when it is + displayed, even if the dimensions of the video surface do not change. + + - Provide a way to listen to incoming EGL/GLES commands from the guest. + This is done by providing a so-called "port number" to initOpenglRender(). + + By default, the port number corresponds to a local TCP port number that the + renderer will bind to and listen. Every new connection to this port will + correspond to the creation of a new guest host connection, each such + connection corresponding to a distinct thread in the guest system. + + For performance reasons, it is possible to listen to either Unix sockets + (on Linux and OS X), or to a Win32 named pipe (on Windows). To do so, one + had to call setStreamType() between library initialization + (i.e. initLibrary()) and construction (i.e. initOpenglRender()). + + Note that in these modes, the port number is still used to differentiate + between several emulator instances. These details are normally handled by + the emulator code so you shouldn't care too much. + +Note that an earlier version of the interface allowed a client of the renderer +library to provide its own IOStream implementation. However, this wasn't very +convenient for a number of reasons. This maybe something that could be done +again if it makes sense, but for now the performance numbers are pretty good. + + +Host emulator: +-------------- + +The code under $QEMU/android/opengles.c is in charge of dynamically loading +the rendering library and initializing / constructing it properly. + +QEMU pipe connections to the 'opengles' service are piped through the code +in $QEMU/android/hw-pipe-net.c. Look for the openglesPipe_init() function, +which is in charge of creating a connection to the renderer library +(either through a TCP socket, or a Unix pipe depending on configuration. +support for Win32 named pipes hasn't been implemented yet in the emulator) +whenever a guest process opens the "opengles" service through /dev/qemu_pipe. + +There is also some support code for the display of the GLES framebuffer +(through the renderer library's subwindow) under $QEMU/skin/window. + +Note that at the moment, scaling and rotation are supported. However, +brightness emulation (which used to modify the pixel values from the +hardware framebuffer before displaying them) doesn't work. + +Another issue is that it is not possible to display anything on top of the +GL subwindow at the moment. E.g. this will obscure the emulated trackball +image (that is normally toggled with Ctrl-T during emulation, or enabled +by pressing the Delete key). + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/README b/src/type3_AndroidCloud/anbox-master/external/android-emugl/README new file mode 100644 index 0000000..8db2d9d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/README @@ -0,0 +1,96 @@ +This directory contains the host-side modules related to hardware OpenGL ES +emulation. The guest-side modules are in +$ANDROID_BUILD_TOP/device/generic/goldfish/opengl + +I. Overview of components: +========================== + +The 'emugen' tool is used to generate several source files related to the +EGL/GLES command stream used between the guest and the host during emulation. + + host/tools/emugen -> emugen program + +Note that emugen is capable of generating, from a single set of specification +files, three types of auto-generated sources: + + - sources to encode commands into a byte stream. + - sources to decode the byte stream into commands. + - sources to wrap normal procedural EGL/GLES calls into context-aware ones. + +Modules under the system/ directory corresponds to code that runs on the +guest, and implement the marshalling of EGL/GLES commands into a stream of +bytes sent to the host through a fast pipe mechanism. + + system/GLESv1_enc -> encoder for GLES 1.1 commands + system/GLESv2_enc -> encoder for GLES 2.0 commands + system/renderControl_enc -> encoder for rendering control commands + system/egl -> emulator-specific guest EGL library + system/GLESv1 -> emulator-specific guest GLES 1.1 library + system/gralloc -> emulator-specific gralloc module + system/OpenglSystemCommon -> library of common routines + +Modules under the host/ directory corresponds to code that runs on the +host, and implement the decoding of the command stream, translation of +EGL/GLES commands into desktop GL 2.0 ones, and rendering to an off-screen +buffer. + + host/libs/GLESv1_dec -> decoder for GLES 1.1 commands + host/libs/GLESv2_dec -> decoder for GLES 2.0 commands + host/libs/renderControl_dec -> decoder for rendering control commands + + host/libs/Translator/EGL -> translator for EGL commands + host/libs/Translator/GLES_CM -> translator for GLES 1.1 commands + host/libs/Translator/GLES_V2 -> translator for GLES 2.0 commands + host/libs/Translator/GLcommon -> library of common translation routines + + host/libs/libOpenglRender -> rendering library (uses all host libs above) + can be used by the 'renderer' program below, + or directly linked into the emulator UI program. + + host/renderer/ -> stand-alone renderer program executable. + this can run in head-less mode and receive requests from + several emulators at the same time. It is the receiving + end of all command streams. + +Modules under the test/ directory correspond to test programs that are useful +to debug the various modules described above: + + tests/EGL_host_wrapper -> a small library used to dynamically load the + desktop libEGL.so or a replacement named by the + ANDROID_EGL_LIB environment variable. This lib + provides all EGL entry points. + + tests/emulator_test_renderer -> a small program to run the rendering library + in a single SDL window on the host desktop. + + tests/gles_android_wrapper -> guest EGL / GLES libraries that are run on + the device to run some tests. Replace the + system/egl and system/GLESv1 modules for now. + + tests/translator_tests/GLES_CM -> desktop GLESv1 translation unit test + tests/translator_tests/GLES_V2 -> desktop GLESv2 translation unit test + tests/translator_tests/MacCommon -> used by translation tests on Mac only. + + tests/ut_rendercontrol_enc -> guest library used by tests/ut_renderer + tests/ut_rendercontrol_dec -> host library used by tests/ut_renderer + tests/ut_renderer -> unit-test for render control and rendering library. + + +II. Build system considerations: +-------------------------------- + +The dependencies on the more than 20 components described in the previous +section are pretty sophisticated, involving lots of auto-generated code and +non-trivial placement for guest/device libraries. + +To simplify the development and maintenance of these modules, a set of +helper GNU Make function is defined in common.mk, and included from the +Android.mk in this directory. + +These functions all begin with the "emugl-" prefix, and can be used to +declare modules, what information they export to other modules, or import +from them, and also what kind of auto-generated sources they depend on. + +Look at the comments inside common.mk and the Android.mk of the modules +to better understand what's happening. + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/README.anbox b/src/type3_AndroidCloud/anbox-master/external/android-emugl/README.anbox new file mode 100644 index 0000000..a322fdf --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/README.anbox @@ -0,0 +1,3 @@ +Taken from branch 'emu-2.0-release' of repository +https://android.googlesource.com/platform/external/qemu/+/emu-2.0-release +at comment 9a21e8c61517ca9aa8fc244810fea96b361e383c diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/common.mk b/src/type3_AndroidCloud/anbox-master/external/android-emugl/common.mk new file mode 100644 index 0000000..76fd4e9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/common.mk @@ -0,0 +1,241 @@ +# This top-level build file is included by all modules that implement +# the hardware OpenGL ES emulation for Android. +# +# We use it to ensure that all sub-Makefiles are included in the right +# order for various variable definitions and usage to happen in the correct +# order. +# + +# The following macros are used to start a new GLES emulation module. +# +# This will define LOCAL_MODULE as $1, plus a few other variables +# needed by the build system (e.g. LOCAL_MODULE_TAGS, LOCAL_MODULE_CLASS...) +# +# NOTE: You still need to define LOCAL_PATH before this +# +# Usage example: +# +# $(call emugl-begin-static-library,) +# LOCAL_SRC_FILES := .... +# LOCAL_C_INCLUDES += .... +# $(call emugl-end-module) +# +emugl-begin-host-static-library = $(call emugl-begin-module,$1,HOST_STATIC_LIBRARY,HOST) +emugl-begin-host-shared-library = $(call emugl-begin-module,$1,HOST_SHARED_LIBRARY,HOST) +emugl-begin-host-executable = $(call emugl-begin-module,$1,HOST_EXECUTABLE,HOST) + +# Internal list of all declared modules (used for sanity checking) +_emugl_modules := +_emugl_HOST_modules := + +# do not use directly, see functions above instead +emugl-begin-module = \ + $(eval include $(CLEAR_VARS)) \ + $(eval LOCAL_MODULE := $1) \ + $(eval LOCAL_MODULE_TAGS := $(if $3,,debug)) \ + $(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \ + $(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\ + $(eval LOCAL_C_INCLUDES += $(EMUGL_COMMON_INCLUDES)) \ + $(eval LOCAL_CFLAGS += $(EMUGL_COMMON_CFLAGS)) \ + $(eval LOCAL_LDLIBS += $(CXX_STD_LIB)) \ + $(eval LOCAL_BUILD_FILE := $(BUILD_$2)) \ + $(call _emugl-init-module,$1,$2,$3) + +# Used to end a module definition, see function definitions above +emugl-end-module = \ + $(eval $(end-emulator-module-ev)) \ + $(eval LOCAL_BUILD_FILE :=) \ + $(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\ + $(if $(EMUGL_DEBUG),$(call emugl-dump-module)) + +# Managing module exports and imports. +# +# A module can 'import' another module, by calling emugl-import. This will +# make the current LOCAL_MODULE inherit various definitions exported from +# the imported module. +# +# Module exports are defined by calling emugl-export. Here is an example: +# +# $(call emugl-begin-static-library,foo) +# LOCAL_SRC_FILES := foo.c +# $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)) +# $(call emugl-export,SHARED_LIBRARIES,libcutils) +# $(call emugl-end-module) +# +# $(call emugl-begin-shared-library,bar) +# LOCAL_SRC_FILES := bar.cpp +# $(call emugl-import,foo) +# $(call emugl-end-module) +# +# Here, we define a static library named 'foo' which exports an include +# path and a shared library requirement, and a shared library 'bar' which +# imports it. +# +# What this means is that: +# +# - 'bar' will automatically inherit foo's LOCAL_PATH in its LOCAL_C_INCLUDES +# - 'bar' will automatically inherit libcutils in its own LOCAL_SHARED_LIBRARIES +# +# Note that order of declaration matters. If 'foo' is defined after 'bar' in +# the example above, nothing will work correctly because dependencies are +# computed at import time. +# +# +# IMPORTANT: Imports are transitive, i.e. when module A imports B, +# it automatically imports anything imported by B too. + +# This is the list of recognized export types we support for now. +EMUGL_EXPORT_TYPES := \ + CFLAGS \ + CXXFLAGS \ + LDLIBS \ + LDFLAGS \ + C_INCLUDES \ + SHARED_LIBRARIES \ + STATIC_LIBRARIES \ + ADDITIONAL_DEPENDENCIES + +# Initialize a module in our database +# $1: Module name +# $2: Module type +# $3: "HOST" for a host module, empty for a target one. +_emugl-init-module = \ + $(eval _emugl_HOST := $(if $3,HOST_,))\ + $(eval _emugl_MODULE := $(_emugl_HOST)$1)\ + $(if $(filter $(_emugl_$(_emugl_HOST)modules),$(_emugl_MODULE)),\ + $(error There is already a $(if $3,host,) module named $1!)\ + )\ + $(eval _mod = $(_emugl_MODULE)) \ + $(eval _emugl.$(_mod).type := $(patsubst HOST_%,%,$2))\ + $(eval _emugl.$(_mod).imports :=) \ + $(eval _emugl,$(_mod).moved :=) \ + $(foreach _type,$(EMUGL_EXPORT_TYPES),\ + $(eval _emugl.$(_mod).export.$(_type) :=)\ + ) + +# Called to indicate that a module exports a given local variable for its +# users. This also adds this to LOCAL_$1 +# $1: Local variable type (e.g. CFLAGS, LDLIBS, etc...) +# $2: Value(s) to append to the export +emugl-export = \ + $(eval _emugl.$(_emugl_MODULE).export.$1 += $2)\ + $(eval LOCAL_$1 := $(LOCAL_$1) $2) + +emugl-export-outer = \ + $(eval _emugl.$(_emugl_MODULE).export.$1 += $2) + +# Called to indicate that a module imports the exports of another module +# $1: list of modules to import +# +emugl-import = \ + $(foreach _imod,$1,\ + $(call _emugl-module-import,$(_emugl_HOST)$(_imod))\ + ) + +_emugl-module-import = \ + $(eval _mod := $(_emugl_MODULE))\ + $(if $(filter-out $(_emugl_$(_emugl_HOST)modules),$1),\ + $(info Unknown imported emugles module: $1)\ + $(if $(_emugl_HOST),\ + $(eval _names := $(patsubst HOST_%,%,$(_emugl_HOST_modules))),\ + $(eval _names := $(_emugl_modules))\ + )\ + $(info Please one of the following names: $(_names))\ + $(error Aborting)\ + )\ + $(if $(filter-out $(_emugl.$(_mod).imports),$1),\ + $(eval _emugl.$(_mod).imports += $1)\ + $(foreach _sub,$(_emugl.$1.imports),\ + $(call _emugl-module-import,$(_sub))\ + )\ + $(foreach _type,$(EMUGL_EXPORT_TYPES),\ + $(eval LOCAL_$(_type) := $(LOCAL_$(_type)) $(_emugl.$1.export.$(_type)))\ + )\ + $(if $(filter EXECUTABLE SHARED_LIBRARY,$(_emugl.$(_emugl_MODULE).type)),\ + $(if $(filter STATIC_LIBRARY,$(_emugl.$1.type)),\ + $(eval LOCAL_STATIC_LIBRARIES := $(1:HOST_%=%) $(LOCAL_STATIC_LIBRARIES))\ + )\ + $(if $(filter SHARED_LIBRARY,$(_emugl.$1.type)),\ + $(if $(_emugl.$1.moved),,\ + $(eval LOCAL_SHARED_LIBRARIES := $(1:HOST_%=%) $(LOCAL_SHARED_LIBRARIES))\ + )\ + )\ + )\ + ) + +_emugl-dump-list = \ + $(foreach _list_item,$(strip $1),$(info . $(_list_item))) + +emugl-dump-module = \ + $(info MODULE=$(_emugl_MODULE))\ + $(info . HOST=$(_emugl_HOST))\ + $(info . TYPE=$(_emugl.$(_emugl_MODULE).type))\ + $(info . IMPORTS=$(_emugl.$(_emugl_MODULE).imports))\ + $(foreach _type,$(EMUGL_EXPORT_TYPES),\ + $(if $(filter C_INCLUDES ADDITIONAL_DEPENDENCIES,$(_type)),\ + $(info . EXPORT.$(_type) :=)\ + $(call _emugl-dump-list,$(_emugl.$(_emugl_MODULE).export.$(_type)))\ + $(info . LOCAL_$(_type) :=)\ + $(call _emugl-dump-list,$(LOCAL_$(_type)))\ + ,\ + $(info . EXPORT.$(_type) := $(strip $(_emugl.$(_emugl_MODULE).export.$(_type))))\ + $(info . LOCAL_$(_type) := $(strip $(LOCAL_$(_type))))\ + )\ + )\ + $(info . LOCAL_SRC_FILES := $(LOCAL_SRC_FILES))\ + +# This function can be called to generate the decoder source files. +# LOCAL_MODULE and LOCAL_MODULE_CLASS must be defined or the build will abort. +# Source files will be stored in the local intermediates directory that will +# be automatically added to your LOCAL_C_INCLUDES. +# +# Usage: +# $(call emugl-gen-decoder,,) +# +emugl-gen-decoder = \ + $(eval _emugl_out := $(call intermediates-dir-for,$(BUILD_TARGET_BITS),$2))\ + $(call emugl-gen-decoder-generic,$(_emugl_out),$1,$2)\ + $(call emugl-export,C_INCLUDES,$(_emugl_out)) + +# DO NOT CALL DIRECTLY, USE emugl-gen-decoder instead. +# +# The following function can be called to generate wire protocol decoder +# source files, Usage is: +# +# $(call emugl-gen-decoder-generic,,,) +# +# is the destination directory where the generated sources are stored +# is the source directory where to find .attrib, etc.. +# is the emugen basename (see host/tools/emugen/README) +# +emugl-gen-decoder-generic = $(eval $(emugl-gen-decoder-generic-ev)) + +define emugl-gen-decoder-generic-ev +_emugl_dec := $$1/$$3 +_emugl_src := $$2/$$3 +GEN := $$(_emugl_dec)_dec.cpp \ + $$(_emugl_dec)_dec.h \ + $$(_emugl_dec)_opcodes.h \ + $$(_emugl_dec)_server_context.h \ + $$(_emugl_dec)_server_context.cpp + +$$(GEN): PRIVATE_PATH := $$(LOCAL_PATH) +$$(GEN): PRIVATE_CUSTOM_TOOL := $$(EMUGL_EMUGEN) -D $$1 -i $$2 $$3 +$$(GEN): $$(EMUGL_EMUGEN) $$(_emugl_src).attrib $$(_emugl_src).in $$(_emugl_src).types + $$(transform-generated-source) + +$$(call emugl-export,ADDITIONAL_DEPENDENCIES,$$(GEN)) +LOCAL_GENERATED_SOURCES += $$(GEN) +LOCAL_C_INCLUDES += $$1 +endef + +# Call this function when your shared library must be placed in a non-standard +# library path (i.e. not under /system/lib +# $1: library sub-path,relative to /system/lib +# For example: $(call emugl-set-shared-library-subpath,egl) +emugl-set-shared-library-subpath = \ + $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$1)\ + $(eval LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$1)\ + $(eval _emugl.$(LOCAL_MODULE).moved := true)\ + $(call emugl-export-outer,ADDITIONAL_DEPENDENCIES,$(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)$(TARGET_SHLIB_SUFFIX)) + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/googletest.mk b/src/type3_AndroidCloud/anbox-master/external/android-emugl/googletest.mk new file mode 100644 index 0000000..9d8e5c0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/googletest.mk @@ -0,0 +1,37 @@ +# This contains common definitions used to define a host module +# to link GoogleTest with the EmuGL test programs. +# +# This is used instead of including external/gtest/Android.mk to +# be able to build both the 32-bit and 64-bit binaries while +# building a 32-bit only SDK (sdk-eng, sdk_x86-eng, sdk_mips-eng). + + +LOCAL_PATH := $(EMULATOR_GTEST_SOURCES_DIR) + +common_SRC_FILES := \ + src/gtest-all.cc \ + src/gtest_main.cc + +common_CFLAGS := -O0 + +ifneq (windows,$(BUILD_TARGET_OS)) + common_LDLIBS += -lpthread +endif + +$(call emugl-begin-host-static-library,libemugl_gtest) +LOCAL_SRC_FILES := $(common_SRC_FILES) +LOCAL_CFLAGS += $(common_CFLAGS) +LOCAL_CPP_EXTENSION := .cc +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include) +$(call emugl-export,LDLIBS,$(common_LDLIBS)) +$(call emugl-end-module) + +$(call emugl-begin-host-static-library,libemugl_gtest_host) +LOCAL_SRC_FILES := $(common_SRC_FILES) +LOCAL_CFLAGS += $(common_CFLAGS) +LOCAL_C_INCLUDES += $(LOCAL_PATH)/include +LOCAL_CPP_EXTENSION := .cc +$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include) +$(call emugl-export,LDLIBS,$(common_LDLIBS) -lpthread) +LOCAL_HOST_BUILD := true +$(call emugl-end-module) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/CMakeLists.txt new file mode 100644 index 0000000..4e1de0b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(tools) +add_subdirectory(libs) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/ETC1/etc1.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/ETC1/etc1.h new file mode 100644 index 0000000..0d38905 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/ETC1/etc1.h @@ -0,0 +1,106 @@ +// Copyright 2009 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef __etc1_h__ +#define __etc1_h__ + +#define ETC1_ENCODED_BLOCK_SIZE 8 +#define ETC1_DECODED_BLOCK_SIZE 48 + +#ifndef ETC1_RGB8_OES +#define ETC1_RGB8_OES 0x8D64 +#endif + +typedef unsigned char etc1_byte; +typedef int etc1_bool; +typedef unsigned int etc1_uint32; + +#ifdef __cplusplus +extern "C" { +#endif + +// Encode a block of pixels. +// +// pIn is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a +// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R +// value of pixel (x, y). +// +// validPixelMask is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether +// the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing. +// +// pOut is an ETC1 compressed version of the data. + +void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 validPixelMask, etc1_byte* pOut); + +// Decode a block of pixels. +// +// pIn is an ETC1 compressed version of the data. +// +// pOut is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a +// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R +// value of pixel (x, y). + +void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut); + +// Return the size of the encoded image data (does not include size of PKM header). + +etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height); + +// Encode an entire image. +// pIn - pointer to the image data. Formatted such that +// pixel (x,y) is at pIn + pixelSize * x + stride * y; +// pOut - pointer to encoded data. Must be large enough to store entire encoded image. +// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image. +// returns non-zero if there is an error. + +int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height, + etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut); + +// Decode an entire image. +// pIn - pointer to encoded data. +// pOut - pointer to the image data. Will be written such that +// pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be +// large enough to store entire image. +// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image. +// returns non-zero if there is an error. + +int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut, + etc1_uint32 width, etc1_uint32 height, + etc1_uint32 pixelSize, etc1_uint32 stride); + +// Size of a PKM header, in bytes. + +#define ETC_PKM_HEADER_SIZE 16 + +// Format a PKM header + +void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height); + +// Check if a PKM header is correctly formatted. + +etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader); + +// Read the image width from a PKM header + +etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader); + +// Read the image height from a PKM header + +etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/gl.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/gl.h new file mode 100644 index 0000000..a40e29d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/gl.h @@ -0,0 +1,774 @@ +#ifndef __gl_h_ +#define __gl_h_ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wredundant-decls" +/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +typedef void GLvoid; +typedef char GLchar; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int32_t GLclampx; + +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; + + +/*************************************************************/ + +/* OpenGL ES core versions */ +#define GL_VERSION_ES_CM_1_0 1 +#define GL_VERSION_ES_CL_1_0 1 +#define GL_VERSION_ES_CM_1_1 1 +#define GL_VERSION_ES_CL_1_1 1 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* AlphaFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* ClipPlaneName */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* ColorMaterialFace */ +/* GL_FRONT_AND_BACK */ + +/* ColorMaterialParameter */ +/* GL_AMBIENT_AND_DIFFUSE */ + +/* ColorPointerType */ +/* GL_UNSIGNED_BYTE */ +/* GL_FLOAT */ +/* GL_FIXED */ + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_FOG 0x0B60 +#define GL_LIGHTING 0x0B50 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_ALPHA_TEST 0x0BC0 +#define GL_BLEND 0x0BE2 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +/* GL_LIGHT0 */ +/* GL_LIGHT1 */ +/* GL_LIGHT2 */ +/* GL_LIGHT3 */ +/* GL_LIGHT4 */ +/* GL_LIGHT5 */ +/* GL_LIGHT6 */ +/* GL_LIGHT7 */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_NORMALIZE 0x0BA1 +#define GL_RESCALE_NORMAL 0x803A +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FogMode */ +/* GL_LINEAR */ +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* FogParameter */ +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_COLOR 0x0B66 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_LINE_WIDTH 0x0B21 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_SHADE_MODEL 0x0B54 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_VIEWPORT 0x0BA2 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_FOG_HINT 0x0C54 +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* LightModelParameter */ +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 + +/* LightParameter */ +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* LogicOp */ +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F + +/* MaterialFace */ +/* GL_FRONT_AND_BACK */ + +/* MaterialParameter */ +#define GL_EMISSION 0x1600 +#define GL_SHININESS 0x1601 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +/* GL_AMBIENT */ +/* GL_DIFFUSE */ +/* GL_SPECULAR */ + +/* MatrixMode */ +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* NormalPointerType */ +/* GL_BYTE */ +/* GL_SHORT */ +/* GL_FLOAT */ +/* GL_FIXED */ + +/* PixelFormat */ +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelStoreParameter */ +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* ShadingModel */ +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 + +/* StencilFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +/* GL_INVERT */ + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TexCoordPointerType */ +/* GL_SHORT */ +/* GL_FLOAT */ +/* GL_FIXED */ +/* GL_BYTE */ + +/* TextureEnvMode */ +#define GL_MODULATE 0x2100 +#define GL_DECAL 0x2101 +/* GL_BLEND */ +#define GL_ADD 0x0104 +/* GL_REPLACE */ + +/* TextureEnvParameter */ +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_ENV_COLOR 0x2201 + +/* TextureEnvTarget */ +#define GL_TEXTURE_ENV 0x2300 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_GENERATE_MIPMAP 0x8191 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F + +/* VertexPointerType */ +/* GL_SHORT */ +/* GL_FLOAT */ +/* GL_FIXED */ +/* GL_BYTE */ + +/* LightName */ +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 + +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A + +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +/* Texture combine + dot3 */ +#define GL_SUBTRACT 0x84E7 +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A + +#define GL_ALPHA_SCALE 0x0D1C + +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A + +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF + +/*------------------------------------------------------------------------* + * required OES extension tokens + *------------------------------------------------------------------------*/ + +/* OES_read_format */ +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +/* OES_point_size_array */ +#ifndef GL_OES_point_size_array +#define GL_POINT_SIZE_ARRAY_OES 0x8B9C +#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A +#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B +#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C +#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F +#endif + +/* GL_OES_point_sprite */ +#ifndef GL_OES_point_sprite +#define GL_POINT_SPRITE_OES 0x8861 +#define GL_COORD_REPLACE_OES 0x8862 +#endif + +/*************************************************************/ + +/* Available only in Common profile */ +GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref); +GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GL_API void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation); +GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); +GL_API void GL_APIENTRY glFogf (GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]); +GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params); +GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); +GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); +GL_API void GL_APIENTRY glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params); +GL_API void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_API void GL_APIENTRY glLightModelf (GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glLightModelfv (GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glLineWidth (GLfloat width); +GL_API void GL_APIENTRY glLoadMatrixf (const GLfloat *m); +GL_API void GL_APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glMultMatrixf (const GLfloat *m); +GL_API void GL_APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GL_API void GL_APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); +GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GL_API void GL_APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glPointSize (GLfloat size); +GL_API void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_API void GL_APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GL_API void GL_APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); +GL_API void GL_APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); + +/* Available in both Common and Common-Lite profiles */ +GL_API void GL_APIENTRY glActiveTexture (GLenum texture); +GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref); +GL_API void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_API void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_API void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GL_API void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GL_API void GL_APIENTRY glClear (GLbitfield mask); +GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +GL_API void GL_APIENTRY glClearDepthx (GLclampx depth); +GL_API void GL_APIENTRY glClearStencil (GLint s); +GL_API void GL_APIENTRY glClientActiveTexture (GLenum texture); +GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation); +GL_API void GL_APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_API void GL_APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GL_API void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GL_API void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GL_API void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_API void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_API void GL_APIENTRY glCullFace (GLenum mode); +GL_API void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_API void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_API void GL_APIENTRY glDepthFunc (GLenum func); +GL_API void GL_APIENTRY glDepthMask (GLboolean flag); +GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar); +GL_API void GL_APIENTRY glDisable (GLenum cap); +GL_API void GL_APIENTRY glDisableClientState (GLenum array); +GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +GL_API void GL_APIENTRY glEnable (GLenum cap); +GL_API void GL_APIENTRY glEnableClientState (GLenum array); +GL_API void GL_APIENTRY glFinish (void); +GL_API void GL_APIENTRY glFlush (void); +GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glFrontFace (GLenum mode); +GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params); +GL_API void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed eqn[4]); +GL_API void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_API void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_API GLenum GL_APIENTRY glGetError (void); +GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params); +GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetPointerv (GLenum pname, GLvoid **params); +GL_API const GLubyte * GL_APIENTRY glGetString (GLenum name); +GL_API void GL_APIENTRY glGetTexEnviv (GLenum env, GLenum pname, GLint *params); +GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_API GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_API GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_API GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glLineWidthx (GLfixed width); +GL_API void GL_APIENTRY glLoadIdentity (void); +GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m); +GL_API void GL_APIENTRY glLogicOp (GLenum opcode); +GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glMatrixMode (GLenum mode); +GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m); +GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz); +GL_API void GL_APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glPointSizex (GLfixed size); +GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units); +GL_API void GL_APIENTRY glPopMatrix (void); +GL_API void GL_APIENTRY glPushMatrix (void); +GL_API void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GL_API void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert); +GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z); +GL_API void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_API void GL_APIENTRY glShadeModel (GLenum mode); +GL_API void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_API void GL_APIENTRY glStencilMask (GLuint mask); +GL_API void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_API void GL_APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GL_API void GL_APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); +GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); +GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GL_API void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z); +GL_API void GL_APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GL_API void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +/*------------------------------------------------------------------------* + * Required OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_read_format */ +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + +/* GL_OES_point_size_array */ +#ifndef GL_OES_point_size_array +#define GL_OES_point_size_array 1 +GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +/* GL_OES_point_sprite */ +#ifndef GL_OES_point_sprite +#define GL_OES_point_sprite 1 +#endif + +#ifdef __cplusplus +} +#endif + +#pragma GCC diagnostic pop + +#endif /* __gl_h_ */ + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glext.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glext.h new file mode 100644 index 0000000..130e4b0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glext.h @@ -0,0 +1,1073 @@ +#ifndef __glext_h_ +#define __glext_h_ + +/* $Revision: 13240 $ on $Date:: 2010-12-17 15:16:00 -0800 #$ */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +#ifndef GL_APIENTRYP +# define GL_APIENTRYP GL_APIENTRY* +#endif + +/*------------------------------------------------------------------------* + * OES extension tokens + *------------------------------------------------------------------------*/ + +/* GL_OES_blend_equation_separate */ +#ifndef GL_OES_blend_equation_separate +/* BLEND_EQUATION_RGB_OES same as BLEND_EQUATION_OES */ +#define GL_BLEND_EQUATION_RGB_OES 0x8009 +#define GL_BLEND_EQUATION_ALPHA_OES 0x883D +#endif + +/* GL_OES_blend_func_separate */ +#ifndef GL_OES_blend_func_separate +#define GL_BLEND_DST_RGB_OES 0x80C8 +#define GL_BLEND_SRC_RGB_OES 0x80C9 +#define GL_BLEND_DST_ALPHA_OES 0x80CA +#define GL_BLEND_SRC_ALPHA_OES 0x80CB +#endif + +/* GL_OES_blend_subtract */ +#ifndef GL_OES_blend_subtract +#define GL_BLEND_EQUATION_OES 0x8009 +#define GL_FUNC_ADD_OES 0x8006 +#define GL_FUNC_SUBTRACT_OES 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_OES 0x800B +#endif + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_ETC1_RGB8_OES 0x8D64 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif + +/* GL_OES_draw_texture */ +#ifndef GL_OES_draw_texture +#define GL_TEXTURE_CROP_RECT_OES 0x8B9D +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +/* GLeglImageOES defined in GL_OES_EGL_image already. */ +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_UNSIGNED_INT 0x1405 +#endif + +/* GL_OES_fixed_point */ +#ifndef GL_OES_fixed_point +#define GL_FIXED_OES 0x140C +#endif + +/* GL_OES_framebuffer_object */ +#ifndef GL_OES_framebuffer_object +#define GL_NONE_OES 0 +#define GL_FRAMEBUFFER_OES 0x8D40 +#define GL_RENDERBUFFER_OES 0x8D41 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +#define GL_RENDERBUFFER_WIDTH_OES 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_OES 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE_OES 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_OES 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_OES 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_OES 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_OES 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_OES 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES 0x8CD3 +#define GL_COLOR_ATTACHMENT0_OES 0x8CE0 +#define GL_DEPTH_ATTACHMENT_OES 0x8D00 +#define GL_STENCIL_ATTACHMENT_OES 0x8D20 +#define GL_FRAMEBUFFER_COMPLETE_OES 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES 0x8CDA +#define GL_FRAMEBUFFER_UNSUPPORTED_OES 0x8CDD +#define GL_FRAMEBUFFER_BINDING_OES 0x8CA6 +#define GL_RENDERBUFFER_BINDING_OES 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE_OES 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION_OES 0x0506 +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +#endif + +/* GL_OES_matrix_get */ +#ifndef GL_OES_matrix_get +#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D +#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E +#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F +#endif + +/* GL_OES_matrix_palette */ +#ifndef GL_OES_matrix_palette +#define GL_MAX_VERTEX_UNITS_OES 0x86A4 +#define GL_MAX_PALETTE_MATRICES_OES 0x8842 +#define GL_MATRIX_PALETTE_OES 0x8840 +#define GL_MATRIX_INDEX_ARRAY_OES 0x8844 +#define GL_WEIGHT_ARRAY_OES 0x86AD +#define GL_CURRENT_PALETTE_MATRIX_OES 0x8843 +#define GL_MATRIX_INDEX_ARRAY_SIZE_OES 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_OES 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_OES 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_OES 0x8849 +#define GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES 0x8B9E +#define GL_WEIGHT_ARRAY_SIZE_OES 0x86AB +#define GL_WEIGHT_ARRAY_TYPE_OES 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_OES 0x86AA +#define GL_WEIGHT_ARRAY_POINTER_OES 0x86AC +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_OES 0x889E +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif + +/* GL_OES_stencil8 */ +#ifndef GL_OES_stencil8 +#define GL_STENCIL_INDEX8_OES 0x8D48 +#endif + +/* GL_OES_stencil_wrap */ +#ifndef GL_OES_stencil_wrap +#define GL_INCR_WRAP_OES 0x8507 +#define GL_DECR_WRAP_OES 0x8508 +#endif + +/* GL_OES_texture_cube_map */ +#ifndef GL_OES_texture_cube_map +#define GL_NORMAL_MAP_OES 0x8511 +#define GL_REFLECTION_MAP_OES 0x8512 +#define GL_TEXTURE_CUBE_MAP_OES 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_OES 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES 0x851C +#define GL_TEXTURE_GEN_MODE_OES 0x2500 +#define GL_TEXTURE_GEN_STR_OES 0x8D60 +#endif + +/* GL_OES_texture_mirrored_repeat */ +#ifndef GL_OES_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_OES 0x8370 +#endif + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 +#endif + +/*------------------------------------------------------------------------* + * AMD extension tokens + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif + +/*------------------------------------------------------------------------* + * APPLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_APPLE_texture_2D_limited_npot */ +/* No new tokens introduced by this extension. */ + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif + +/*------------------------------------------------------------------------* + * ARM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ARM_rgba8 */ +/* No new tokens introduced by this extension. */ + +/*------------------------------------------------------------------------* + * EXT extension tokens + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#endif + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_COLOR_EXT 0x1800 +#define GL_DEPTH_EXT 0x1801 +#define GL_STENCIL_EXT 0x1802 +#endif + +/* GL_EXT_multi_draw_arrays */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_BGRA_EXT 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_EXT_texture_lod_bias */ +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +/*------------------------------------------------------------------------* + * IMG extension tokens + *------------------------------------------------------------------------*/ + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_BGRA_IMG 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif + +/* GL_IMG_texture_env_enhanced_fixed_function */ +#ifndef GL_IMG_texture_env_enhanced_fixed_function +#define GL_MODULATE_COLOR_IMG 0x8C04 +#define GL_RECIP_ADD_SIGNED_ALPHA_IMG 0x8C05 +#define GL_TEXTURE_ALPHA_MODULATE_IMG 0x8C06 +#define GL_FACTOR_ALPHA_MODULATE_IMG 0x8C07 +#define GL_FRAGMENT_ALPHA_MODULATE_IMG 0x8C08 +#define GL_ADD_BLEND_IMG 0x8C09 +#define GL_DOT3_RGBA_IMG 0x86AF +#endif + +/* GL_IMG_user_clip_plane */ +#ifndef GL_IMG_user_clip_plane +#define GL_CLIP_PLANE0_IMG 0x3000 +#define GL_CLIP_PLANE1_IMG 0x3001 +#define GL_CLIP_PLANE2_IMG 0x3002 +#define GL_CLIP_PLANE3_IMG 0x3003 +#define GL_CLIP_PLANE4_IMG 0x3004 +#define GL_CLIP_PLANE5_IMG 0x3005 +#define GL_MAX_CLIP_PLANES_IMG 0x0D32 +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +#endif + +/*------------------------------------------------------------------------* + * NV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +/*------------------------------------------------------------------------* + * QCOM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_QCOM_driver_control */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 +#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 +#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 +#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 +#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 +#define GL_TEXTURE_TYPE_QCOM 0x8BD7 +#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 +#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 +#define GL_TEXTURE_TARGET_QCOM 0x8BDA +#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB +#define GL_STATE_RESTORE 0x8BDC +#endif + +/* GL_QCOM_extended_get2 */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_WRITEONLY_RENDERING_QCOM 0x8823 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 +#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 +#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 +#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 +#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 +#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 +#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 +#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 +#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 +#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 +#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 +#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 +#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 +#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 +#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 +#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 +#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 +#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 +#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 +#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 +#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 +#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 +#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 +#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 +#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 +#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 +#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 +#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 +#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 +#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 +#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 +#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 +#endif + +/*------------------------------------------------------------------------* + * End of extension tokens, start of corresponding extension functions + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------* + * OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_blend_equation_separate */ +#ifndef GL_OES_blend_equation_separate +#define GL_OES_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha); +#endif +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEOESPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +/* GL_OES_blend_func_separate */ +#ifndef GL_OES_blend_func_separate +#define GL_OES_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glBlendFuncSeparateOES (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +/* GL_OES_blend_subtract */ +#ifndef GL_OES_blend_subtract +#define GL_OES_blend_subtract 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glBlendEquationOES (GLenum mode); +#endif +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC) (GLenum mode); +#endif + +/* GL_OES_byte_coordinates */ +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +#endif + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#endif + +/* GL_OES_draw_texture */ +#ifndef GL_OES_draw_texture +#define GL_OES_draw_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); +GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height); +GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); +GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords); +GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords); +GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords); +GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); +GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWTEXSOESPROC) (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXIOESPROC) (GLint x, GLint y, GLint z, GLint width, GLint height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXXOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXSVOESPROC) (const GLshort *coords); +typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOESPROC) (const GLint *coords); +typedef void (GL_APIENTRYP PFNGLDRAWTEXXVOESPROC) (const GLfixed *coords); +typedef void (GL_APIENTRYP PFNGLDRAWTEXFOESPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); +typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOESPROC) (const GLfloat *coords); +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif + +/* GL_OES_extended_matrix_palette */ +#ifndef GL_OES_extended_matrix_palette +#define GL_OES_extended_matrix_palette 1 +#endif + +/* GL_OES_fbo_render_mipmap */ +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif + +/* GL_OES_fixed_point */ +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glAlphaFuncxOES (GLenum func, GLclampx ref); +GL_API void GL_APIENTRY glClearColorxOES (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +GL_API void GL_APIENTRY glClearDepthxOES (GLclampx depth); +GL_API void GL_APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GL_API void GL_APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GL_API void GL_APIENTRY glDepthRangexOES (GLclampx zNear, GLclampx zFar); +GL_API void GL_APIENTRY glFogxOES (GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glFogxvOES (GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glFrustumxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +GL_API void GL_APIENTRY glGetClipPlanexOES (GLenum pname, GLfixed eqn[4]); +GL_API void GL_APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetLightxvOES (GLenum light, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetMaterialxvOES (GLenum face, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetTexEnvxvOES (GLenum env, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GL_API void GL_APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glLineWidthxOES (GLfixed width); +GL_API void GL_APIENTRY glLoadMatrixxOES (const GLfixed *m); +GL_API void GL_APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glMultMatrixxOES (const GLfixed *m); +GL_API void GL_APIENTRY glMultiTexCoord4xOES (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GL_API void GL_APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GL_API void GL_APIENTRY glOrthoxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +GL_API void GL_APIENTRY glPointParameterxOES (GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glPointSizexOES (GLfixed size); +GL_API void GL_APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GL_API void GL_APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GL_API void GL_APIENTRY glSampleCoveragexOES (GLclampx value, GLboolean invert); +GL_API void GL_APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GL_API void GL_APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +#endif +typedef void (GL_APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLclampx ref); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLclampx depth); +typedef void (GL_APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (GL_APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLclampx zNear, GLclampx zFar); +typedef void (GL_APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum pname, GLfixed eqn[4]); +typedef void (GL_APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (GL_APIENTRYP PFNGLGETLIGHTXVOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (GL_APIENTRYP PFNGLGETMATERIALXVOESPROC) (GLenum face, GLenum pname, GLfixed *params); +typedef void (GL_APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum env, GLenum pname, GLfixed *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (GL_APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (GL_APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (GL_APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (GL_APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (GL_APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (GL_APIENTRYP PFNGLORTHOXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar); +typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXOESPROC) (GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (GL_APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEXOESPROC) (GLclampx value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (GL_APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +#endif + +/* GL_OES_framebuffer_object */ +#ifndef GL_OES_framebuffer_object +#define GL_OES_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API GLboolean GL_APIENTRY glIsRenderbufferOES (GLuint renderbuffer); +GL_API void GL_APIENTRY glBindRenderbufferOES (GLenum target, GLuint renderbuffer); +GL_API void GL_APIENTRY glDeleteRenderbuffersOES (GLsizei n, const GLuint* renderbuffers); +GL_API void GL_APIENTRY glGenRenderbuffersOES (GLsizei n, GLuint* renderbuffers); +GL_API void GL_APIENTRY glRenderbufferStorageOES (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_API void GL_APIENTRY glGetRenderbufferParameterivOES (GLenum target, GLenum pname, GLint* params); +GL_API GLboolean GL_APIENTRY glIsFramebufferOES (GLuint framebuffer); +GL_API void GL_APIENTRY glBindFramebufferOES (GLenum target, GLuint framebuffer); +GL_API void GL_APIENTRY glDeleteFramebuffersOES (GLsizei n, const GLuint* framebuffers); +GL_API void GL_APIENTRY glGenFramebuffersOES (GLsizei n, GLuint* framebuffers); +GL_API GLenum GL_APIENTRY glCheckFramebufferStatusOES (GLenum target); +GL_API void GL_APIENTRY glFramebufferRenderbufferOES (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_API void GL_APIENTRY glFramebufferTexture2DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_API void GL_APIENTRY glGetFramebufferAttachmentParameterivOES (GLenum target, GLenum attachment, GLenum pname, GLint* params); +GL_API void GL_APIENTRY glGenerateMipmapOES (GLenum target); +#endif +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOESPROC) (GLenum target); +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); +GL_API GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); +GL_API void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid ** params); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid ** params); +#endif + +/* GL_OES_matrix_get */ +#ifndef GL_OES_matrix_get +#define GL_OES_matrix_get 1 +#endif + +/* GL_OES_matrix_palette */ +#ifndef GL_OES_matrix_palette +#define GL_OES_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glCurrentPaletteMatrixOES (GLuint matrixpaletteindex); +GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES (void); +GL_API void GL_APIENTRY glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GL_API void GL_APIENTRY glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif +typedef void (GL_APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC) (GLuint matrixpaletteindex); +typedef void (GL_APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC) (void); +typedef void (GL_APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#endif + +/* GL_OES_query_matrix */ +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES (GLfixed mantissa[16], GLint exponent[16]); +#endif +typedef GLbitfield (GL_APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed mantissa[16], GLint exponent[16]); +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif + +/* GL_OES_single_precision */ +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar); +GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]); +GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth); +#endif +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar); +typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +typedef void (GL_APIENTRYP PFNGLORTHOFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +typedef void (GL_APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum pname, GLfloat eqn[4]); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#endif + +/* GL_OES_stencil8 */ +#ifndef GL_OES_stencil8 +#define GL_OES_stencil8 1 +#endif + +/* GL_OES_stencil_wrap */ +#ifndef GL_OES_stencil_wrap +#define GL_OES_stencil_wrap 1 +#endif + +/* GL_OES_texture_cube_map */ +#ifndef GL_OES_texture_cube_map +#define GL_OES_texture_cube_map 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param); +GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params); +GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param); +GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params); +GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params); +GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params); +GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +#endif +typedef void (GL_APIENTRYP PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (GL_APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (GL_APIENTRYP PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +#endif + +/* GL_OES_texture_env_crossbar */ +#ifndef GL_OES_texture_env_crossbar +#define GL_OES_texture_env_crossbar 1 +#endif + +/* GL_OES_texture_mirrored_repeat */ +#ifndef GL_OES_texture_mirrored_repeat +#define GL_OES_texture_mirrored_repeat 1 +#endif + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_OES_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glBindVertexArrayOES (GLuint array); +GL_API void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); +GL_API void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); +GL_API GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); +#endif +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); +#endif + +/*------------------------------------------------------------------------* + * AMD extension functions + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#endif + +/*------------------------------------------------------------------------* + * APPLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_APPLE_texture_2D_limited_npot */ +#ifndef GL_APPLE_texture_2D_limited_npot +#define GL_APPLE_texture_2D_limited_npot 1 +#endif + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GL_API void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#endif + +/*------------------------------------------------------------------------* + * ARM extension functions + *------------------------------------------------------------------------*/ + +/* GL_ARM_rgba8 */ +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif + +/*------------------------------------------------------------------------* + * EXT extension functions + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#endif + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_EXT_discard_framebuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif +typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif + +/* GL_EXT_multi_draw_arrays */ +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_EXT_read_format_bgra 1 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif + +/* GL_EXT_texture_lod_bias */ +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension functions + *------------------------------------------------------------------------*/ + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#endif + +/* GL_IMG_texture_env_enhanced_fixed_function */ +#ifndef GL_IMG_texture_env_enhanced_fixed_function +#define GL_IMG_texture_env_enhanced_fixed_function 1 +#endif + +/* GL_IMG_user_clip_plane */ +#ifndef GL_IMG_user_clip_plane +#define GL_IMG_user_clip_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glClipPlanefIMG (GLenum, const GLfloat *); +GL_API void GL_APIENTRY glClipPlanexIMG (GLenum, const GLfixed *); +#endif +typedef void (GL_APIENTRYP PFNGLCLIPPLANEFIMGPROC) (GLenum p, const GLfloat *eqn); +typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMGPROC) (GLenum p, const GLfixed *eqn); +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + +/*------------------------------------------------------------------------* + * NV extension functions + *------------------------------------------------------------------------*/ + +/* NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GL_API void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *); +GL_API GLboolean GL_APIENTRY glIsFenceNV (GLuint); +GL_API GLboolean GL_APIENTRY glTestFenceNV (GLuint); +GL_API void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GL_API void GL_APIENTRY glFinishFenceNV (GLuint); +GL_API void GL_APIENTRY glSetFenceNV (GLuint, GLenum); +#endif +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +/*------------------------------------------------------------------------* + * QCOM extension functions + *------------------------------------------------------------------------*/ + +/* GL_QCOM_driver_control */ +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); +GL_API void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +GL_API void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); +GL_API void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); +#endif +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +#endif + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_QCOM_extended_get 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); +GL_API void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +GL_API void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +GL_API void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +GL_API void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +GL_API void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); +GL_API void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +GL_API void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); +#endif + +/* GL_QCOM_extended_get2 */ +#ifndef GL_QCOM_extended_get2 +#define GL_QCOM_extended_get2 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); +GL_API void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +GL_API GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); +GL_API void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_QCOM_writeonly_rendering 1 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_QCOM_tiled_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +GL_API void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); +#endif +typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __glext_h_ */ + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glplatform.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glplatform.h new file mode 100644 index 0000000..2db6ee2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/GLES/glplatform.h @@ -0,0 +1,30 @@ +#ifndef __glplatform_h_ +#define __glplatform_h_ + +/* $Revision: 10601 $ on $Date:: 2010-03-04 22:15:27 -0800 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 1.X gl.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +#include + +#ifndef GL_API +#define GL_API KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __glplatform_h_ */ diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h new file mode 100644 index 0000000..b70773a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/EGLDispatch.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#pragma once + +#include "OpenGLESDispatch/RenderEGL_functions.h" +#include "OpenGLESDispatch/RenderEGL_extensions_functions.h" + +// This header is used to define the EGLDispatch structure that contains +// pointers to the EGL shared library used by libOpenglRender. Normally, +// this will be our own libEGL_translator, but one could imagine a +// vendor-specific being used instead. + +// There is a single global instance of this structure, named |s_egl|, +// which must be initialized by calling init_egl_dispatch() before use. + +// Note that our code requires the implementation of misc EGL extensions +// including eglSetSwapRectangleANDROID(), see RenderEGL_extensions_functions.h +// for a full list. + +#define RENDER_EGL_DEFINE_TYPE(return_type, function_name, signature) \ + typedef return_type (EGLAPIENTRY *function_name ## _t) signature; + +#define RENDER_EGL_DECLARE_MEMBER(return_type, function_name, signature) \ + function_name ## _t function_name; + +// Define function typedefs. +LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DEFINE_TYPE) +LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DEFINE_TYPE) + +// Define EGLDispatch structure. +struct EGLDispatch { + bool initialized = false; + LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER) + LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER) +}; + +// Initialize EGLDispatch function. Return true on success, false on failure. +bool init_egl_dispatch(const char *path); + +// Global EGLDispatch instance. Call init_egl_dispatch() before using it. +extern EGLDispatch s_egl; diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h new file mode 100644 index 0000000..464fa39 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv1Dispatch.h @@ -0,0 +1,42 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#pragma once + +#include "OpenGLESDispatch/gldefs.h" +#include "OpenGLESDispatch/gles_functions.h" +#include "KHR/khrplatform.h" + +// Define function pointer types. +#define GLES1_DISPATCH_DEFINE_TYPE(return_type,func_name,signature,callargs) \ + typedef return_type (KHRONOS_APIENTRY * func_name ## _t) signature; + +LIST_GLES1_FUNCTIONS(GLES1_DISPATCH_DEFINE_TYPE,GLES1_DISPATCH_DEFINE_TYPE) + +struct GLESv1Dispatch { + bool initialized = false; +#define GLES1_DISPATCH_DECLARE_POINTER(return_type,func_name,signature,callargs) \ + func_name ## _t func_name; + LIST_GLES1_FUNCTIONS(GLES1_DISPATCH_DECLARE_POINTER, + GLES1_DISPATCH_DECLARE_POINTER) +}; + +#undef GLES1_DISPATCH_DECLARE_POINTER +#undef GLES1_DISPATCH_DEFINE_TYPE + +bool gles1_dispatch_init(const char *path, GLESv1Dispatch* dispatch_table); + +// Used to initialize the decoder. +void* gles1_dispatch_get_proc_func(const char* name, void* userData); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h new file mode 100644 index 0000000..f58b31c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/GLESv2Dispatch.h @@ -0,0 +1,42 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#pragma once + +#include "OpenGLESDispatch/gldefs.h" +#include "OpenGLESDispatch/gles_functions.h" +#include "KHR/khrplatform.h" + +// Define function pointer types. +#define GLES2_DISPATCH_DEFINE_TYPE(return_type,func_name,signature,callargs) \ + typedef return_type (KHRONOS_APIENTRY * func_name ## _t) signature; + +LIST_GLES2_FUNCTIONS(GLES2_DISPATCH_DEFINE_TYPE,GLES2_DISPATCH_DEFINE_TYPE) + +struct GLESv2Dispatch { + bool initialized = false; +#define GLES2_DISPATCH_DECLARE_POINTER(return_type,func_name,signature,callargs) \ + func_name ## _t func_name; + LIST_GLES2_FUNCTIONS(GLES2_DISPATCH_DECLARE_POINTER, + GLES2_DISPATCH_DECLARE_POINTER) +}; + +#undef GLES2_DISPATCH_DECLARE_POINTER +#undef GLES2_DISPATCH_DEFINE_TYPE + +bool gles2_dispatch_init(const char *path, GLESv2Dispatch* dispatch_table); + +// Used to initialize the decoder. +void* gles2_dispatch_get_proc_func(const char* name, void* userData); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gldefs.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gldefs.h new file mode 100644 index 0000000..77df117 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gldefs.h @@ -0,0 +1,45 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +typedef double GLclampd; /* double precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef void* GLeglImageOES; + +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_INT 0x1404 +#define GL_HALF_FLOAT_NV 0x140B +#define GL_HALF_FLOAT 0x140B +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_POINT_SPRITE 0x8861 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gles_functions.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gles_functions.h new file mode 100644 index 0000000..6e4dfa1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/OpenGLESDispatch/gles_functions.h @@ -0,0 +1,50 @@ +// Copyright 2016 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "OpenGLESDispatch/gles_common_functions.h" +#include "OpenGLESDispatch/gles_extensions_functions.h" +#include "OpenGLESDispatch/gles1_only_functions.h" +#include "OpenGLESDispatch/gles1_extensions_functions.h" +#include "OpenGLESDispatch/gles2_only_functions.h" +#include "OpenGLESDispatch/gles2_extensions_functions.h" +#include "OpenGLESDispatch/gles3_only_functions.h" + +// As a special case, LIST_GLES3_ONLY_FUNCTIONS below uses the Y parameter +// instead of the X one, meaning that the corresponding functions are +// optional extensions. This is only because currently, the only GLESv3 +// API we support is glGetStringi(), which is not always provided by +// host desktop GL drivers (though most do). +#define LIST_GLES_FUNCTIONS(X,Y) \ + LIST_GLES_COMMON_FUNCTIONS(X) \ + LIST_GLES_EXTENSIONS_FUNCTIONS(Y) \ + LIST_GLES1_ONLY_FUNCTIONS(X) \ + LIST_GLES1_EXTENSIONS_FUNCTIONS(Y) \ + LIST_GLES2_ONLY_FUNCTIONS(X) \ + LIST_GLES2_EXTENSIONS_FUNCTIONS(Y) \ + LIST_GLES3_ONLY_FUNCTIONS(Y) \ + +#define LIST_GLES1_FUNCTIONS(X, Y) \ + LIST_GLES_COMMON_FUNCTIONS(X) \ + LIST_GLES_EXTENSIONS_FUNCTIONS(Y) \ + LIST_GLES1_ONLY_FUNCTIONS(X) \ + LIST_GLES1_EXTENSIONS_FUNCTIONS(Y) \ + +#define LIST_GLES2_FUNCTIONS(X, Y) \ + LIST_GLES_COMMON_FUNCTIONS(X) \ + LIST_GLES_EXTENSIONS_FUNCTIONS(Y) \ + LIST_GLES2_ONLY_FUNCTIONS(X) \ + LIST_GLES2_EXTENSIONS_FUNCTIONS(Y) \ + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/libOpenglRender/IOStream.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/libOpenglRender/IOStream.h new file mode 100644 index 0000000..2f228e4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/include/libOpenglRender/IOStream.h @@ -0,0 +1,85 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __IO_STREAM_H__ +#define __IO_STREAM_H__ + +#include +#include + +class IOStream { +public: + IOStream(size_t bufSize) { + m_buf = NULL; + m_bufsize = bufSize; + m_free = 0; + } + + virtual void *allocBuffer(size_t minSize) = 0; + virtual size_t commitBuffer(size_t size) = 0; + virtual const unsigned char *read(void *buf, size_t *inout_len) = 0; + virtual void forceStop() = 0; + + virtual ~IOStream() { + // NOTE: m_buf is 'owned' by the child class thus we expect it to be released by it + } + + unsigned char *alloc(size_t len) { + if (m_buf && len > m_free) { + if (flush() < 0) + return NULL; // we failed to flush so something is wrong + } + + if (!m_buf || len > m_bufsize) { + int allocLen = m_bufsize < len ? len : m_bufsize; + m_buf = static_cast(allocBuffer(allocLen)); + if (!m_buf) + return NULL; + m_bufsize = m_free = allocLen; + } + + unsigned char *ptr; + + ptr = m_buf + (m_bufsize - m_free); + m_free -= len; + + return ptr; + } + + int flush() { + if (!m_buf || m_free == m_bufsize) return 0; + + int stat = commitBuffer(m_bufsize - m_free); + m_buf = NULL; + m_free = 0; + return stat; + } + +private: + unsigned char *m_buf; + size_t m_bufsize; + size_t m_free; +}; + +// +// When a client opens a connection to the renderer, it should +// send unsigned int value indicating the "clientFlags". +// The following are the bitmask of the clientFlags. +// currently only one bit is used which flags the server +// it should exit. +// +#define IOSTREAM_CLIENT_EXIT_SERVER 1 + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/CMakeLists.txt new file mode 100644 index 0000000..25c813c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/CMakeLists.txt @@ -0,0 +1,40 @@ +FUNCTION(PREPEND var prefix) + SET(listVar "") + FOREACH(f ${ARGN}) + LIST(APPEND listVar "${prefix}/${f}") + ENDFOREACH(f) + SET(${var} "${listVar}" PARENT_SCOPE) +ENDFUNCTION(PREPEND) + +PREPEND(GLHEADERS_SOURCES libOpenGLESDispatch/ + render_egl_extensions.entries + render_egl.entries + gles_common.entries + gles_extensions.entries + gles1_only.entries + gles1_extensions.entries + gles2_only.entries + gles2_extensions.entries + gles3_only.entries) + +PREPEND(GLHEADERS_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/../include/OpenGLESDispatch/ + gles1_extensions_functions.h + gles1_only_functions.h + gles2_extensions_functions.h + gles2_only_functions.h + gles3_only_functions.h + gles_common_functions.h + gles_extensions_functions.h + RenderEGL_extensions_functions.h + RenderEGL_functions.h) + +add_custom_command( + OUTPUT ${GLHEADERS_GENERATED_SOURCES} + COMMAND ${CMAKE_SOURCE_DIR}/scripts/gen-emugl-headers.sh ${CMAKE_BINARY_DIR} + DEPENDS ${GLHEADERS_SOURCES} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) + +include(GLESv1_dec/CMakeLists.txt) +include(GLESv2_dec/CMakeLists.txt) +include(libOpenGLESDispatch/CMakeLists.txt) +include(renderControl_dec/CMakeLists.txt) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/CMakeLists.txt new file mode 100644 index 0000000..d748250 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/CMakeLists.txt @@ -0,0 +1,26 @@ +set(CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/GLESv1_dec) + +PREPEND(GENERATED_SOURCES ${CURRENT_BINARY_DIR}/ + gles1_dec.cpp + gles1_opcodes.h + gles1_server_context.cpp) + +add_custom_command( + OUTPUT ${GENERATED_SOURCES} + POST_BUILD + COMMAND mkdir -p ${CURRENT_BINARY_DIR} && ${CMAKE_BINARY_DIR}/external/android-emugl/host/tools/emugen/emugen + -D ${CURRENT_BINARY_DIR} gles1 + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + DEPENDS emugen) + +PREPEND(SOURCES ${CMAKE_CURRENT_LIST_DIR}/ + GLESv1Decoder.cpp) + +if ("${cmake_build_type_lower}" STREQUAL "trace") + set(OPENGL_DEBUG "-DOPENGL_DEBUG_PRINTOUT -DCHECK_GL_ERROR") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENGL_DEBUG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENGL_DEBUG}") +endif() + +add_library(GLESv1_dec STATIC ${SOURCES} ${GENERATED_SOURCES} ${GLHEADERS_GENERATED_SOURCES}) +target_link_libraries(GLESv1_dec OpenglCodecCommon) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.cpp new file mode 100644 index 0000000..4a227dc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.cpp @@ -0,0 +1,229 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "GLESv1Decoder.h" + +#include +#include +#include + +#include +#include +#include + +static inline void* SafePointerFromUInt(GLuint value) { + return (void*)(uintptr_t)value; +} + +GLESv1Decoder::GLESv1Decoder() +{ + m_contextData = NULL; + m_glesDso = NULL; +} + +GLESv1Decoder::~GLESv1Decoder() +{ + if (m_glesDso != NULL) { + delete m_glesDso; + } +} + + +int GLESv1Decoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData) +{ + this->initDispatchByName(getProcFunc, getProcFuncData); + + glGetCompressedTextureFormats = s_glGetCompressedTextureFormats; + glVertexPointerOffset = s_glVertexPointerOffset; + glColorPointerOffset = s_glColorPointerOffset; + glNormalPointerOffset = s_glNormalPointerOffset; + glTexCoordPointerOffset = s_glTexCoordPointerOffset; + glPointSizePointerOffset = s_glPointSizePointerOffset; + glWeightPointerOffset = s_glWeightPointerOffset; + glMatrixIndexPointerOffset = s_glMatrixIndexPointerOffset; + + glVertexPointerData = s_glVertexPointerData; + glColorPointerData = s_glColorPointerData; + glNormalPointerData = s_glNormalPointerData; + glTexCoordPointerData = s_glTexCoordPointerData; + glPointSizePointerData = s_glPointSizePointerData; + glWeightPointerData = s_glWeightPointerData; + glMatrixIndexPointerData = s_glMatrixIndexPointerData; + + glDrawElementsOffset = s_glDrawElementsOffset; + glDrawElementsData = s_glDrawElementsData; + glFinishRoundTrip = s_glFinishRoundTrip; + + return 0; +} + +int GLESv1Decoder::s_glFinishRoundTrip(void *self) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glFinish(); + return 0; +} + +void GLESv1Decoder::s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glVertexPointer(size, type, stride, SafePointerFromUInt(offset)); +} + +void GLESv1Decoder::s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glColorPointer(size, type, stride, SafePointerFromUInt(offset)); +} + +void GLESv1Decoder::s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glTexCoordPointer(size, type, stride, SafePointerFromUInt(offset)); +} + +void GLESv1Decoder::s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glNormalPointer(type, stride, SafePointerFromUInt(offset)); +} + +void GLESv1Decoder::s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glPointSizePointerOES(type, stride, SafePointerFromUInt(offset)); +} + +void GLESv1Decoder::s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glWeightPointerOES(size, type, stride, SafePointerFromUInt(offset)); +} + +void GLESv1Decoder::s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glMatrixIndexPointerOES(size, type, stride, SafePointerFromUInt(offset)); +} + + + +#define STORE_POINTER_DATA_OR_ABORT(location) \ + if (ctx->m_contextData != NULL) { \ + ctx->m_contextData->storePointerData((location), data, datalen); \ + } else { \ + return; \ + } + +void GLESv1Decoder::s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + + STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::VERTEX_LOCATION); + + ctx->glVertexPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::VERTEX_LOCATION)); +} + +void GLESv1Decoder::s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + + STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::COLOR_LOCATION); + + ctx->glColorPointer(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::COLOR_LOCATION)); +} + +void GLESv1Decoder::s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + STORE_POINTER_DATA_OR_ABORT((GLDecoderContextData::PointerDataLocation) + (GLDecoderContextData::TEXCOORD0_LOCATION + unit)); + + ctx->glTexCoordPointer(size, type, 0, + ctx->m_contextData->pointerData((GLDecoderContextData::PointerDataLocation) + (GLDecoderContextData::TEXCOORD0_LOCATION + unit))); +} + +void GLESv1Decoder::s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + + STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::NORMAL_LOCATION); + + ctx->glNormalPointer(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::NORMAL_LOCATION)); +} + +void GLESv1Decoder::s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + + STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::POINTSIZE_LOCATION); + + ctx->glPointSizePointerOES(type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::POINTSIZE_LOCATION)); +} + +void GLESv1Decoder::s_glWeightPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + + STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::WEIGHT_LOCATION); + + ctx->glWeightPointerOES(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::WEIGHT_LOCATION)); +} + +void GLESv1Decoder::s_glMatrixIndexPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + + STORE_POINTER_DATA_OR_ABORT(GLDecoderContextData::MATRIXINDEX_LOCATION); + + ctx->glMatrixIndexPointerOES(size, type, 0, ctx->m_contextData->pointerData(GLDecoderContextData::MATRIXINDEX_LOCATION)); +} + +void GLESv1Decoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset)); +} + +void GLESv1Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)self; + ctx->glDrawElements(mode, count, type, data); +} + +void GLESv1Decoder::s_glGetCompressedTextureFormats(void *self, GLint count, GLint *data) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *) self; + ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, data); +} + +void *GLESv1Decoder::s_getProc(const char *name, void *userData) +{ + GLESv1Decoder *ctx = (GLESv1Decoder *)userData; + + if (ctx == NULL || ctx->m_glesDso == NULL) { + return NULL; + } + + void *func = NULL; +#ifdef USE_EGL_GETPROCADDRESS + func = (void *) eglGetProcAddress(name); +#endif + if (func == NULL) { + func = (void *)(ctx->m_glesDso->findSymbol(name)); + } + return func; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.h new file mode 100644 index 0000000..477a1ae --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/GLESv1Decoder.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GL_DECODER_H_ +#define _GL_DECODER_H_ + +#include "gles1_dec.h" + +#include "GLDecoderContextData.h" +#include "emugl/common/shared_library.h" + +class GLESv1Decoder : public gles1_decoder_context_t +{ +public: + typedef void *(*get_proc_func_t)(const char *name, void *userData); + + GLESv1Decoder(); + ~GLESv1Decoder(); + int initGL(get_proc_func_t getProcFunc, void *getProcFuncData); + void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; } + +private: + static void gles1_APIENTRY s_glGetCompressedTextureFormats(void * self, GLint cont, GLint *data); + static void gles1_APIENTRY s_glVertexPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen); + static void gles1_APIENTRY s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset); + + static void gles1_APIENTRY s_glColorPointerData(void *self, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen); + static void gles1_APIENTRY s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset); + + static void gles1_APIENTRY s_glTexCoordPointerData(void *self, GLint unit, GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen); + static void gles1_APIENTRY s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset); + + static void gles1_APIENTRY s_glNormalPointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen); + static void gles1_APIENTRY s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset); + + static void gles1_APIENTRY s_glPointSizePointerData(void *self, GLenum type, GLsizei stride, void *data, GLuint datalen); + static void gles1_APIENTRY s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset); + + static void gles1_APIENTRY s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset); + static void gles1_APIENTRY s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen); + + static void gles1_APIENTRY s_glWeightPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen); + static void gles1_APIENTRY s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset); + + static void gles1_APIENTRY s_glMatrixIndexPointerData(void * self, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen); + static void gles1_APIENTRY s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset); + + static int gles1_APIENTRY s_glFinishRoundTrip(void *self); + + static void * s_getProc(const char *name, void *userData); + + GLDecoderContextData *m_contextData; + emugl::SharedLibrary* m_glesDso; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.addon b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.addon new file mode 100644 index 0000000..2331f87 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.addon @@ -0,0 +1,15 @@ +GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) + +GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glTexCoordPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) + +GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset); +GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen); + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.attrib b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.attrib new file mode 100644 index 0000000..8889bd7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.attrib @@ -0,0 +1,694 @@ +GLOBAL + base_opcode 1024 + encoder_headers "glUtils.h" "GLEncoderUtils.h" + +#void glClipPlanef(GLenum plane, GLfloat *equation) +glClipPlanef + dir equation in + len equation (4 * sizeof(float)) + +#void glFogfv(GLenum pname, GLfloat *params) +glFogfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetFloatv(GLenum pname, GLfloat *params) +glGetFloatv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetLightfv(GLenum light, GLenum pname, GLfloat *params) +glGetLightfv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +glGetMaterialfv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params) +glGetTexEnvfv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +glGetTexParameterfv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glLightModelfv(GLenum pname, GLfloat *params) +glLightModelfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glLightfv(GLenum light, GLenum pname, GLfloat *params) +glLightfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glLoadMatrixf(GLfloat *m) +glLoadMatrixf + len m (16 * sizeof(GLfloat)) + +#void glMaterialfv(GLenum face, GLenum pname, GLfloat *params) +glMaterialfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glMultMatrixf(GLfloat *m) +glMultMatrixf + len m (16 * sizeof(GLfloat)) + +#void glPointParameterfv(GLenum pname, GLfloat *params) +glPointParameterfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glTexEnvfv(GLenum target, GLenum pname, GLfloat *params) +glTexEnvfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +glTexParameterfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage) +glBufferData + len data size + var_flag data nullAllowed + +#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) +glBufferSubData + dir data in + len data size + var_flag data nullAllowed + +#void glClipPlanex(GLenum plane, GLfixed *eqn) +glClipPlanex + dir eqn in + len eqn (4 * sizeof(GLfixed)) + +#void glColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) +#we treat the pointer as offset to a VBO +glColorPointer + len pointer (sizeof(unsigned int)) + flag unsupported + +#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data) +glCompressedTexImage2D + len data imageSize + var_flag data nullAllowed + +#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data) +glCompressedTexSubImage2D + len data imageSize + var_flag data nullAllowed + +#void glDeleteBuffers(GLsizei n, GLuint *buffers) +glDeleteBuffers + len buffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glDeleteTextures(GLsizei n, GLuint *textures) +glDeleteTextures + len textures (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#this function is marked as unsupported - it shouldn't be called directly +#instead it translated into - glDrawDirectElements and glDrawIndirectElements +#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices) +glDrawElements + flag unsupported + + +#void glFogxv(GLenum pname, GLfixed *params) +glFogxv + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetBooleanv(GLenum pname, GLboolean *params) +glGetBooleanv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLboolean)) + +#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +glGetBufferParameteriv + len params (sizeof(GLint)) + dir params out + +#void glGenBuffers(GLsizei n, GLuint *buffers) +glGenBuffers + len buffers (n * sizeof(GLuint)) + dir buffers out + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenTextures(GLsizei n, GLuint *textures) +glGenTextures + len textures (n * sizeof(GLuint)) + dir textures out + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGetFixedv(GLenum pname, GLfixed *params) +glGetFixedv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetIntegerv(GLenum pname, GLint *params) +glGetIntegerv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glGetLightxv(GLenum light, GLenum pname, GLfixed *params) +glGetLightxv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params) +glGetMaterialxv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetPointerv(GLenum pname, void **params) +glGetPointerv + flag unsupported + +#GLubyte* glGetString(GLenum name) +glGetString + flag unsupported + +#void glGetTexEnviv(GLenum env, GLenum pname, GLint *params) +glGetTexEnviv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params) +glGetTexEnvxv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) +glGetTexParameteriv + dir params out + len params (sizeof(GLint)) + +#void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params) +glGetTexParameterxv + dir params out + len params (sizeof(GLfixed)) + +#void glLightModelxv(GLenum pname, GLfixed *params) +glLightModelxv + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glLightxv(GLenum light, GLenum pname, GLfixed *params) +glLightxv + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glLoadMatrixx(GLfixed *m) +glLoadMatrixx + len m (16 * sizeof(GLfixed)) + +#void glMaterialxv(GLenum face, GLenum pname, GLfixed *params) +glMaterialxv + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glMultMatrixx(GLfixed *m) +glMultMatrixx + len m (16 * sizeof(GLfixed)) + +#void glNormalPointer(GLenum type, GLsizei stride, GLvoid *pointer) +#we treat the pointer as an offset to a VBO +glNormalPointer + len pointer (sizeof(unsigned int)) + flag unsupported + +#void glPointParameterxv(GLenum pname, GLfixed *params) +glPointParameterxv + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +glReadPixels + dir pixels out + len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 1) + +#void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) +glTexCoordPointer + len pointer (sizeof(unsigned int)) + flag unsupported + +#void glTexEnviv(GLenum target, GLenum pname, GLint *params) +glTexEnviv + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glTexEnvxv(GLenum target, GLenum pname, GLfixed *params) +glTexEnvxv + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels) +glTexImage2D + dir pixels in + len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0) + var_flag pixels nullAllowed isLarge + +#void glTexParameteriv(GLenum target, GLenum pname, GLint *params) +glTexParameteriv + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glTexParameterxv(GLenum target, GLenum pname, GLfixed *params) +glTexParameterxv + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +glTexSubImage2D + len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0) + var_flag pixels nullAllowed isLarge + +#void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) +# we treat the pointer as an offset to a VBO +glVertexPointer + flag unsupported + +#void glPointSizePointerOES(GLenum type, GLsizei stride, GLvoid *pointer) +glPointSizePointerOES + len pointer (sizeof(unsigned int)) + flag unsupported + +#void glGetClipPlanef(GLenum pname, GLfloat * eqn) +glGetClipPlanef + dir eqn out + len eqn (4 * sizeof(GLfloat)) + +#void glVertexPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) +glVertexPointerData + len data datalen + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) + flag custom_decoder + flag not_api + +#void glColorPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) +glColorPointerData + len data datalen + flag custom_decoder + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) + flag not_api + +#void glNormalPointerData(GLenum type, GLsizei stride, void *data, GLuint datalen) +glNormalPointerData + len data datalen + flag custom_decoder + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 3, type, stride, datalen) + flag not_api + +#void glPointSizePointerData(GLenum type, GLsizei stride, void *data, GLuint datalen) +glPointSizePointerData + len data datalen + flag custom_decoder + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, 1, type, stride, datalen) + flag not_api + +#void glTexCoordPointerData(GLint size, GLenum type, GLsizei stride, void *data, GLuint datalen) +glTexCoordPointerData + len data datalen + flag custom_decoder + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) + flag not_api + +#void glWeightPointerData(GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +glWeightPointerData + len data datalen + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen) + flag custom_decoder + flag not_api + +#void glMatrixIndexPointerData(GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +glMatrixIndexPointerData + len data datalen + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char*)data, size, type, stride, datalen) + flag custom_decoder + flag not_api + +glVertexPointerOffset + flag custom_decoder + flag not_api +glNormalPointerOffset + flag custom_decoder + flag not_api +glTexCoordPointerOffset + flag custom_decoder + flag not_api +glPointSizePointerOffset + flag custom_decoder + flag not_api +glColorPointerOffset + flag custom_decoder + flag not_api +glWeightPointerOffset + flag custom_decoder + flag not_api +glMatrixIndexPointerOffset + flag custom_decoder + flag not_api + +glDrawElementsData + len data datalen + flag custom_decoder + flag not_api + +glDrawElementsOffset + flag custom_decoder + flag not_api + +glGetCompressedTextureFormats + dir formats out + len formats (count * sizeof(GLint)) + flag custom_decoder + flag not_api + +glFinishRoundTrip + flag custom_decoder + flag not_api + +#gles1 extensions + +#void glDrawTexsvOES(GLshort *coords) +glDrawTexsvOES + len coords (5 * sizeof(GLshort)) + +#void glDrawTexivOES(GLint *coords) +glDrawTexivOES + len coords (5 * sizeof(GLint)) + +#void glDrawTexxvOES(GLfixed *coords) +glDrawTexxvOES + len coords (5 * sizeof(GLfixed)) + +#void glDrawTexfvOES(GLfloat *coords) +glDrawTexfvOES + len coords (5 * sizeof(GLfloat)) + +#glClipPlanexOES(GLenum plane, const GLfixed * equation) +glClipPlanexOES + dir equation in + len equation (4 * sizeof(GLfixed)) + +#glClipPlanexIMG(GLenum plane, const GLfixed * equation) +glClipPlanexIMG + dir equation in + len equation (4 * sizeof(GLfixed)) + +#void glFogxvOES(GLenum pname, GLfixed *params) +glFogxvOES + dir params in + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetClipPlanexOES(GLenum pname, GLfixed * eqn) +glGetClipPlanexOES + dir eqn out + len eqn (4 * sizeof(GLfixed)) + +#void glGetClipPlanex(GLenum pname, GLfixed * eqn) +glGetClipPlanex + dir eqn out + len eqn (4 * sizeof(GLfixed)) + +#void glGetFixedvOES(GLenum pname, GLfixed *params) +glGetFixedvOES + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetLightxvOES(GLenum light, GLenum pname, GLfixed *params) +glGetLightxvOES + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetMaterialxvOES(GLenum face, GLenum pname, GLfixed *params) +glGetMaterialxvOES + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetTexEnvxvOES(GLenum env, GLenum pname, GLfixed *params) +glGetTexEnvxvOES + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params) +glGetTexParameterxvOES + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glLightModelxvOES(GLenum pname, GLfixed *params) +glLightModelxvOES + dir params in + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glLightxvOES(GLenum light, GLenum pname, GLfixed *params) +glLightxvOES + dir params in + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glLoadMatrixxOES(GLfixed *m) +glLoadMatrixxOES + dir m in + len m (16 * sizeof(GLfixed)) + +#void glMaterialxvOES(GLenum face, GLenum pname, GLfixed *params) +glMaterialxvOES + dir params in + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glMultMatrixxOES(GLfixed *m) +glMultMatrixxOES + dir m in + len m (16 * sizeof(GLfixed)) + +#void glPointParameterxvOES(GLenum pname, GLfixed *params) +glPointParameterxvOES + dir params in + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glTexEnvxvOES(GLenum target, GLenum pname, GLfixed *params) +glTexEnvxvOES + dir params in + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glTexParameterxvOES(GLenum target, GLenum pname, GLfixed *params) +glTexParameterxvOES + dir params in + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glDeleteRenderbuffersOES(GLsizei n, GLuint *renderbuffers) +glDeleteRenderbuffersOES + dir renderbuffers in + len renderbuffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenRenderbuffersOES(GLsizei n, GLuint *renderbuffers) +glGenRenderbuffersOES + dir renderbuffers out + len renderbuffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint *params) +glGetRenderbufferParameterivOES + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glDeleteFramebuffersOES(GLsizei n, GLuint *framebuffers) +glDeleteFramebuffersOES + dir framebuffers in + len framebuffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenFramebuffersOES(GLsizei n, GLuint *framebuffers) +glGenFramebuffersOES + dir framebuffers out + len framebuffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params) +glGetFramebufferAttachmentParameterivOES + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void* glMapBufferOES(GLenum target, GLenum access) +glMapBufferOES + flag unsupported + +#void glGetBufferPointervOES(GLenum target, GLenum pname, GLvoid ** params) +glGetBufferPointervOES + flag unsupported + +#void glMatrixIndexPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) +glMatrixIndexPointerOES + len pointer (sizeof(unsigned int)) + flag unsupported + +#void glWeightPointerOES(GLint size, GLenum type, GLsizei stride, GLvoid *pointer) +glWeightPointerOES + len pointer (sizeof(unsigned int)) + flag unsupported + +#glQueryMatrixxOES(GLfixed * mantissa, GLint * exponent) +glQueryMatrixxOES + dir mantissa out + len mantissa (16 * sizeof(GLfixed)) + dir exponent out + len exponent (16 * sizeof(GLfixed)) + +#void glClipPlanefOES(GLenum plane, GLfloat *equation) +glClipPlanefOES + dir equation in + len equation (4 * sizeof(GLfloat)) + +#void glClipPlanefIMG(GLenum plane, GLfloat *equation) +glClipPlanefIMG + dir equation in + len equation (4 * sizeof(GLfloat)) + +#void glGetClipPlanefOES(GLenum pname, GLfloat * eqn) +glGetClipPlanefOES + dir eqn out + len eqn (4 * sizeof(GLfloat)) + +#void glTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params) +glTexGenfvOES + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glTexGenivOES(GLenum coord, GLenum pname, GLint *params) +glTexGenivOES + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params) +glTexGenxvOES + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glGetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params) +glGetTexGenfvOES + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetTexGenivOES(GLenum coord, GLenum pname, GLint *params) +glGetTexGenivOES + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glGetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params) +glGetTexGenxvOES + len params (glUtilsParamSize(pname) * sizeof(GLfixed)) + +#void glDeleteVertexArraysOES(GLsizei n, const GLuint *arrays) +glDeleteVertexArraysOES + dir arrays in + len arrays (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenVertexArraysOES(GLsizei n, GLuint *arrays) +glGenVertexArraysOES + dir arrays out + len arrays (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments) +glDiscardFramebufferEXT + dir attachments in + len attachments (numAttachments * sizeof(const GLenum)) + +#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) +glMultiDrawArraysEXT + flag unsupported + +#void glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount) +glMultiDrawElementsEXT + flag unsupported + +#void glMultiDrawArraysSUN(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) +glMultiDrawArraysSUN + flag unsupported + +#void glMultiDrawElementsSUN(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount) +glMultiDrawElementsSUN + flag unsupported + +#void glDeleteFencesNV(GLsizei n, const GLuint *fences) +glDeleteFencesNV + dir fences in + len fences (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenFencesNV(GLsizei n, GLuint *fences) +glGenFencesNV + dir fences in + len fences (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) +glGetFenceivNV + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls) +glGetDriverControlsQCOM + dir num out + len num (1 * sizeof(GLint)) + dir driverControls out + len driverControls (size * sizeof(GLuint)) + +#void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) +glGetDriverControlStringQCOM + dir length out + len length (1 * sizeof(GLsizei)) + dir driverControlString out + len driverControlString (1 * sizeof(GLchar)) + +#void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures) +glExtGetTexturesQCOM + dir textures out + len textures (maxTextures * sizeof(GLuint)) + dir numTextures out + len numTextures (1 * sizeof(GLint)) + +#void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) +glExtGetBuffersQCOM + dir buffers out + len buffers (maxBuffers * sizeof(GLuint)) + dir numBuffers out + len numBuffers (1 * sizeof(GLint)) + +#void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) +glExtGetRenderbuffersQCOM + dir renderbuffers out + len renderbuffers (maxRenderbuffers * sizeof(GLuint)) + dir numRenderbuffers out + len numRenderbuffers (1 * sizeof(GLint)) + +#void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) +glExtGetFramebuffersQCOM + dir framebuffers out + len framebuffers (maxFramebuffers * sizeof(GLuint)) + dir numFramebuffers out + len numFramebuffers (1 * sizeof(GLint)) + +#void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) +glExtGetTexLevelParameterivQCOM + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) +glExtGetTexSubImageQCOM + dir texels out + len texels (depth * glesv1_enc::pixelDataSize(self, width, height, format, type, 0)) + +#void glExtGetBufferPointervQCOM(GLenum target, GLvoid **params) +glExtGetBufferPointervQCOM + flag unsupported + +#void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders) +glExtGetShadersQCOM + dir shaders out + len shaders (maxShaders * sizeof(GLuint)) + dir numShaders out + len numShaders (1 * sizeof(GLint)) + +#void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms) +glExtGetProgramsQCOM + dir programs out + len programs (maxPrograms * sizeof(GLuint)) + dir numPrograms out + len numPrograms (1 * sizeof(GLint)) + +#void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length) +glExtGetProgramBinarySourceQCOM + flag unsupported diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.in b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.in new file mode 100644 index 0000000..74d5454 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.in @@ -0,0 +1,298 @@ +GL_ENTRY(void, glAlphaFunc, GLenum func, GLclampf ref) +GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +GL_ENTRY(void, glClearDepthf, GLclampf depth) +GL_ENTRY(void, glClipPlanef, GLenum plane, const GLfloat *equation) +GL_ENTRY(void, glColor4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar) +GL_ENTRY(void, glFogf, GLenum pname, GLfloat param) +GL_ENTRY(void, glFogfv, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glFrustumf, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +GL_ENTRY(void, glGetClipPlanef, GLenum pname, GLfloat* eqn) +GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat *params) +GL_ENTRY(void, glGetLightfv, GLenum light, GLenum pname, GLfloat *params) +GL_ENTRY(void, glGetMaterialfv, GLenum face, GLenum pname, GLfloat *params) +GL_ENTRY(void, glGetTexEnvfv, GLenum env, GLenum pname, GLfloat *params) +GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat *params) +GL_ENTRY(void, glLightModelf, GLenum pname, GLfloat param) +GL_ENTRY(void, glLightModelfv, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glLightf, GLenum light, GLenum pname, GLfloat param) +GL_ENTRY(void, glLightfv, GLenum light, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glLineWidth, GLfloat width) +GL_ENTRY(void, glLoadMatrixf, const GLfloat *m) +GL_ENTRY(void, glMaterialf, GLenum face, GLenum pname, GLfloat param) +GL_ENTRY(void, glMaterialfv, GLenum face, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glMultMatrixf, const GLfloat *m) +GL_ENTRY(void, glMultiTexCoord4f, GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +GL_ENTRY(void, glNormal3f, GLfloat nx, GLfloat ny, GLfloat nz) +GL_ENTRY(void, glOrthof, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +GL_ENTRY(void, glPointParameterf, GLenum pname, GLfloat param) +GL_ENTRY(void, glPointParameterfv, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glPointSize, GLfloat size) +GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units) +GL_ENTRY(void, glRotatef, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +GL_ENTRY(void, glScalef, GLfloat x, GLfloat y, GLfloat z) +GL_ENTRY(void, glTexEnvf, GLenum target, GLenum pname, GLfloat param) +GL_ENTRY(void, glTexEnvfv, GLenum target, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param) +GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glTranslatef, GLfloat x, GLfloat y, GLfloat z) +GL_ENTRY(void, glActiveTexture, GLenum texture) +GL_ENTRY(void, glAlphaFuncx, GLenum func, GLclampx ref) +GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer) +GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture) +GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor) +GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) +GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) +GL_ENTRY(void, glClear, GLbitfield mask) +GL_ENTRY(void, glClearColorx, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +GL_ENTRY(void, glClearDepthx, GLclampx depth) +GL_ENTRY(void, glClearStencil, GLint s) +GL_ENTRY(void, glClientActiveTexture, GLenum texture) +GL_ENTRY(void, glColor4ub, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +GL_ENTRY(void, glColor4x, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +GL_ENTRY(void, glColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) +GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) +GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +GL_ENTRY(void, glCullFace, GLenum mode) +GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint *buffers) +GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint *textures) +GL_ENTRY(void, glDepthFunc, GLenum func) +GL_ENTRY(void, glDepthMask, GLboolean flag) +GL_ENTRY(void, glDepthRangex, GLclampx zNear, GLclampx zFar) +GL_ENTRY(void, glDisable, GLenum cap) +GL_ENTRY(void, glDisableClientState, GLenum array) +GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count) +GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +GL_ENTRY(void, glEnable, GLenum cap) +GL_ENTRY(void, glEnableClientState, GLenum array) +GL_ENTRY(void, glFinish, void) +GL_ENTRY(void, glFlush, void) +GL_ENTRY(void, glFogx, GLenum pname, GLfixed param) +GL_ENTRY(void, glFogxv, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glFrontFace, GLenum mode) +GL_ENTRY(void, glFrustumx, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean *params) +GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint *params) +GL_ENTRY(void, glClipPlanex, GLenum pname, const GLfixed * eqn) +GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint *buffers) +GL_ENTRY(void, glGenTextures, GLsizei n, GLuint *textures) +GL_ENTRY(GLenum, glGetError, void) +GL_ENTRY(void, glGetFixedv, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint *params) +GL_ENTRY(void, glGetLightxv, GLenum light, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetMaterialxv, GLenum face, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetPointerv, GLenum pname, GLvoid **params) +GL_ENTRY(const GLubyte *, glGetString, GLenum name) +GL_ENTRY(void, glGetTexEnviv, GLenum env, GLenum pname, GLint *params) +GL_ENTRY(void, glGetTexEnvxv, GLenum env, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint *params) +GL_ENTRY(void, glGetTexParameterxv, GLenum target, GLenum pname, GLfixed *params) +GL_ENTRY(void, glHint, GLenum target, GLenum mode) +GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer) +GL_ENTRY(GLboolean, glIsEnabled, GLenum cap) +GL_ENTRY(GLboolean, glIsTexture, GLuint texture) +GL_ENTRY(void, glLightModelx, GLenum pname, GLfixed param) +GL_ENTRY(void, glLightModelxv, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glLightx, GLenum light, GLenum pname, GLfixed param) +GL_ENTRY(void, glLightxv, GLenum light, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glLineWidthx, GLfixed width) +GL_ENTRY(void, glLoadIdentity, void) +GL_ENTRY(void, glLoadMatrixx, const GLfixed *m) +GL_ENTRY(void, glLogicOp, GLenum opcode) +GL_ENTRY(void, glMaterialx, GLenum face, GLenum pname, GLfixed param) +GL_ENTRY(void, glMaterialxv, GLenum face, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glMatrixMode, GLenum mode) +GL_ENTRY(void, glMultMatrixx, const GLfixed *m) +GL_ENTRY(void, glMultiTexCoord4x, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +GL_ENTRY(void, glNormal3x, GLfixed nx, GLfixed ny, GLfixed nz) +GL_ENTRY(void, glNormalPointer, GLenum type, GLsizei stride, const GLvoid *pointer) +GL_ENTRY(void, glOrthox, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param) +GL_ENTRY(void, glPointParameterx, GLenum pname, GLfixed param) +GL_ENTRY(void, glPointParameterxv, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glPointSizex, GLfixed size) +GL_ENTRY(void, glPolygonOffsetx, GLfixed factor, GLfixed units) +GL_ENTRY(void, glPopMatrix, void) +GL_ENTRY(void, glPushMatrix, void) +GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +GL_ENTRY(void, glRotatex, GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert) +GL_ENTRY(void, glSampleCoveragex, GLclampx value, GLboolean invert) +GL_ENTRY(void, glScalex, GLfixed x, GLfixed y, GLfixed z) +GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height) +GL_ENTRY(void, glShadeModel, GLenum mode) +GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask) +GL_ENTRY(void, glStencilMask, GLuint mask) +GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass) +GL_ENTRY(void, glTexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +GL_ENTRY(void, glTexEnvi, GLenum target, GLenum pname, GLint param) +GL_ENTRY(void, glTexEnvx, GLenum target, GLenum pname, GLfixed param) +GL_ENTRY(void, glTexEnviv, GLenum target, GLenum pname, const GLint *params) +GL_ENTRY(void, glTexEnvxv, GLenum target, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param) +GL_ENTRY(void, glTexParameterx, GLenum target, GLenum pname, GLfixed param) +GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint *params) +GL_ENTRY(void, glTexParameterxv, GLenum target, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +GL_ENTRY(void, glTranslatex, GLfixed x, GLfixed y, GLfixed z) +GL_ENTRY(void, glVertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height) +GL_ENTRY(void, glPointSizePointerOES, GLenum type, GLsizei stride, const GLvoid *pointer) + +GL_ENTRY(void, glVertexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glColorPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glNormalPointerOffset, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glPointSizePointerOffset, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glTexCoordPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glWeightPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) +GL_ENTRY(void, glMatrixIndexPointerOffset, GLint size, GLenum type, GLsizei stride, GLuint offset) + +GL_ENTRY(void, glVertexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glColorPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glNormalPointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glTexCoordPointerData, GLint unit, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glPointSizePointerData, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glWeightPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glMatrixIndexPointerData, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen) + +GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset) +GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen) +GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats); + +GL_ENTRY(int, glFinishRoundTrip, void) + +#opengl extensions + +GL_ENTRY(void, glBlendEquationSeparateOES, GLenum modeRGB, GLenum modeAlpha) +GL_ENTRY(void, glBlendFuncSeparateOES, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +GL_ENTRY(void, glBlendEquationOES, GLenum mode) +GL_ENTRY(void, glDrawTexsOES, GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +GL_ENTRY(void, glDrawTexiOES, GLint x, GLint y, GLint z, GLint width, GLint height) +GL_ENTRY(void, glDrawTexxOES, GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +GL_ENTRY(void, glDrawTexsvOES, const GLshort *coords) +GL_ENTRY(void, glDrawTexivOES, const GLint *coords) +GL_ENTRY(void, glDrawTexxvOES, const GLfixed *coords) +GL_ENTRY(void, glDrawTexfOES, GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +GL_ENTRY(void, glDrawTexfvOES, const GLfloat *coords) +GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image) +GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image) +GL_ENTRY(void, glAlphaFuncxOES, GLenum func, GLclampx ref) +GL_ENTRY(void, glClearColorxOES, GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +GL_ENTRY(void, glClearDepthxOES, GLclampx depth) +GL_ENTRY(void, glClipPlanexOES, GLenum plane, const GLfixed * equation) +GL_ENTRY(void, glClipPlanexIMG, GLenum plane, const GLfixed * equation) +GL_ENTRY(void, glColor4xOES, GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +GL_ENTRY(void, glDepthRangexOES, GLclampx zNear, GLclampx zFar) +GL_ENTRY(void, glFogxOES, GLenum pname, GLfixed param) +GL_ENTRY(void, glFogxvOES, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glFrustumxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +GL_ENTRY(void, glGetClipPlanexOES, GLenum pname, GLfixed* eqn) +GL_ENTRY(void, glGetClipPlanex, GLenum pname, GLfixed* eqn) +GL_ENTRY(void, glGetFixedvOES, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetLightxvOES, GLenum light, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetMaterialxvOES, GLenum face, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetTexEnvxvOES, GLenum env, GLenum pname, GLfixed *params) +GL_ENTRY(void, glGetTexParameterxvOES, GLenum target, GLenum pname, GLfixed *params) +GL_ENTRY(void, glLightModelxOES, GLenum pname, GLfixed param) +GL_ENTRY(void, glLightModelxvOES, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glLightxOES, GLenum light, GLenum pname, GLfixed param) +GL_ENTRY(void, glLightxvOES, GLenum light, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glLineWidthxOES, GLfixed width) +GL_ENTRY(void, glLoadMatrixxOES, const GLfixed *m) +GL_ENTRY(void, glMaterialxOES, GLenum face, GLenum pname, GLfixed param) +GL_ENTRY(void, glMaterialxvOES, GLenum face, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glMultMatrixxOES, const GLfixed *m) +GL_ENTRY(void, glMultiTexCoord4xOES, GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +GL_ENTRY(void, glNormal3xOES, GLfixed nx, GLfixed ny, GLfixed nz) +GL_ENTRY(void, glOrthoxOES, GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +GL_ENTRY(void, glPointParameterxOES, GLenum pname, GLfixed param) +GL_ENTRY(void, glPointParameterxvOES, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glPointSizexOES, GLfixed size) +GL_ENTRY(void, glPolygonOffsetxOES, GLfixed factor, GLfixed units) +GL_ENTRY(void, glRotatexOES, GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +GL_ENTRY(void, glSampleCoveragexOES, GLclampx value, GLboolean invert) +GL_ENTRY(void, glScalexOES, GLfixed x, GLfixed y, GLfixed z) +GL_ENTRY(void, glTexEnvxOES, GLenum target, GLenum pname, GLfixed param) +GL_ENTRY(void, glTexEnvxvOES, GLenum target, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glTexParameterxOES, GLenum target, GLenum pname, GLfixed param) +GL_ENTRY(void, glTexParameterxvOES, GLenum target, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glTranslatexOES, GLfixed x, GLfixed y, GLfixed z) +GL_ENTRY(GLboolean, glIsRenderbufferOES, GLuint renderbuffer) +GL_ENTRY(void, glBindRenderbufferOES, GLenum target, GLuint renderbuffer) +GL_ENTRY(void, glDeleteRenderbuffersOES, GLsizei n, const GLuint* renderbuffers) +GL_ENTRY(void, glGenRenderbuffersOES, GLsizei n, GLuint* renderbuffers) +GL_ENTRY(void, glRenderbufferStorageOES, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +GL_ENTRY(void, glGetRenderbufferParameterivOES, GLenum target, GLenum pname, GLint* params) +GL_ENTRY(GLboolean, glIsFramebufferOES, GLuint framebuffer) +GL_ENTRY(void, glBindFramebufferOES, GLenum target, GLuint framebuffer) +GL_ENTRY(void, glDeleteFramebuffersOES, GLsizei n, const GLuint* framebuffers) +GL_ENTRY(void, glGenFramebuffersOES, GLsizei n, GLuint* framebuffers) +GL_ENTRY(GLenum, glCheckFramebufferStatusOES, GLenum target) +GL_ENTRY(void, glFramebufferRenderbufferOES, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +GL_ENTRY(void, glFramebufferTexture2DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +GL_ENTRY(void, glGetFramebufferAttachmentParameterivOES, GLenum target, GLenum attachment, GLenum pname, GLint* params) +GL_ENTRY(void, glGenerateMipmapOES, GLenum target) +GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access) +GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target) +GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid* *params) +GL_ENTRY(void, glCurrentPaletteMatrixOES, GLuint matrixpaletteindex) +GL_ENTRY(void, glLoadPaletteFromModelViewMatrixOES, void) +GL_ENTRY(void, glMatrixIndexPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) +GL_ENTRY(void, glWeightPointerOES, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer) +GL_ENTRY(GLbitfield, glQueryMatrixxOES, GLfixed * mantissa, GLint * exponent) +GL_ENTRY(void, glDepthRangefOES, GLclampf zNear, GLclampf zFar) +GL_ENTRY(void, glFrustumfOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +GL_ENTRY(void, glOrthofOES, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +GL_ENTRY(void, glClipPlanefOES, GLenum plane, const GLfloat *equation) +GL_ENTRY(void, glClipPlanefIMG, GLenum plane, const GLfloat *equation) +GL_ENTRY(void, glGetClipPlanefOES, GLenum pname, GLfloat * eqn) +GL_ENTRY(void, glClearDepthfOES, GLclampf depth) +GL_ENTRY(void, glTexGenfOES, GLenum coord, GLenum pname, GLfloat param) +GL_ENTRY(void, glTexGenfvOES, GLenum coord, GLenum pname, const GLfloat *params) +GL_ENTRY(void, glTexGeniOES, GLenum coord, GLenum pname, GLint param) +GL_ENTRY(void, glTexGenivOES, GLenum coord, GLenum pname, const GLint *params) +GL_ENTRY(void, glTexGenxOES, GLenum coord, GLenum pname, GLfixed param) +GL_ENTRY(void, glTexGenxvOES, GLenum coord, GLenum pname, const GLfixed *params) +GL_ENTRY(void, glGetTexGenfvOES, GLenum coord, GLenum pname, GLfloat *params) +GL_ENTRY(void, glGetTexGenivOES, GLenum coord, GLenum pname, GLint *params) +GL_ENTRY(void, glGetTexGenxvOES, GLenum coord, GLenum pname, GLfixed *params) +GL_ENTRY(void, glBindVertexArrayOES, GLuint array) +GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays) +GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays) +GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array) +GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments) +GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) +GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const *indices, GLsizei primcount) +GL_ENTRY(void, glMultiDrawArraysSUN, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount) +GL_ENTRY(void, glMultiDrawElementsSUN, GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount) +GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences) +GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences) +GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence) +GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence) +GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params) +GL_ENTRY(void, glFinishFenceNV, GLuint fence) +GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition) +GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls) +GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) +GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl) +GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl) +GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures) +GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers) +GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint * renderbuffers, GLint maxRenderbuffers, GLint * numRenderbuffers) +GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) +GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) +GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param) +GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) +GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoid* *params) +GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders) +GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms) +GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program) +GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length) +GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) +GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.types b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.types new file mode 100644 index 0000000..2d9a3b0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1.types @@ -0,0 +1,34 @@ +GLbitfield 32 0x%08x +GLboolean 8 %d +GLclampf 32 %f +GLclampx 32 0x%08x +GLeglImageOES 32 %p +GLenum 32 0x%08x +GLfixed 32 0x%08x +GLfloat 32 %f +GLint 32 %d +GLintptr 32 %p +GLshort 16 %d +GLsizei 32 %d +GLsizeiptr 32 %p +GLubyte 8 0x%02x +GLuint 32 %u +GLvoid 0 %x +GLchar 8 %d +GLenum* 32 0x%08x +GLboolean* 32 0x%08x +GLclampf* 32 0x%08x +GLclampx* 32 0x%08x +GLeglImageOES* 32 0x%08x +GLfixed* 32 0x%08x +GLfloat* 32 0x%08x +GLint* 32 0x%08x +GLshort* 32 0x%08x +GLsizei* 32 0x%08x +GLubyte* 32 0x%08x +GLuint* 32 0x%08x +GLvoid* 32 0x%08x +GLchar* 32 0x%08x +GLvoid** 32 0x%08x +void* 32 0x%08x +GLvoid*const* 32 0x%08x diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1_types.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1_types.h new file mode 100644 index 0000000..c8355ad --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv1_dec/gles1_types.h @@ -0,0 +1,21 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __GLES1_TYPES__H +#define __GLES1_TYPES__H + +#include "gl_base_types.h" + +#endif // __GLES1_TYPES__H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/CMakeLists.txt new file mode 100644 index 0000000..b61ef75 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/CMakeLists.txt @@ -0,0 +1,26 @@ +set(CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/GLESv2_dec) + +PREPEND(GENERATED_SOURCES ${CURRENT_BINARY_DIR}/ + gles2_dec.cpp + gles2_opcodes.h + gles2_server_context.cpp) + +add_custom_command( + OUTPUT ${GENERATED_SOURCES} + POST_BUILD + COMMAND mkdir -p ${CURRENT_BINARY_DIR} && ${CMAKE_BINARY_DIR}/external/android-emugl/host/tools/emugen/emugen + -D ${CURRENT_BINARY_DIR} gles2 + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + DEPENDS emugen) + +PREPEND(SOURCES ${CMAKE_CURRENT_LIST_DIR}/ + GLESv2Decoder.cpp) + +if ("${cmake_build_type_lower}" STREQUAL "trace") + set(OPENGL_DEBUG "-DOPENGL_DEBUG_PRINTOUT -DCHECK_GL_ERROR") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENGL_DEBUG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENGL_DEBUG}") +endif() + +add_library(GLESv2_dec STATIC ${SOURCES} ${GENERATED_SOURCES} ${GLHEADERS_GENERATED_SOURCES}) +target_link_libraries(GLESv2_dec OpenglCodecCommon) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.cpp new file mode 100644 index 0000000..f8fc907 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.cpp @@ -0,0 +1,129 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "GLESv2Decoder.h" + +#include +#include +#include + +static inline void* SafePointerFromUInt(GLuint value) { + return (void*)(uintptr_t)value; +} + +GLESv2Decoder::GLESv2Decoder() +{ + m_contextData = NULL; + m_GL2library = NULL; +} + +GLESv2Decoder::~GLESv2Decoder() +{ + delete m_GL2library; +} + +void *GLESv2Decoder::s_getProc(const char *name, void *userData) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *) userData; + + if (ctx == NULL || ctx->m_GL2library == NULL) { + return NULL; + } + + void *func = NULL; +#ifdef USE_EGL_GETPROCADDRESS + func = (void *) eglGetProcAddress(name); +#endif + if (func == NULL) { + func = (void *) ctx->m_GL2library->findSymbol(name); + } + return func; +} + +int GLESv2Decoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData) +{ + this->initDispatchByName(getProcFunc, getProcFuncData); + + glGetCompressedTextureFormats = s_glGetCompressedTextureFormats; + glVertexAttribPointerData = s_glVertexAttribPointerData; + glVertexAttribPointerOffset = s_glVertexAttribPointerOffset; + + glDrawElementsOffset = s_glDrawElementsOffset; + glDrawElementsData = s_glDrawElementsData; + glShaderString = s_glShaderString; + glFinishRoundTrip = s_glFinishRoundTrip; + return 0; + +} + +int GLESv2Decoder::s_glFinishRoundTrip(void *self) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *)self; + ctx->glFinish(); + return 0; +} + +void GLESv2Decoder::s_glGetCompressedTextureFormats(void *self, int count, GLint *formats) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *) self; + + int nFormats; + ctx->glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nFormats); + if (nFormats > count) { + fprintf(stderr, "%s: GetCompressedTextureFormats: The requested number of formats does not match the number that is reported by OpenGL\n", __FUNCTION__); + } else { + ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats); + } +} + +void GLESv2Decoder::s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, void * data, GLuint datalen) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *) self; + if (ctx->m_contextData != NULL) { + ctx->m_contextData->storePointerData(indx, data, datalen); + // note - the stride of the data is always zero when it comes out of the codec. + // See gl2.attrib for the packing function call. + ctx->glVertexAttribPointer(indx, size, type, normalized, 0, ctx->m_contextData->pointerData(indx)); + } +} + +void GLESv2Decoder::s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, GLuint data) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *) self; + ctx->glVertexAttribPointer(indx, size, type, normalized, stride, SafePointerFromUInt(data)); +} + + +void GLESv2Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *)self; + ctx->glDrawElements(mode, count, type, data); +} + + +void GLESv2Decoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *)self; + ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset)); +} + +void GLESv2Decoder::s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len) +{ + GLESv2Decoder *ctx = (GLESv2Decoder *)self; + ctx->glShaderSource(shader, 1, &string, NULL); +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.h new file mode 100644 index 0000000..8d6f4af --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/GLESv2Decoder.h @@ -0,0 +1,48 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef _GL2_DECODER_H_ +#define _GL2_DECODER_H_ + +#include "gles2_dec.h" +#include "GLDecoderContextData.h" +#include "emugl/common/shared_library.h" + +class GLESv2Decoder : public gles2_decoder_context_t +{ +public: + typedef void *(*get_proc_func_t)(const char *name, void *userData); + GLESv2Decoder(); + ~GLESv2Decoder(); + int initGL(get_proc_func_t getProcFunc, void *getProcFuncData); + void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; } +private: + GLDecoderContextData *m_contextData; + emugl::SharedLibrary* m_GL2library; + + static void *s_getProc(const char *name, void *userData); + static void gles2_APIENTRY s_glGetCompressedTextureFormats(void *self, int count, GLint *formats); + static void gles2_APIENTRY s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, void * data, GLuint datalen); + static void gles2_APIENTRY s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type, + GLboolean normalized, GLsizei stride, GLuint offset); + + static void gles2_APIENTRY s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset); + static void gles2_APIENTRY s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen); + static void gles2_APIENTRY s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len); + static int gles2_APIENTRY s_glFinishRoundTrip(void *self); +}; +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.attrib b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.attrib new file mode 100644 index 0000000..d84a8b6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.attrib @@ -0,0 +1,595 @@ +GLOBAL + base_opcode 2048 + encoder_headers "glUtils.h" "GL2EncoderUtils.h" + +#void glBindAttribLocation(GLuint program, GLuint index, GLchar *name) +glBindAttribLocation + len name (strlen(name) + 1) + +#void glBufferData(GLenum target, GLsizeiptr size, GLvoid *data, GLenum usage) +glBufferData + len data size + var_flag data nullAllowed isLarge + +#void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) +glBufferSubData + len data size + var_flag data nullAllowed isLarge + +#void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid *data) +glCompressedTexImage2D + len data imageSize + var_flag data nullAllowed isLarge + +#void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid *data) +glCompressedTexSubImage2D + len data imageSize + var_flag data nullAllowed isLarge + +#void glDeleteBuffers(GLsizei n, GLuint *buffers) +glDeleteBuffers + len buffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glDeleteFramebuffers(GLsizei n, GLuint *framebuffers) +glDeleteFramebuffers + len framebuffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers) +glDeleteRenderbuffers + len renderbuffers (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glDeleteTextures(GLsizei n, GLuint *textures) +glDeleteTextures + len textures (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glDrawElements(GLenum mode, GLsizei count, GLenum type, GLvoid *indices) +glDrawElements + flag unsupported + +#void glGenBuffers(GLsizei n, GLuint *buffers) +glGenBuffers + len buffers (n * sizeof(GLuint)) + dir buffers out + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenFramebuffers(GLsizei n, GLuint *framebuffers) +glGenFramebuffers + len framebuffers (n * sizeof(GLuint)) + dir framebuffers out + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers) +glGenRenderbuffers + len renderbuffers (n * sizeof(GLuint)) + dir renderbuffers out + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenTextures(GLsizei n, GLuint *textures) +glGenTextures + len textures (n * sizeof(GLuint)) + dir textures out + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) +glGetActiveAttrib + len name bufsize + dir name out + var_flag name nullAllowed + dir length out + len length (sizeof(GLsizei)) + var_flag length nullAllowed + dir size out + len size (sizeof(GLint)) + var_flag size nullAllowed + dir type out + len type (sizeof(GLenum)) + var_flag type nullAllowed + +#void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) +glGetActiveUniform + len name bufsize + dir name out + var_flag name nullAllowed + dir length out + len length (sizeof(GLsizei)) + var_flag length nullAllowed + dir size out + len size (sizeof(GLint)) + var_flag size nullAllowed + dir type out + len type (sizeof(GLenum)) + var_flag type nullAllowed + + +#void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei *count, GLuint *shaders) +glGetAttachedShaders + len shaders (maxcount*sizeof(GLuint)) + dir shaders out + dir count out + var_flag count nullAllowed + len count (sizeof(GLsizei)) + +#int glGetAttribLocation(GLuint program, GLchar *name) +glGetAttribLocation + len name (strlen(name) + 1) + +#void glGetBooleanv(GLenum pname, GLboolean *params) +glGetBooleanv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLboolean)) + +#void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +glGetBufferParameteriv + len params (sizeof(GLint)) + dir params out + +#void glGetFloatv(GLenum pname, GLfloat *params) +glGetFloatv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params) +glGetFramebufferAttachmentParameteriv + dir params out + len params (sizeof(GLint)) + +#void glGetIntegerv(GLenum pname, GLint *params) +glGetIntegerv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glGetProgramiv(GLuint program, GLenum pname, GLint *params) +glGetProgramiv + dir params out + len params sizeof(GLint) +#XXX - might change if extension constants that return more then one value + + +#void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) +glGetProgramInfoLog + dir infolog out + len infolog bufsize + dir length out + len length sizeof(GLsizei) + var_flag length nullAllowed + +#void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) +glGetRenderbufferParameteriv + dir params out + len params sizeof(GLint) +# XXX - might change if pname with value larger then one is added + +#void glGetShaderiv(GLuint shader, GLenum pname, GLint *params) +glGetShaderiv + dir params out + len params sizeof(GLint) +# XXX - might change if pname with value larger then one is added + +#void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *infolog) +glGetShaderInfoLog + dir length out + len length (sizeof(GLsizei)) + var_flag length nullAllowed + dir infolog out + len infolog bufsize + + +#void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision) +glGetShaderPrecisionFormat + dir range out + len range (2 * sizeof(GLint)) + dir precision out + len precision (sizeof(GLint)) + +#void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source) +glGetShaderSource + dir length out + len length (sizeof(GLsizei)) + var_flag length nullAllowed + dir source out + len source bufsize + +#GLubyte* glGetString(GLenum name) +glGetString + flag unsupported + +#void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +glGetTexParameterfv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) +glGetTexParameteriv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glGetUniformfv(GLuint program, GLint location, GLfloat *params) +glGetUniformfv + dir params out + len params glSizeof(glesv2_enc::uniformType(self, program, location)) + +#void glGetUniformiv(GLuint program, GLint location, GLint *params) +glGetUniformiv + dir params out + len params glSizeof(glesv2_enc::uniformType(self, program, location)) + +#int glGetUniformLocation(GLuint program, GLchar *name) +glGetUniformLocation + len name (strlen(name) + 1) + +# client-state shall be handled locally by the encoder in most cases. +# however, GL_CURRENT_VERTEX_ATTRIB and potential others are handled by the server side, +# thus we still need to implement it. +#void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) +glGetVertexAttribfv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) + +#see glGetVertexAttribfv for comments +#void glGetVertexAttribiv(GLuint index, GLenum pname, GLint *params) +glGetVertexAttribiv + dir params out + len params (glUtilsParamSize(pname) * sizeof(GLint)) + + + +#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +glReadPixels + dir pixels out + len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 1) + +#void glShaderBinary(GLsizei n, GLuint *shaders, GLenum binaryformat, GLvoid *binary, GLsizei length) +glShaderBinary + flag unsupported + +#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels) +glTexImage2D + dir pixels in + len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0) + var_flag pixels nullAllowed isLarge + +#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +glTexParameterfv + len params (glUtilsParamSize(pname) * sizeof(GLfloat)) +#void glTexParameteriv(GLenum target, GLenum pname, GLint *params) +glTexParameteriv + len params (glUtilsParamSize(pname) * sizeof(GLint)) + +#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +glTexSubImage2D + len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0) + var_flag pixels nullAllowed isLarge + +#void glUniform1fv(GLint location, GLsizei count, GLfloat *v) +glUniform1fv + len v (count * sizeof(GLfloat)) + +#void glUniform1iv(GLint location, GLsizei count, GLint *v) +glUniform1iv + len v (count * sizeof(GLint)) + +#void glUniform2fv(GLint location, GLsizei count, GLfloat *v) +glUniform2fv + len v (count * 2 * sizeof(GLfloat)) + +#void glUniform2iv(GLint location, GLsizei count, GLint *v) +glUniform2iv + len v (count * 2 * sizeof(GLint)) + +#void glUniform3fv(GLint location, GLsizei count, GLfloat *v) +glUniform3fv + len v (count * 3 * sizeof(GLfloat)) + +#void glUniform3iv(GLint location, GLsizei count, GLint *v) +glUniform3iv + len v (3 * count * sizeof(GLint)) + +#void glUniform4fv(GLint location, GLsizei count, GLfloat *v) +glUniform4fv + len v (4 * count * sizeof(GLfloat)) + +#void glUniform4iv(GLint location, GLsizei count, GLint *v) +glUniform4iv + len v (4 * count * sizeof(GLint)) + +#void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value) +glUniformMatrix2fv + len value (count * 4 * sizeof(GLfloat)) + +#void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value) +glUniformMatrix3fv + len value (count * 9 * sizeof(GLfloat)) + +#void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, GLfloat *value) +glUniformMatrix4fv + len value (count * 16 * sizeof(GLfloat)) + +#void glVertexAttrib1fv(GLuint indx, GLfloat *values) +glVertexAttrib1fv + len values (sizeof(GLfloat)) +#void glVertexAttrib2fv(GLuint indx, GLfloat *values) +glVertexAttrib2fv + len values (2 * sizeof(GLfloat)) + +#void glVertexAttrib3fv(GLuint indx, GLfloat *values) +glVertexAttrib3fv + len values (3 * sizeof(GLfloat)) + +#void glVertexAttrib4fv(GLuint indx, GLfloat *values) +glVertexAttrib4fv + len values (4 * sizeof(GLfloat)) + +#void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *ptr) +glVertexAttribPointer + flag unsupported + +#void glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) +glGetProgramBinaryOES + flag unsupported + +#void glProgramBinaryOES(GLuint program, GLenum binaryFormat, GLvoid *binary, GLint length) +glProgramBinaryOES + flag unsupported + +#void* glMapBufferOES(GLenum target, GLenum access) +glMapBufferOES + flag unsupported + +#void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid *pixels) +glTexImage3DOES + len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) + var_flag pixels nullAllowed isLarge + +#void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *pixels) +glTexSubImage3DOES + len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0) + var_flag pixels nullAllowed isLarge + +#void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLvoid *data) +glCompressedTexImage3DOES + len data imageSize + var_flag data nullAllowed isLarge + +#void glCompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLvoid *data) +glCompressedTexSubImage3DOES + len data imageSize + var_flag data nullAllowed isLarge + +#void glDeleteVertexArraysOES(GLsizei n, GLuint *arrays) +glDeleteVertexArraysOES + len arrays (n * sizeof(GLuint)) + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + +#void glGenVertexArraysOES(GLsizei n, GLuint *arrays) +glGenVertexArraysOES + len arrays (n * sizeof(GLuint)) + dir arrays out + param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; } + + +#void glDiscardFramebufferEXT(GLenum target, GLsizei numAttachments, GLenum *attachments) +glDiscardFramebufferEXT + len attachments (numAttachments * sizeof(GLenum)) + +#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) +glMultiDrawArraysEXT + flag unsupported +#void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount) +glMultiDrawElementsEXT + flag unsupported + + +# handled by encoder +#void glShaderSource(GLuint shader, GLsizei count, GLstr *string, const GLint *length) +glShaderSource + flag unsupported + + + +#void glGetPerfMonitorGroupsAMD(GLint *numGroups, GLsizei groupsSize, GLuint *groups) +glGetPerfMonitorGroupsAMD + flag unsupported + +#void glGetPerfMonitorCountersAMD(GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters) +glGetPerfMonitorCountersAMD + flag unsupported + +#void glGetPerfMonitorGroupStringAMD(GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString) +glGetPerfMonitorGroupStringAMD + flag unsupported + +#void glGetPerfMonitorCounterStringAMD(GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString) +glGetPerfMonitorCounterStringAMD + flag unsupported + +#void glGetPerfMonitorCounterInfoAMD(GLuint group, GLuint counter, GLenum pname, GLvoid *data) +glGetPerfMonitorCounterInfoAMD + flag unsupported + +#void glGenPerfMonitorsAMD(GLsizei n, GLuint *monitors) +glGenPerfMonitorsAMD + flag unsupported + +#void glDeletePerfMonitorsAMD(GLsizei n, GLuint *monitors) +glDeletePerfMonitorsAMD + flag unsupported + +#void glSelectPerfMonitorCountersAMD(GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList) +glSelectPerfMonitorCountersAMD + flag unsupported + +#void glBeginPerfMonitorAMD(GLuint monitor) +glBeginPerfMonitorAMD + flag unsupported + +#void glEndPerfMonitorAMD(GLuint monitor) +glEndPerfMonitorAMD + flag unsupported + +#void glGetPerfMonitorCounterDataAMD(GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten) +glGetPerfMonitorCounterDataAMD + flag unsupported + +#void glRenderbufferStorageMultisampleIMG(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +glRenderbufferStorageMultisampleIMG + flag unsupported + +#void glFramebufferTexture2DMultisampleIMG(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +glFramebufferTexture2DMultisampleIMG + flag unsupported + +#void glDeleteFencesNV(GLsizei n, GLuint *fences) +glDeleteFencesNV + flag unsupported + +#void glGenFencesNV(GLsizei n, GLuint *fences) +glGenFencesNV + flag unsupported + +#GLboolean glIsFenceNV(GLuint fence) +glIsFenceNV + flag unsupported + +#GLboolean glTestFenceNV(GLuint fence) +glTestFenceNV + flag unsupported + +#void glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) +glGetFenceivNV + flag unsupported + +#void glFinishFenceNV(GLuint fence) +glFinishFenceNV + flag unsupported + +#void glSetFenceNV(GLuint fence, GLenum condition) +glSetFenceNV + flag unsupported + +#void glCoverageMaskNV(GLboolean mask) +glCoverageMaskNV + flag unsupported + +#void glCoverageOperationNV(GLenum operation) +glCoverageOperationNV + flag unsupported + +#void glGetDriverControlsQCOM(GLint *num, GLsizei size, GLuint *driverControls) +glGetDriverControlsQCOM + flag unsupported + +#void glGetDriverControlStringQCOM(GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) +glGetDriverControlStringQCOM + flag unsupported + +#void glEnableDriverControlQCOM(GLuint driverControl) +glEnableDriverControlQCOM + flag unsupported + +#void glDisableDriverControlQCOM(GLuint driverControl) +glDisableDriverControlQCOM + flag unsupported + +#void glExtGetTexturesQCOM(GLuint *textures, GLint maxTextures, GLint *numTextures) +glExtGetTexturesQCOM + flag unsupported + +#void glExtGetBuffersQCOM(GLuint *buffers, GLint maxBuffers, GLint *numBuffers) +glExtGetBuffersQCOM + flag unsupported + +#void glExtGetRenderbuffersQCOM(GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) +glExtGetRenderbuffersQCOM + flag unsupported + +#void glExtGetFramebuffersQCOM(GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) +glExtGetFramebuffersQCOM + flag unsupported + +#void glExtGetTexLevelParameterivQCOM(GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) +glExtGetTexLevelParameterivQCOM + flag unsupported + +#void glExtTexObjectStateOverrideiQCOM(GLenum target, GLenum pname, GLint param) +glExtTexObjectStateOverrideiQCOM + flag unsupported + +#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) +glExtGetTexSubImageQCOM + flag unsupported + +#void glExtGetBufferPointervQCOM(GLenum target, GLvoidptr *params) +glExtGetBufferPointervQCOM + flag unsupported + +#void glExtGetShadersQCOM(GLuint *shaders, GLint maxShaders, GLint *numShaders) +glExtGetShadersQCOM + flag unsupported + +#void glExtGetProgramsQCOM(GLuint *programs, GLint maxPrograms, GLint *numPrograms) +glExtGetProgramsQCOM + flag unsupported + +#GLboolean glExtIsProgramBinaryQCOM(GLuint program) +glExtIsProgramBinaryQCOM + flag unsupported + +#void glExtGetProgramBinarySourceQCOM(GLuint program, GLenum shadertype, GLchar *source, GLint *length) +glExtGetProgramBinarySourceQCOM + flag unsupported + +#void glStartTilingQCOM(GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) +glStartTilingQCOM + flag unsupported + +#void glEndTilingQCOM(GLbitfield preserveMask) +glEndTilingQCOM + flag unsupported + + +#void glVertexAttribPointerData(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen) +glVertexAttribPointerData + len data datalen + custom_pack data glUtilsPackPointerData((unsigned char *)ptr, (unsigned char *)data, size, type, stride, datalen) + flag custom_decoder + flag not_api + +glVertexAttribPointerOffset + flag custom_decoder + flag not_api + +#client-state, handled by the encoder +#GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer) +glGetVertexAttribPointerv + flag unsupported + +glDrawElementsData + len data datalen + flag custom_decoder + flag not_api + +glDrawElementsOffset + flag custom_decoder + flag not_api + +#GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats) +glGetCompressedTextureFormats + dir formats out + len formats (count * sizeof(GLint)) + flag custom_decoder + flag not_api + +#GL_ENTRY(void, glShaderString, GLuint shader, GLchar *string, GLsizei len) +glShaderString + len string len + flag custom_decoder + flag not_api + +glFinishRoundTrip + flag custom_decoder + flag not_api + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.in b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.in new file mode 100644 index 0000000..f60db16 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.in @@ -0,0 +1,214 @@ +GL_ENTRY(void, glActiveTexture, GLenum texture) +GL_ENTRY(void, glAttachShader, GLuint program, GLuint shader) +GL_ENTRY(void, glBindAttribLocation, GLuint program, GLuint index, const GLchar* name) +GL_ENTRY(void, glBindBuffer, GLenum target, GLuint buffer) +GL_ENTRY(void, glBindFramebuffer, GLenum target, GLuint framebuffer) +GL_ENTRY(void, glBindRenderbuffer, GLenum target, GLuint renderbuffer) +GL_ENTRY(void, glBindTexture, GLenum target, GLuint texture) +GL_ENTRY(void, glBlendColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +GL_ENTRY(void, glBlendEquation, GLenum mode ) +GL_ENTRY(void, glBlendEquationSeparate, GLenum modeRGB, GLenum modeAlpha) +GL_ENTRY(void, glBlendFunc, GLenum sfactor, GLenum dfactor) +GL_ENTRY(void, glBlendFuncSeparate, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +GL_ENTRY(void, glBufferData, GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) +GL_ENTRY(void, glBufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) +GL_ENTRY(GLenum, glCheckFramebufferStatus, GLenum target) +GL_ENTRY(void, glClear, GLbitfield mask) +GL_ENTRY(void, glClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +GL_ENTRY(void, glClearDepthf, GLclampf depth) +GL_ENTRY(void, glClearStencil, GLint s) +GL_ENTRY(void, glColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +GL_ENTRY(void, glCompileShader, GLuint shader) +GL_ENTRY(void, glCompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data) +GL_ENTRY(void, glCompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data) +GL_ENTRY(void, glCopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +GL_ENTRY(void, glCopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +GL_ENTRY(GLuint, glCreateProgram, void) +GL_ENTRY(GLuint, glCreateShader, GLenum type) +GL_ENTRY(void, glCullFace, GLenum mode) +GL_ENTRY(void, glDeleteBuffers, GLsizei n, const GLuint* buffers) +GL_ENTRY(void, glDeleteFramebuffers, GLsizei n, const GLuint* framebuffers) +GL_ENTRY(void, glDeleteProgram, GLuint program) +GL_ENTRY(void, glDeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers) +GL_ENTRY(void, glDeleteShader, GLuint shader) +GL_ENTRY(void, glDeleteTextures, GLsizei n, const GLuint* textures) +GL_ENTRY(void, glDepthFunc, GLenum func) +GL_ENTRY(void, glDepthMask, GLboolean flag) +GL_ENTRY(void, glDepthRangef, GLclampf zNear, GLclampf zFar) +GL_ENTRY(void, glDetachShader, GLuint program, GLuint shader) +GL_ENTRY(void, glDisable, GLenum cap) +GL_ENTRY(void, glDisableVertexAttribArray, GLuint index) +GL_ENTRY(void, glDrawArrays, GLenum mode, GLint first, GLsizei count) +GL_ENTRY(void, glDrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) +GL_ENTRY(void, glEnable, GLenum cap) +GL_ENTRY(void, glEnableVertexAttribArray, GLuint index) +GL_ENTRY(void, glFinish, void) +GL_ENTRY(void, glFlush, void) +GL_ENTRY(void, glFramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +GL_ENTRY(void, glFramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +GL_ENTRY(void, glFrontFace, GLenum mode) +GL_ENTRY(void, glGenBuffers, GLsizei n, GLuint* buffers) +GL_ENTRY(void, glGenerateMipmap, GLenum target) +GL_ENTRY(void, glGenFramebuffers, GLsizei n, GLuint* framebuffers) +GL_ENTRY(void, glGenRenderbuffers, GLsizei n, GLuint* renderbuffers) +GL_ENTRY(void, glGenTextures, GLsizei n, GLuint* textures) +GL_ENTRY(void, glGetActiveAttrib, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +GL_ENTRY(void, glGetActiveUniform, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) +GL_ENTRY(void, glGetAttachedShaders, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) +GL_ENTRY(int, glGetAttribLocation, GLuint program, const GLchar* name) +GL_ENTRY(void, glGetBooleanv, GLenum pname, GLboolean* params) +GL_ENTRY(void, glGetBufferParameteriv, GLenum target, GLenum pname, GLint* params) +GL_ENTRY(GLenum, glGetError, void) +GL_ENTRY(void, glGetFloatv, GLenum pname, GLfloat* params) +GL_ENTRY(void, glGetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params) +GL_ENTRY(void, glGetIntegerv, GLenum pname, GLint* params) +GL_ENTRY(void, glGetProgramiv, GLuint program, GLenum pname, GLint* params) +GL_ENTRY(void, glGetProgramInfoLog, GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) +GL_ENTRY(void, glGetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params) +GL_ENTRY(void, glGetShaderiv, GLuint shader, GLenum pname, GLint* params) +GL_ENTRY(void, glGetShaderInfoLog, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) +GL_ENTRY(void, glGetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +GL_ENTRY(void, glGetShaderSource, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) +GL_ENTRY(const GLubyte*, glGetString, GLenum name) +GL_ENTRY(void, glGetTexParameterfv, GLenum target, GLenum pname, GLfloat* params) +GL_ENTRY(void, glGetTexParameteriv, GLenum target, GLenum pname, GLint* params) +GL_ENTRY(void, glGetUniformfv, GLuint program, GLint location, GLfloat* params) +GL_ENTRY(void, glGetUniformiv, GLuint program, GLint location, GLint* params) +GL_ENTRY(int, glGetUniformLocation, GLuint program, const GLchar* name) +GL_ENTRY(void, glGetVertexAttribfv, GLuint index, GLenum pname, GLfloat* params) +GL_ENTRY(void, glGetVertexAttribiv, GLuint index, GLenum pname, GLint* params) +GL_ENTRY(void, glGetVertexAttribPointerv, GLuint index, GLenum pname, GLvoid** pointer) +GL_ENTRY(void, glHint, GLenum target, GLenum mode) +GL_ENTRY(GLboolean, glIsBuffer, GLuint buffer) +GL_ENTRY(GLboolean, glIsEnabled, GLenum cap) +GL_ENTRY(GLboolean, glIsFramebuffer, GLuint framebuffer) +GL_ENTRY(GLboolean, glIsProgram, GLuint program) +GL_ENTRY(GLboolean, glIsRenderbuffer, GLuint renderbuffer) +GL_ENTRY(GLboolean, glIsShader, GLuint shader) +GL_ENTRY(GLboolean, glIsTexture, GLuint texture) +GL_ENTRY(void, glLineWidth, GLfloat width) +GL_ENTRY(void, glLinkProgram, GLuint program) +GL_ENTRY(void, glPixelStorei, GLenum pname, GLint param) +GL_ENTRY(void, glPolygonOffset, GLfloat factor, GLfloat units) +GL_ENTRY(void, glReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) +GL_ENTRY(void, glReleaseShaderCompiler, void) +GL_ENTRY(void, glRenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +GL_ENTRY(void, glSampleCoverage, GLclampf value, GLboolean invert) +GL_ENTRY(void, glScissor, GLint x, GLint y, GLsizei width, GLsizei height) +GL_ENTRY(void, glShaderBinary, GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length) +GL_ENTRY(void, glShaderSource, GLuint shader, GLsizei count, const GLchar*const* string, const GLint* length) +GL_ENTRY(void, glStencilFunc, GLenum func, GLint ref, GLuint mask) +GL_ENTRY(void, glStencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask) +GL_ENTRY(void, glStencilMask, GLuint mask) +GL_ENTRY(void, glStencilMaskSeparate, GLenum face, GLuint mask) +GL_ENTRY(void, glStencilOp, GLenum fail, GLenum zfail, GLenum zpass) +GL_ENTRY(void, glStencilOpSeparate, GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +GL_ENTRY(void, glTexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +GL_ENTRY(void, glTexParameterf, GLenum target, GLenum pname, GLfloat param) +GL_ENTRY(void, glTexParameterfv, GLenum target, GLenum pname, const GLfloat* params) +GL_ENTRY(void, glTexParameteri, GLenum target, GLenum pname, GLint param) +GL_ENTRY(void, glTexParameteriv, GLenum target, GLenum pname, const GLint* params) +GL_ENTRY(void, glTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels) +GL_ENTRY(void, glUniform1f, GLint location, GLfloat x) +GL_ENTRY(void, glUniform1fv, GLint location, GLsizei count, const GLfloat* v) +GL_ENTRY(void, glUniform1i, GLint location, GLint x) +GL_ENTRY(void, glUniform1iv, GLint location, GLsizei count, const GLint* v) +GL_ENTRY(void, glUniform2f, GLint location, GLfloat x, GLfloat y) +GL_ENTRY(void, glUniform2fv, GLint location, GLsizei count, const GLfloat* v) +GL_ENTRY(void, glUniform2i, GLint location, GLint x, GLint y) +GL_ENTRY(void, glUniform2iv, GLint location, GLsizei count, const GLint* v) +GL_ENTRY(void, glUniform3f, GLint location, GLfloat x, GLfloat y, GLfloat z) +GL_ENTRY(void, glUniform3fv, GLint location, GLsizei count, const GLfloat* v) +GL_ENTRY(void, glUniform3i, GLint location, GLint x, GLint y, GLint z) +GL_ENTRY(void, glUniform3iv, GLint location, GLsizei count, const GLint* v) +GL_ENTRY(void, glUniform4f, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +GL_ENTRY(void, glUniform4fv, GLint location, GLsizei count, const GLfloat* v) +GL_ENTRY(void, glUniform4i, GLint location, GLint x, GLint y, GLint z, GLint w) +GL_ENTRY(void, glUniform4iv, GLint location, GLsizei count, const GLint* v) +GL_ENTRY(void, glUniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +GL_ENTRY(void, glUniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +GL_ENTRY(void, glUniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +GL_ENTRY(void, glUseProgram, GLuint program) +GL_ENTRY(void, glValidateProgram, GLuint program) +GL_ENTRY(void, glVertexAttrib1f, GLuint indx, GLfloat x) +GL_ENTRY(void, glVertexAttrib1fv, GLuint indx, const GLfloat* values) +GL_ENTRY(void, glVertexAttrib2f, GLuint indx, GLfloat x, GLfloat y) +GL_ENTRY(void, glVertexAttrib2fv, GLuint indx, const GLfloat* values) +GL_ENTRY(void, glVertexAttrib3f, GLuint indx, GLfloat x, GLfloat y, GLfloat z) +GL_ENTRY(void, glVertexAttrib3fv, GLuint indx, const GLfloat* values) +GL_ENTRY(void, glVertexAttrib4f, GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +GL_ENTRY(void, glVertexAttrib4fv, GLuint indx, const GLfloat* values) +GL_ENTRY(void, glVertexAttribPointer, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) +GL_ENTRY(void, glViewport, GLint x, GLint y, GLsizei width, GLsizei height) +GL_ENTRY(void, glEGLImageTargetTexture2DOES, GLenum target, GLeglImageOES image) +GL_ENTRY(void, glEGLImageTargetRenderbufferStorageOES, GLenum target, GLeglImageOES image) +GL_ENTRY(void, glGetProgramBinaryOES, GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) +GL_ENTRY(void, glProgramBinaryOES, GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length) +GL_ENTRY(void*, glMapBufferOES, GLenum target, GLenum access) +GL_ENTRY(GLboolean, glUnmapBufferOES, GLenum target) +#GL_ENTRY(void, glGetBufferPointervOES, GLenum target, GLenum pname, GLvoid** params) +GL_ENTRY(void, glTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) +GL_ENTRY(void, glTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) +GL_ENTRY(void, glCopyTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) +GL_ENTRY(void, glCompressedTexImage3DOES, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) +GL_ENTRY(void, glCompressedTexSubImage3DOES, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) +GL_ENTRY(void, glFramebufferTexture3DOES, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) +GL_ENTRY(void, glBindVertexArrayOES, GLuint array) +GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays) +GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays) +GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array) +GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments) +GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) +GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const* indices, GLsizei primcount) + +#not supported +GL_ENTRY(void, glGetPerfMonitorGroupsAMD, GLint *numGroups, GLsizei groupsSize, GLuint *groups) +GL_ENTRY(void, glGetPerfMonitorCountersAMD, GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters) +GL_ENTRY(void, glGetPerfMonitorGroupStringAMD, GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString) +GL_ENTRY(void, glGetPerfMonitorCounterStringAMD, GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString) +GL_ENTRY(void, glGetPerfMonitorCounterInfoAMD, GLuint group, GLuint counter, GLenum pname, GLvoid *data) +GL_ENTRY(void, glGenPerfMonitorsAMD, GLsizei n, GLuint *monitors) +GL_ENTRY(void, glDeletePerfMonitorsAMD, GLsizei n, GLuint *monitors) +GL_ENTRY(void, glSelectPerfMonitorCountersAMD, GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList) +GL_ENTRY(void, glBeginPerfMonitorAMD, GLuint monitor) +GL_ENTRY(void, glEndPerfMonitorAMD, GLuint monitor) +GL_ENTRY(void, glGetPerfMonitorCounterDataAMD, GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten) + +GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) +GL_ENTRY(void, glFramebufferTexture2DMultisampleIMG, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) +GL_ENTRY(void, glDeleteFencesNV, GLsizei n, const GLuint *fences) +GL_ENTRY(void, glGenFencesNV, GLsizei n, GLuint *fences) +GL_ENTRY(GLboolean, glIsFenceNV, GLuint fence) +GL_ENTRY(GLboolean, glTestFenceNV, GLuint fence) +GL_ENTRY(void, glGetFenceivNV, GLuint fence, GLenum pname, GLint *params) +GL_ENTRY(void, glFinishFenceNV, GLuint fence) +GL_ENTRY(void, glSetFenceNV, GLuint fence, GLenum condition) +GL_ENTRY(void, glCoverageMaskNV, GLboolean mask) +GL_ENTRY(void, glCoverageOperationNV, GLenum operation) +GL_ENTRY(void, glGetDriverControlsQCOM, GLint *num, GLsizei size, GLuint *driverControls) +GL_ENTRY(void, glGetDriverControlStringQCOM, GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString) +GL_ENTRY(void, glEnableDriverControlQCOM, GLuint driverControl) +GL_ENTRY(void, glDisableDriverControlQCOM, GLuint driverControl) +GL_ENTRY(void, glExtGetTexturesQCOM, GLuint *textures, GLint maxTextures, GLint *numTextures) +GL_ENTRY(void, glExtGetBuffersQCOM, GLuint *buffers, GLint maxBuffers, GLint *numBuffers) +GL_ENTRY(void, glExtGetRenderbuffersQCOM, GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers) +GL_ENTRY(void, glExtGetFramebuffersQCOM, GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers) +GL_ENTRY(void, glExtGetTexLevelParameterivQCOM, GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params) +GL_ENTRY(void, glExtTexObjectStateOverrideiQCOM, GLenum target, GLenum pname, GLint param) +GL_ENTRY(void, glExtGetTexSubImageQCOM, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels) +GL_ENTRY(void, glExtGetBufferPointervQCOM, GLenum target, GLvoidptr *params) +GL_ENTRY(void, glExtGetShadersQCOM, GLuint *shaders, GLint maxShaders, GLint *numShaders) +GL_ENTRY(void, glExtGetProgramsQCOM, GLuint *programs, GLint maxPrograms, GLint *numPrograms) +GL_ENTRY(GLboolean, glExtIsProgramBinaryQCOM, GLuint program) +GL_ENTRY(void, glExtGetProgramBinarySourceQCOM, GLuint program, GLenum shadertype, GLchar *source, GLint *length) +GL_ENTRY(void, glStartTilingQCOM, GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask) +GL_ENTRY(void, glEndTilingQCOM, GLbitfield preserveMask) + +# add-ons +GL_ENTRY(void, glVertexAttribPointerData, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void * data, GLuint datalen) +GL_ENTRY(void, glVertexAttribPointerOffset, GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint offset) +GL_ENTRY(void, glDrawElementsOffset, GLenum mode, GLsizei count, GLenum type, GLuint offset) +GL_ENTRY(void, glDrawElementsData, GLenum mode, GLsizei count, GLenum type, void *data, GLuint datalen) +GL_ENTRY(void, glGetCompressedTextureFormats, int count, GLint *formats) +GL_ENTRY(void, glShaderString, GLuint shader, const GLchar* string, GLsizei len) +GL_ENTRY(int, glFinishRoundTrip, void) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.types b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.types new file mode 100644 index 0000000..86e10f9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2.types @@ -0,0 +1,38 @@ +GLbitfield 32 0x%08x +GLboolean 8 %d +GLclampf 32 %f +GLclampx 32 0x%08x +GLeglImageOES 32 %p +GLenum 32 0x%08x +GLfixed 32 0x%08x +GLfloat 32 %f +GLint 32 %d +GLintptr 32 %p +GLshort 16 %d +GLsizei 32 %d +GLsizeiptr 32 %p +GLubyte 8 0x%02x +GLuint 32 %u +GLvoid 0 %x +GLchar 8 %d +GLenum* 32 0x%08x +GLboolean* 32 0x%08x +GLclampf* 32 0x%08x +GLclampx* 32 0x%08x +GLeglImageOES* 32 0x%08x +GLfixed* 32 0x%08x +GLfloat* 32 0x%08x +GLint* 32 0x%08x +GLshort* 32 0x%08x +GLsizei* 32 0x%08x +GLubyte* 32 0x%08x +GLuint* 32 0x%08x +GLvoid* 32 0x%08x +GLchar* 32 0x%08x +GLchar** 32 0x%08x +GLvoid** 32 0x%08x +void* 32 0x%08x +GLstr* 32 0x%08x +GLvoidptr* 32 0x%08x +GLchar*const* 32 0x%08x +GLvoid*const* 32 0x%08x diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2_types.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2_types.h new file mode 100644 index 0000000..bfff61d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/GLESv2_dec/gles2_types.h @@ -0,0 +1,21 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _GL_2_TYPES_H_ +#define _GL_2_TYPES_H_ +#include "gl_base_types.h" + +typedef void *GLvoidptr; +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/CMakeLists.txt new file mode 100644 index 0000000..0ed3432 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/CMakeLists.txt @@ -0,0 +1,10 @@ +PREPEND(SOURCES ${CMAKE_CURRENT_LIST_DIR}/ + EGLDispatch.cpp + GLESv2Dispatch.cpp + GLESv1Dispatch.cpp) + +add_library(OpenGLESDispatch STATIC ${SOURCES} ${GLHEADERS_GENERATED_SOURCES}) +target_link_libraries(OpenGLESDispatch + emugl_common + GLESv2_dec + GLESv1_dec) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/EGLDispatch.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/EGLDispatch.cpp new file mode 100644 index 0000000..d942f5b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/EGLDispatch.cpp @@ -0,0 +1,58 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "OpenGLESDispatch/EGLDispatch.h" + +#include "emugl/common/shared_library.h" + +#include +#include + +namespace { +constexpr const char *egl_lib_env_var{"ANBOX_EGL_LIB"}; +} + +EGLDispatch s_egl; + +#define RENDER_EGL_LOAD_FIELD(return_type, function_name, signature) \ + s_egl. function_name = (function_name ## _t) lib->findSymbol(#function_name); + +#define RENDER_EGL_LOAD_OPTIONAL_FIELD(return_type, function_name, signature) \ + if (s_egl.eglGetProcAddress) s_egl. function_name = \ + (function_name ## _t) s_egl.eglGetProcAddress(#function_name); \ + if (!s_egl.function_name || !s_egl.eglGetProcAddress) \ + RENDER_EGL_LOAD_FIELD(return_type, function_name, signature) + +bool init_egl_dispatch(const char *path) { + const char *libName = getenv(egl_lib_env_var); + if (!libName) + libName = path; + if (!libName) + return false; + + char error[256]; + emugl::SharedLibrary *lib = emugl::SharedLibrary::open(libName, error, sizeof(error)); + if (!lib) { + printf("Failed to open %s: [%s]\n", libName, error); + return false; + } + + LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_LOAD_FIELD) + LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_LOAD_OPTIONAL_FIELD) + + s_egl.initialized = true; + + return true; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv1Dispatch.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv1Dispatch.cpp new file mode 100644 index 0000000..52be3d4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv1Dispatch.cpp @@ -0,0 +1,104 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "OpenGLESDispatch/GLESv1Dispatch.h" +#include "OpenGLESDispatch/EGLDispatch.h" + +#include +#include + +#include "emugl/common/shared_library.h" + +extern EGLDispatch s_egl; + +static emugl::SharedLibrary *s_gles1_lib = NULL; + +static void gles1_unimplemented() { + fprintf(stderr, "Called unimplemented GLESv1 API\n"); +} + +static void gles1_dummy() {} + +#define ASSIGN_DUMMY(return_type, function_name, signature, call_args) do { \ + dispatch_table-> function_name = reinterpret_cast(gles1_dummy); \ + } while(0); + + +#define LOOKUP_SYMBOL(return_type,function_name,signature,callargs) \ + dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \ + s_gles1_lib->findSymbol(#function_name)); + +#define LOOKUP_EXT_SYMBOL(return_type,function_name,signature,callargs) \ + dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \ + s_egl.eglGetProcAddress(#function_name)); + +namespace { +constexpr const char *glesv1_lib_env_var{"ANBOX_GLESv1_LIB"}; +} + +bool gles1_dispatch_init(const char *path, GLESv1Dispatch* dispatch_table) { + if (!dispatch_table) + return false; + + // If no path is given we assign dummy functions to all GL calls + // we would have loaded from a real implementation. + if (!path) { + LIST_GLES1_FUNCTIONS(ASSIGN_DUMMY, ASSIGN_DUMMY); + return true; + } + + const char* libName = getenv(glesv1_lib_env_var); + if (!libName) + libName = path; + if (!libName) + return false; + + char error[256]; + s_gles1_lib = emugl::SharedLibrary::open(libName, error, sizeof(error)); + if (!s_gles1_lib) { + fprintf(stderr, "%s: Could not load %s [%s]\n", __FUNCTION__, + libName, error); + return false; + } + + LIST_GLES1_FUNCTIONS(LOOKUP_SYMBOL,LOOKUP_EXT_SYMBOL) + + dispatch_table->initialized = true; + + return true; +} + +// +// This function is called only during initialization of the decoder before +// any thread has been created - hence it should NOT be thread safe. +// +void *gles1_dispatch_get_proc_func(const char *name, void *userData) +{ + void* func = NULL; + if (s_gles1_lib && !func) { + func = (void *)s_gles1_lib->findSymbol(name); + } + + if (!func) { + func = (void *)s_egl.eglGetProcAddress(name); + } + + // To make it consistent with the guest, redirect any unsupported functions + // to gles1_unimplemented. + if (!func) { + func = (void *)gles1_unimplemented; + } + return func; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv2Dispatch.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv2Dispatch.cpp new file mode 100644 index 0000000..ec6b610 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/GLESv2Dispatch.cpp @@ -0,0 +1,100 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "OpenGLESDispatch/GLESv2Dispatch.h" +#include "OpenGLESDispatch/EGLDispatch.h" + +#include +#include + +#include "emugl/common/shared_library.h" + +extern EGLDispatch s_egl; + +static emugl::SharedLibrary *s_gles2_lib = NULL; + +namespace { +constexpr const char *glesv2_lib_env_var{"ANDROID_GLESv2_LIB"}; +} + +// An unimplemented function which prints out an error message. +// To make it consistent with the guest, all GLES2 functions not supported by +// the driver should be redirected to this function. + +static void gles2_unimplemented() { + fprintf(stderr, "Called unimplemented GLESv2 API\n"); +} + +// +// This function is called only once during initialiation before +// any thread has been created - hence it should NOT be thread safe. +// +bool gles2_dispatch_init(const char *path, GLESv2Dispatch *dispatch_table) +{ + const char *libName = getenv(glesv2_lib_env_var); + if (!libName) + libName = path; + if (!libName) + return false; + + char error[256]; + s_gles2_lib = emugl::SharedLibrary::open(libName, error, sizeof(error)); + if (!s_gles2_lib) { + fprintf(stderr, "%s: Could not load %s [%s]\n", __FUNCTION__, + libName, error); + return false; + } + + // + // init the GLES dispatch table + // +#define LOOKUP_SYMBOL(return_type,function_name,signature,callargs) \ + dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \ + s_gles2_lib->findSymbol(#function_name)); + +#define LOOKUP_EXT_SYMBOL(return_type,function_name,signature,callargs) \ + dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \ + s_egl.eglGetProcAddress(#function_name)); + + LIST_GLES2_FUNCTIONS(LOOKUP_SYMBOL,LOOKUP_EXT_SYMBOL) + + dispatch_table->initialized = true; + + return true; +} + +// +// This function is called only during initialization before +// any thread has been created - hence it should NOT be thread safe. +// +void *gles2_dispatch_get_proc_func(const char *name, void *userData) +{ + void* func = NULL; + + if (s_gles2_lib && !func) { + func = (void *)s_gles2_lib->findSymbol(name); + } + + if (!func) { + func = (void *)s_egl.eglGetProcAddress(name); + } + + // To make it consistent with the guest, redirect any unsupported functions + // to gles2_unimplemented. + if (!func) { + func = (void *)gles2_unimplemented; + } + return func; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_extensions.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_extensions.entries new file mode 100644 index 0000000..72c0526 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_extensions.entries @@ -0,0 +1,21 @@ +!gles1_extensions + +# OpenGL functions which are needed ONLY for implementing GLES 1.1 EXTENSIONS +void glCurrentPaletteMatrixARB(GLint index); +void glMatrixIndexuivARB(GLint size, GLuint * indices); +void glMatrixIndexPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +void glWeightPointerARB(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +void glTexGenf(GLenum coord, GLenum pname, GLfloat param); +void glTexGeni(GLenum coord, GLenum pname, GLint param); +void glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params); +void glTexGeniv(GLenum coord, GLenum pname, const GLint *params); +void glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); +void glGetTexGeniv(GLenum coord, GLenum pname, GLint *params); +void glDrawTexsOES(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); +void glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height); +void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); +void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); +void glDrawTexsvOES(const GLshort *coords); +void glDrawTexivOES(const GLint *coords); +void glDrawTexfvOES(const GLfloat *coords); +void glDrawTexxvOES(const GLfixed *coords); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_only.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_only.entries new file mode 100644 index 0000000..650b6a8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles1_only.entries @@ -0,0 +1,65 @@ +!gles1_only + +# OpenGL functions which are needed ONLY for implementing GLES 1.1 + +void glAlphaFunc(GLenum func, GLclampf ref); +void glBegin( GLenum mode ); +void glClientActiveTexture( GLenum texture ); +void glClipPlane(GLenum plane, const GLdouble *equation); +void glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +void glColor4fv( const GLfloat *v ); +void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +void glColor4ubv( const GLubyte *v ); +void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +void glDisableClientState(GLenum array); +void glEnableClientState(GLenum array); +void glEnd(void); +void glFogf(GLenum pname, GLfloat param); +void glFogfv(GLenum pname, const GLfloat *params); +void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +void glGetClipPlane(GLenum plane, GLdouble *equation); +void glGetDoublev( GLenum pname, GLdouble *params ); +void glGetLightfv(GLenum light, GLenum pname, GLfloat *params); +void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params); +void glGetPointerv(GLenum pname, GLvoid* *params); +void glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params); +void glGetTexEnviv(GLenum target, GLenum pname, GLint *params); +void glLightf(GLenum light, GLenum pname, GLfloat param); +void glLightfv(GLenum light, GLenum pname, const GLfloat *params); +void glLightModelf(GLenum pname, GLfloat param); +void glLightModelfv(GLenum pname, const GLfloat *params); +void glLoadIdentity(void); +void glLoadMatrixf(const GLfloat *m); +void glLogicOp(GLenum opcode); +void glMaterialf(GLenum face, GLenum pname, GLfloat param); +void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params); +void glMultiTexCoord2fv( GLenum target, const GLfloat *v ); +void glMultiTexCoord2sv( GLenum target, const GLshort *v ); +void glMultiTexCoord3fv( GLenum target, const GLfloat *v ); +void glMultiTexCoord3sv( GLenum target, const GLshort *v ); +void glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +void glMultiTexCoord4fv( GLenum target, const GLfloat *v ); +void glMultiTexCoord4sv( GLenum target, const GLshort *v ); +void glMultMatrixf(const GLfloat *m); +void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); +void glNormal3fv( const GLfloat *v ); +void glNormal3sv( const GLshort *v ); +void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +void glPointParameterf(GLenum param, GLfloat value); +void glPointParameterfv(GLenum param, const GLfloat *values); +void glPointSize(GLfloat size); +void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +void glScalef(GLfloat x, GLfloat y, GLfloat z); +void glTexEnvf(GLenum target, GLenum pname, GLfloat param); +void glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params); +void glMatrixMode(GLenum mode); +void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer); +void glPopMatrix(void); +void glPushMatrix(void); +void glShadeModel(GLenum mode); +void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +void glTexEnvi(GLenum target, GLenum pname, GLint param); +void glTexEnviv(GLenum target, GLenum pname, const GLint *params); +void glTranslatef(GLfloat x, GLfloat y, GLfloat z); +void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_extensions.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_extensions.entries new file mode 100644 index 0000000..06ee78f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_extensions.entries @@ -0,0 +1,6 @@ +!gles2_extensions + +# GLES 2.0 extensions +void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +void glReleaseShaderCompiler(void); +void glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_only.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_only.entries new file mode 100644 index 0000000..cecc447 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles2_only.entries @@ -0,0 +1,81 @@ +!gles2_only + +# OpenGL functions which are needed ONLY for implementing GLES 2.0 +void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); +void glStencilMaskSeparate(GLenum face, GLuint mask); +void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +GLboolean glIsProgram(GLuint program); +GLboolean glIsShader(GLuint shader); +void glVertexAttrib1f(GLuint indx, GLfloat x); +void glVertexAttrib1fv(GLuint indx, const GLfloat* values); +void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); +void glVertexAttrib2fv(GLuint indx, const GLfloat* values); +void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); +void glVertexAttrib3fv(GLuint indx, const GLfloat* values); +void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +void glVertexAttrib4fv(GLuint indx, const GLfloat* values); +void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); +void glDisableVertexAttribArray(GLuint index); +void glEnableVertexAttribArray(GLuint index); +void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); +void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); +void glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer); +void glUniform1f(GLint location, GLfloat x); +void glUniform1fv(GLint location, GLsizei count, const GLfloat* v); +void glUniform1i(GLint location, GLint x); +void glUniform1iv(GLint location, GLsizei count, const GLint* v); +void glUniform2f(GLint location, GLfloat x, GLfloat y); +void glUniform2fv(GLint location, GLsizei count, const GLfloat* v); +void glUniform2i(GLint location, GLint x, GLint y); +void glUniform2iv(GLint location, GLsizei count, const GLint* v); +void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z); +void glUniform3fv(GLint location, GLsizei count, const GLfloat* v); +void glUniform3i(GLint location, GLint x, GLint y, GLint z); +void glUniform3iv(GLint location, GLsizei count, const GLint* v); +void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +void glUniform4fv(GLint location, GLsizei count, const GLfloat* v); +void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w); +void glUniform4iv(GLint location, GLsizei count, const GLint* v); +void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +void glAttachShader(GLuint program, GLuint shader); +void glBindAttribLocation(GLuint program, GLuint index, const GLchar* name); +void glCompileShader(GLuint shader); +GLuint glCreateProgram(void); +GLuint glCreateShader(GLenum type); +void glDeleteProgram(GLuint program); +void glDeleteShader(GLuint shader); +void glDetachShader(GLuint program, GLuint shader); +void glLinkProgram(GLuint program); +void glUseProgram(GLuint program); +void glValidateProgram(GLuint program); +void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +int glGetAttribLocation(GLuint program, const GLchar* name); +void glGetProgramiv(GLuint program, GLenum pname, GLint* params); +void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); +void glGetShaderiv(GLuint shader, GLenum pname, GLint* params); +void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); +void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); +void glGetUniformfv(GLuint program, GLint location, GLfloat* params); +void glGetUniformiv(GLuint program, GLint location, GLint* params); +int glGetUniformLocation(GLuint program, const GLchar* name); +void glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); + +# The following are not used by GLDispatch but by GLESv2Dispatch +void glBindFramebuffer(GLenum target, GLuint framebuffer); +void glGenFramebuffers(GLsizei n, GLuint* framebuffers); +void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLenum glCheckFramebufferStatus(GLenum target); +void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers); + +GLboolean glIsRenderbuffer(GLuint renderbuffer); +void glBindRenderbuffer(GLenum target, GLuint renderbuffer); +void glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers); +void glGenRenderbuffers(GLsizei n, GLuint *renderbuffers); +void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params); +void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles3_only.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles3_only.entries new file mode 100644 index 0000000..2feb1b2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles3_only.entries @@ -0,0 +1,18 @@ +!gles3_only + +# GLES 3.x functions required by the translator library. +# Right now, this is only use to get glGetStringi() from the host GL library +# in order to deal with the fact that glGetString(GL_EXTENSIONS) is obsolete +# in OpenGL 3.0, and some drivers don't implement it anymore (i.e. the +# function just returns NULL). + +%#include +% +%// Used to avoid adding GLES3/gl3.h to our headers. +%#ifndef GL_NUM_EXTENSIONS +%#define GL_NUM_EXTENSIONS 0x821D +%#endif + +%typedef const GLubyte* GLconstubyteptr; + +GLconstubyteptr glGetStringi(GLenum name, GLint index); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_common.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_common.entries new file mode 100644 index 0000000..275f805 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_common.entries @@ -0,0 +1,68 @@ +!gles_common + +# Functions common to both GLES 1.x and 2.0 + +%#include +%// Return types must be single words, see GLDispatch.cpp +%typedef const GLubyte* GLconstubyteptr; + +void glActiveTexture( GLenum texture ); +void glBindBuffer(GLenum target, GLuint buffer); +void glBindTexture(GLenum target, GLuint texture); +void glBlendFunc(GLenum sfactor, GLenum dfactor); +void glBlendEquation( GLenum mode ); +void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); +void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +void glClear(GLbitfield mask); +void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +void glClearStencil(GLint s); +void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +void glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); +void glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); +void glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +void glCullFace(GLenum mode); +void glDeleteBuffers(GLsizei n, const GLuint *buffers); +void glDeleteTextures(GLsizei n, const GLuint *textures); +void glDepthFunc(GLenum func); +void glDepthMask(GLboolean flag); +void glDisable(GLenum cap); +void glDrawArrays(GLenum mode, GLint first, GLsizei count); +void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +void glEnable(GLenum cap); +void glFinish(void); +void glFlush(void); +void glFrontFace(GLenum mode); +void glGenBuffers(GLsizei n, GLuint *buffers); +void glGenTextures(GLsizei n, GLuint *textures); +void glGetBooleanv(GLenum pname, GLboolean *params); +void glGetBufferParameteriv(GLenum buffer, GLenum parameter, GLint *value); +GLenum glGetError(void); +void glGetFloatv(GLenum pname, GLfloat *params); +void glGetIntegerv(GLenum pname, GLint *params); +GLconstubyteptr glGetString(GLenum name); +void glTexParameterf(GLenum target, GLenum pname, GLfloat param); +void glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params); +void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params); +void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params); +void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params); +void glHint(GLenum target, GLenum mode); +GLboolean glIsBuffer(GLuint buffer); +GLboolean glIsEnabled(GLenum cap); +GLboolean glIsTexture(GLuint texture); +void glLineWidth(GLfloat width); +void glPolygonOffset(GLfloat factor, GLfloat units); +void glPixelStorei(GLenum pname, GLint param); +void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +void glSampleCoverage( GLclampf value, GLboolean invert ); +void glScissor(GLint x, GLint y, GLsizei width, GLsizei height); +void glStencilFunc(GLenum func, GLint ref, GLuint mask); +void glStencilMask(GLuint mask); +void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); +void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +void glTexParameteri(GLenum target, GLenum pname, GLint param); +void glTexParameteriv(GLenum target, GLenum pname, const GLint *params); +void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +void glViewport(GLint x, GLint y, GLsizei width, GLsizei height); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_extensions.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_extensions.entries new file mode 100644 index 0000000..817e8ad --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/gles_extensions.entries @@ -0,0 +1,24 @@ +!gles_extensions + +# Common GLES 1.x / 2.0 extension functions +GLboolean glIsRenderbufferEXT(GLuint renderbuffer); +void glBindRenderbufferEXT(GLenum target, GLuint renderbuffer); +void glDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers); +void glGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers); +void glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +void glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params); +GLboolean glIsFramebufferEXT(GLuint framebuffer); +void glBindFramebufferEXT(GLenum target, GLuint framebuffer); +void glDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers); +void glGenFramebuffersEXT(GLsizei n, GLuint *framebuffers); +GLenum glCheckFramebufferStatusEXT(GLenum target); +void glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +void glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +void glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +void glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +void glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params); +void glGenerateMipmapEXT(GLenum target); + +# The following extensions are used by GLESv1Dispatch and GLESv2Dispatch, but not by GLDispatch +void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); +void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl.entries new file mode 100644 index 0000000..314c9be --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl.entries @@ -0,0 +1,26 @@ +# The list of EGL functions used by libOpenglRender, without extensions. +# This is only a subset of the full EGL API. + +!Render_EGL +%#include + +EGLint eglGetError(void); +EGLDisplay eglGetDisplay(EGLNativeDisplayType dpy); +EGLBoolean eglInitialize(EGLDisplay dpy, EGLint* major, EGLint* minor); +char* eglQueryString(EGLDisplay dpy, EGLint id); +EGLBoolean eglGetConfigs(EGLDisplay display, EGLConfig* configs, EGLint config_size, EGLint* num_config); +EGLBoolean eglChooseConfig(EGLDisplay display, const EGLint* attribs, EGLConfig* configs, EGLint config_size, EGLint* num_config); +EGLBoolean eglGetConfigAttrib(EGLDisplay display, EGLConfig config, EGLint attribute, EGLint* value); +EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, EGLNativeWindowType native_window, const EGLint* attrib_list); +EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, const EGLint* attrib_list); +EGLBoolean eglDestroySurface(EGLDisplay display, EGLSurface surface); +EGLBoolean eglBindAPI(EGLenum api); +EGLenum eglQueryAPI(void); +EGLBoolean eglReleaseThread(void); +EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, const EGLint* attrib_list); +EGLBoolean eglDestroyContext(EGLDisplay display, EGLContext context); +EGLBoolean eglMakeCurrent(EGLDisplay display, EGLSurface draw, EGLSurface read, EGLContext context); +EGLContext eglGetCurrentContext(void); +EGLSurface eglGetCurrentSurface(EGLint readdraw); +EGLBoolean eglSwapBuffers(EGLDisplay display, EGLSurface surface); +void* eglGetProcAddress(const char* function_name); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl_extensions.entries b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl_extensions.entries new file mode 100644 index 0000000..cd6d32a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/libOpenGLESDispatch/render_egl_extensions.entries @@ -0,0 +1,11 @@ +# The list of EGL extension functions used by libOpenglRender. +# This is only a subset of the full EGL API. + +!Render_EGL_extensions + +%#include +%#define EGL_EGLEXT_PROTOTYPES +%#include + +EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list); +EGLBoolean eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/CMakeLists.txt new file mode 100644 index 0000000..3b2f890 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/CMakeLists.txt @@ -0,0 +1,22 @@ +set(CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/GLESv1_dec) + +PREPEND(GENERATED_SOURCES ${CURRENT_BINARY_DIR}/ + renderControl_dec.cpp + renderControl_server_context.cpp) + +add_custom_command( + OUTPUT ${GENERATED_SOURCES} + POST_BUILD + COMMAND mkdir -p ${CURRENT_BINARY_DIR} && ${CMAKE_BINARY_DIR}/external/android-emugl/host/tools/emugen/emugen + -D ${CURRENT_BINARY_DIR} renderControl + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + DEPENDS emugen) + +if ("${cmake_build_type_lower}" STREQUAL "trace") + set(OPENGL_DEBUG "-DOPENGL_DEBUG_PRINTOUT -DCHECK_GL_ERROR") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENGL_DEBUG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENGL_DEBUG}") +endif() + +add_library(renderControl_dec STATIC ${GENERATED_SOURCES}) +target_link_libraries(renderControl_dec OpenglCodecCommon) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.attrib b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.attrib new file mode 100644 index 0000000..4a3bb18 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.attrib @@ -0,0 +1,47 @@ +GLOBAL + base_opcode 10000 + encoder_headers "glUtils.h" + +rcGetEGLVersion + dir major out + len major sizeof(EGLint) + dir minor out + len minor sizeof(EGLint) + +rcQueryEGLString + dir buffer out + len buffer bufferSize + +rcGetGLString + dir buffer out + len buffer bufferSize + +rcGetNumConfigs + dir numAttribs out + len numAttribs sizeof(uint32_t) + +rcGetConfigs + dir buffer out + len buffer bufSize + +rcChooseConfig + dir attribs in + len attribs attribs_size + dir configs out + var_flag configs nullAllowed + len configs configs_size*sizeof(uint32_t) + +rcReadColorBuffer + dir pixels out + len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height) + +rcUpdateColorBuffer + dir pixels in + len pixels (((glUtilsPixelBitSize(format, type) * width) >> 3) * height) + var_flag pixels isLarge + +rcCloseColorBuffer + flag flushOnEncode + +rcPostLayer + len name (strlen(name) + 1) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.in b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.in new file mode 100644 index 0000000..2a95ef8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.in @@ -0,0 +1,37 @@ +GL_ENRTY(GLint, rcGetRendererVersion) +GL_ENTRY(EGLint, rcGetEGLVersion, EGLint *major, EGLint *minor) +GL_ENTRY(EGLint, rcQueryEGLString, EGLenum name, void *buffer, EGLint bufferSize) +GL_ENTRY(EGLint, rcGetGLString, EGLenum name, void *buffer, EGLint bufferSize) +GL_ENTRY(EGLint, rcGetNumConfigs, uint32_t *numAttribs) +GL_ENTRY(EGLint, rcGetConfigs, uint32_t bufSize, GLuint *buffer) +GL_ENTRY(EGLint, rcChooseConfig, EGLint *attribs, uint32_t attribs_size, uint32_t *configs, uint32_t configs_size) +GL_ENTRY(EGLint, rcGetFBParam, EGLint param) +GL_ENTRY(uint32_t, rcCreateContext, uint32_t config, uint32_t share, uint32_t glVersion) +GL_ENTRY(void, rcDestroyContext, uint32_t context) +GL_ENTRY(uint32_t, rcCreateWindowSurface, uint32_t config, uint32_t width, uint32_t height) +GL_ENTRY(void, rcDestroyWindowSurface, uint32_t windowSurface) +GL_ENTRY(uint32_t, rcCreateColorBuffer, uint32_t width, uint32_t height, GLenum internalFormat) +GL_ENTRY(void, rcOpenColorBuffer, uint32_t colorbuffer) +GL_ENTRY(void, rcCloseColorBuffer, uint32_t colorbuffer) +GL_ENTRY(void, rcSetWindowColorBuffer, uint32_t windowSurface, uint32_t colorBuffer) +GL_ENTRY(int, rcFlushWindowColorBuffer, uint32_t windowSurface) +GL_ENTRY(EGLint, rcMakeCurrent, uint32_t context, uint32_t drawSurf, uint32_t readSurf) +GL_ENTRY(void, rcFBPost, uint32_t colorBuffer) +GL_ENTRY(void, rcFBSetSwapInterval, EGLint interval) +GL_ENTRY(void, rcBindTexture, uint32_t colorBuffer) +GL_ENTRY(void, rcBindRenderbuffer, uint32_t colorBuffer) +GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead) +GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels) +GL_ENTRY(int, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels) +GL_ENTRY(int, rcOpenColorBuffer2, uint32_t colorbuffer) +GL_ENTRY(uint32_t, rcCreateClientImage, uint32_t context, EGLenum target, GLuint buffer) +GL_ENTRY(int, rcDestroyClientImage, uint32_t image) +GL_ENTRY(void, rcSelectChecksumCalculator, uint32_t newProtocol, uint32_t reserved) +GL_ENTRY(int, rcGetNumDisplays) +GL_ENTRY(int, rcGetDisplayWidth, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayHeight, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayDpiX, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayDpiY, uint32_t displayId) +GL_ENTRY(int, rcGetDisplayVsyncPeriod, uint32_t displayId) +GL_ENTRY(void, rcPostLayer, const char* name, uint32_t colorBuffer, float alpha, int32_t sourceCropLeft, int32_t sourceCropTop, int32_t sourceCropRight, int32_t sourceCropBottom, int32_t displayFrameLeft, int32_t displayFrameTop, int32_t displayFrameRight, int32_t displayFrameBottom) +GL_ENTRY(void, rcPostAllLayersDone) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.types b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.types new file mode 100644 index 0000000..9bb0546 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl.types @@ -0,0 +1,13 @@ +uint32_t 32 0x%08x +int32_t 32 0x%08x +EGLint 32 0x%08x +GLint 32 0x%08x +GLuint 32 0x%08x +GLenum 32 0x%08x +EGLenum 32 0x%08x +uint32_t* 32 0x%08x +EGLint* 32 0x%08x +GLint* 32 0x%08x +GLuint* 32 0x%08x +void* 32 0x%08x +char* 32 0x%08x diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl_types.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl_types.h new file mode 100644 index 0000000..da215bb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/libs/renderControl_dec/renderControl_types.h @@ -0,0 +1,28 @@ +/* +* Copyright 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include "glUtils.h" + +// values for 'param' argument of rcGetFBParam +#define FB_WIDTH 1 +#define FB_HEIGHT 2 +#define FB_XDPI 3 +#define FB_YDPI 4 +#define FB_FPS 5 +#define FB_MIN_SWAP_INTERVAL 6 +#define FB_MAX_SWAP_INTERVAL 7 diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/CMakeLists.txt new file mode 100644 index 0000000..01d9785 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(emugen) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.cpp new file mode 100644 index 0000000..f912cb5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.cpp @@ -0,0 +1,1392 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "ApiGen.h" +#include "EntryPoint.h" +#include +#include +#include "strUtils.h" +#include +#include + +/* Define this to 1 to enable support for the 'isLarge' variable flag + * that instructs the encoder to send large data buffers by a direct + * write through the pipe (i.e. without copying it into a temporary + * buffer. This has definite performance benefits when using a QEMU Pipe. + * + * Set to 0 otherwise. + */ +#define WITH_LARGE_SUPPORT 1 + +// Set to 1 to ensure buffers passed to/from EGL/GL are properly aligned. +// This prevents crashes with certain backends (e.g. OSMesa). +#define USE_ALIGNED_BUFFERS 1 + +EntryPoint * ApiGen::findEntryByName(const std::string & name) +{ + EntryPoint * entry = NULL; + + size_t n = this->size(); + for (size_t i = 0; i < n; i++) { + if (at(i).name() == name) { + entry = &(at(i)); + break; + } + } + return entry; +} + +void ApiGen::printHeader(FILE *fp) const +{ + fprintf(fp, "// Generated Code - DO NOT EDIT !!\n"); + fprintf(fp, "// generated by 'emugen'\n"); +} + +int ApiGen::genProcTypes(const std::string &filename, SideType side) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + printHeader(fp); + + const char* basename = m_basename.c_str(); + + fprintf(fp, "#ifndef __%s_%s_proc_t_h\n", basename, sideString(side)); + fprintf(fp, "#define __%s_%s_proc_t_h\n", basename, sideString(side)); + fprintf(fp, "\n\n"); + fprintf(fp, "\n#include \"%s_types.h\"\n",basename); + fprintf(fp, "#ifndef %s_APIENTRY\n",basename); + fprintf(fp, "#define %s_APIENTRY \n",basename); + fprintf(fp, "#endif\n"); + + + for (size_t i = 0; i < size(); i++) { + EntryPoint *e = &at(i); + + fprintf(fp, "typedef "); + e->retval().printType(fp); + fprintf(fp, " (%s_APIENTRY *%s_%s_proc_t) (", basename, e->name().c_str(), sideString(side)); + if (side == CLIENT_SIDE) { fprintf(fp, "void * ctx"); } + if (e->customDecoder() && side == SERVER_SIDE) { fprintf(fp, "void *ctx"); } + + VarsArray & evars = e->vars(); + size_t n = evars.size(); + + for (size_t j = 0; j < n; j++) { + if (!evars[j].isVoid()) { + if (j != 0 || side == CLIENT_SIDE || (side == SERVER_SIDE && e->customDecoder())) fprintf(fp, ", "); + evars[j].printType(fp); + } + } + fprintf(fp, ");\n"); + } + fprintf(fp, "\n\n#endif\n"); + return 0; +} + +int ApiGen::genFuncTable(const std::string &filename, SideType side) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + printHeader(fp); + + fprintf(fp, "#ifndef __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side)); + fprintf(fp, "#define __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side)); + fprintf(fp, "\n\n"); + fprintf(fp, "static const struct _%s_funcs_by_name {\n", m_basename.c_str()); + fprintf(fp, + "\tconst char *name;\n" \ + "\tvoid *proc;\n" \ + "} %s_funcs_by_name[] = {\n", m_basename.c_str()); + + + for (size_t i = 0; i < size(); i++) { + EntryPoint *e = &at(i); + if (e->notApi()) continue; + fprintf(fp, "\t{\"%s\", (void*)%s},\n", e->name().c_str(), e->name().c_str()); + } + fprintf(fp, "};\n"); + fprintf(fp, "static const int %s_num_funcs = sizeof(%s_funcs_by_name) / sizeof(struct _%s_funcs_by_name);\n", + m_basename.c_str(), m_basename.c_str(), m_basename.c_str()); + fprintf(fp, "\n\n#endif\n"); + return 0; +} + +int ApiGen::genContext(const std::string & filename, SideType side) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + printHeader(fp); + + fprintf(fp, "#ifndef __%s_%s_context_t_h\n", m_basename.c_str(), sideString(side)); + fprintf(fp, "#define __%s_%s_context_t_h\n", m_basename.c_str(), sideString(side)); + + fprintf(fp, "\n#include \"%s_%s_proc.h\"\n", + m_basename.c_str(), + side == CLIENT_SIDE ? "client" : "server"); + fprintf(fp, "\n#include \"%s_types.h\"\n", m_basename.c_str()); + + StringVec & contextHeaders = side == CLIENT_SIDE ? m_clientContextHeaders : m_serverContextHeaders; + for (size_t i = 0; i < contextHeaders.size(); i++) { + fprintf(fp, "#include %s\n", contextHeaders[i].c_str()); + } + fprintf(fp, "\n"); + + fprintf(fp, "\nstruct %s_%s_context_t {\n\n", + m_basename.c_str(), sideString(side)); + + // API entry points + for (size_t i = 0; i < size(); i++) { + EntryPoint *e = &at(i); + fprintf(fp, "\t%s_%s_proc_t %s;\n", e->name().c_str(), sideString(side), e->name().c_str()); + } + + // virtual destructor + fprintf(fp, "\t virtual ~%s_%s_context_t() {}\n", m_basename.c_str(), sideString(side)); + // accessor + if (side == CLIENT_SIDE || side == WRAPPER_SIDE) { + fprintf(fp, "\n\ttypedef %s_%s_context_t *CONTEXT_ACCESSOR_TYPE(void);\n", + m_basename.c_str(), sideString(side)); + fprintf(fp, "\tstatic void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);\n"); + } + + // init function + fprintf(fp, "\tint initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);\n"); + + //client site set error virtual func + if (side == CLIENT_SIDE) { + fprintf(fp, "\tvirtual void setError(unsigned int error){ (void)error; };\n"); + fprintf(fp, "\tvirtual unsigned int getError(){ return 0; };\n"); + } + + fprintf(fp, "};\n"); + + fprintf(fp, "\n#endif\n"); + fclose(fp); + return 0; +} + +int ApiGen::genEntryPoints(const std::string & filename, SideType side) +{ + + if (side != CLIENT_SIDE && side != WRAPPER_SIDE) { + fprintf(stderr, "Entry points are only defined for Client and Wrapper components\n"); + return -999; + } + + + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return errno; + } + + printHeader(fp); + fprintf(fp, "#include \n"); + fprintf(fp, "#include \n"); + fprintf(fp, "#include \"%s_%s_context.h\"\n", m_basename.c_str(), sideString(side)); + fprintf(fp, "\n"); + + fprintf(fp, "#ifndef GL_TRUE\n"); + fprintf(fp, "extern \"C\" {\n"); + + for (size_t i = 0; i < size(); i++) { + fprintf(fp, "\t"); at(i).print(fp, false); fprintf(fp, ";\n"); + } + fprintf(fp, "};\n\n"); + fprintf(fp, "#endif\n"); + + fprintf(fp, "#ifndef GET_CONTEXT\n"); + fprintf(fp, "static %s_%s_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;\n", + m_basename.c_str(), sideString(side)); + + fprintf(fp, + "void %s_%s_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }\n", + m_basename.c_str(), sideString(side)); + fprintf(fp, "#define GET_CONTEXT %s_%s_context_t * ctx = getCurrentContext()\n", + m_basename.c_str(), sideString(side)); + fprintf(fp, "#endif\n\n"); + + + for (size_t i = 0; i < size(); i++) { + EntryPoint *e = &at(i); + e->print(fp); + fprintf(fp, "{\n"); + fprintf(fp, "\tGET_CONTEXT;\n"); + + bool shouldReturn = !e->retval().isVoid(); + bool shouldCallWithContext = (side == CLIENT_SIDE); + //param check + if (shouldCallWithContext) { + for (size_t j=0; jvars().size(); j++) { + if (e->vars()[j].paramCheckExpression() != "") + fprintf(fp, "\t%s\n", e->vars()[j].paramCheckExpression().c_str()); + } + } + fprintf(fp, "\t%sctx->%s(%s", + shouldReturn ? "return " : "", + e->name().c_str(), + shouldCallWithContext ? "ctx" : ""); + size_t nvars = e->vars().size(); + + for (size_t j = 0; j < nvars; j++) { + if (!e->vars()[j].isVoid()) { + fprintf(fp, "%s %s", + j != 0 || shouldCallWithContext ? "," : "", + e->vars()[j].name().c_str()); + } + } + fprintf(fp, ");\n"); + fprintf(fp, "}\n\n"); + } + fclose(fp); + return 0; +} + + +int ApiGen::genOpcodes(const std::string &filename) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return errno; + } + + printHeader(fp); + fprintf(fp, "#ifndef __GUARD_%s_opcodes_h_\n", m_basename.c_str()); + fprintf(fp, "#define __GUARD_%s_opcodes_h_\n\n", m_basename.c_str()); + for (size_t i = 0; i < size(); i++) { + fprintf(fp, "#define OP_%s \t\t\t\t\t%u\n", at(i).name().c_str(), (unsigned int)i + m_baseOpcode); + } + fprintf(fp, "#define OP_last \t\t\t\t\t%u\n", (unsigned int)size() + m_baseOpcode); + fprintf(fp,"\n\n#endif\n"); + fclose(fp); + return 0; + +} +int ApiGen::genAttributesTemplate(const std::string &filename ) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + + for (size_t i = 0; i < size(); i++) { + if (at(i).hasPointers()) { + fprintf(fp, "#"); + at(i).print(fp); + fprintf(fp, "%s\n\n", at(i).name().c_str()); + } + } + fclose(fp); + return 0; +} + +int ApiGen::genEncoderHeader(const std::string &filename) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + + printHeader(fp); + std::string classname = m_basename + "_encoder_context_t"; + + fprintf(fp, "\n#ifndef GUARD_%s\n", classname.c_str()); + fprintf(fp, "#define GUARD_%s\n\n", classname.c_str()); + + fprintf(fp, "#include \"IOStream.h\"\n"); + fprintf(fp, "#include \"ChecksumCalculator.h\"\n"); + fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(CLIENT_SIDE)); + + for (size_t i = 0; i < m_encoderHeaders.size(); i++) { + fprintf(fp, "#include %s\n", m_encoderHeaders[i].c_str()); + } + fprintf(fp, "\n"); + + fprintf(fp, "struct %s : public %s_%s_context_t {\n\n", + classname.c_str(), m_basename.c_str(), sideString(CLIENT_SIDE)); + fprintf(fp, "\tIOStream *m_stream;\n"); + fprintf(fp, "\tChecksumCalculator *m_checksumCalculator;\n\n"); + + fprintf(fp, "\t%s(IOStream *stream, ChecksumCalculator *checksumCalculator);\n", classname.c_str()); + fprintf(fp, "};\n\n"); + + fprintf(fp, "#endif // GUARD_%s", classname.c_str()); + + fclose(fp); + return 0; +} + +// Format the byte length expression for a given variable into a user-provided buffer +// If the variable type is not a pointer, this is simply its size as a decimal constant +// If the variable is a pointer, this will be an expression provided by the .attrib file +// through the 'len' attribute. +// +// Returns 1 if the variable is a pointer, 0 otherwise +// +static int getVarEncodingSizeExpression(Var& var, EntryPoint* e, char* buff, size_t bufflen) +{ + int ret = 0; + if (!var.isPointer()) { + snprintf(buff, bufflen, "%u", (unsigned int) var.type()->bytes()); + } else { + ret = 1; + const char* lenExpr = var.lenExpression().c_str(); + const char* varname = var.name().c_str(); + if (e != NULL && lenExpr[0] == '\0') { + fprintf(stderr, "%s: data len is undefined for '%s'\n", + e->name().c_str(), varname); + } + if (var.nullAllowed()) { + snprintf(buff, bufflen, "((%s != NULL) ? %s : 0)", varname, lenExpr); + } else { + snprintf(buff, bufflen, "%s", lenExpr); + } + } + return ret; +} + +static int writeVarEncodingSize(Var& var, FILE* fp) +{ + int ret = 0; + if (!var.isPointer()) { + fprintf(fp, "%u", (unsigned int) var.type()->bytes()); + } else { + ret = 1; + fprintf(fp, "__size_%s", var.name().c_str()); + } + return ret; +} + + + +static void writeVarEncodingExpression(Var& var, FILE* fp) +{ + const char* varname = var.name().c_str(); + + if (var.isPointer()) { + // encode a pointer header + fprintf(fp, "\t*(unsigned int *)(ptr) = __size_%s; ptr += 4;\n", varname); + + Var::PointerDir dir = var.pointerDir(); + if (dir == Var::POINTER_INOUT || dir == Var::POINTER_IN) { + if (var.nullAllowed()) { + fprintf(fp, "\tif (%s != NULL) ", varname); + } else { + fprintf(fp, "\t"); + } + + if (var.packExpression().size() != 0) { + fprintf(fp, "%s;", var.packExpression().c_str()); + } else { + fprintf(fp, "memcpy(ptr, %s, __size_%s);", + varname, varname); + } + + fprintf(fp, "ptr += __size_%s;\n", varname); + } + } else { + // encode a non pointer variable + if (!var.isVoid()) { + fprintf(fp, "\t\tmemcpy(ptr, &%s, %u); ptr += %u;\n", + varname, + (unsigned) var.type()->bytes(), + (unsigned) var.type()->bytes()); + } + } +} + +#if WITH_LARGE_SUPPORT +static void writeVarLargeEncodingExpression(Var& var, FILE* fp) +{ + const char* varname = var.name().c_str(); + + fprintf(fp, "\tstream->writeFully(&__size_%s,4);\n", varname); + fprintf(fp, "\tif (useChecksum) checksumCalculator->addBuffer(&__size_%s,4);\n", varname); + if (var.nullAllowed()) { + fprintf(fp, "\tif (%s != NULL) {\n", varname); + } + if (var.writeExpression() != "") { + fprintf(fp, "%s", var.writeExpression().c_str()); + } else { + fprintf(fp, "\t\tstream->writeFully(%s, __size_%s);\n", varname, varname); + fprintf(fp, "\t\tif (useChecksum) checksumCalculator->addBuffer(%s, __size_%s);\n", varname, varname); + } + if (var.nullAllowed()) fprintf(fp, "\t}\n"); +} +#endif /* WITH_LARGE_SUPPORT */ + +static void writeEncodingChecksumValidatorOnReturn(const char* funcName, FILE* fp) { + fprintf(fp, "\tif (useChecksum) {\n" + "\t\tstd::unique_ptr checksumBuf(new unsigned char[checksumSize]);\n" + "\t\tstream->readback(checksumBuf.get(), checksumSize);\n" + "\t\tif (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) {\n" + "\t\t\tALOGE(\"%s: GL communication error, please report this issue to b.android.com.\\n\");\n" + "\t\t\tabort();\n" + "\t\t}\n" + "\t}\n", + funcName + ); +} + +int ApiGen::genEncoderImpl(const std::string &filename) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + + printHeader(fp); + fprintf(fp, "\n\n"); + fprintf(fp, "#include \n"); + fprintf(fp, "#include \n"); + fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str()); + fprintf(fp, "#include \"%s_enc.h\"\n\n\n", m_basename.c_str()); + fprintf(fp, "#include \n\n"); + fprintf(fp, "namespace {\n\n"); + + // unsupport printout + fprintf(fp, + "void enc_unsupported()\n" + "{\n" + "\tALOGE(\"Function is unsupported\\n\");\n" + "}\n\n"); + + // entry points; + std::string classname = m_basename + "_encoder_context_t"; + + size_t n = size(); + for (size_t i = 0; i < n; i++) { + EntryPoint *e = &at(i); + + if (e->unsupported()) continue; + + + e->print(fp, true, "_enc", /* classname + "::" */"", "void *self"); + fprintf(fp, "{\n"); + +// fprintf(fp, "\n\tDBG(\">>>> %s\\n\");\n", e->name().c_str()); + fprintf(fp, "\n\t%s *ctx = (%s *)self;\n", + classname.c_str(), + classname.c_str()); + fprintf(fp, "\tIOStream *stream = ctx->m_stream;\n" + "\tChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;\n" + "\tbool useChecksum = checksumCalculator->getVersion() > 0;\n\n"); + VarsArray & evars = e->vars(); + size_t maxvars = evars.size(); + size_t j; + + char buff[256]; + + // Define the __size_XXX variables that contain the size of data + // associated with pointers. + for (j = 0; j < maxvars; j++) { + Var& var = evars[j]; + + if (!var.isPointer()) + continue; + + const char* varname = var.name().c_str(); + fprintf(fp, "\tconst unsigned int __size_%s = ", varname); + + getVarEncodingSizeExpression(var, e, buff, sizeof(buff)); + fprintf(fp, "%s;\n", buff); + } + + bool hasLargeFields = false; +#if WITH_LARGE_SUPPORT + // We need to take care of 'isLarge' variable in a special way + // Anything before an isLarge variable can be packed into a single + // buffer, which is then commited. Each isLarge variable is a pointer + // to data that can be written to directly through the pipe, which + // will be instant when using a QEMU pipe + + size_t nvars = 0; + size_t npointers = 0; + + // First, compute the total size, 8 bytes for the opcode + payload size (without checksum) + fprintf(fp, "\t unsigned char *ptr;\n"); + fprintf(fp, "\t unsigned char *buf;\n"); + fprintf(fp, "\t const size_t sizeWithoutChecksum = 8"); + + for (j = 0; j < maxvars; j++) { + fprintf(fp, " + "); + npointers += writeVarEncodingSize(evars[j], fp); + } + if (npointers > 0) { + fprintf(fp, " + %zu*4", npointers); + } + fprintf(fp, ";\n"); + + // Then, size of the checksum string + fprintf(fp, "\t const size_t checksumSize = checksumCalculator->checksumByteSize();\n"); + + // And, size of the whole thing + fprintf(fp, "\t const size_t totalSize = sizeWithoutChecksum + checksumSize;\n"); + + // We need to divide the packet into fragments. Each fragment contains + // either copied arguments to a temporary buffer, or direct writes for + // large variables. + // + // The first fragment must also contain the opcode+payload_size+checksum_size + // + nvars = 0; + while (nvars < maxvars || maxvars == 0) { + + // Skip over non-large fields + for (j = nvars; j < maxvars; j++) { + if (evars[j].isLarge()) + break; + } + + // Write a fragment if needed. + if (nvars == 0 || j > nvars) { + const char* plus = ""; + + if (nvars == 0 && j == maxvars) { + // Simple shortcut for the common case where we don't have large variables; + fprintf(fp, "\tbuf = stream->alloc(totalSize);\n"); + + } else { + hasLargeFields = true; + // allocate buffer from the stream until the first large variable + fprintf(fp, "\tbuf = stream->alloc("); + plus = ""; + + if (nvars == 0) { + fprintf(fp,"8"); plus = " + "; + } + if (j > nvars) { + npointers = 0; + for (j = nvars; j < maxvars && !evars[j].isLarge(); j++) { + fprintf(fp, "%s", plus); plus = " + "; + npointers += writeVarEncodingSize(evars[j], fp); + } + if (npointers > 0) { + fprintf(fp, "%s%zu*4", plus, npointers); plus = " + "; + } + } + fprintf(fp,");\n"); + } + fprintf(fp, "\tptr = buf;\n"); + + // encode packet header if needed. + if (nvars == 0) { + fprintf(fp, "\tint tmp = OP_%s;memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); + fprintf(fp, "\tmemcpy(ptr, &totalSize, 4); ptr += 4;\n\n"); + } + + if (maxvars == 0) { + fprintf(fp, "\n\tif (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);\n"); + break; + } + + // encode non-large fields in this fragment + for (j = nvars; j < maxvars && !evars[j].isLarge(); j++) { + writeVarEncodingExpression(evars[j],fp); + } + + fprintf(fp, "\n\tif (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);\n"); + // Ensure the fragment is commited if it is followed by a large variable + if (j < maxvars) { + fprintf(fp, "\tstream->flush();\n"); + } + } + + // If we have one or more large variables, write them directly. + // As size + data + for ( ; j < maxvars && evars[j].isLarge(); j++) { + writeVarLargeEncodingExpression(evars[j], fp); + } + + nvars = j; + } + +#else /* !WITH_LARGE_SUPPORT */ + size_t nvars = evars.size(); + size_t npointers = 0; + fprintf(fp, "\t const size_t sizeWithoutChecksum = 8"); + for (size_t j = 0; j < nvars; j++) { + npointers += getVarEncodingSizeExpression(evars[j],e,buff,sizeof(buff)); + fprintf(fp, " + %s", buff); + } + fprintf(fp, " + %u * 4;\n", (unsigned int) npointers); + // Size of checksum + fprintf(fp, "\t const size_t checksumSize = checksumCalculator->checksumByteSize();\n"); + // Size of the whole thing + fprintf(fp, "\t const size_t totalSize = sizeWithoutChecksum + checksumSize;\n"); + + // allocate buffer from the stream; + fprintf(fp, "\t unsigned char *ptr = stream->alloc(sizeWithoutChecksum);\n\n"); + + // encode into the stream; + fprintf(fp, "\tint tmp = OP_%s; memcpy(ptr, &tmp, 4); ptr += 4;\n", e->name().c_str()); + fprintf(fp, "\tmemcpy(ptr, &sizeWithoutChecksum, 4); ptr += 4;\n\n"); + + // out variables + for (size_t j = 0; j < nvars; j++) { + writeVarEncodingExpression(evars[j], fp); + } +#endif /* !WITH_LARGE_SUPPORT */ + + // checksum + if (hasLargeFields) { + fprintf(fp, "\tbuf = stream->alloc(checksumSize);\n"); + fprintf(fp, "\tif (useChecksum) checksumCalculator->writeChecksum(buf, checksumSize);\n\n"); + } else { + fprintf(fp, "\tif (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;\n\n"); + } + + // in variables; + bool hasReadbackChecksum = false; + for (size_t j = 0; j < nvars; j++) { + if (evars[j].isPointer()) { + Var::PointerDir dir = evars[j].pointerDir(); + if (dir == Var::POINTER_INOUT || dir == Var::POINTER_OUT) { + const char* varname = evars[j].name().c_str(); + const char* indent = "\t"; + if (evars[j].nullAllowed()) { + fprintf(fp, "\tif (%s != NULL) {\n",varname); + indent = "\t\t"; + } + fprintf(fp, "%sstream->readback(%s, __size_%s);\n", + indent, varname, varname); + fprintf(fp, "%sif (useChecksum) checksumCalculator->addBuffer(%s, __size_%s);\n", + indent, varname, varname); + if (evars[j].nullAllowed()) { + fprintf(fp, "\t}\n"); + } + hasReadbackChecksum = true; + } + } + } +//XXX fprintf(fp, "\n\tDBG(\"<<<< %s\\n\");\n", e->name().c_str()); + + // todo - return value for pointers + if (e->retval().isPointer()) { + fprintf(stderr, "WARNING: %s : return value of pointer is unsupported\n", + e->name().c_str()); + if (e->flushOnEncode()) { + fprintf(fp, "\tstream->flush();\n"); + } + fprintf(fp, "\t return NULL;\n"); + } else if (e->retval().type()->name() != "void") { + fprintf(fp, "\n\t%s retval;\n", e->retval().type()->name().c_str()); + fprintf(fp, "\tstream->readback(&retval, %u);\n",(unsigned) e->retval().type()->bytes()); + fprintf(fp, "\tif (useChecksum) checksumCalculator->addBuffer(&retval, %u);\n", + (unsigned) e->retval().type()->bytes()); + writeEncodingChecksumValidatorOnReturn(e->name().c_str(), fp); + fprintf(fp, "\treturn retval;\n"); + } else { + if (e->flushOnEncode()) fprintf(fp, "\tstream->flush();\n"); + if (hasReadbackChecksum) writeEncodingChecksumValidatorOnReturn(e->name().c_str(), fp); + } + fprintf(fp, "}\n\n"); + } + + fprintf(fp, "} // namespace\n\n"); + + // constructor + fprintf(fp, "%s::%s(IOStream *stream, ChecksumCalculator *checksumCalculator)\n{\n", classname.c_str(), classname.c_str()); + fprintf(fp, "\tm_stream = stream;\n"); + fprintf(fp, "\tm_checksumCalculator = checksumCalculator;\n\n"); + + for (size_t i = 0; i < n; i++) { + EntryPoint *e = &at(i); + if (e->unsupported()) { + fprintf(fp, + "\tthis->%s = (%s_%s_proc_t) &enc_unsupported;\n", + e->name().c_str(), + e->name().c_str(), + sideString(CLIENT_SIDE)); + } else { + fprintf(fp, + "\tthis->%s = &%s_enc;\n", + e->name().c_str(), + e->name().c_str()); + } + } + fprintf(fp, "}\n\n"); + + fclose(fp); + return 0; +} + + +int ApiGen::genDecoderHeader(const std::string &filename) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + + printHeader(fp); + std::string classname = m_basename + "_decoder_context_t"; + + fprintf(fp, "\n#ifndef GUARD_%s\n", classname.c_str()); + fprintf(fp, "#define GUARD_%s\n\n", classname.c_str()); + + fprintf(fp, "#include \"IOStream.h\" \n"); + fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(SERVER_SIDE)); + if (strcmp(classname.c_str(), "gles2_decoder_context_t") == 0) { + fprintf(fp, "\n#include \n"); + fprintf(fp, "\n#include \n"); + } + fprintf(fp, "\n#include \"emugl/common/logging.h\"\n"); + + for (size_t i = 0; i < m_decoderHeaders.size(); i++) { + fprintf(fp, "#include %s\n", m_decoderHeaders[i].c_str()); + } + fprintf(fp, "\n"); + + fprintf(fp, "struct %s : public %s_%s_context_t {\n\n", + classname.c_str(), m_basename.c_str(), sideString(SERVER_SIDE)); + fprintf(fp, "\tsize_t decode(void *buf, size_t bufsize, IOStream *stream);\n"); + if (strcmp(classname.c_str(), "gles2_decoder_context_t") == 0){ + fprintf(fp, + "\tvoid freeShader(); \n\ + \tvoid freeProgram(); \n\ + \tstd::map m_programs; \n\ + \tstd::map m_shaders; \n\ + \tstd::mutex m_lock; \n\ + "); + + + } + fprintf(fp, "\n};\n\n"); + fprintf(fp, "#endif // GUARD_%s\n", classname.c_str()); + + fclose(fp); + return 0; +} + +int ApiGen::genContextImpl(const std::string &filename, SideType side) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + printHeader(fp); + + std::string classname = m_basename + "_" + sideString(side) + "_context_t"; + size_t n = size(); + fprintf(fp, "\n\n#include \n"); + fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(side)); + fprintf(fp, "#include \n\n"); + + fprintf(fp, "int %s::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)\n{\n", classname.c_str()); + for (size_t i = 0; i < n; i++) { + EntryPoint *e = &at(i); + fprintf(fp, "\t%s = (%s_%s_proc_t) getProc(\"%s\", userData);\n", + e->name().c_str(), + e->name().c_str(), + sideString(side), + e->name().c_str()); + } + fprintf(fp, "\treturn 0;\n"); + fprintf(fp, "}\n\n"); + fclose(fp); + return 0; +} + +int ApiGen::genDecoderImpl(const std::string &filename) +{ + FILE *fp = fopen(filename.c_str(), "wt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + + printHeader(fp); + + std::string classname = m_basename + "_decoder_context_t"; + + size_t n = size(); + + fprintf(fp, "\n\n#include \n"); + fprintf(fp, "#include \"%s_opcodes.h\"\n\n", m_basename.c_str()); + fprintf(fp, "#include \"%s_dec.h\"\n\n\n", m_basename.c_str()); + fprintf(fp, "#include \"ProtocolUtils.h\"\n\n"); + fprintf(fp, "#include \"ChecksumCalculatorThreadInfo.h\"\n\n"); + fprintf(fp, "#include \n\n"); + fprintf(fp, "typedef unsigned int tsize_t; // Target \"size_t\", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.\n\n"); + + // helper macros + fprintf(fp, "# define DEBUG(...) do { if (emugl_cxt_logger) { emugl_cxt_logger(LogLevel::TRACE, __VA_ARGS__); } } while(0)\n\n"); + + fprintf(fp, + "#ifdef CHECK_GLERROR\n" + "# define SET_LASTCALL(name) sprintf(lastCall, #name)\n" + "#else\n" + "# define SET_LASTCALL(name) ((void)0)\n" + "#endif\n\n"); + + // helper templates + fprintf(fp, "using namespace emugl;\n\n"); + + // glsl shader/program free; + if (strcmp(classname.c_str(), "gles2_decoder_context_t") == 0) { + fprintf(fp, "void %s::freeShader(){\n", classname.c_str()); + fprintf(fp, + " \n\ +\tauto it = m_shaders.begin();\n\ +\tm_lock.lock();\n\ +\twhile(it != m_shaders.end()) \n\ +\t{\n\ +\t\tthis->glDeleteShader(it->first);\n\ +\t\tit++;\n\ +\t}\n\ +\tm_lock.unlock();\n\ +}\n\n"); + + fprintf(fp, "void %s::freeProgram(){\n", classname.c_str()); + fprintf(fp, + " \n\ +\tauto it = m_programs.begin(); \n\ +\tm_lock.lock();\n\ +\twhile(it != m_programs.end()) \n\ +\t{\n\ +\t\tthis->glDeleteProgram(it->first);\n\ +\t\tit++;\n\ +\t}\n\ +\tm_lock.unlock();\n\ +}\n\n"); + } + + // decoder switch; + fprintf(fp, "size_t %s::decode(void *buf, size_t len, IOStream *stream)\n{\n", classname.c_str()); + fprintf(fp, + " \n\ +\tsize_t pos = 0;\n\ +\tif (len < 8) return pos; \n\ +\tunsigned char *ptr = (unsigned char *)buf;\n\ +\tbool unknownOpcode = false; \n\ +#ifdef CHECK_GL_ERROR \n\ +\tchar lastCall[256] = {0}; \n\ +#endif \n\ +\twhile ((len - pos >= 8) && !unknownOpcode) { \n\ +\t\tuint32_t opcode = *(uint32_t *)ptr; \n\ +\t\tsize_t packetLen = *(uint32_t *)(ptr + 4);\n\ +\t\tif (len - pos < packetLen) return pos; \n\ +\t\tbool useChecksum = ChecksumCalculatorThreadInfo::getVersion() > 0;\n\ +\t\tsize_t checksumSize = 0;\n\ +\t\tif (useChecksum) {\n\ +\t\t\tchecksumSize = ChecksumCalculatorThreadInfo::checksumByteSize();\n\ +\t\t}\n\ +\t\tswitch(opcode) {\n"); + + for (size_t f = 0; f < n; f++) { + enum Pass_t { + PASS_FIRST = 0, + PASS_VariableDeclarations = PASS_FIRST, + PASS_Protocol, + PASS_TmpBuffAlloc, + PASS_MemAlloc, + PASS_DebugPrint, + PASS_FunctionCall, + PASS_FlushOutput, + PASS_Epilog, + PASS_LAST }; + EntryPoint *e = &at(f); + + // construct a printout string; + std::string printString = ""; + for (size_t i = 0; i < e->vars().size(); i++) { + Var *v = &e->vars()[i]; + if (!v->isVoid()) printString += (v->isPointer() ? "%p(%u)" : v->type()->printFormat()) + " "; + } + printString += ""; + // TODO - add for return value; + + fprintf(fp, "\t\tcase OP_%s: {\n", e->name().c_str()); + + bool totalTmpBuffExist = false; + std::string totalTmpBuffOffset = "0"; + std::string *tmpBufOffset = new std::string[e->vars().size()]; + + // construct retval type string + std::string retvalType; + if (!e->retval().isVoid()) { + retvalType = e->retval().type()->name(); + } + + for (int pass = PASS_FIRST; pass < PASS_LAST; pass++) { + if (pass == PASS_FunctionCall && + !e->retval().isVoid() && + !e->retval().isPointer()) { + fprintf(fp, "\t\t\t*(%s *)(&tmpBuf[%s]) = ", retvalType.c_str(), + totalTmpBuffOffset.c_str()); + } + + + if (pass == PASS_FunctionCall) { + fprintf(fp, "\t\t\tthis->%s(", e->name().c_str()); + if (e->customDecoder()) { + fprintf(fp, "this"); // add a context to the call + } + } else if (pass == PASS_DebugPrint) { + fprintf(fp, + "\t\t\tDEBUG(\"%s(%%p): %s(%s)\", stream", + m_basename.c_str(), + e->name().c_str(), + printString.c_str()); + if (e->vars().size() > 0 && !e->vars()[0].isVoid()) { + fprintf(fp, ","); + } + } + + std::string varoffset = "8"; // skip the header + VarsArray & evars = e->vars(); + // allocate memory for out pointers; + for (size_t j = 0; j < evars.size(); j++) { + Var *v = & evars[j]; + if (v->isVoid()) { + continue; + } + const char* var_name = v->name().c_str(); + const char* var_type_name = v->type()->name().c_str(); + const unsigned var_type_bytes = v->type()->bytes(); + + if ((pass == PASS_FunctionCall) && + (j != 0 || e->customDecoder())) { + fprintf(fp, ", "); + } + if (pass == PASS_DebugPrint && j != 0) { + fprintf(fp, ", "); + } + + if (!v->isPointer()) { + if (pass == PASS_VariableDeclarations) { + fprintf(fp, + "\t\t\t%s var_%s = Unpack<%s,uint%u_t>(ptr + %s);\n", + var_type_name, + var_name, + var_type_name, + var_type_bytes * 8U, + varoffset.c_str()); + } + + if (pass == PASS_FunctionCall || + pass == PASS_DebugPrint) { + fprintf(fp, "var_%s", var_name); + } + varoffset += " + " + toString(var_type_bytes); + continue; + } + + if (pass == PASS_VariableDeclarations) { + fprintf(fp, + "\t\t\tuint32_t size_%s __attribute__((unused)) = Unpack(ptr + %s);\n", + var_name, + varoffset.c_str()); + } + + if (v->pointerDir() == Var::POINTER_IN || + v->pointerDir() == Var::POINTER_INOUT) { + if (pass == PASS_VariableDeclarations) { +#if USE_ALIGNED_BUFFERS + fprintf(fp, + "\t\t\tInputBuffer inptr_%s(ptr + %s + 4, size_%s);\n", + var_name, + varoffset.c_str(), + var_name); + } + if (pass == PASS_FunctionCall) { + if (v->nullAllowed()) { + fprintf(fp, + "size_%s == 0 ? NULL : (%s)(inptr_%s.get())", + var_name, + var_type_name, + var_name); + } else { + fprintf(fp, + "(%s)(inptr_%s.get())", + var_type_name, + var_name); + } + } else if (pass == PASS_DebugPrint) { + fprintf(fp, + "(%s)(inptr_%s.get()), size_%s", + var_type_name, + var_name, + var_name); + } +#else // !USE_ALIGNED_BUFFERS + fprintf(fp, + "unsigned char *inptr_%s = (ptr + %s + 4);\n", + var_name, + varoffset.c_str()); + } + if (pass == PASS_FunctionCall) { + if (v->nullAllowed()) { + fprintf(fp, + "size_%s == 0 ? NULL : (%s)(inptr_%s)", + var_name, + var_type_name, + var_name); + } else { + fprintf(fp, + "(%s)(inptr_%s)", + var_type_name, + var_name); + } + } else if (pass == PASS_DebugPrint) { + fprintf(fp, + "(%s)(inptr_%s), size_%s", + var_type_name, + var_name, + var_name); + } +#endif // !USE_ALIGNED_BUFFERS + varoffset += " + 4 + size_"; + varoffset += var_name; + } else { // out pointer; + if (pass == PASS_TmpBuffAlloc) { + if (!totalTmpBuffExist) { + fprintf(fp, + "\t\t\tsize_t totalTmpSize = size_%s;\n", + var_name); + } else { + fprintf(fp, + "\t\t\ttotalTmpSize += size_%s;\n", + var_name); + } + tmpBufOffset[j] = totalTmpBuffOffset; + totalTmpBuffOffset += " + size_"; + totalTmpBuffOffset += var_name; + totalTmpBuffExist = true; + } else if (pass == PASS_MemAlloc) { +#if USE_ALIGNED_BUFFERS + fprintf(fp, + "\t\t\tOutputBuffer outptr_%s(&tmpBuf[%s], size_%s);\n", + var_name, + tmpBufOffset[j].c_str(), + var_name); + } else if (pass == PASS_FunctionCall) { + if (v->nullAllowed()) { + fprintf(fp, + "size_%s == 0 ? NULL : (%s)(outptr_%s.get())", + var_name, + var_type_name, + var_name); + } else { + fprintf(fp, + "(%s)(outptr_%s.get())", + var_type_name, + var_name); + } + } else if (pass == PASS_DebugPrint) { + fprintf(fp, + "(%s)(outptr_%s.get()), size_%s", + var_type_name, + var_name, + var_name); + } + if (pass == PASS_FlushOutput) { + fprintf(fp, + "\t\t\toutptr_%s.flush();\n", + var_name); + } +#else // !USE_ALIGNED_BUFFERS + fprintf(fp, + "\t\t\tunsigned char *outptr_%s = &tmpBuf[%s];\n", + var_name, + tmpBufOffset[j].c_str()); + fprintf(fp, + "\t\t\tmemset(outptr_%s, 0, %s);\n", + var_name, + toString(v->type()->bytes()).c_str()); + } else if (pass == PASS_FunctionCall) { + if (v->nullAllowed()) { + fprintf(fp, + "size_%s == 0 ? NULL : (%s)(outptr_%s)", + var_name, + var_type_name, + var_name); + } else { + fprintf(fp, + "(%s)(outptr_%s)", + var_type_name, + var_name); + } + } else if (pass == PASS_DebugPrint) { + fprintf(fp, + "(%s)(outptr_%s), size_%s", + var_type_name, + var_name, + varoffset.c_str()); + } +#endif // !USE_ALIGNED_BUFFERS + varoffset += " + 4"; + } + } + + if (pass == PASS_Protocol) { + fprintf(fp, + "\t\t\tif (useChecksum) {\n" + "\t\t\t\tChecksumCalculatorThreadInfo::validOrDie(ptr, %s, " + "ptr + %s, checksumSize, " + "\n\t\t\t\t\t\"%s::decode," + " OP_%s: GL checksumCalculator failure\\n\");\n" + "\t\t\t}\n", + varoffset.c_str(), + varoffset.c_str(), + varoffset.c_str(), + classname.c_str() + ); + + varoffset += " + 4"; + } + + if (pass == PASS_FunctionCall || + pass == PASS_DebugPrint) { + fprintf(fp, ");\n"); + } + + if (pass == PASS_TmpBuffAlloc) { + if (!e->retval().isVoid() && !e->retval().isPointer()) { + if (!totalTmpBuffExist) + fprintf(fp, + "\t\t\tsize_t totalTmpSize = sizeof(%s);\n", + retvalType.c_str()); + else + fprintf(fp, + "\t\t\ttotalTmpSize += sizeof(%s);\n", + retvalType.c_str()); + + totalTmpBuffExist = true; + } + if (totalTmpBuffExist) { + fprintf(fp, + "\t\t\ttotalTmpSize += checksumSize;\n" + "\t\t\tunsigned char *tmpBuf = stream->alloc(totalTmpSize);\n"); + } + } + + if (pass == PASS_Epilog) { + // send back out pointers data as well as retval + if (totalTmpBuffExist) { + fprintf(fp, + "\t\t\tif (useChecksum) {\n" + "\t\t\t\tChecksumCalculatorThreadInfo::writeChecksum(" + "&tmpBuf[0], totalTmpSize - checksumSize, " + "&tmpBuf[totalTmpSize - checksumSize], checksumSize);\n" + "\t\t\t}\n" + "\t\t\tstream->flush();\n"); + } + } + + } // pass; + fprintf(fp, "\t\t\tSET_LASTCALL(\"%s\");\n", e->name().c_str()); + if (strcmp(m_basename.c_str(), "gles2") == 0) { + if (strcmp(e->name().c_str(), "glAttachShader") == 0){ + fprintf(fp, "\n\ + \t\t\tm_lock.lock();\n\ + m_shaders.insert({var_shader, 1});\n\ + m_lock.unlock();\n"); + } else if(strcmp(e->name().c_str(), "glDeleteProgram") == 0){ + fprintf(fp, + "\t\t\tm_lock.lock(); \n" + "\t\t\tauto pro = m_programs.find(var_program); \n" + "\t\t\tif (pro != m_programs.end()) \n" + "\t\t\t{ \n" + "\t\t\t\tm_programs.erase(pro); \n" + "\t\t\t}\n" + "\t\t\tm_lock.unlock();\n"); + } else if(strcmp(e->name().c_str(), "glDeleteShader") == 0){ + fprintf(fp, + "\t\t\tm_lock.lock(); \n\ + \t\t\tauto shader = m_shaders.find(var_shader); \n\ + \t\t\tif (shader != m_shaders.end()) \n\ + \t\t\t{ \n\ + \t\t\t\tm_shaders.erase(shader); \n\ + \t\t\t} \n\ + \t\t\tm_lock.unlock(); \n"); + } else if(strcmp(e->name().c_str(), "glLinkProgram") == 0){ + fprintf(fp, " \n\ + \t\t\tm_lock.lock();\n\ + \t\t\tm_programs.insert({var_program, 1});\n\ + \t\t\tm_lock.unlock();\n"); + } + } + fprintf(fp, "\t\t\tbreak;\n"); + fprintf(fp, "\t\t}\n"); + + delete [] tmpBufOffset; + } + fprintf(fp, "\t\t\tdefault:\n"); + fprintf(fp, "\t\t\t\tunknownOpcode = true;\n"); + fprintf(fp, "\t\t} //switch\n"); + if (strstr(m_basename.c_str(), "gl")) { + fprintf(fp, "#ifdef CHECK_GL_ERROR\n"); + fprintf(fp, "\tint err = lastCall[0] ? this->glGetError() : GL_NO_ERROR;\n"); + fprintf(fp, "\tif (err) fprintf(stderr, \"%s Error: 0x%%X in %%s\\n\", err, lastCall);\n", m_basename.c_str()); + fprintf(fp, "#endif\n"); + } + + fprintf(fp, "\t\tif (!unknownOpcode) {\n"); + fprintf(fp, "\t\t\tpos += packetLen;\n"); + fprintf(fp, "\t\t\tptr += packetLen;\n"); + fprintf(fp, "\t\t}\n"); + fprintf(fp, "\t} // while\n"); + fprintf(fp, "\treturn pos;\n"); + fprintf(fp, "}\n"); + + fclose(fp); + return 0; +} + +int ApiGen::readSpec(const std::string & filename) +{ + FILE *specfp = fopen(filename.c_str(), "rt"); + if (specfp == NULL) { + return -1; + } + + char line[1000]; + unsigned int lc = 0; + while (fgets(line, sizeof(line), specfp) != NULL) { + lc++; + EntryPoint ref; + if (ref.parse(lc, std::string(line))) { + push_back(ref); + updateMaxEntryPointsParams(ref.vars().size()); + } + } + fclose(specfp); + return 0; +} + +int ApiGen::readAttributes(const std::string & attribFilename) +{ + enum { ST_NAME, ST_ATT } state; + + FILE *fp = fopen(attribFilename.c_str(), "rt"); + if (fp == NULL) { + perror(attribFilename.c_str()); + return -1; + } + char buf[1000]; + + state = ST_NAME; + EntryPoint *currentEntry = NULL; + size_t lc = 0; + bool globalAttributes = false; + while (fgets(buf, sizeof(buf), fp) != NULL) { + lc++; + std::string line(buf); + if (line.size() == 0) continue; // could that happen? + + if (line.at(0) == '#') continue; // comment + + size_t first = line.find_first_not_of(" \t\n"); + if (state == ST_ATT && (first == std::string::npos || first == 0)) state = ST_NAME; + + line = trim(line); + if (line.size() == 0 || line.at(0) == '#') continue; + + switch(state) { + case ST_NAME: + if (line == "GLOBAL") { + globalAttributes = true; + } else { + globalAttributes = false; + currentEntry = findEntryByName(line); + if (currentEntry == NULL) { + fprintf(stderr, "WARNING: %u: attribute of non existant entry point %s\n", (unsigned int)lc, line.c_str()); + } + } + state = ST_ATT; + break; + case ST_ATT: + if (globalAttributes) { + setGlobalAttribute(line, lc); + } else if (currentEntry != NULL) { + currentEntry->setAttribute(line, lc); + } + break; + } + } + return 0; +} + + +int ApiGen::setGlobalAttribute(const std::string & line, size_t lc) +{ + size_t pos = 0; + size_t last; + std::string token = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + + if (token == "base_opcode") { + std::string str = getNextToken(line, pos, &last, WHITESPACE); + if (str.size() == 0) { + fprintf(stderr, "line %u: missing value for base_opcode\n", (unsigned) lc); + } else { + setBaseOpcode(atoi(str.c_str())); + } + } else if (token == "encoder_headers") { + std::string str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + while (str.size() != 0) { + encoderHeaders().push_back(str); + str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + } + } else if (token == "client_context_headers") { + std::string str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + while (str.size() != 0) { + clientContextHeaders().push_back(str); + str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + } + } else if (token == "server_context_headers") { + std::string str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + while (str.size() != 0) { + serverContextHeaders().push_back(str); + str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + } + } else if (token == "decoder_headers") { + std::string str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + while (str.size() != 0) { + decoderHeaders().push_back(str); + str = getNextToken(line, pos, &last, WHITESPACE); + pos = last; + } + } + else { + fprintf(stderr, "WARNING: %u : unknown global attribute %s\n", (unsigned int)lc, line.c_str()); + } + + return 0; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.h new file mode 100644 index 0000000..8ba18af --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/ApiGen.h @@ -0,0 +1,97 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __API_GEN_H_ +#define __API_GEN_H_ + +#include +#include +#include "EntryPoint.h" + + +class ApiGen : public std::vector { + +public: + typedef std::vector StringVec; + typedef enum { CLIENT_SIDE, SERVER_SIDE, WRAPPER_SIDE } SideType; + + ApiGen(const std::string & basename) : + m_basename(basename), + m_maxEntryPointsParams(0), + m_baseOpcode(0) + { } + virtual ~ApiGen() {} + int readSpec(const std::string & filename); + int readAttributes(const std::string & attribFilename); + size_t maxEntryPointsParams() { return m_maxEntryPointsParams; } + void updateMaxEntryPointsParams(size_t val) { + if (m_maxEntryPointsParams == 0 || val > m_maxEntryPointsParams) m_maxEntryPointsParams = val; + } + int baseOpcode() { return m_baseOpcode; } + void setBaseOpcode(int base) { m_baseOpcode = base; } + + const char *sideString(SideType side) { + const char *retval; + switch(side) { + case CLIENT_SIDE: + retval = "client"; + break; + case SERVER_SIDE: + retval = "server"; + break; + case WRAPPER_SIDE: + retval = "wrapper"; + break; + default: + retval = "unknown"; + } + return retval; + } + + StringVec & clientContextHeaders() { return m_clientContextHeaders; } + StringVec & encoderHeaders() { return m_encoderHeaders; } + StringVec & serverContextHeaders() { return m_serverContextHeaders; } + StringVec & decoderHeaders() { return m_decoderHeaders; } + + EntryPoint * findEntryByName(const std::string & name); + int genOpcodes(const std::string &filename); + int genAttributesTemplate(const std::string &filename); + int genProcTypes(const std::string &filename, SideType side); + int genFuncTable(const std::string &filename, SideType side); + + int genContext(const std::string &filename, SideType side); + int genContextImpl(const std::string &filename, SideType side); + + int genEntryPoints(const std::string &filename, SideType side); + + int genEncoderHeader(const std::string &filename); + int genEncoderImpl(const std::string &filename); + + int genDecoderHeader(const std::string &filename); + int genDecoderImpl(const std::string &filename); + +protected: + virtual void printHeader(FILE *fp) const; + std::string m_basename; + StringVec m_clientContextHeaders; + StringVec m_encoderHeaders; + StringVec m_serverContextHeaders; + StringVec m_decoderHeaders; + size_t m_maxEntryPointsParams; // record the maximum number of parameters in the entry points; + int m_baseOpcode; + int setGlobalAttribute(const std::string & line, size_t lc); +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/CMakeLists.txt new file mode 100644 index 0000000..8285126 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/CMakeLists.txt @@ -0,0 +1,13 @@ +if (NOT "${HOST_CMAKE_CXX_COMPILER}" STREQUAL "") + set (CMAKE_CXX_COMPILER "${HOST_CMAKE_CXX_COMPILER}") +endif() + +set(SOURCES + ApiGen.cpp + EntryPoint.cpp + main.cpp + Parser.cpp + strUtils.cpp + TypeFactory.cpp) + +add_executable(emugen ${SOURCES}) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.cpp new file mode 100644 index 0000000..8f91c83 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.cpp @@ -0,0 +1,349 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "EntryPoint.h" + +#include "Parser.h" +#include "TypeFactory.h" +#include "strUtils.h" + +#include +#include + +#include + +EntryPoint::EntryPoint() +{ + reset(); +} + +EntryPoint::~EntryPoint() +{ +} + +void EntryPoint::reset() +{ + m_unsupported = false; + m_customDecoder = false; + m_notApi = false; + m_flushOnEncode = false; + m_vars.empty(); +} + +// return true for valid line (need to get into the entry points list) +bool EntryPoint::parse(unsigned int lc, const std::string & str) +{ + size_t pos, last; + std::string field; + + reset(); + std::string linestr = trim(str); + + if (linestr.size() == 0) return false; + if (linestr.at(0) == '#') return false; + + // skip PREFIX + field = getNextToken(linestr, 0, &last, "("); + pos = last + 1; + // return type + field = getNextToken(linestr, pos, &last, ",)"); + + std::string error; + std::string retTypeName; + if (!parseTypeDeclaration(field, &retTypeName, &error)) { + fprintf(stderr, + "line: %d: Parsing error in field <%s>: %s\n", + lc, + field.c_str(), + error.c_str()); + return false; + } + pos = last + 1; + const VarType *theType = TypeFactory::instance()->getVarTypeByName(retTypeName); + if (theType->name() == "UNKNOWN") { + fprintf(stderr, "UNKNOWN retval: %s\n", linestr.c_str()); + } + + m_retval.init(std::string(""), + theType, + std::string(""), + Var::POINTER_OUT, + std::string(""), + std::string("")); + + // function name + m_name = getNextToken(linestr, pos, &last, ",)"); + pos = last + 1; + + // parameters; + int nvars = 0; + while (pos < linestr.size() - 1) { + field = getNextToken(linestr, pos, &last, ",)"); + if (field == "void") { + // 'void' is used as a special case for functions that don't take + // parameters at all. + break; + } + std::string vartype, varname; + if (!parseParameterDeclaration(field, &vartype, &varname, &error)) { + fprintf(stderr, + "line: %d: Parsing error in field <%s>, error: %s\n", + lc, + field.c_str(), + error.c_str()); + return false; + } + nvars++; + const VarType *v = TypeFactory::instance()->getVarTypeByName(vartype); + if (v->id() == 0) { + fprintf(stderr, "%d: Unknown type: %s\n", lc, vartype.c_str()); + } else { + if (varname == "" && + !(v->name() == "void" && !v->isPointer())) { + std::ostringstream oss; + oss << "var" << nvars; + varname = oss.str(); + } + + m_vars.push_back(Var(varname, v, std::string(""), Var::POINTER_IN, "", "")); + } + pos = last + 1; + } + return true; +} + +void EntryPoint::print(FILE *fp, bool newline, + const std::string & name_suffix, + const std::string & name_prefix, + const std::string & ctx_param ) const +{ + fprintf(fp, "%s %s%s%s(", + m_retval.type()->name().c_str(), + name_prefix.c_str(), + m_name.c_str(), + name_suffix.c_str()); + + if (ctx_param != "") fprintf(fp, "%s ", ctx_param.c_str()); + + for (size_t i = 0; i < m_vars.size(); i++) { + if (m_vars[i].isVoid()) continue; + if (i != 0 || ctx_param != "") fprintf(fp, ", "); + fprintf(fp, "%s %s", m_vars[i].type()->name().c_str(), + m_vars[i].name().c_str()); + } + fprintf(fp, ")%s", newline? "\n" : ""); +} + +Var * EntryPoint::var(const std::string & name) +{ + Var *v = NULL; + for (size_t i = 0; i < m_vars.size(); i++) { + if (m_vars[i].name() == name) { + v = &m_vars[i]; + break; + } + } + return v; +} + +bool EntryPoint::hasPointers() +{ + bool pointers = false; + if (m_retval.isPointer()) pointers = true; + if (!pointers) { + for (size_t i = 0; i < m_vars.size(); i++) { + if (m_vars[i].isPointer()) { + pointers = true; + break; + } + } + } + return pointers; +} + +int EntryPoint::setAttribute(const std::string &line, size_t lc) +{ + size_t pos = 0; + size_t last; + std::string token = getNextToken(line, 0, &last, WHITESPACE); + + if (token == "len") { + pos = last; + std::string varname = getNextToken(line, pos, &last, WHITESPACE); + + if (varname.size() == 0) { + fprintf(stderr, "ERROR: %u: Missing variable name in 'len' attribute\n", (unsigned int)lc); + return -1; + } + Var * v = var(varname); + if (v == NULL) { + fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", + (unsigned int)lc, varname.c_str(), name().c_str()); + return -2; + } + // set the size expression into var + pos = last; + v->setLenExpression(line.substr(pos)); + } else if (token == "param_check") { + pos = last; + std::string varname = getNextToken(line, pos, &last, WHITESPACE); + + if (varname.size() == 0) { + fprintf(stderr, "ERROR: %u: Missing variable name in 'param_check' attribute\n", (unsigned int)lc); + return -1; + } + Var * v = var(varname); + if (v == NULL) { + fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", + (unsigned int)lc, varname.c_str(), name().c_str()); + return -2; + } + // set the size expression into var + pos = last; + v->setParamCheckExpression(line.substr(pos)); + + } else if (token == "dir") { + pos = last; + std::string varname = getNextToken(line, pos, &last, WHITESPACE); + if (varname.size() == 0) { + fprintf(stderr, "ERROR: %u: Missing variable name in 'dir' attribute\n", (unsigned int)lc); + return -1; + } + Var * v = var(varname); + if (v == NULL) { + fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", + (unsigned int)lc, varname.c_str(), name().c_str()); + return -2; + } + + pos = last; + std::string pointerDirStr = getNextToken(line, pos, &last, WHITESPACE); + if (pointerDirStr.size() == 0) { + fprintf(stderr, "ERROR: %u: missing pointer directions\n", (unsigned int)lc); + return -3; + } + + if (pointerDirStr == "out") { + v->setPointerDir(Var::POINTER_OUT); + } else if (pointerDirStr == "inout") { + v->setPointerDir(Var::POINTER_INOUT); + } else if (pointerDirStr == "in") { + v->setPointerDir(Var::POINTER_IN); + } else { + fprintf(stderr, "ERROR: %u: unknow pointer direction %s\n", (unsigned int)lc, pointerDirStr.c_str()); + } + } else if (token == "var_flag") { + pos = last; + std::string varname = getNextToken(line, pos, &last, WHITESPACE); + if (varname.size() == 0) { + fprintf(stderr, "ERROR: %u: Missing variable name in 'var_flag' attribute\n", (unsigned int)lc); + return -1; + } + Var * v = var(varname); + if (v == NULL) { + fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", + (unsigned int)lc, varname.c_str(), name().c_str()); + return -2; + } + int count = 0; + for (;;) { + pos = last; + std::string flag = getNextToken(line, pos, &last, WHITESPACE); + if (flag.size() == 0) { + if (count == 0) { + fprintf(stderr, "ERROR: %u: missing flag\n", (unsigned int) lc); + return -3; + } + break; + } + count++; + + if (flag == "nullAllowed") { + if (v->isPointer()) { + v->setNullAllowed(true); + } else { + fprintf(stderr, "WARNING: %u: setting nullAllowed for non-pointer variable %s\n", + (unsigned int) lc, v->name().c_str()); + } + } else if (flag == "isLarge") { + if (v->isPointer()) { + v->setIsLarge(true); + } else { + fprintf(stderr, "WARNING: %u: setting isLarge flag for a non-pointer variable %s\n", + (unsigned int) lc, v->name().c_str()); + } + } else { + fprintf(stderr, "WARNING: %u: unknow flag %s\n", (unsigned int)lc, flag.c_str()); + } + } + } else if (token == "custom_pack") { + pos = last; + std::string varname = getNextToken(line, pos, &last, WHITESPACE); + + if (varname.size() == 0) { + fprintf(stderr, "ERROR: %u: Missing variable name in 'custom_pack' attribute\n", (unsigned int)lc); + return -1; + } + Var * v = var(varname); + if (v == NULL) { + fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", + (unsigned int)lc, varname.c_str(), name().c_str()); + return -2; + } + // set the size expression into var + pos = last; + v->setPackExpression(line.substr(pos)); + } else if (token == "custom_write") { + pos = last; + std::string varname = getNextToken(line, pos, &last, WHITESPACE); + + if (varname.size() == 0) { + fprintf(stderr, "ERROR: %u: Missing variable name in 'custom_write' attribute\n", (unsigned int)lc); + return -1; + } + Var * v = var(varname); + if (v == NULL) { + fprintf(stderr, "ERROR: %u: variable %s is not a parameter of %s\n", + (unsigned int)lc, varname.c_str(), name().c_str()); + return -2; + } + // set the size expression into var + pos = last; + v->setWriteExpression(line.substr(pos)); + } else if (token == "flag") { + pos = last; + std::string flag = getNextToken(line, pos, &last, WHITESPACE); + if (flag.size() == 0) { + fprintf(stderr, "ERROR: %u: missing flag\n", (unsigned int) lc); + return -4; + } + + if (flag == "unsupported") { + setUnsupported(true); + } else if (flag == "custom_decoder") { + setCustomDecoder(true); + } else if (flag == "not_api") { + setNotApi(true); + } else if (flag == "flushOnEncode") { + setFlushOnEncode(true); + } else { + fprintf(stderr, "WARNING: %u: unknown flag %s\n", (unsigned int)lc, flag.c_str()); + } + } else { + fprintf(stderr, "WARNING: %u: unknown attribute %s\n", (unsigned int)lc, token.c_str()); + } + + return 0; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.h new file mode 100644 index 0000000..1061d25 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/EntryPoint.h @@ -0,0 +1,70 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __EntryPoint__H__ +#define __EntryPoint__H__ + +#include +#include +#include + +#include "Var.h" + +//--------------------------------------------------- + +typedef std::vector VarsArray; + +class EntryPoint { +public: + EntryPoint(); + virtual ~EntryPoint(); + bool parse(unsigned int lc, const std::string & str); + void reset(); // reset the class to empty; + void print(FILE *fp = stdout, bool newline = true, + const std::string & name_suffix = std::string(""), + const std::string & name_prefix = std::string(""), + const std::string & ctx_param = std::string("")) const; + const std::string & name() const { return m_name; } + VarsArray & vars() { return m_vars; } + Var & retval() { return m_retval; } + Var * var(const std::string & name); + bool hasPointers(); + bool unsupported() const { return m_unsupported; } + void setUnsupported(bool state) { m_unsupported = state; } + bool customDecoder() { return m_customDecoder; } + void setCustomDecoder(bool state) { m_customDecoder = state; } + bool notApi() const { return m_notApi; } + void setNotApi(bool state) { m_notApi = state; } + bool flushOnEncode() const { return m_flushOnEncode; } + void setFlushOnEncode(bool state) { m_flushOnEncode = state; } + int setAttribute(const std::string &line, size_t lc); + +private: + enum { PR_RETVAL = 0, PR_NAME, PR_VARS, PR_DONE } prState; + std::string m_name; + Var m_retval; + VarsArray m_vars; + bool m_unsupported; + bool m_customDecoder; + bool m_notApi; + bool m_flushOnEncode; + + void err(unsigned int lc, const char *msg) { + fprintf(stderr, "line %d: %s\n", lc, msg); + } +}; + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.cpp new file mode 100644 index 0000000..0839f20 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.cpp @@ -0,0 +1,191 @@ +/* +* Copyright 2014 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "Parser.h" + +#include + +#define WHITESPACE " \t\n" + +// Parse the |input| string as a list of type-specific tokens. +// This tokenizes the input, using whitespace as separators and '*' as +// a single token too. On success, return true and sets |*out| to the +// list of tokens. On failure, return false. +// +// Example: 'const char**foo' -> ['const', 'char', '*', '*', 'foo'] +// +static bool parseTypeTokens(const std::string& input, + std::vector* out, + std::string* error) { + out->clear(); + size_t pos = 0U; + + // Parse all tokens in the input, treat '*' as a single token. + // I.e. + for (;;) { + // skip leading whitespace. + pos = input.find_first_not_of(WHITESPACE, pos); + if (pos == std::string::npos) { + break; // end of parse. + } + + // If this is a star, ensure it follows a type name. + // otherwise treat it as part of the final type. + if (input[pos] == '*') { + out->push_back(std::string("*")); + pos += 1U; + continue; + } + + // find end of type/token. + size_t end = input.find_first_of(WHITESPACE "*", pos); + if (end == std::string::npos) { + end = input.size(); + } + + std::string str = input.substr(pos, end - pos); + if (str.size() == 0) { + // Sanity check: should not happen. + if (error != NULL) { + *error = "Unexpected empty token !?"; + } + return false; + } + + out->push_back(str); + pos = end; + } + + if (error != NULL) { + // Sanity check: require non-empty input + if (out->empty()) { + *error = "Empty parameter declaration!"; + return false; + } + + // Sanity check: There must be base type name before any '*' + for (size_t n = 0; n < out->size(); ++n) { + std::string& token = (*out)[n]; + if (token == "*") { + *error = "Unexpected '*' before type name"; + return false; + } else if (token != "const") { + break; + } + } + } + + return true; +} + +// Given |tokens|, an input vector of strings, join the first |count| items +// into a normalized type string, and return it. +static std::string buildTypeString(const std::vector& tokens, + size_t count) { + std::string result; + + for (size_t n = 0; n < count; ++n) { + const std::string& token = tokens[n]; + if (n > 0 && token != "*") { + result.append(" "); + } + result.append(token); + } + return result; +} + + +std::string normalizeTypeDeclaration(const std::string& input) { + std::vector tokens; + if (!parseTypeTokens(input, &tokens, NULL)) { + return ""; + } + return buildTypeString(tokens, tokens.size()); +} + +bool parseTypeDeclaration(const std::string& input, + std::string* typeName, + std::string* error) { + // The type name can be made of several tokens, e.g. 'unsigned int' + // use an array to store them, and a count variable. Each item can be + // one of '*', 'const' or a type name component (e.g. 'struct', 'unsigned') + std::vector tokens; + + if (!parseTypeTokens(input, &tokens, error)) { + return false; + } + + // Sanity check, there must be a least one non-special tokens. + size_t nonSpecialCount = 0; + for (size_t n = 0; n < tokens.size(); ++n) { + if (tokens[n] != "*" && tokens[n] != "const") { + nonSpecialCount++; + } + } + if (nonSpecialCount == 0) { + *error = "Missing type name"; + return false; + } + // Build the type name from all tokens before it. + *typeName = buildTypeString(tokens, tokens.size()); + return true; +} + + +bool parseParameterDeclaration(const std::string& param, + std::string* typeName, + std::string* variableName, + std::string* error) { + std::vector tokens; + + if (!parseTypeTokens(param, &tokens, error)) { + return false; + } + + // Sanity check, there must be a least two non-special tokens. + size_t nonSpecialCount = 0; + for (size_t n = 0; n < tokens.size(); ++n) { + if (tokens[n] != "*" && tokens[n] != "const") { + nonSpecialCount++; + } + } + if (nonSpecialCount == 0) { + *error = "Missing type name"; + return false; + } + if (nonSpecialCount == 1) { + *error = "Missing variable name"; + return false; + } + + // Sanity check: variable name must not be followed by 'const' or '*' + const std::string& lastToken = tokens[tokens.size() - 1U]; + if (lastToken == "*") { + *error = "Extra '*' after variable name"; + return false; + } + if (lastToken == "const") { + *error = "Extra 'const' after variable name"; + return false; + } + + // Extract the variable name as the last token. + if (variableName) { + *variableName = lastToken; + } + // Build the type name from all tokens before it. + *typeName = buildTypeString(tokens, tokens.size() - 1U); + return true; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.h new file mode 100644 index 0000000..f62c076 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser.h @@ -0,0 +1,68 @@ +/* +* Copyright 2014 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef PARSER_H +#define PARSER_H + +#include + +// Normalize a type declaration. This gets rid of leading/trailing whitespace +// as well as ensure there is a single space separating all input tokens, +// with the exception of '*' which is treated specially by never being +// prepended with a space. +// |input| is the input type declaration. Return normalized form. +// Note that this doesn't try to validate the input. +std::string normalizeTypeDeclaration(const std::string& input); + +// Parse a return type declaration. |input| is the type declaration +// (e.g. 'const char**'). On success return true and sets |*typeName| to +// the appropriate normalized type string. On failure, return false and +// sets |*error| with a human-friendly message explaining the reason for +// failure. +// +// Note that the returned type string is normalized, see comment for +// parseParameterDeclaration() for examples. +// +// NOTE: This does not support declarations of arrays or functions! +// +bool parseTypeDeclaration(const std::string& input, + std::string* typeName, + std::string* error); + +// Parse a function parameter declaration and extract the type and variable +// name from it. |param| is the individual parameter declaration from the +// function's signature (e.g. 'const char *items') +// +// On success, returns true and sets |*vartype| and |*varname| to the +// appropriate type name and variable name. |varname| can be NULL if the caller +// isn't interested in the variable name. +// +// On failure, return false and sets |*error| to a human-friendly message +// explaining the reason for failure. +// +// Note that the returned type name is normalized with regards to whitespace +// and star location, e.g.: +// +// const void *items -> 'const void*' +// char* *items -> 'char**' +// const void * const * items -> 'const void* const*' +// unsigned int *const data -> 'unsigned int* const' +// +bool parseParameterDeclaration(const std::string& param, + std::string* typeName, + std::string* variableName, + std::string* error); + +#endif // PARSER_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser_unittest.cpp new file mode 100644 index 0000000..904b247 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Parser_unittest.cpp @@ -0,0 +1,120 @@ +/* +* Copyright 2014 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "Parser.h" + +#include + +#define ARRAYLEN(x) (sizeof(x) / sizeof(x[0])) + +TEST(ParserTest, normalizeTypeDeclaration) { + static const struct { + const char* expected; + const char* input; + } kData[] = { + { "char", "char" }, + { "const unsigned int", " const unsigned\tint\n" }, + { "char* const**", "char *const* *" }, + }; + const size_t kDataSize = ARRAYLEN(kData); + for (size_t n = 0; n < kDataSize; ++n) { + std::string result; + std::string text = "When parsing '"; + text += kData[n].input; + text += "'"; + + result = normalizeTypeDeclaration(kData[n].input); + EXPECT_STREQ(kData[n].expected, result.c_str()) << text; + } +} + +TEST(ParserTest, parseTypeDeclaration) { + static const struct { + const char* input; + bool expected; + const char* expectedType; + const char* expectedError; + } kData[] = { + { "const", false, NULL, "Missing type name" }, + { "const const", false, NULL, "Missing type name" }, + { "foo", true, "foo", NULL }, + { "void", true, "void", NULL }, + { "const foo", true, "const foo", NULL }, + { "foo *", true, "foo*", NULL }, + { "char foo", true, "char foo", NULL }, + { "\tunsigned \t int\n", true, "unsigned int", NULL }, + { "const * char", false, NULL, "Unexpected '*' before type name" }, + { "const char * ", true, "const char*", NULL }, + { "const void*const * *", true, "const void* const**", NULL }, + }; + const size_t kDataSize = ARRAYLEN(kData); + for (size_t n = 0; n < kDataSize; ++n) { + std::string varname, vartype, error; + std::string text = "When parsing '"; + text += kData[n].input; + text += "'"; + + EXPECT_EQ(kData[n].expected, + parseTypeDeclaration(kData[n].input, + &vartype, + &error)) << text; + if (kData[n].expected) { + EXPECT_STREQ(kData[n].expectedType, vartype.c_str()) << text; + } else { + EXPECT_STREQ(kData[n].expectedError, error.c_str()) << text; + } + } +} + +TEST(ParserTest, parseParameterDeclaration) { + static const struct { + const char* input; + bool expected; + const char* expectedType; + const char* expectedVariable; + const char* expectedError; + } kData[] = { + { "foo", false, NULL, NULL, "Missing variable name" }, + { "const", false, NULL, NULL, "Missing type name" }, + { "const foo", false, NULL, NULL, "Missing variable name" }, + { "const const", false, NULL, NULL, "Missing type name" }, + { "char foo", true, "char", "foo", NULL }, + { "unsigned int\t bar\n", true, "unsigned int", "bar", NULL }, + { "const * char foo", false, NULL, NULL, "Unexpected '*' before type name" }, + { "const char * foo", true, "const char*", "foo", NULL }, + { "const void*const *data", true, "const void* const*", "data", NULL }, + { "char foo const", false, NULL, NULL, "Extra 'const' after variable name" }, + { "int bar*", false, NULL, NULL, "Extra '*' after variable name" }, + }; + const size_t kDataSize = ARRAYLEN(kData); + for (size_t n = 0; n < kDataSize; ++n) { + std::string varname, vartype, error; + std::string text = "When parsing '"; + text += kData[n].input; + text += "'"; + + EXPECT_EQ(kData[n].expected, + parseParameterDeclaration(kData[n].input, + &vartype, + &varname, + &error)) << text; + if (kData[n].expected) { + EXPECT_STREQ(kData[n].expectedType, vartype.c_str()) << text; + EXPECT_STREQ(kData[n].expectedVariable, varname.c_str()) << text; + } else { + EXPECT_STREQ(kData[n].expectedError, error.c_str()) << text; + } + } +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/README b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/README new file mode 100644 index 0000000..0fe85f9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/README @@ -0,0 +1,332 @@ +Introduction: +------------- +The emugen tool is a tool to generate a wire protocol implementation +based on provided API. The tool generates c++ encoder code that takes +API calls and encodes them into the wire and decoder code that decodes +the wire stream and calls server matching API. +The emugen tool includes additional functionality that enables to +generate an wrapper library. The wrapper library provides entry points +for the specified API, where each entry routes the call via a dispatch +table. The dispatch table may be initialized as required by a specific application. + +The following paragraphs includes the following: + * Wire Protocol Description + * Input files description & format + * Generated code description. + + +Note: In this document, the caller is referred to as Encoder or Client +and the callee is referred to as the Decoder or Server. These terms +are used interchangeably by the context. + + + +Wire Protocol packet structure: +------------------------------- +A general Encoder->Decoder packet is structured as following: +struct Packet { + unsigned int opcode; + unsigned int packet_len; + … parameter 1 + … parameter 2 +}; +A general Decoder->Encoder reply is expected to be received in the +context of the ‘call’ that triggered it, thus it includes the reply +data only, with no context headers. In precise term terms, a reply +packet will look like: + +struct { + ...// reply data +}; + +consider the following function call: +int foo(int p1, short s1) +will be encoded into : +{ + 101, // foo opcode + 14, // sizeof(opcode) + sizeof(packet_len) + sizeof(int) + sizeof(short) + p1, // 4 bytes + s1 // 2 bytes +} + +Since ‘foo’ returns value, the caller is expected to read back the return packet from the server->client stream. The return value in this example is in thus the return packet is: +{ + int retval; +} + + +Pointer decoding: +---------------- +The wire protocol also allows exchanging of pointer data +(arrays). Pointers are defined with directions: + + in : Data is sent from the caller to the calle + out: Data is sent from the callee to the caller + in_out: data is sent from the caller and return in place. + +‘in’ and ‘in_out’ encoded with their len: +{ + unsinged int pointer_data_len; + unsigned char data[pointer_data_len];… // pointer data +} + +‘out’ pointers are encoded by data length only: +{ +unsigned int pointer_data_len; +} + +‘out’ and ‘in_out’ pointer’s data is returned in the return +packet. For example, consider the following call: + +int foo(int n, int *ptr); // assume that ‘data’ is in_out pointer which contains ‘n’ ints + +The caller packet will have the following form: +{ + 101, // foo opcode + xx, sizeof(opcode) + sizeof(datalen) + sizeof(int) + sizeof(unsigned int) + n * sizeof(int); + n, // the n parameter + n * sizeof(int), // size of the data in ptr + … // n* sizeof(int) bytes +} + +The return packet is; +{ + …. // n * sizeof(int) bytes of data return in ptr + retval // sizeof(int) - the return value of the function; +} + +Endianess +--------- +The Wire protocol is designed to impose minimum overhead on the client +side. Thus, the data endianness that is sent across the wire is +determined by the ‘client’ side. It is up to the server side to +determine the client endianess and marshal the packets as required. + + + +Emugen input files - protocol specification +------------------------------------------- +The protocol generated by emugen consists of two input files: + +1. basename.in - A sepcification of the protocol RPC procedures. This +part of the specification is expected to be generated automatically +from c/c++ header files or similar. + +‘basename’ is the basename for the protocol and will be used to prefix +the files that are generated for this protocol. A line in the .in +file has the following format: + +[prefix](retvalType, FuncName, [param name],...) +where + retvalType - The function return value type + FuncName - function name + mandatory parameter type + [param name] - optional parameter name +Examples: +GL_ENTRY(void, glVertex1f, float v) +XXX(int *, foo, int n, float, short) +XXX(void, glFlush, void) + +Note: Empty lines in the file are ignored. A line starts with # is a comment + +2. basename.attrib - Attributes information of the API. +This file includes additional flags, pointers datalen information and +global attributes of the protocol. For uptodate format of the file, +please refer to the specification file in the project source +tree. The format of the .attrib file is described below. + +3. basename.types - Types information + +This files describes the types that are described by the API. A type +is defined as follows: + +where: + is the name of the type as described in the API + 0, 8, 16, 32 sizes are accepted + a string to format the value of the type, as +acceted by printf(3) + true or false string species whether the type should be +treated as a pointer. + +example: +GLint 32 %d false +GLint* 32 %p true +GLptr 32 %p true + +Encoder generated code files +---------------------------- +In order to generate the encoder files, one should run the ‘emugen’ +tool as follows: + +emugen -i -E +where: + containes the api specification files (basename.in + basename.attrib) + - a directory name to generate the encoder output files + basename - The basename for the api. + +Assuming the basename is ‘api’, The following files are generated: + +api_opcodes.h - defines the protocol opcodes. The first opcode value +is 0, unless defined otherwise in the .attrib file + +api_entry.cpp - defines entry points for the functions that are +defined by the protocol. this File also includes a function call +‘setContextAccessor(void *(*f)()). This function should be used to +provide a callback function that is used by the functions to access +the encoder context. For example, such callback could fetch the +context from a Thread Local Storage (TLS) location. + +api_client_proc.h - type defintions for the protocol procedures. + +api_client_context.h - defines the client side dispatch table data +structure that stores the encoding functions. This data structure also +includes ‘accessors’ methods such that library user can override +default entries for special case handling. + +api_client_context.cpp - defines an initialization function for +dispatch table + +api_enc.h - This header file defines the encoder data strcuture. The +encoder data structure inherits its functionality from the +‘client_context’ class above and adds encoding and streaming +functionality. + +api_enc.cpp - Encoder implementation. + +Decoder generated files +----------------------- +In order to generate the decoder files, one should run the ‘emugen’ +tool as follows: +emugen -i -D basename +where: + containes the api specification files (basename.in + basename.attrib) + - a directory name to generate the decoder output files + basename - The basename for the api. + +With resepct to the example above, Emugen will generate the following +files: + +api_opcodes.h - Protocol opcodes + +api_server_proc.h - type definitions for the server side procedures + +api_server_context.h - dispatch table the decoder functions + +api_server_context.cpp - dispatch table initialization function +api_dec.h - Decoder header file + +api_dec.cpp - Decoder implementation. In addtion, this file includes +an intiailization function that uses a user provided callback to +initialize the API server implementation. An example for such +initialization is loading a set of functions from a shared library +module. + +Wrapper generated files +----------------------- +In order to generate a wrapper library files, one should run the +'emugen' tool as follows: + +emugen -i -W basename +where: + containes the api specification files (basename.in + basename.attrib) + - a directory name to generate the wrapper output files + basename - The basename for the api. + +With resepct to the example above, Emugen will generate the following +files: + +api_wrapper_proc.h - type definitions for the wrapper procedures + +api_wrapper_context.h - dispatch table the wrapper functions + +api_wrapper_context.cpp - dispatch table initialization function +api_wrapper_entry.cpp - entry points for the API + + +.attrib file format description: +------------------------------- +The .attrib file is an input file to emugen and is used to provide + additional information that is required for the code generation. +The file format is as follows: + +a line that starts with # is ignored (comment) +a empty line just whitespace of (" " "\t" "\n") is ignored. + +The file is divided into 'sections', each describes a specific API +function call. A section starts with the name of the function in +column 0. + +A section that starts with the reserved word 'GLOBAL' provides global +attributes. + +below are few sections examples: + +GLOBAL + encoder_headers string.h kuku.h + +glVertex3fv + len data (size) +glTexImage2D + len pixels (pixels == NULL? 0 : (format_pixel_size(internalformat) * width * height * type_size(type))) + + +Global section flags description: + +base_opcode + set the base opcode value for this api + format: base_opcode 100 + +encoder_headers + a list of headers that will be included in the encoder header file + format: encoder_headers "kuku.h" + +client_context_headers + a list of headers that will be included in the client context header file + format: client_context_headers "kuku.h" + +decoder_headers + a list of headers that will be included in the decoder header file + format: decoder_headers "kuku.h" + +server_context_headers + a list of headers that will be included in the server context header file + format: server_context_headers "kuku.h" + + +Entry point flags description: + + len + desciption : provide an expression to calcualte an expression data len + format: len + +custom_pack + description: provide an expression to pack data into the stream. + format: custom_pack + The stream is represented by a (unsigned char *)ptr. The expression may also refer + to other function parameters. In addition, the expression may refer to 'void *self' which + is the encoding context as provided by the caller. + + dir + description : set a pointer direction (in - for data that goes + to the codec, out from data that returns from the codec. + format: dir <[in | out | inout]> + + var_flag + description : set variable flags + format: var_flag < nullAllowed | isLarge | ... > + + nullAllowed -> for pointer variables, indicates that NULL is a valid value + isLarge -> for pointer variables, indicates that the data should be sent without an intermediate copy + + flag + description: set entry point flag; + format: flag < unsupported | ... > + supported flags are: + unsupported - The encoder side implementation is pointed to "unsuppored reporting function". + custom_decoder - The decoder is expected to be provided with + custom implementation. The call to the + deocder function includes a pointer to the + context + not_api - the function is not native gl api + + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.cpp new file mode 100644 index 0000000..1e0cc96 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.cpp @@ -0,0 +1,157 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "TypeFactory.h" + +#include "Parser.h" +#include "VarType.h" +#include "strUtils.h" + +#include +#include + +#include +#include + + +TypeFactory * TypeFactory::m_instance = NULL; + +typedef std::map TypeMap; +static TypeMap g_varMap; +static bool g_initialized = false; +static int g_typeId = 0; + + +#define ADD_TYPE(name, size, printformat,ispointer) \ + g_varMap.insert(std::pair(name, VarType(g_typeId++, name, (size + 7) >> 3, printformat , ispointer))); + +void TypeFactory::initBaseTypes() +{ + g_initialized = true; + ADD_TYPE("UNKNOWN", 0, "0x%x", false); + ADD_TYPE("void", 0, "0x%x", false); + ADD_TYPE("char", 8, "%c", false); + ADD_TYPE("int", 32, "%d", false); + ADD_TYPE("float", 32, "%d", false); + ADD_TYPE("short", 16, "%d", false); +} + +int TypeFactory::initFromFile(const std::string &filename) +{ + if (!g_initialized) { + initBaseTypes(); + } + + FILE *fp = fopen(filename.c_str(), "rt"); + if (fp == NULL) { + perror(filename.c_str()); + return -1; + } + char line[1000]; + int lc = 0; + while(fgets(line, sizeof(line), fp) != NULL) { + lc++; + std::string str = trim(line); + if (str.size() == 0 || str.at(0) == '#') { + continue; + } + size_t pos = 0, last; + std::string name; + name = getNextToken(str, pos, &last, WHITESPACE); + name = normalizeTypeDeclaration(name); + if (name.size() == 0) { + fprintf(stderr, "Error: %d : missing type name\n", lc); + return -2; + } + pos = last + 1; + std::string size; + size = getNextToken(str, pos, &last, WHITESPACE); + if (size.size() == 0) { + fprintf(stderr, "Error: %d : missing type width\n", lc); + return -2; + } + pos = last + 1; + std::string printString; + printString = getNextToken(str, pos, &last, WHITESPACE); + if (printString.size() == 0) { + fprintf(stderr, "Error: %d : missing print-string\n", lc); + return -2; + } + + // The ispointer definition is optional since we can just + // look at the type name, and determine it is a pointer if + // it ends with '*'. + bool isPointer = (name[name.size() - 1U] == '*'); + + pos = last + 1; + std::string pointerDef; + pointerDef = getNextToken(str, pos, &last, WHITESPACE); + if (pointerDef.size() != 0) { + // Just a little sanity check. + if (std::string("true")==pointerDef) { + if (!isPointer) { + fprintf(stderr, "Error: %d: invalid isPointer definition: 'true' but name does not end with '*'!\n", lc); + return -2; + } + } else if (std::string("false")==pointerDef) { + if (isPointer) { + fprintf(stderr, "Error: %d: invalid isPointer definition: 'false' but name does end with '*'!\n", lc); + return -2; + } + } else { + fprintf(stderr, "Error: %d : invalid isPointer definition, must be either \"true\" or \"false\"\n", lc); + return -2; + } + } + + size_t bitSize = atoi(size.c_str()); + size_t byteSize = (bitSize + 7) >> 3; + + if (getVarTypeByName(name)->id() != 0) { + fprintf(stderr, + "Warining: %d : type %s is already known, definition in line %d is taken\n", + lc, name.c_str(), lc); + } + g_varMap.insert(std::pair( + name, VarType(g_typeId++, + name, + byteSize, + printString, + isPointer))); + std::string constName = "const " + name; + g_varMap.insert(std::pair( + constName, VarType(g_typeId++, + constName, + byteSize, + printString, + isPointer))); //add a const type + } + g_initialized = true; + return 0; +} + + +const VarType * TypeFactory::getVarTypeByName(const std::string & type) +{ + if (!g_initialized) { + initBaseTypes(); + } + TypeMap::iterator i = g_varMap.find(type); + if (i == g_varMap.end()) { + i = g_varMap.find("UNKNOWN"); + } + return &(i->second); +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.h new file mode 100644 index 0000000..deee2ca --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/TypeFactory.h @@ -0,0 +1,37 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __TYPE__FACTORY__H__ +#define __TYPE__FACTORY__H__ + +#include +#include "VarType.h" + +class TypeFactory { +public: + static TypeFactory *instance() { + if (m_instance == NULL) { + m_instance = new TypeFactory; + } + return m_instance; + } + const VarType * getVarTypeByName(const std::string &type); + int initFromFile(const std::string &filename); +private: + static TypeFactory *m_instance; + void initBaseTypes(); + TypeFactory() {} +}; +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Var.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Var.h new file mode 100644 index 0000000..322c66a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/Var.h @@ -0,0 +1,110 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __VAR__H__ +#define __VAR__H__ + +#include "VarType.h" +#include +#include + +class Var { +public: + // pointer data direction - from the client point of view. + typedef enum { POINTER_OUT = 0x1, POINTER_IN = 0x2, POINTER_INOUT = 0x3 } PointerDir; + Var() : + m_name(""), + m_type(NULL), + m_lenExpression(""), + m_pointerDir(POINTER_IN), + m_nullAllowed(false), + m_isLarge(false), + m_packExpression(""), + m_writeExpression(""), + m_paramCheckExpression("") + + { + } + + Var(const std::string & name, + const VarType * vartype, + const std::string & lenExpression, + PointerDir dir, + const std::string &packExpression, + const std::string &writeExpression) : + m_name(name), + m_type(const_cast(vartype)), + m_lenExpression(lenExpression), + m_pointerDir(dir), + m_nullAllowed(false), + m_isLarge(false), + m_packExpression(packExpression), + m_writeExpression(writeExpression), + m_paramCheckExpression("") + { + } + + void init(const std::string name, const VarType * vartype, + std::string lenExpression, + PointerDir dir, + std::string packExpression, + std::string writeExpression) { + m_name = name; + m_type = vartype; + m_lenExpression = lenExpression; + m_packExpression = packExpression; + m_writeExpression = writeExpression; + m_pointerDir = dir; + m_nullAllowed = false; + m_isLarge = false; + + } + + const std::string & name() const { return m_name; } + const VarType * type() const { return m_type; } + bool isPointer() const { return m_type->isPointer(); } + bool isVoid() const { return ((m_type->bytes() == 0) && (!m_type->isPointer())); } + const std::string & lenExpression() const { return m_lenExpression; } + const std::string & packExpression() const { return(m_packExpression); } + const std::string & writeExpression() const { return(m_writeExpression); } + const std::string & paramCheckExpression() const { return m_paramCheckExpression; } + void setLenExpression(const std::string & lenExpression) { m_lenExpression = lenExpression; } + void setPackExpression(const std::string & packExpression) { m_packExpression = packExpression; } + void setWriteExpression(const std::string & writeExpression) { m_writeExpression = writeExpression; } + void setParamCheckExpression(const std::string & paramCheckExpression) { m_paramCheckExpression = paramCheckExpression; } + void setPointerDir(PointerDir dir) { m_pointerDir = dir; } + PointerDir pointerDir() { return m_pointerDir; } + void setNullAllowed(bool state) { m_nullAllowed = state; } + void setIsLarge(bool state) { m_isLarge = state; } + bool nullAllowed() const { return m_nullAllowed; } + bool isLarge() const { return m_isLarge; } + void printType(FILE *fp) { fprintf(fp, "%s", m_type->name().c_str()); } + void printTypeName(FILE *fp) { printType(fp); fprintf(fp, " %s", m_name.c_str()); } + +private: + std::string m_name; + const VarType * m_type; + bool m_pointer; // is this variable a pointer; + std::string m_lenExpression; // an expression to calcualte a pointer data size + PointerDir m_pointerDir; + bool m_nullAllowed; + bool m_isLarge; + std::string m_packExpression; // an expression to pack data into the stream + std::string m_writeExpression; // an expression to write data into the stream + std::string m_paramCheckExpression; //an expression to check parameter value + +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/VarType.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/VarType.h new file mode 100644 index 0000000..b6937a0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/VarType.h @@ -0,0 +1,62 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __VARTYPE__H__ +#define __VARTYPE__H__ + +#include + +// VarType models the types of values used on the wire protocol by +// both encoders and decoders. Each type is identified by a unique id, +// and a name, and provides a size in bytes for the values, a printf-like +// formatter string, and a flag telling if the value corresponds to a +// pointer. +class VarType { +public: + VarType() : + m_id(0), + m_name("default_constructed"), + m_byteSize(0), + m_printFormat("0x%x"), + m_isPointer(false) {} + + VarType(size_t id, + const std::string& name, + size_t byteSize, + const std::string& printFormat, + bool isPointer) : + m_id(id), + m_name(name), + m_byteSize(byteSize), + m_printFormat(printFormat), + m_isPointer(isPointer) {} + + ~VarType() {} + + size_t id() const { return m_id; } + const std::string& name() const { return m_name; } + size_t bytes() const { return m_byteSize; } + const std::string& printFormat() const { return m_printFormat; } + bool isPointer() const { return m_isPointer; } + +private: + size_t m_id; + std::string m_name; + size_t m_byteSize; + std::string m_printFormat; + bool m_isPointer; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/errors.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/errors.h new file mode 100644 index 0000000..d09c292 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/errors.h @@ -0,0 +1,24 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _ERRORS_H_ +#define _ERRORS_H_ + +#define BAD_USAGE -1 +#define BAD_SPEC_FILE -2 +#define BAD_TYPES_FILE -3 +#define BAD_ATTRIBUTES_FILE -4 + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.c b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.c new file mode 100644 index 0000000..3523538 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.c @@ -0,0 +1,76 @@ +#include "getopt.h" + +#include +#include + +#define _getprogname() nargv[0] + +int opterr = 1; +int optind = 1; +int optopt = 0; +char* optarg; + +int getopt(int argc, char* const argv[], const char* ostr) { + static const char kEmpty[] = ""; + static const char* place = kEmpty; + if (!*place) { + if (optind >= argc) + return -1; + + const char* arg = argv[optind]; + if (arg[0] != '-') { + // Not an option. + return -1; + } + if (arg[1] == '-' && !arg[2]) { + // '--' -> end of options. + return -1; + } + if (!arg[1]) { + // Single '-', If the program wants it, treat it as an option. + // Otherwise, it's the end of options. + if (!strchr(ostr, '-')) { + return -1; + } + optopt = '-'; + place = arg + 1; + } else { + optopt = arg[1]; + place = arg + 2; + } + }; + + char* oindex = strchr(ostr, optopt); + if (!oindex) { + // Unsupported option. + (void)fprintf(stderr, "%s: illegal option -- %c\n", argv[0]); + return '?'; + } + if (oindex[1] != ':') { + // No argument needed. + optarg = NULL; + if (!*place) + optind++; + return optopt; + } + + // This option needs an argument. Either after the option character, + // or the argument that follows. + if (*place) { + optarg = (char *)place; + } else if (argc > ++optind) { + optarg = (char *)argv[optind]; + } else if (oindex[2] == ':') { + // Optional argument is missing. + place = kEmpty; + optarg = NULL; + return optopt; + } else { + // Missing argument. + place = kEmpty; + (void)fprintf(stderr, "%s: option requires an argument --%c\n", + argv[0], optopt); + return ':'; + } + return optopt; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.h new file mode 100644 index 0000000..cc04850 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/getopt.h @@ -0,0 +1,18 @@ +#ifndef GETOPT_H +#define GETOPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern int optind; +extern char* optarg; +extern int optopt; + +int getopt(int argc, char* const argv[], const char* ostr); + +#ifdef __cplusplus +} +#endif + +#endif // GETOPT_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/main.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/main.cpp new file mode 100644 index 0000000..5408617 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/main.cpp @@ -0,0 +1,164 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include +#include +#include "errors.h" +#include "EntryPoint.h" +#include "strUtils.h" +#include "ApiGen.h" +#include "TypeFactory.h" +#include "getopt.h" + +const std::string SPEC_EXTENSION = std::string(".in"); +const std::string ATTRIB_EXTENSION = std::string(".attrib"); +const std::string TYPES_EXTENTION = std::string(".types"); + + +void usage(const char *filename) +{ + fprintf(stderr, "Usage: %s [options] \n", filename); + fprintf(stderr, "\t-h: This message\n"); + fprintf(stderr, "\t-E

: generate encoder into dir\n"); + fprintf(stderr, "\t-D : generate decoder into dir\n"); + fprintf(stderr, "\t-i: input dir, local directory by default\n"); + fprintf(stderr, "\t-T : generate attribute template into the input directory\n\t\tno other files are generated\n"); + fprintf(stderr, "\t-W : generate wrapper into dir\n"); +} + +int main(int argc, char *argv[]) +{ + std::string encoderDir = ""; + std::string decoderDir = ""; + std::string wrapperDir = ""; + std::string inDir = "."; + bool generateAttributesTemplate = false; + + int c; + while((c = getopt(argc, argv, "TE:D:i:hW:")) != -1) { + switch(c) { + case 'W': + wrapperDir = std::string(optarg); + break; + case 'T': + generateAttributesTemplate = true; + break; + case 'h': + usage(argv[0]); + exit(0); + break; + case 'E': + encoderDir = std::string(optarg); + break; + case 'D': + decoderDir = std::string(optarg); + break; + case 'i': + inDir = std::string(optarg); + break; + case ':': + fprintf(stderr, "Missing argument !!\n"); + // fall through + default: + usage(argv[0]); + exit(0); + } + } + + if (optind >= argc) { + fprintf(stderr, "Usage: %s [options] \n", argv[0]); + return BAD_USAGE; + } + + if (encoderDir.size() == 0 && + decoderDir.size() == 0 && + generateAttributesTemplate == false && + wrapperDir.size() == 0) { + fprintf(stderr, "No output specified - aborting\n"); + return BAD_USAGE; + } + + std::string baseName = std::string(argv[optind]); + ApiGen apiEntries(baseName); + + // init types; + std::string typesFilename = inDir + "/" + baseName + TYPES_EXTENTION; + + if (TypeFactory::instance()->initFromFile(typesFilename) < 0) { + fprintf(stderr, "missing or error reading types file: %s...ignored\n", typesFilename.c_str()); + } + + std::string filename = inDir + "/" + baseName + SPEC_EXTENSION; + if (apiEntries.readSpec(filename) < 0) { + perror(filename.c_str()); + return BAD_SPEC_FILE; + } + + + if (generateAttributesTemplate) { + apiEntries.genAttributesTemplate(inDir + "/" + baseName + ATTRIB_EXTENSION); + exit(0); + } + + std::string attribFileName = inDir + "/" + baseName + ATTRIB_EXTENSION; + if (apiEntries.readAttributes(attribFileName) < 0) { + perror(attribFileName.c_str()); + fprintf(stderr, "failed to parse attributes\n"); + exit(1); + } + + if (encoderDir.size() != 0) { + + apiEntries.genOpcodes(encoderDir + "/" + baseName + "_opcodes.h"); + apiEntries.genContext(encoderDir + "/" + baseName + "_client_context.h", ApiGen::CLIENT_SIDE); + apiEntries.genContextImpl(encoderDir + "/" + baseName + "_client_context.cpp", ApiGen::CLIENT_SIDE); + + apiEntries.genProcTypes(encoderDir + "/" + baseName + "_client_proc.h", ApiGen::CLIENT_SIDE); + apiEntries.genFuncTable(encoderDir + "/" + baseName + "_ftable.h", ApiGen::CLIENT_SIDE); + + apiEntries.genEntryPoints(encoderDir + "/" + baseName + "_entry.cpp", ApiGen::CLIENT_SIDE); + apiEntries.genEncoderHeader(encoderDir + "/" + baseName + "_enc.h"); + apiEntries.genEncoderImpl(encoderDir + "/" + baseName + "_enc.cpp"); + } + + if (decoderDir.size() != 0) { + apiEntries.genOpcodes(decoderDir + "/" + baseName + "_opcodes.h"); + apiEntries.genProcTypes(decoderDir + "/" + baseName + "_server_proc.h", ApiGen::SERVER_SIDE); + apiEntries.genContext(decoderDir + "/" + baseName + "_server_context.h", ApiGen::SERVER_SIDE); + apiEntries.genContextImpl(decoderDir + "/" + baseName + "_server_context.cpp", ApiGen::SERVER_SIDE); + apiEntries.genDecoderHeader(decoderDir + "/" + baseName + "_dec.h"); + apiEntries.genDecoderImpl(decoderDir + "/" + baseName + "_dec.cpp"); + } + + if (wrapperDir.size() != 0) { + apiEntries.genProcTypes(wrapperDir + "/" + baseName + "_wrapper_proc.h", ApiGen::WRAPPER_SIDE); + apiEntries.genContext(wrapperDir + "/" + baseName + "_wrapper_context.h", ApiGen::WRAPPER_SIDE); + apiEntries.genContextImpl(wrapperDir + "/" + baseName + "_wrapper_context.cpp", ApiGen::WRAPPER_SIDE); + apiEntries.genEntryPoints(wrapperDir + "/" + baseName + "_wrapper_entry.cpp", ApiGen::WRAPPER_SIDE); + } + +#ifdef DEBUG_DUMP + int withPointers = 0; + printf("%d functions found\n", int(apiEntries.size())); + for (int i = 0; i < apiEntries.size(); i++) { + if (apiEntries[i].hasPointers()) { + withPointers++; + apiEntries[i].print(); + } + } + fprintf(stdout, "%d entries has poitners\n", withPointers); +#endif + +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.cpp new file mode 100644 index 0000000..357054b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.cpp @@ -0,0 +1,49 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "strUtils.h" + +using namespace std; + + +std::string getNextToken(const std::string & str, size_t pos, size_t * last, const std::string & delim) +{ + if (str.size() == 0 || pos >= str.size()) return ""; + + pos = str.find_first_not_of(WHITESPACE, pos); + if (pos == std::string::npos) return ""; + + *last = str.find_first_of(delim, pos); + if (*last == std::string::npos) *last = str.size(); + std::string retval = str.substr(pos, *last - pos); + retval = trim(retval); + return retval; +} + + +std::string trim(const string & str) +{ + string result; + string::size_type start = str.find_first_not_of(WHITESPACE, 0); + string::size_type end = str.find_last_not_of(WHITESPACE); + if (start == string::npos || end == string::npos) { + result = string(""); + } else { + result = str.substr(start, end - start + 1); + } + return result; +} + + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.h new file mode 100644 index 0000000..3fa0908 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/strUtils.h @@ -0,0 +1,33 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef STR_UTILS_H_ +#define STR_UTILS_H_ + +#include +#include + +#define WHITESPACE " \t\n" + +std::string trim(const std::string & str); +std::string getNextToken(const std::string & str, size_t pos, size_t * last, const std::string & delim); +template std::string inline toString(const T& t) { + std::stringstream ss; + ss << t; + return ss.str(); + +} + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/run-tests.sh b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/run-tests.sh new file mode 100644 index 0000000..67409ed --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/run-tests.sh @@ -0,0 +1,129 @@ +#!/bin/sh + +# Copyright 2014 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -e + +export LANG=C +export LC_ALL=C + +PROGDIR=$(dirname "$0") +PROGNAME=$(basename "$0") + +fatal () { + echo "ERROR: $@" + exit 1 +} + +OPT_EMUGEN= +OPT_HELP= +OPT_OUT_DIR= +OPT_TOOL= + +for OPT; do + OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true) + case $OPT in + --help|-h|-?) + OPT_HELP=true + ;; + --emugen=*) + OPT_EMUGEN=$OPTARG + ;; + --out-dir=*) + OPT_OUT_DIR=$OPTARG + ;; + --tool=*) + OPT_TOOL=$OPTARG + ;; + -*) + fatal "Invalid option '$OPT', see --help." + ;; + *) + fatal "This script doesn't take arguments, see --help." + ;; + esac +done + +if [ "$OPT_HELP" ]; then + cat </input, and uses them as input to 'emugen'. It then +compares the output to t./expected/ content. + +Valid options: + --help|-h|-? Print this help. + --out-dir= Generate outputs into . + --emugen= Emugen program path, if not in path. + --tool= Launch visual diff tool in case of differences. +EOF + exit 0 +fi + +# Find emugen program +EMUGEN= +if [ "$OPT_EMUGEN" ]; then + EMUGEN=$OPT_EMUGEN +else + EMUGEN=$(which emugen 2>/dev/null || true) + if [ -z "$EMUGEN" ]; then + fatal "Cannot find 'emugen' program in PATH, use --emugen= option." + fi + echo "Auto-config: --emugen=$EMUGEN" +fi +if [ ! -f "$EMUGEN" ]; then + fatal "Emugen program doesn't exist: $EMUGEN" +fi + +# Create output directory. +OUT_DIR= +if [ "$OPT_OUT_DIR" ]; then + OUT_DIR=$OPT_OUT_DIR +else + OUT_DIR=/tmp/$USER-emugen-testing + echo "Auto-config: --out-dir=$OUT_DIR" +fi +mkdir -p "$OUT_DIR" && rm -rf "$OUT_DIR/emugen" + +OUT_DIR=$OUT_DIR/emugen + +# Find test directories +TEST_DIRS=$(cd "$PROGDIR" && find . -name "t.*" | sed -e 's|^\./||') +for TEST_DIR in $TEST_DIRS; do + IN=$PROGDIR/$TEST_DIR/input + PREFIXES=$(cd $IN && find . -name "*.in" | sed -e 's|^\./||g' -e 's|\.in$||g') + OUT=$OUT_DIR/$TEST_DIR + mkdir -p "$OUT/encoder" + mkdir -p "$OUT/decoder" + mkdir -p "$OUT/wrapper" + for PREFIX in $PREFIXES; do + echo "Processing $IN/foo.*" + $EMUGEN -i "$PROGDIR/$TEST_DIR/input" -D "$OUT/decoder" -E "$OUT/encoder" -W "$OUT/wrapper" $PREFIX + done + if ! diff -qr "$PROGDIR/$TEST_DIR/expected" "$OUT"; then + if [ "$OPT_TOOL" ]; then + $OPT_TOOL "$PROGDIR/$TEST_DIR/expected" "$OUT" + else + echo "ERROR: Invalid differences between actual and expected output!" + diff -burN "$PROGDIR/$TEST_DIR/expected" "$OUT" + exit 1 + fi + fi +done + +echo "All good!" +exit 0 diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp new file mode 100644 index 0000000..8122de0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp @@ -0,0 +1,128 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include "foo_opcodes.h" + +#include "foo_dec.h" + + +#include "ProtocolUtils.h" + +#include "ChecksumCalculatorThreadInfo.h" + +#include + +typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled. + +#ifdef OPENGL_DEBUG_PRINTOUT +# define DEBUG(...) do { if (emugl_cxt_logger) { emugl_cxt_logger(__VA_ARGS__); } } while(0) +#else +# define DEBUG(...) ((void)0) +#endif + +#ifdef CHECK_GLERROR +# define SET_LASTCALL(name) sprintf(lastCall, #name) +#else +# define SET_LASTCALL(name) ((void)0) +#endif + +using namespace emugl; + +size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream) +{ + + size_t pos = 0; + if (len < 8) return pos; + unsigned char *ptr = (unsigned char *)buf; + bool unknownOpcode = false; +#ifdef CHECK_GL_ERROR + char lastCall[256] = {0}; +#endif + while ((len - pos >= 8) && !unknownOpcode) { + uint32_t opcode = *(uint32_t *)ptr; + size_t packetLen = *(uint32_t *)(ptr + 4); + if (len - pos < packetLen) return pos; + bool useChecksum = ChecksumCalculatorThreadInfo::getVersion() > 0; + size_t checksumSize = 0; + if (useChecksum) { + checksumSize = ChecksumCalculatorThreadInfo::checksumByteSize(); + } + switch(opcode) { + case OP_fooAlphaFunc: { + FooInt var_func = Unpack(ptr + 8); + FooFloat var_ref = Unpack(ptr + 8 + 4); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + 4, ptr + 8 + 4 + 4, checksumSize, + "8 + 4 + 4::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooAlphaFunc(%d %f )\n", stream,var_func, var_ref); + this->fooAlphaFunc(var_func, var_ref); + SET_LASTCALL("fooAlphaFunc"); + break; + } + case OP_fooIsBuffer: { + uint32_t size_stuff __attribute__((unused)) = Unpack(ptr + 8); + InputBuffer inptr_stuff(ptr + 8 + 4, size_stuff); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_stuff, ptr + 8 + 4 + size_stuff, checksumSize, + "8 + 4 + size_stuff::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n"); + } + size_t totalTmpSize = sizeof(FooBoolean); + totalTmpSize += checksumSize; + unsigned char *tmpBuf = stream->alloc(totalTmpSize); + DEBUG("foo(%p): fooIsBuffer(%p(%u) )\n", stream,(void*)(inptr_stuff.get()), size_stuff); + *(FooBoolean *)(&tmpBuf[0]) = this->fooIsBuffer((void*)(inptr_stuff.get())); + if (useChecksum) { + ChecksumCalculatorThreadInfo::writeChecksum(&tmpBuf[0], totalTmpSize - checksumSize, &tmpBuf[totalTmpSize - checksumSize], checksumSize); + } + stream->flush(); + SET_LASTCALL("fooIsBuffer"); + break; + } + case OP_fooUnsupported: { + uint32_t size_params __attribute__((unused)) = Unpack(ptr + 8); + InputBuffer inptr_params(ptr + 8 + 4, size_params); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_params, ptr + 8 + 4 + size_params, checksumSize, + "8 + 4 + size_params::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooUnsupported(%p(%u) )\n", stream,(void*)(inptr_params.get()), size_params); + this->fooUnsupported((void*)(inptr_params.get())); + SET_LASTCALL("fooUnsupported"); + break; + } + case OP_fooDoEncoderFlush: { + FooInt var_param = Unpack(ptr + 8); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4, ptr + 8 + 4, checksumSize, + "8 + 4::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooDoEncoderFlush(%d )\n", stream,var_param); + this->fooDoEncoderFlush(var_param); + SET_LASTCALL("fooDoEncoderFlush"); + break; + } + case OP_fooTakeConstVoidPtrConstPtr: { + uint32_t size_param __attribute__((unused)) = Unpack(ptr + 8); + InputBuffer inptr_param(ptr + 8 + 4, size_param); + if (useChecksum) { + ChecksumCalculatorThreadInfo::validOrDie(ptr, 8 + 4 + size_param, ptr + 8 + 4 + size_param, checksumSize, + "8 + 4 + size_param::decode, OP_foo_decoder_context_t: GL checksumCalculator failure\n"); + } + DEBUG("foo(%p): fooTakeConstVoidPtrConstPtr(%p(%u) )\n", stream,(const void* const*)(inptr_param.get()), size_param); + this->fooTakeConstVoidPtrConstPtr((const void* const*)(inptr_param.get())); + SET_LASTCALL("fooTakeConstVoidPtrConstPtr"); + break; + } + default: + unknownOpcode = true; + } //switch + if (!unknownOpcode) { + pos += packetLen; + ptr += packetLen; + } + } // while + return pos; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h new file mode 100644 index 0000000..3646de5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h @@ -0,0 +1,18 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + +#ifndef GUARD_foo_decoder_context_t +#define GUARD_foo_decoder_context_t + +#include "IOStream.h" +#include "foo_server_context.h" + + + +struct foo_decoder_context_t : public foo_server_context_t { + + size_t decode(void *buf, size_t bufsize, IOStream *stream); + +}; + +#endif // GUARD_foo_decoder_context_t diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h new file mode 100644 index 0000000..7219caa --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h @@ -0,0 +1,14 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __GUARD_foo_opcodes_h_ +#define __GUARD_foo_opcodes_h_ + +#define OP_fooAlphaFunc 200 +#define OP_fooIsBuffer 201 +#define OP_fooUnsupported 202 +#define OP_fooDoEncoderFlush 203 +#define OP_fooTakeConstVoidPtrConstPtr 204 +#define OP_last 205 + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp new file mode 100644 index 0000000..22ff47f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp @@ -0,0 +1,20 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include "foo_server_context.h" + + +#include + +int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + fooAlphaFunc = (fooAlphaFunc_server_proc_t) getProc("fooAlphaFunc", userData); + fooIsBuffer = (fooIsBuffer_server_proc_t) getProc("fooIsBuffer", userData); + fooUnsupported = (fooUnsupported_server_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_server_proc_t) getProc("fooDoEncoderFlush", userData); + fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_server_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); + return 0; +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h new file mode 100644 index 0000000..b2d6537 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h @@ -0,0 +1,22 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_server_context_t_h +#define __foo_server_context_t_h + +#include "foo_server_proc.h" + +#include "foo_types.h" + + +struct foo_server_context_t { + + fooAlphaFunc_server_proc_t fooAlphaFunc; + fooIsBuffer_server_proc_t fooIsBuffer; + fooUnsupported_server_proc_t fooUnsupported; + fooDoEncoderFlush_server_proc_t fooDoEncoderFlush; + fooTakeConstVoidPtrConstPtr_server_proc_t fooTakeConstVoidPtrConstPtr; + virtual ~foo_server_context_t() {} + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h new file mode 100644 index 0000000..bf7ff53 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h @@ -0,0 +1,21 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_server_proc_t_h +#define __foo_server_proc_t_h + + + +#include "foo_types.h" + +#include "emugl/common/logging.h" +#ifndef foo_APIENTRY +#define foo_APIENTRY +#endif +typedef void (foo_APIENTRY *fooAlphaFunc_server_proc_t) (FooInt, FooFloat); +typedef FooBoolean (foo_APIENTRY *fooIsBuffer_server_proc_t) (void*); +typedef void (foo_APIENTRY *fooUnsupported_server_proc_t) (void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_server_proc_t) (FooInt); +typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_server_proc_t) (const void* const*); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp new file mode 100644 index 0000000..f09e881 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp @@ -0,0 +1,20 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include "foo_client_context.h" + + +#include + +int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + fooAlphaFunc = (fooAlphaFunc_client_proc_t) getProc("fooAlphaFunc", userData); + fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData); + fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_client_proc_t) getProc("fooDoEncoderFlush", userData); + fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_client_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); + return 0; +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h new file mode 100644 index 0000000..d63e835 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h @@ -0,0 +1,27 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_client_context_t_h +#define __foo_client_context_t_h + +#include "foo_client_proc.h" + +#include "foo_types.h" + + +struct foo_client_context_t { + + fooAlphaFunc_client_proc_t fooAlphaFunc; + fooIsBuffer_client_proc_t fooIsBuffer; + fooUnsupported_client_proc_t fooUnsupported; + fooDoEncoderFlush_client_proc_t fooDoEncoderFlush; + fooTakeConstVoidPtrConstPtr_client_proc_t fooTakeConstVoidPtrConstPtr; + virtual ~foo_client_context_t() {} + + typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void); + static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); + virtual void setError(unsigned int error){ (void)error; }; + virtual unsigned int getError(){ return 0; }; +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h new file mode 100644 index 0000000..6cf72d5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h @@ -0,0 +1,21 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_client_proc_t_h +#define __foo_client_proc_t_h + + + +#include "foo_types.h" + +#include "emugl/common/logging.h" +#ifndef foo_APIENTRY +#define foo_APIENTRY +#endif +typedef void (foo_APIENTRY *fooAlphaFunc_client_proc_t) (void * ctx, FooInt, FooFloat); +typedef FooBoolean (foo_APIENTRY *fooIsBuffer_client_proc_t) (void * ctx, void*); +typedef void (foo_APIENTRY *fooUnsupported_client_proc_t) (void * ctx, void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_client_proc_t) (void * ctx, FooInt); +typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_client_proc_t) (void * ctx, const void* const*); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp new file mode 100644 index 0000000..94455dd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp @@ -0,0 +1,153 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include +#include "foo_opcodes.h" + +#include "foo_enc.h" + + +#include + +namespace { + +void enc_unsupported() +{ + ALOGE("Function is unsupported\n"); +} + +void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, &func, 4); ptr += 4; + memcpy(ptr, &ref, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +FooBoolean fooIsBuffer_enc(void *self , void* stuff) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_stuff = (4 * sizeof(float)); + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_stuff + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_stuff; ptr += 4; + memcpy(ptr, stuff, __size_stuff);ptr += __size_stuff; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + + FooBoolean retval; + stream->readback(&retval, 1); + if (useChecksum) checksumCalculator->addBuffer(&retval, 1); + if (useChecksum) { + std::unique_ptr checksumBuf(new unsigned char[checksumSize]); + stream->readback(checksumBuf.get(), checksumSize); + if (!checksumCalculator->validate(checksumBuf.get(), checksumSize)) { + ALOGE("fooIsBuffer: GL communication error, please report this issue to b.android.com.\n"); + abort(); + } + } + return retval; +} + +void fooDoEncoderFlush_enc(void *self , FooInt param) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + 4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooDoEncoderFlush;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + memcpy(ptr, ¶m, 4); ptr += 4; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + + stream->flush(); +} + +void fooTakeConstVoidPtrConstPtr_enc(void *self , const void* const* param) +{ + + foo_encoder_context_t *ctx = (foo_encoder_context_t *)self; + IOStream *stream = ctx->m_stream; + ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator; + bool useChecksum = checksumCalculator->getVersion() > 0; + + const unsigned int __size_param = ; + unsigned char *ptr; + unsigned char *buf; + const size_t sizeWithoutChecksum = 8 + __size_param + 1*4; + const size_t checksumSize = checksumCalculator->checksumByteSize(); + const size_t totalSize = sizeWithoutChecksum + checksumSize; + buf = stream->alloc(totalSize); + ptr = buf; + int tmp = OP_fooTakeConstVoidPtrConstPtr;memcpy(ptr, &tmp, 4); ptr += 4; + memcpy(ptr, &totalSize, 4); ptr += 4; + + *(unsigned int *)(ptr) = __size_param; ptr += 4; + memcpy(ptr, param, __size_param);ptr += __size_param; + + if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf); + if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize; + +} + +} // namespace + +foo_encoder_context_t::foo_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator) +{ + m_stream = stream; + m_checksumCalculator = checksumCalculator; + + this->fooAlphaFunc = &fooAlphaFunc_enc; + this->fooIsBuffer = &fooIsBuffer_enc; + this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported; + this->fooDoEncoderFlush = &fooDoEncoderFlush_enc; + this->fooTakeConstVoidPtrConstPtr = &fooTakeConstVoidPtrConstPtr_enc; +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h new file mode 100644 index 0000000..8325831 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h @@ -0,0 +1,23 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + +#ifndef GUARD_foo_encoder_context_t +#define GUARD_foo_encoder_context_t + +#include "IOStream.h" +#include "ChecksumCalculator.h" +#include "foo_client_context.h" + + +#include "fooUtils.h" +#include "fooBase.h" + +struct foo_encoder_context_t : public foo_client_context_t { + + IOStream *m_stream; + ChecksumCalculator *m_checksumCalculator; + + foo_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator); +}; + +#endif // GUARD_foo_encoder_context_t \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp new file mode 100644 index 0000000..b91129c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp @@ -0,0 +1,53 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#include +#include +#include "foo_client_context.h" + +#ifndef GL_TRUE +extern "C" { + void fooAlphaFunc(FooInt func, FooFloat ref); + FooBoolean fooIsBuffer(void* stuff); + void fooUnsupported(void* params); + void fooDoEncoderFlush(FooInt param); + void fooTakeConstVoidPtrConstPtr(const void* const* param); +}; + +#endif +#ifndef GET_CONTEXT +static foo_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; +void foo_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } +#define GET_CONTEXT foo_client_context_t * ctx = getCurrentContext() +#endif + +void fooAlphaFunc(FooInt func, FooFloat ref) +{ + GET_CONTEXT; + ctx->fooAlphaFunc(ctx, func, ref); +} + +FooBoolean fooIsBuffer(void* stuff) +{ + GET_CONTEXT; + if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; } + return ctx->fooIsBuffer(ctx, stuff); +} + +void fooUnsupported(void* params) +{ + GET_CONTEXT; + ctx->fooUnsupported(ctx, params); +} + +void fooDoEncoderFlush(FooInt param) +{ + GET_CONTEXT; + ctx->fooDoEncoderFlush(ctx, param); +} + +void fooTakeConstVoidPtrConstPtr(const void* const* param) +{ + GET_CONTEXT; + ctx->fooTakeConstVoidPtrConstPtr(ctx, param); +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h new file mode 100644 index 0000000..e397e50 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h @@ -0,0 +1,20 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_client_ftable_t_h +#define __foo_client_ftable_t_h + + +static const struct _foo_funcs_by_name { + const char *name; + void *proc; +} foo_funcs_by_name[] = { + {"fooAlphaFunc", (void*)fooAlphaFunc}, + {"fooIsBuffer", (void*)fooIsBuffer}, + {"fooUnsupported", (void*)fooUnsupported}, + {"fooDoEncoderFlush", (void*)fooDoEncoderFlush}, + {"fooTakeConstVoidPtrConstPtr", (void*)fooTakeConstVoidPtrConstPtr}, +}; +static const int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h new file mode 100644 index 0000000..7219caa --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h @@ -0,0 +1,14 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __GUARD_foo_opcodes_h_ +#define __GUARD_foo_opcodes_h_ + +#define OP_fooAlphaFunc 200 +#define OP_fooIsBuffer 201 +#define OP_fooUnsupported 202 +#define OP_fooDoEncoderFlush 203 +#define OP_fooTakeConstVoidPtrConstPtr 204 +#define OP_last 205 + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp new file mode 100644 index 0000000..6e132b1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp @@ -0,0 +1,20 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' + + +#include +#include "foo_wrapper_context.h" + + +#include + +int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData) +{ + fooAlphaFunc = (fooAlphaFunc_wrapper_proc_t) getProc("fooAlphaFunc", userData); + fooIsBuffer = (fooIsBuffer_wrapper_proc_t) getProc("fooIsBuffer", userData); + fooUnsupported = (fooUnsupported_wrapper_proc_t) getProc("fooUnsupported", userData); + fooDoEncoderFlush = (fooDoEncoderFlush_wrapper_proc_t) getProc("fooDoEncoderFlush", userData); + fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_wrapper_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData); + return 0; +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h new file mode 100644 index 0000000..3315acc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h @@ -0,0 +1,25 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_wrapper_context_t_h +#define __foo_wrapper_context_t_h + +#include "foo_server_proc.h" + +#include "foo_types.h" + + +struct foo_wrapper_context_t { + + fooAlphaFunc_wrapper_proc_t fooAlphaFunc; + fooIsBuffer_wrapper_proc_t fooIsBuffer; + fooUnsupported_wrapper_proc_t fooUnsupported; + fooDoEncoderFlush_wrapper_proc_t fooDoEncoderFlush; + fooTakeConstVoidPtrConstPtr_wrapper_proc_t fooTakeConstVoidPtrConstPtr; + virtual ~foo_wrapper_context_t() {} + + typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void); + static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f); + int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData); +}; + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp new file mode 100644 index 0000000..7591393 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp @@ -0,0 +1,52 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#include +#include +#include "foo_wrapper_context.h" + +#ifndef GL_TRUE +extern "C" { + void fooAlphaFunc(FooInt func, FooFloat ref); + FooBoolean fooIsBuffer(void* stuff); + void fooUnsupported(void* params); + void fooDoEncoderFlush(FooInt param); + void fooTakeConstVoidPtrConstPtr(const void* const* param); +}; + +#endif +#ifndef GET_CONTEXT +static foo_wrapper_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL; +void foo_wrapper_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; } +#define GET_CONTEXT foo_wrapper_context_t * ctx = getCurrentContext() +#endif + +void fooAlphaFunc(FooInt func, FooFloat ref) +{ + GET_CONTEXT; + ctx->fooAlphaFunc( func, ref); +} + +FooBoolean fooIsBuffer(void* stuff) +{ + GET_CONTEXT; + return ctx->fooIsBuffer( stuff); +} + +void fooUnsupported(void* params) +{ + GET_CONTEXT; + ctx->fooUnsupported( params); +} + +void fooDoEncoderFlush(FooInt param) +{ + GET_CONTEXT; + ctx->fooDoEncoderFlush( param); +} + +void fooTakeConstVoidPtrConstPtr(const void* const* param) +{ + GET_CONTEXT; + ctx->fooTakeConstVoidPtrConstPtr( param); +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h new file mode 100644 index 0000000..421c910 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h @@ -0,0 +1,21 @@ +// Generated Code - DO NOT EDIT !! +// generated by 'emugen' +#ifndef __foo_wrapper_proc_t_h +#define __foo_wrapper_proc_t_h + + + +#include "foo_types.h" + +#include "emugl/common/logging.h" +#ifndef foo_APIENTRY +#define foo_APIENTRY +#endif +typedef void (foo_APIENTRY *fooAlphaFunc_wrapper_proc_t) (FooInt, FooFloat); +typedef FooBoolean (foo_APIENTRY *fooIsBuffer_wrapper_proc_t) (void*); +typedef void (foo_APIENTRY *fooUnsupported_wrapper_proc_t) (void*); +typedef void (foo_APIENTRY *fooDoEncoderFlush_wrapper_proc_t) (FooInt); +typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_wrapper_proc_t) (const void* const*); + + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.attrib b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.attrib new file mode 100644 index 0000000..80644d8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.attrib @@ -0,0 +1,15 @@ +GLOBAL + base_opcode 200 + encoder_headers "fooUtils.h" "fooBase.h" + +fooIsBuffer + dir stuff in + len stuff (4 * sizeof(float)) + param_check stuff if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; } + +fooUnsupported + dir params in + flag unsupported + +fooDoEncoderFlush + flag flushOnEncode diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.in b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.in new file mode 100644 index 0000000..4e98f88 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.in @@ -0,0 +1,5 @@ +FOO_ENTRY(void, fooAlphaFunc, FooInt func, FooFloat ref) +FOO_ENTRY(FooBoolean, fooIsBuffer, void* stuff) +FOO_ENTRY(void, fooUnsupported, void* params) +FOO_ENTRY(void, fooDoEncoderFlush, FooInt param) +FOO_ENTRY(void, fooTakeConstVoidPtrConstPtr, const void* const* param) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.types b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.types new file mode 100644 index 0000000..05d72fb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/host/tools/emugen/tests/t.001/input/foo.types @@ -0,0 +1,10 @@ +FooBoolean 8 %d +FooInt 32 %d +FooShort 16 %d +FooFloat 32 %f +FooEnum 32 %08x +FooVoid 0 %x +FooChar 8 %d +FooChar* 32 0x%08x +void* 32 0x%08x +void*const* 32 0x%08x diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/scripts/gen-headers.sh b/src/type3_AndroidCloud/anbox-master/external/android-emugl/scripts/gen-headers.sh new file mode 100644 index 0000000..c079fe7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/scripts/gen-headers.sh @@ -0,0 +1,114 @@ +#!/bin/sh + +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Run this script to re-generate headers with the gen-entries.py script. + +set -e +export LANG=C +export LC_ALL=C + +PROGDIR=$(dirname "$0") + +panic () { + echo "ERROR: $@" + exit 1 +} + +QEMU_TOP_DIR=$(cd $PROGDIR/../../.. && pwd -P) +SCRIPT_DIR=android/scripts +if [ ! -d "$QEMU_TOP_DIR/$SCRIPT_DIR" ]; then + panic "Missing scripts directory: $QEMU_TOP_DIR/$SCRIPT_DIR" +fi + +cd $QEMU_TOP_DIR +GEN_ENTRIES=$SCRIPT_DIR/gen-entries.py +if [ ! -f "$GEN_ENTRIES" ]; then + panic "Missing script: $GEN_ENTRIES" +fi + +FAILURES= + +# $1: Source file +# $2: Target file +# $3: gen-entries script. +gen_functions_header () { + local SRC_FILE="$1" + local DST_FILE="$2" + local GEN_ENTRIES="$3" + if [ ! -f "$SRC_FILE" ]; then + echo "ERROR: Missing source file: $SRC_FILE" + FAILURES=true + else + echo "Generating $DST_FILE" + $GEN_ENTRIES --mode=functions $SRC_FILE --output=$DST_FILE + fi +} + +# $1: Source file +# $2: Target file +# $3: gen-entries script. +gen_funcargs_header () { + local SRC_FILE="$1" + local DST_FILE="$2" + local GEN_ENTRIES="$3" + if [ ! -f "$SRC_FILE" ]; then + echo "ERROR: Missing source file: $SRC_FILE" + FAILURES=true + else + echo "Generating $DST_FILE" + $GEN_ENTRIES --mode=funcargs $SRC_FILE --output=$DST_FILE + fi +} + + +## +## libOpenglRender headers. +## +LIBRENDER_DIR=distrib/android-emugl/host/libs/libOpenglRender +LIBRENDER_INCLUDE=distrib/android-emugl/host/include/OpenglRender +gen_funcargs_header \ + "$LIBRENDER_DIR"/render_api.entries \ + "$LIBRENDER_INCLUDE"/render_api_functions.h \ + "$GEN_ENTRIES" + +## +## libOpenGLESDispatch headers. +## +OPENGLES_DISPATCH_SRCDIR=distrib/android-emugl/host/libs/libOpenGLESDispatch +OPENGLES_DISPATCH_INCLUDE=distrib/android-emugl/host/include/OpenGLESDispatch + +gen_functions_header \ + "$OPENGLES_DISPATCH_SRCDIR"/render_egl.entries \ + "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_functions.h \ + "$GEN_ENTRIES" + +gen_functions_header \ + "$OPENGLES_DISPATCH_SRCDIR"/render_egl_extensions.entries \ + "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_extensions_functions.h \ + "$GEN_ENTRIES" + +GLES_ENTRIES="gles_common gles_extensions gles1_only gles1_extensions gles2_only \ +gles2_extensions gles3_only" + +for ENTRY in $GLES_ENTRIES; do + SRC_FILE=$OPENGLES_DISPATCH_SRCDIR/${ENTRY}.entries + DST_FILE=$OPENGLES_DISPATCH_INCLUDE/${ENTRY}_functions.h + gen_funcargs_header "$SRC_FILE" "$DST_FILE" "$GEN_ENTRIES" +done + +if [ "$FAILURES" ]; then + exit 1 +fi diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/CMakeLists.txt new file mode 100644 index 0000000..2fc0fcb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(emugl) +add_subdirectory(OpenglCodecCommon) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/CMakeLists.txt new file mode 100644 index 0000000..fe3db64 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/CMakeLists.txt @@ -0,0 +1,15 @@ +set(SOURCES + ChecksumCalculator.cpp + ChecksumCalculator.h + ChecksumCalculatorThreadInfo.cpp + ChecksumCalculatorThreadInfo.h + CMakeLists.txt + ErrorLog.h + gl_base_types.h + GLDecoderContextData.h + glUtils.cpp + glUtils.h + Makefile + ProtocolUtils.h) + +add_library(OpenglCodecCommon STATIC ${SOURCES}) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.cpp new file mode 100644 index 0000000..60940b8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.cpp @@ -0,0 +1,154 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "ChecksumCalculator.h" + +#include +#include +#include + +// Checklist when implementing new protocol: +// 1. update CHECKSUMHELPER_MAX_VERSION +// 2. update maxChecksumSize() +// 3. update checksumByteSize() +// 4. update addBuffer, writeChecksum, resetChecksum, validate + +// change CHECKSUMHELPER_MAX_VERSION when you want to update the protocol version +#define CHECKSUMHELPER_MAX_VERSION 1 + +// checksum buffer size +// Please add a new checksum buffer size when implementing a new protocol, +// as well as modifying the maxChecksumSize function. +static const size_t kV1ChecksumSize = 8; + +static constexpr size_t maxChecksumSize() { + return 0 > kV1ChecksumSize ? 0 : kV1ChecksumSize; +} + +static const size_t kMaxChecksumSize = maxChecksumSize(); + +// utility macros to create checksum string at compilation time +#define CHECKSUMHELPER_VERSION_STR_PREFIX "ANDROID_EMU_CHECKSUM_HELPER_v" +#define CHECKSUMHELPER_MACRO_TO_STR(x) #x +#define CHECKSUMHELPER_MACRO_VAL_TO_STR(x) CHECKSUMHELPER_MACRO_TO_STR(x) + +static const uint32_t kMaxVersion = CHECKSUMHELPER_MAX_VERSION; +static const char* kMaxVersionStrPrefix = CHECKSUMHELPER_VERSION_STR_PREFIX; +static const char* kMaxVersionStr = CHECKSUMHELPER_VERSION_STR_PREFIX CHECKSUMHELPER_MACRO_VAL_TO_STR(CHECKSUMHELPER_MAX_VERSION); + +#undef CHECKSUMHELPER_MAX_VERSION +#undef CHECKSUMHELPER_VERSION_STR_PREFIX +#undef CHECKSUMHELPER_MACRO_TO_STR +#undef CHECKSUMHELPER_MACRO_VAL_TO_STR + +uint32_t ChecksumCalculator::getMaxVersion() {return kMaxVersion;} +const char* ChecksumCalculator::getMaxVersionStr() {return kMaxVersionStr;} +const char* ChecksumCalculator::getMaxVersionStrPrefix() {return kMaxVersionStrPrefix;} + +bool ChecksumCalculator::setVersion(uint32_t version) { + if (version > kMaxVersion) { // unsupported version + LOG_CHECKSUMHELPER("%s: ChecksumCalculator Set Unsupported version Version %d\n", + __FUNCTION__, m_version); + return false; + } + if (m_isEncodingChecksum) { // setVersion is called in the middle of encoding checksums + LOG_CHECKSUMHELPER("%s: called between addBuffer and writeChecksum\n", + __FUNCTION__); + return false; + } + m_version = version; + LOG_CHECKSUMHELPER("%s: ChecksumCalculator Set Version %d\n", __FUNCTION__, + m_version); + return true; +} + +size_t ChecksumCalculator::checksumByteSize() const { + switch (m_version) { + case 0: + return 0; + case 1: + return sizeof(uint32_t) + sizeof(m_numWrite); + default: + return 0; + } +} + +void ChecksumCalculator::addBuffer(const void* buf, size_t packetLen) { + m_isEncodingChecksum = true; + switch (m_version) { + case 1: + m_v1BufferTotalLength += packetLen; + break; + } +} + +bool ChecksumCalculator::writeChecksum(void* outputChecksum, size_t outputChecksumLen) { + if (outputChecksumLen < checksumByteSize()) return false; + char *checksumPtr = (char *)outputChecksum; + switch (m_version) { + case 1: { // protocol v1 is to reverse the packetLen and write it at the end + uint32_t val = computeV1Checksum(); + memcpy(checksumPtr, &val, sizeof(val)); + memcpy(checksumPtr+sizeof(val), &m_numWrite, sizeof(m_numWrite)); + break; + } + } + resetChecksum(); + m_numWrite++; + return true; +} + +void ChecksumCalculator::resetChecksum() { + switch (m_version) { + case 1: + m_v1BufferTotalLength = 0; + break; + } + m_isEncodingChecksum = false; +} + +bool ChecksumCalculator::validate(const void* expectedChecksum, size_t expectedChecksumLen) { + size_t checksumSize = checksumByteSize(); + if (expectedChecksumLen != checksumSize) { + m_numRead++; + resetChecksum(); + return false; + } + // buffers for computing the checksum + unsigned char sChecksumBuffer[kMaxChecksumSize]; + switch (m_version) { + case 1: { + uint32_t val = computeV1Checksum(); + memcpy(sChecksumBuffer, &val, sizeof(val)); + memcpy(sChecksumBuffer+sizeof(val), &m_numRead, sizeof(m_numRead)); + break; + } + } + bool isValid = !memcmp(sChecksumBuffer, expectedChecksum, checksumSize); + m_numRead++; + resetChecksum(); + return isValid; +} + +uint32_t ChecksumCalculator::computeV1Checksum() { + uint32_t revLen = m_v1BufferTotalLength; + revLen = (revLen & 0xffff0000) >> 16 | (revLen & 0x0000ffff) << 16; + revLen = (revLen & 0xff00ff00) >> 8 | (revLen & 0x00ff00ff) << 8; + revLen = (revLen & 0xf0f0f0f0) >> 4 | (revLen & 0x0f0f0f0f) << 4; + revLen = (revLen & 0xcccccccc) >> 2 | (revLen & 0x33333333) << 2; + revLen = (revLen & 0xaaaaaaaa) >> 1 | (revLen & 0x55555555) << 1; + return revLen; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.h new file mode 100644 index 0000000..d315304 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculator.h @@ -0,0 +1,181 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include +#include + +// Set TRACE_CHECKSUMHELPER to 1 to debug creation/destruction of GLprotocol +// instances. +#define TRACE_CHECKSUMHELPER 0 + +#if TRACE_CHECKSUMHELPER +#define LOG_CHECKSUMHELPER(...) fprintf(stderr, __VA_ARGS__) +#else +#define LOG_CHECKSUMHELPER(...) +#endif + +// ChecksumCalculator adds checksum as an array of bytes to GL pipe communication, which +// size depends on the protocol version. Each pipe should use one ChecksumCalculator. +// It can: +// (1) take a list of buffers one by one and compute their checksum string, +// in this case the checksum should be as the data in those buffers are +// concatenated; +// (2) compute the checksum of the buffer list, then either write them into +// a buffer provided by user, or compare it against a checksum provided +// by user +// (3) support different checksum version in future. +// +// For backward compatibility, checksum version 0 behaves the same as there is +// no checksum (i.e., checksumByteSize returns 0, validate always returns true, +// addBuffer and writeCheckSum does nothing). +// +// Notice that to detect package lost, ChecksumCalculator also keeps track of how +// many times it generates/validates checksums, and might use it as part of the +// checksum. +// +// To evaluate checksums from a list of data buffers buf1, buf2... Please call +// addBuffer(buf1, buf1len), addBuffer(buf2, buf2len) ... in order. +// Then if the checksum needs to be encoded into a buffer, one needs to allocate +// a checksum buffer with size checksumByteSize(), and call +// writeChecksum(checksumBuffer) to write the checksum to the buffer. +// If the checksum needs to be validated against an existing one, one needs to +// call validate(existChecksum, existChecksumLen). +// +// The checksum generator and validator must be set to the same version, and +// the validator must check ALL checksums in the order they are generated, +// otherwise the validation function will return false. +// +// It is allowed to change the checksum version between calculating two +// checksums. This is designed for backward compatibility reason. +// +// Example 1, encoding and decoding: +// +// bool testChecksum(void* buf, size_t bufLen) { +// // encoding message +// ChecksumCalculator encoder; +// encoder.setVersion(1); +// encoder.addBuffer(buf, bufLen); +// std::vector message(bufLen + encoder.checksumByteSize()); +// memcpy(&message[0], buf, bufLen); +// encoder.writeChecksum(&message[0] + bufLen, encoder.checksumByteSize()); +// +// // decoding message +// ChecksumCalculator decoder; +// decoder.setVersion(1); +// decoder.addBuffer(&message[0], bufLen); +// return decoder.validate(&message[0] + bufLen, decoder.checksumByteSize()); +// } +// The return value is true. +// +// Example 2, decoding will fail if the order of messages is wrong: +// +// bool testChecksumOrder(void* buf1, size_t bufLen1, +// void* buf2, size_t bufLen2) { +// // encoding messages +// ChecksumCalculator encoder; +// encoder.setVersion(1); +// +// std::vector message1(bufLen1 + encoder.checksumByteSize()); +// std::vector message2(bufLen2 + encoder.checksumByteSize()); +// +// encoder.addBuffer(buf1, bufLen1); +// std::vector message1(bufLen1 + encoder.checksumByteSize()); +// memcpy(&message1[0], buf1, bufLen1); +// encoder.writeChecksum(&message1[0] + bufLen1, encoder.checksumByteSize()); +// +// encoder.addBuffer(buf2, bufLen2); +// std::vector message2(bufLen2 + encoder.checksumByteSize()); +// memcpy(&message2[0], buf2, bufLen2); +// encoder.writeChecksum(&message2[0] + bufLen2, encoder.checksumByteSize()); +// +// // decoding messages +// ChecksumCalculator decoder; +// decoder.setVersion(1); +// decoder.addBuffer(&message2[0], bufLen2); +// // returns false because the decoding order is not consistent with +// // encoding order +// if (!decoder.validate(&message2[0]+bufLen2, decoder.checksumByteSize())) { +// return false; +// } +// +// decoder.addBuffer(&message1[0], bufLen1); +// if (!decoder.validate(&message1[0]+bufLen1, decoder.checksumByteSize())) { +// return false; +// } +// +// return false; +// } + +class ChecksumCalculator { +public: + // Get and set current checksum version + uint32_t getVersion() const { return m_version; } + // Call setVersion to set a checksum version. It should be called before + // addBuffer(), writeChecksum() and validate(). And it should be called + // exact once per rendering thread if both host and guest support checksum. + // It won't be called if either host or guest does not support checksum. + bool setVersion(uint32_t version); + + // Maximum supported checksum version + static uint32_t getMaxVersion(); + // A version string that looks like "ANDROID_EMU_CHECKSUM_HELPER_v1" + // Used multiple times when the guest queries the maximum supported version + // from the host. + // The library owns the returned pointer. The returned pointer will be + // deconstructed when unloading library. + static const char* getMaxVersionStr(); + static const char* getMaxVersionStrPrefix(); + + // Size of checksum in the current version + size_t checksumByteSize() const; + + // Update the current checksum value from the data + // at |buf| of |bufLen| bytes. Once all buffers + // have been added, call writeChecksum() to store + // the final checksum value and reset its state. + void addBuffer(const void* buf, size_t bufLen); + // Write the checksum from the list of buffers to outputChecksum + // Will reset the list of buffers by calling resetChecksum. + // Return false if the buffer is not long enough + // Please query buffer size from checksumByteSize() + bool writeChecksum(void* outputChecksum, size_t outputChecksumLen); + // Restore the states for computing checksums. + // Automatically called at the end of writeChecksum and validate. + // Can also be used to abandon the current checksum being calculated. + // Notes: it doesn't update the internal read / write counter + void resetChecksum(); + + // Calculate the checksum from the list of buffers and + // compare it with the checksum encoded in expectedChecksum + // Will reset the list of buffers by calling resetChecksum. + bool validate(const void* expectedChecksum, size_t expectedChecksumLen); +protected: + uint32_t m_version = 0; + // A temporary state used to compute the total length of a list of buffers, + // if addBuffer is called. + uint32_t m_numRead = 0; + uint32_t m_numWrite = 0; + // m_isEncodingChecksum is true when between addBuffer and writeChecksum + bool m_isEncodingChecksum = false; +private: + // Compute a 32bit checksum + // Used in protocol v1 + uint32_t computeV1Checksum(); + // The buffer used in protocol version 1 to compute checksum. + uint32_t m_v1BufferTotalLength = 0; +}; diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.cpp new file mode 100644 index 0000000..aedfea1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.cpp @@ -0,0 +1,103 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "ChecksumCalculatorThreadInfo.h" + +#include "emugl/common/crash_reporter.h" +#include "emugl/common/lazy_instance.h" +#include "emugl/common/thread_store.h" + +#include +#include +#include + +namespace { + +class ChecksumCalculatorThreadStore : public ::emugl::ThreadStore { +public: + ChecksumCalculatorThreadStore() : ::emugl::ThreadStore(NULL) {} +}; + +#ifdef TRACE_CHECKSUMHELPER +std::atomic sNumInstances(0); +#endif // TRACE_CHECKSUMHELPER + +} + +static ::emugl::LazyInstance s_tls = + LAZY_INSTANCE_INIT; + +static ChecksumCalculatorThreadInfo* getChecksumCalculatorThreadInfo() { + return static_cast(s_tls->get()); +} + +ChecksumCalculatorThreadInfo::ChecksumCalculatorThreadInfo() { + LOG_CHECKSUMHELPER( + "%s: Checksum thread created (%u instances)\n", __FUNCTION__, + (size_t)sNumInstances); + s_tls->set(this); +} + +ChecksumCalculatorThreadInfo::~ChecksumCalculatorThreadInfo() { + LOG_CHECKSUMHELPER( + "%s: GLprotocol destroyed (%u instances)\n", __FUNCTION__, + (size_t)sNumInstances); + s_tls->set(NULL); +} + +uint32_t ChecksumCalculatorThreadInfo::getVersion() { + return getChecksumCalculatorThreadInfo()->m_protocol.getVersion(); +} + +bool ChecksumCalculatorThreadInfo::setVersion(uint32_t version) { + return getChecksumCalculatorThreadInfo()->m_protocol.setVersion(version); +} + +size_t ChecksumCalculatorThreadInfo::checksumByteSize() { + return getChecksumCalculatorThreadInfo()->m_protocol.checksumByteSize(); +} + +bool ChecksumCalculatorThreadInfo::writeChecksum(void* buf, + size_t bufLen, + void* outputChecksum, + size_t outputChecksumLen) { + ChecksumCalculator& protocol = + getChecksumCalculatorThreadInfo()->m_protocol; + protocol.addBuffer(buf, bufLen); + return protocol.writeChecksum(outputChecksum, outputChecksumLen); +} + +bool ChecksumCalculatorThreadInfo::validate(void* buf, + size_t bufLen, + void* checksum, + size_t checksumLen) { + ChecksumCalculator& protocol = + getChecksumCalculatorThreadInfo()->m_protocol; + protocol.addBuffer(buf, bufLen); + return protocol.validate(checksum, checksumLen); +} + +void ChecksumCalculatorThreadInfo::validOrDie(void* buf, + size_t bufLen, + void* checksum, + size_t checksumLen, + const char* message) { + // We should actually call crashhandler_die(message), but I don't think we + // can link to that library from here + if (!validate(buf, bufLen, checksum, checksumLen)) { + emugl_crash_reporter(emugl::LogLevel::FATAL, message); + } +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h new file mode 100644 index 0000000..993551f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ChecksumCalculatorThreadInfo.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "ChecksumCalculator.h" + +// ChecksumCalculatorThreadInfo is the class that makes ChecksumCalculator +// thread-safe. On the host, please only use ChecksumCalculator through this +// class. + +class ChecksumCalculatorThreadInfo { +public: + ChecksumCalculatorThreadInfo(); + ~ChecksumCalculatorThreadInfo(); + + static uint32_t getVersion(); + static bool setVersion(uint32_t version); + + static uint32_t getMaxVersion(); + static const char* getMaxVersionString() { + return ChecksumCalculator::getMaxVersionStr(); + } + + static size_t checksumByteSize(); + static bool writeChecksum(void* buf, + size_t bufLen, + void* outputChecksum, + size_t outputChecksumLen); + + static bool validate(void* buf, + size_t bufLen, + void* checksum, + size_t checksumLen); + static void validOrDie(void* buf, + size_t bufLen, + void* checksum, + size_t checksumLen, + const char* message); + +private: + ChecksumCalculator m_protocol; +}; diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ErrorLog.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ErrorLog.h new file mode 100644 index 0000000..bb450ee --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ErrorLog.h @@ -0,0 +1,28 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef _ERROR_LOG_H_ +#define _ERROR_LOG_H_ + +#include +#define ERR(...) fprintf(stderr, __VA_ARGS__) +#define EMUGL_DEBUG +#ifdef EMUGL_DEBUG +# define DBG(...) fprintf(stderr, __VA_ARGS__) +#else +# define DBG(...) ((void)0) +#endif + +#endif // _ERROR_LOG_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/GLDecoderContextData.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/GLDecoderContextData.h new file mode 100644 index 0000000..3a6ee17 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/GLDecoderContextData.h @@ -0,0 +1,82 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#pragma once + +#include +#include + +#include +#include + +// Convenient class used to hold the common context data shared +// by both the GLESv1 and GLESv2 decoders. This corresponds to +// vertex attribute buffers. +class GLDecoderContextData { +public: + // List of supported vertex attribute indices, as they appear in + // a glVertexAttribPointer() call. + typedef enum { + VERTEX_LOCATION = 0, + NORMAL_LOCATION = 1, + COLOR_LOCATION = 2, + POINTSIZE_LOCATION = 3, + TEXCOORD0_LOCATION = 4, + TEXCOORD1_LOCATION = 5, + TEXCOORD2_LOCATION = 6, + TEXCOORD3_LOCATION = 7, + TEXCOORD4_LOCATION = 8, + TEXCOORD5_LOCATION = 9, + TEXCOORD6_LOCATION = 10, + TEXCOORD7_LOCATION = 11, + MATRIXINDEX_LOCATION = 12, + WEIGHT_LOCATION = 13, + LAST_LOCATION = 14 + } PointerDataLocation; + + // Default constructor. + GLDecoderContextData(int numLocations = kMaxVertexAttributes) + : mPointerData(), + mNumLocations(static_cast(numLocations)) { + mPointerData.resize(mNumLocations); + } + + // Store |len| bytes from |data| into the buffer associated with + // vertex attribute index |loc|. + void storePointerData(unsigned int loc, void *data, size_t len) { + if (loc < mNumLocations) { + std::string& ptrData = mPointerData[loc]; + ptrData.assign(reinterpret_cast(data), len); + } else { + // User error, don't do anything here + } + } + + // Return pointer to data associated with vertex attribute index |loc| + void* pointerData(unsigned int loc) const { + if (loc < mNumLocations) { + return const_cast(mPointerData[loc].c_str()); + } else { + // User error. Return nullptr. + return nullptr; + } + } + +private: + static const int kMaxVertexAttributes = 64; + + std::vector mPointerData; + unsigned mNumLocations = 0; +}; diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/Makefile b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/Makefile new file mode 100644 index 0000000..e8bf431 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/Makefile @@ -0,0 +1,13 @@ + +ROOT=../.. + +include $(ROOT)/make/commondefs + +CXXFILES = TcpStream.cpp GLClientState.cpp glUtils.cpp +CXXINCS += -I$(ROOT)/libs/GLESv1 -I$(ROOT)/include + +LIBRARY_NAME = libcodecCommon.a + +include $(COMMONRULES) + + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ProtocolUtils.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ProtocolUtils.h new file mode 100644 index 0000000..9b832dd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/ProtocolUtils.h @@ -0,0 +1,193 @@ +#ifndef EMUGL_PROTOCOL_UTILS_H +#define EMUGL_PROTOCOL_UTILS_H + +#include +#include +#include +#include + +namespace emugl { + +// Helper macro +#define COMPILE_ASSERT(cond) static char kAssert##__LINE__[1 - 2 * !(cond)] __attribute__((unused)) = { 0 } + +// Helper template: is_pointer. +// is_pointer::value is true iff |T| is a pointer type. +template struct is_pointer { + static const bool value = false; +}; + +template struct is_pointer { + static const bool value = true; +}; + +// A helper template to extract values form the wire protocol stream +// and convert them to appropriate host values. +// +// The wire protocol uses 32-bit exclusively when transferring +// GLintptr or GLsizei values, as well as opaque handles like GLeglImage, +// from the guest (even when the guest is 64-bit). +// +// The corresponding host definitions depend on the host bitness. For +// example, GLintptr is 64-bit on linux-x86_64. The following is a set +// of templates that can simplify the conversion of protocol values +// into host ones. +// +// The most important one is: +// +// unpack(const void* ptr) +// +// Which reads bytes from |ptr|, using |SIZE_TYPE| as the underlying +// sized-integer specifier (e.g. 'uint32_t'), and converting the result +// into a |HOST_TYPE| value. For example: +// +// unpack(ptr + 12); +// +// will read a 4-byte value from |ptr + 12| and convert it into +// an EGLImage, which is a host void*. The template detects host +// pointer types to perform proper type casting. +// +// TODO(digit): Add custom unpackers to handle generic opaque void* values. +// and map them to unique 32-bit values. + +template +struct UnpackerT {}; + +template +struct UnpackerT { + static inline T unpack(const void* ptr) { + COMPILE_ASSERT(sizeof(T) == sizeof(S)); + return (T)(*(S*)(ptr)); + } +}; + +template +struct UnpackerT { + static inline T unpack(const void* ptr) { + return (T)(uintptr_t)(*(S*)(ptr)); + } +}; + +template <> +struct UnpackerT { + static inline float unpack(const void* ptr) { + union { + float f; + uint32_t u; + } v; + v.u = *(uint32_t*)(ptr); + return v.f; + } +}; + +template <> +struct UnpackerT { + static inline double unpack(const void* ptr) { + union { + double d; + uint32_t u; + } v; + v.u = *(uint64_t*)(ptr); + return v.d; + } +}; + +template <> +struct UnpackerT { + static inline ssize_t unpack(const void* ptr) { + return (ssize_t)*(int32_t*)(ptr); + } +}; + +template +inline T Unpack(const void* ptr) { + return UnpackerT::value>::unpack(ptr); +} + +// Helper class used to ensure input buffers passed to EGL/GL functions +// are properly aligned (preventing crashes with some backends). +// Usage example: +// +// InputBuffer inputBuffer(ptr, size); +// glDoStuff(inputBuffer.get()); +// +// inputBuffer.get() will return the original value of |ptr| if it was +// aligned on an 8-byte boundary. Otherwise, it will return the address +// of an aligned heap-allocated copy of the original |size| bytes starting +// from |ptr|. The heap block is released at scope exit. +class InputBuffer { +public: + InputBuffer(const void* input, size_t size, size_t align = 8) : + mBuff(input), mIsCopy(false) { + if (((uintptr_t)input & (align - 1U)) != 0) { + void* newBuff = malloc(size); + memcpy(newBuff, input, size); + mBuff = newBuff; + mIsCopy = true; + } + } + + ~InputBuffer() { + if (mIsCopy) { + free((void*)mBuff); + } + } + + const void* get() const { + return mBuff; + } + +private: + const void* mBuff; + bool mIsCopy; +}; + +// Helper class used to ensure that output buffers passed to EGL/GL functions +// are aligned on 8-byte addresses. +// Usage example: +// +// ptr = stream->alloc(size); +// OutputBuffer outputBuffer(ptr, size); +// glGetStuff(outputBuffer.get()); +// outputBuffer.flush(); +// +// outputBuffer.get() returns the original value of |ptr| if it was already +// aligned on an 8=byte boundary. Otherwise, it returns the size of an heap +// allocated zeroed buffer of |size| bytes. +// +// outputBuffer.flush() copies the content of the heap allocated buffer back +// to |ptr| explictly, if needed. If a no-op if |ptr| was aligned. +class OutputBuffer { +public: + OutputBuffer(unsigned char* ptr, size_t size, size_t align = 8) : + mOrgBuff(ptr), mBuff(ptr), mSize(size) { + if (((uintptr_t)ptr & (align - 1U)) != 0) { + void* newBuff = calloc(1, size); + mBuff = newBuff; + } + } + + ~OutputBuffer() { + if (mBuff != mOrgBuff) { + free(mBuff); + } + } + + void* get() const { + return mBuff; + } + + void flush() { + if (mBuff != mOrgBuff) { + memcpy(mOrgBuff, mBuff, mSize); + } + } +private: + unsigned char* mOrgBuff; + void* mBuff; + size_t mSize; +}; + +} // namespace emugl + +#endif // EMUGL_PROTOCOL_UTILS_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.cpp new file mode 100644 index 0000000..e9e82b7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.cpp @@ -0,0 +1,416 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#include "glUtils.h" + +#include "ErrorLog.h" + +#include + +size_t glSizeof(GLenum type) +{ + size_t retval = 0; + switch(type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + retval = 1; + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_HALF_FLOAT_OES: + retval = 2; + break; + case GL_INT: + case GL_FLOAT: + case GL_FIXED: + case GL_BOOL: + retval = 4; + break; +#ifdef GL_DOUBLE + case GL_DOUBLE: + retval = 8; + break; +#endif + case GL_FLOAT_VEC2: + case GL_INT_VEC2: + case GL_BOOL_VEC2: + retval = 8; + break; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + case GL_FLOAT_VEC3: + retval = 12; + break; + case GL_FLOAT_VEC4: + case GL_BOOL_VEC4: + case GL_INT_VEC4: + case GL_FLOAT_MAT2: + retval = 16; + break; + case GL_FLOAT_MAT3: + retval = 36; + break; + case GL_FLOAT_MAT4: + retval = 64; + break; + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + retval = 4; + break; + default: + ERR("**** ERROR unknown type 0x%x (%s,%d)\n", type, __FUNCTION__,__LINE__); + } + return retval; + +} + +size_t glUtilsParamSize(GLenum param) +{ + size_t s = 0; + + switch(param) + { + case GL_DEPTH_TEST: + case GL_DEPTH_FUNC: + case GL_DEPTH_BITS: + case GL_MAX_CLIP_PLANES: + case GL_GREEN_BITS: + case GL_MAX_MODELVIEW_STACK_DEPTH: + case GL_MAX_PROJECTION_STACK_DEPTH: + case GL_MAX_TEXTURE_STACK_DEPTH: + case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: + case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + case GL_MAX_TEXTURE_SIZE: + case GL_TEXTURE_GEN_MODE_OES: + case GL_TEXTURE_ENV_MODE: + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_SPOT_EXPONENT: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + case GL_SHININESS: + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_POINT_SIZE: + case GL_POINT_SIZE_MIN: + case GL_POINT_SIZE_MAX: + case GL_POINT_FADE_THRESHOLD_SIZE: + case GL_CULL_FACE_MODE: + case GL_FRONT_FACE: + case GL_SHADE_MODEL: + case GL_DEPTH_WRITEMASK: + case GL_DEPTH_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_WRITEMASK: + case GL_MATRIX_MODE: + case GL_MODELVIEW_STACK_DEPTH: + case GL_PROJECTION_STACK_DEPTH: + case GL_TEXTURE_STACK_DEPTH: + case GL_ALPHA_TEST_FUNC: + case GL_ALPHA_TEST_REF: + case GL_ALPHA_TEST: + case GL_BLEND_DST: + case GL_BLEND_SRC: + case GL_BLEND: + case GL_LOGIC_OP_MODE: + case GL_SCISSOR_TEST: + case GL_MAX_TEXTURE_UNITS: + case GL_ACTIVE_TEXTURE: + case GL_ALPHA_BITS: + case GL_ARRAY_BUFFER_BINDING: + case GL_BLUE_BITS: + case GL_CLIENT_ACTIVE_TEXTURE: + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + case GL_COLOR_ARRAY: + case GL_COLOR_ARRAY_BUFFER_BINDING: + case GL_COLOR_ARRAY_SIZE: + case GL_COLOR_ARRAY_STRIDE: + case GL_COLOR_ARRAY_TYPE: + case GL_COLOR_LOGIC_OP: + case GL_COLOR_MATERIAL: + case GL_PACK_ALIGNMENT: + case GL_PERSPECTIVE_CORRECTION_HINT: + case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: + case GL_POINT_SIZE_ARRAY_STRIDE_OES: + case GL_POINT_SIZE_ARRAY_TYPE_OES: + case GL_POINT_SMOOTH: + case GL_POINT_SMOOTH_HINT: + case GL_POINT_SPRITE_OES: + case GL_COORD_REPLACE_OES: + case GL_COMBINE_ALPHA: + case GL_SRC0_RGB: + case GL_SRC1_RGB: + case GL_SRC2_RGB: + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_SRC0_ALPHA: + case GL_SRC1_ALPHA: + case GL_SRC2_ALPHA: + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + case GL_COMBINE_RGB: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_RESCALE_NORMAL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_ALPHA_TO_ONE: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FUNC: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_WRITEMASK: + case GL_TEXTURE_2D: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_TEXTURE_BINDING_EXTERNAL_OES: + case GL_TEXTURE_COORD_ARRAY: + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: + case GL_TEXTURE_COORD_ARRAY_SIZE: + case GL_TEXTURE_COORD_ARRAY_STRIDE: + case GL_TEXTURE_COORD_ARRAY_TYPE: + case GL_UNPACK_ALIGNMENT: + case GL_VERTEX_ARRAY: + case GL_VERTEX_ARRAY_BUFFER_BINDING: + case GL_VERTEX_ARRAY_SIZE: + case GL_VERTEX_ARRAY_STRIDE: + case GL_VERTEX_ARRAY_TYPE: + case GL_SPOT_CUTOFF: + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_GENERATE_MIPMAP: + case GL_GENERATE_MIPMAP_HINT: + case GL_RENDERBUFFER_WIDTH_OES: + case GL_RENDERBUFFER_HEIGHT_OES: + case GL_RENDERBUFFER_INTERNAL_FORMAT_OES: + case GL_RENDERBUFFER_RED_SIZE_OES: + case GL_RENDERBUFFER_GREEN_SIZE_OES: + case GL_RENDERBUFFER_BLUE_SIZE_OES: + case GL_RENDERBUFFER_ALPHA_SIZE_OES: + case GL_RENDERBUFFER_DEPTH_SIZE_OES: + case GL_RENDERBUFFER_STENCIL_SIZE_OES: + case GL_RENDERBUFFER_BINDING: + case GL_FRAMEBUFFER_BINDING: + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES: + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES: + case GL_FENCE_STATUS_NV: + case GL_FENCE_CONDITION_NV: + case GL_TEXTURE_WIDTH_QCOM: + case GL_TEXTURE_HEIGHT_QCOM: + case GL_TEXTURE_DEPTH_QCOM: + case GL_TEXTURE_INTERNAL_FORMAT_QCOM: + case GL_TEXTURE_FORMAT_QCOM: + case GL_TEXTURE_TYPE_QCOM: + case GL_TEXTURE_IMAGE_VALID_QCOM: + case GL_TEXTURE_NUM_LEVELS_QCOM: + case GL_TEXTURE_TARGET_QCOM: + case GL_TEXTURE_OBJECT_VALID_QCOM: + case GL_BLEND_EQUATION_RGB_OES: + case GL_BLEND_EQUATION_ALPHA_OES: + case GL_BLEND_DST_RGB_OES: + case GL_BLEND_SRC_RGB_OES: + case GL_BLEND_DST_ALPHA_OES: + case GL_BLEND_SRC_ALPHA_OES: + case GL_MAX_LIGHTS: + case GL_SHADER_TYPE: + case GL_DELETE_STATUS: + case GL_COMPILE_STATUS: + case GL_INFO_LOG_LENGTH: + case GL_SHADER_SOURCE_LENGTH: + case GL_CURRENT_PROGRAM: + case GL_LINK_STATUS: + case GL_VALIDATE_STATUS: + case GL_ATTACHED_SHADERS: + case GL_ACTIVE_UNIFORMS: + case GL_ACTIVE_ATTRIBUTES: + case GL_SUBPIXEL_BITS: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + case GL_NUM_SHADER_BINARY_FORMATS: + case GL_SHADER_COMPILER: + case GL_MAX_VERTEX_ATTRIBS: + case GL_MAX_VERTEX_UNIFORM_VECTORS: + case GL_MAX_VARYING_VECTORS: + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + case GL_MAX_RENDERBUFFER_SIZE: + case GL_MAX_TEXTURE_IMAGE_UNITS: + case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: + case GL_LINE_WIDTH: + s = 1; + break; + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_DEPTH_RANGE: + case GL_MAX_VIEWPORT_DIMS: + case GL_SMOOTH_POINT_SIZE_RANGE: + case GL_SMOOTH_LINE_WIDTH_RANGE: + s= 2; + break; + case GL_SPOT_DIRECTION: + case GL_POINT_DISTANCE_ATTENUATION: + case GL_CURRENT_NORMAL: + s = 3; + break; + case GL_CURRENT_VERTEX_ATTRIB: + case GL_CURRENT_TEXTURE_COORDS: + case GL_CURRENT_COLOR: + case GL_FOG_COLOR: + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + case GL_POSITION: + case GL_LIGHT_MODEL_AMBIENT: + case GL_TEXTURE_ENV_COLOR: + case GL_SCISSOR_BOX: + case GL_VIEWPORT: + case GL_TEXTURE_CROP_RECT_OES: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_AMBIENT_AND_DIFFUSE: + case GL_BLEND_COLOR: + s = 4; + break; + case GL_MODELVIEW_MATRIX: + case GL_PROJECTION_MATRIX: + case GL_TEXTURE_MATRIX: + s = 16; + break; + default: + ERR("glUtilsParamSize: unknow param 0x%08x\n", param); + s = 1; // assume 1 + } + return s; +} + +void glUtilsPackPointerData(unsigned char *dst, unsigned char *src, + int size, GLenum type, unsigned int stride, + unsigned int datalen) +{ + unsigned int vsize = size * glSizeof(type); + if (stride == 0) stride = vsize; + + if (stride == vsize) { + memcpy(dst, src, datalen); + } else { + for (unsigned int i = 0; i < datalen; i += vsize) { + memcpy(dst, src, vsize); + dst += vsize; + src += stride; + } + } +} + +int glUtilsPixelBitSize(GLenum format, GLenum type) +{ + int components = 0; + int componentsize = 0; + int pixelsize = 0; + switch(type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + componentsize = 8; + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_RGB565_OES: + case GL_RGB5_A1_OES: + case GL_RGBA4_OES: + pixelsize = 16; + break; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_FIXED: + case GL_UNSIGNED_INT_24_8_OES: + pixelsize = 32; + break; + default: + ERR("glUtilsPixelBitSize: unknown pixel type - assuming pixel data 0\n"); + componentsize = 0; + } + + if (pixelsize == 0) { + switch(format) { +#if 0 + case GL_RED: + case GL_GREEN: + case GL_BLUE: +#endif + case GL_ALPHA: + case GL_LUMINANCE: + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL_OES: + components = 1; + break; + case GL_LUMINANCE_ALPHA: + components = 2; + break; + case GL_RGB: +#if 0 + case GL_BGR: +#endif + components = 3; + break; + case GL_RGBA: + case GL_BGRA_EXT: + components = 4; + break; + default: + ERR("glUtilsPixelBitSize: unknown pixel format...\n"); + components = 0; + } + pixelsize = components * componentsize; + } + + return pixelsize; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.h new file mode 100644 index 0000000..63b35cc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/glUtils.h @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#pragma once + +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +size_t glSizeof(GLenum type); + +size_t glUtilsParamSize(GLenum param); + +void glUtilsPackPointerData(unsigned char *dst, unsigned char *str, + int size, GLenum type, unsigned int stride, + unsigned int datalen); + +int glUtilsPixelBitSize(GLenum format, GLenum type); + +#ifdef __cplusplus +} +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/gl_base_types.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/gl_base_types.h new file mode 100644 index 0000000..38c594b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/OpenglCodecCommon/gl_base_types.h @@ -0,0 +1,62 @@ +/* +* Copyright (C) 2011 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +#ifndef __GL_BASE_TYPES__H +#define __GL_BASE_TYPES__H + +#include + +#ifndef gles1_APIENTRY +#define gles1_APIENTRY KHRONOS_APIENTRY +#endif + +#ifndef gles2_APIENTRY +#define gles2_APIENTRY KHRONOS_APIENTRY +#endif + +typedef void GLvoid; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef char GLchar; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int32_t GLclampx; +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; +typedef char *GLstr; +/* JR XXX Treating this as an in handle - is this correct? */ +typedef void * GLeglImageOES; + +/* ErrorCode */ +#ifndef GL_INVALID_ENUM +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 +#endif + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/CMakeLists.txt new file mode 100644 index 0000000..e4717b2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(common) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/CMakeLists.txt new file mode 100644 index 0000000..09388c6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/CMakeLists.txt @@ -0,0 +1,33 @@ +set(COMMON_SOURCES + condition_variable.h + crash_reporter.cpp + crash_reporter.h + id_to_object_map.cpp + id_to_object_map.h + lazy_instance.cpp + lazy_instance.h + logging.cpp + logging.h + message_channel.cpp + message_channel.h + mutex.h + mutex_unittest.cpp + pod_vector.cpp + pod_vector.h + scoped_pointer_vector.h + shared_library.cpp + shared_library.h + smart_ptr.cpp + smart_ptr.h + sockets.cpp + sockets.h + thread.h + thread_pthread.cpp + thread_store.cpp + thread_store.h + thread_unittest.cpp + unique_integer_map.h) + +add_library(emugl_common STATIC ${COMMON_SOURCES}) +target_link_libraries(emugl_common + dl pthread) diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable.h new file mode 100644 index 0000000..66f9d02 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable.h @@ -0,0 +1,91 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_CONDITION_VARIABLE_H +#define EMUGL_CONDITION_VARIABLE_H + +#include "emugl/common/mutex.h" +#include "emugl/common/pod_vector.h" + +#ifdef _WIN32 +#include +#else +#include +#endif + +namespace emugl { + +// A class that implements a condition variable, which can be used in +// association with a Mutex to blocking-wait for specific conditions. +// Useful to implement various synchronization data structures. +// For an example, see ::emugl::MessageChannel. +class ConditionVariable { +public: +#ifdef _WIN32 + + // Default constructor. + ConditionVariable(); + + // Destructor. + ~ConditionVariable(); + + // Wait until the condition variable is signaled. Note that spurious + // wakeups are always a possibility, so always check the condition + // in a loop, i.e. do: + // + // while (!condition) { condVar.wait(&lock); } + // + // instead of: + // + // if (!condition) { condVar.wait(&lock); } + // + void wait(Mutex* userLock); + + // Signal that a condition was reached. This will wake at most one + // waiting thread that is blocked on wait(). + void signal(); + +private: + PodVector mWaiters; + Mutex mLock; + +#else // !_WIN32 + + // Note: on Posix systems, make it a naive wrapper around pthread_cond_t. + + ConditionVariable() { + pthread_cond_init(&mCond, NULL); + } + + ~ConditionVariable() { + pthread_cond_destroy(&mCond); + } + + void wait(Mutex* userLock) { + pthread_cond_wait(&mCond, &userLock->mLock); + } + + void signal() { + pthread_cond_signal(&mCond); + } + +private: + pthread_cond_t mCond; + +#endif // !_WIN32 +}; + +} // namespace emugl + +#endif // EMUGL_CONDITION_VARIABLE_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_unittest.cpp new file mode 100644 index 0000000..1ebaa63 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_unittest.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/condition_variable.h" + +#include "emugl/common/mutex.h" + +#include + +namespace emugl { + +TEST(ConditionVariable, init) { + ConditionVariable cond; +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_win32.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_win32.cpp new file mode 100644 index 0000000..e0e51a4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/condition_variable_win32.cpp @@ -0,0 +1,114 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/condition_variable.h" + +#include "emugl/common/lazy_instance.h" +#include "emugl/common/mutex.h" +#include "emugl/common/pod_vector.h" + +// Technical note: this is loosely based on the Chromium implementation +// of ConditionVariable. This version works on Windows XP and above and +// doesn't try to use Vista's CONDITION_VARIABLE types. + +namespace emugl { + +namespace { + +// Helper class which implements a free list of event handles. +class WaitEventStorage { +public: + WaitEventStorage() : mFreeHandles(), mLock() {} + + ~WaitEventStorage() { + for (size_t n = 0; n < mFreeHandles.size(); ++n) { + CloseHandle(mFreeHandles[n]); + } + } + + HANDLE alloc() { + HANDLE handle; + mLock.lock(); + size_t size = mFreeHandles.size(); + if (size > 0) { + handle = mFreeHandles[size - 1U]; + mFreeHandles.remove(size - 1U); + } else { + handle = CreateEvent(NULL, TRUE, FALSE, NULL); + } + mLock.unlock(); + return handle; + } + + void free(HANDLE h) { + mLock.lock(); + ResetEvent(h); + mFreeHandles.push_back(h); + mLock.unlock(); + } + +private: + PodVector mFreeHandles; + Mutex mLock; +}; + +LazyInstance sWaitEvents = LAZY_INSTANCE_INIT; + +} // namespace + +ConditionVariable::ConditionVariable() : mWaiters(), mLock() {} + +ConditionVariable::~ConditionVariable() { + mLock.lock(); + for (size_t n = 0; n < mWaiters.size(); ++n) { + CloseHandle(mWaiters[n]); + } + mWaiters.resize(0U); + mLock.unlock(); +} + +void ConditionVariable::wait(Mutex* userLock) { + // Grab new waiter event handle. + mLock.lock(); + HANDLE handle = sWaitEvents->alloc(); + mWaiters.push_back(handle); + mLock.unlock(); + + // Unlock user lock then wait for event. + userLock->unlock(); + WaitForSingleObject(handle, INFINITE); + // NOTE: The handle has been removed from mWaiters here, + // see signal() below. Close/recycle the event. + sWaitEvents->free(handle); + userLock->lock(); +} + +void ConditionVariable::signal() { + mLock.lock(); + size_t size = mWaiters.size(); + if (size > 0U) { + // NOTE: This wakes up the thread that went to sleep most + // recently (LIFO) for performance reason. For better + // fairness, using (FIFO) would be appropriate. + HANDLE handle = mWaiters[size - 1U]; + mWaiters.remove(size - 1U); + SetEvent(handle); + // NOTE: The handle will be closed/recycled by the waiter. + } else { + // Nothing to signal. + } + mLock.unlock(); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.cpp new file mode 100644 index 0000000..2df5d1b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.cpp @@ -0,0 +1,33 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "crash_reporter.h" + +#include + +void default_crash_reporter(const emugl::LogLevel &level, const char* format, ...) { + abort(); +} + +logger_t emugl_crash_reporter = default_crash_reporter; + +void set_emugl_crash_reporter(logger_t crash_reporter) { + if (crash_reporter) { + emugl_crash_reporter = crash_reporter; + } else { + emugl_crash_reporter = default_crash_reporter; + } +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.h new file mode 100644 index 0000000..3f189dd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/crash_reporter.h @@ -0,0 +1,22 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#pragma once + +#include "emugl/common/logging.h" + +extern logger_t emugl_crash_reporter; +void set_emugl_crash_reporter(logger_t crash_reporter); diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.cpp new file mode 100644 index 0000000..597c9eb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.cpp @@ -0,0 +1,236 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/id_to_object_map.h" + +#include + +namespace emugl { + +namespace { + +typedef IdToObjectMapBase::KeyType KeyType; + +enum { + kMinShift = 3, + kMaxShift = 31, + kMinCapacity = (1 << kMinShift), + kLoadScale = 1024, + kMinLoad = kLoadScale/4, // 25% minimum load. + kMaxLoad = kLoadScale*3/4, // 75% maximum load. + + kInvalidKey = IdToObjectMapBase::kMaxId + 1U, + kTombstone = IdToObjectMapBase::kMaxId + 2U, +}; + +// Return a number that indicates if the current |capacity| is appropriate +// to hold |size| items in our map. +// -1 -> the capacity is too small and needs to be increased. +// 0 -> the capacity is ok. +// +1 -> the capacity is too large and needs to be decreased. +int capacityCompare(size_t shift, size_t size) { + size_t capacity = 1U << shift; + // Essentially, one can rewrite: + // load < minLoad + // as: + // size / capacity < minLoad + // capacity * minLoad > size + if (capacity * kMinLoad > size * kLoadScale) + return +1; + + // Similarly, one can rewrite: + // load > maxLoad + // as: + // size / capacity > maxLoad + // capacity * maxLoad < size + if (capacity * kMaxLoad < size * kLoadScale) + return -1; + + return 0; +} + +size_t probeKeys(const KeyType* keys, size_t shift, KeyType key) { + static const int kPrimes[] = { + 1, /* For 1 << 0 */ + 2, + 3, + 7, + 13, + 31, + 61, + 127, + 251, + 509, + 1021, + 2039, + 4093, + 8191, + 16381, + 32749, + 65521, /* For 1 << 16 */ + 131071, + 262139, + 524287, + 1048573, + 2097143, + 4194301, + 8388593, + 16777213, + 33554393, + 67108859, + 134217689, + 268435399, + 536870909, + 1073741789, + 2147483647 /* For 1 << 31 */ + }; + + size_t slot = key % kPrimes[shift]; + size_t step = 0; + for (;;) { + KeyType k = keys[slot]; + if (k == kInvalidKey || k == kTombstone || k == key) + return slot; + + step += 1; + slot = (slot + step) & (1U << shift); + } +} + +} // namespace + +IdToObjectMapBase::IdToObjectMapBase() : + mCount(0), mShift(kMinShift) { + size_t capacity = 1U << mShift; + mKeys = static_cast(::calloc(sizeof(mKeys[0]), capacity)); + mValues = static_cast(::calloc(sizeof(mValues[0]), capacity)); + for (size_t n = 0; n < capacity; ++n) { + mKeys[n] = kInvalidKey; + } +} + +IdToObjectMapBase::~IdToObjectMapBase() { + mShift = 0; + mCount = 0; + ::free(mKeys); + ::free(mValues); +} + +bool IdToObjectMapBase::contains(KeyType key) const { + size_t slot = probeKeys(mKeys, mShift, key); + switch (mKeys[slot]) { + case kInvalidKey: + case kTombstone: + return false; + default: + ; + } + return true; +} + +bool IdToObjectMapBase::find(KeyType key, void** value) const { + size_t slot = probeKeys(mKeys, mShift, key); + if (!isValidKey(mKeys[slot])) { + *value = NULL; + return false; + } + *value = mValues[slot]; + return true; +} + +void* IdToObjectMapBase::set(KeyType key, void* value) { + if (!value) + return remove(key); + + size_t slot = probeKeys(mKeys, mShift, key); + void* result; + if (isValidKey(mKeys[slot])) { + result = mValues[slot]; + mValues[slot] = value; + } else { + mKeys[slot] = key; + mValues[slot] = value; + result = NULL; + mCount++; + resize(mCount); + } + return result; +} + +void* IdToObjectMapBase::remove(KeyType key) { + size_t slot = probeKeys(mKeys, mShift, key); + if (!isValidKey(mKeys[slot])) + return NULL; + + void* result = mValues[slot]; + mValues[slot] = NULL; + mKeys[slot] = kTombstone; + mCount--; + return result; +} + +void IdToObjectMapBase::resize(size_t newSize) { + int ret = capacityCompare(mShift, newSize); + if (!ret) + return; + + size_t oldCapacity = 1U << mShift; + size_t newShift = mShift; + + if (ret < 0) { + // Capacity is too small and must be increased. + do { + if (newShift == kMaxShift) + break; + ++newShift; + } while (capacityCompare(newShift, newSize) < 0); + } else { + // Capacity is too large and must be decreased. + do { + if (newShift == kMinShift) + break; + newShift--; + } while (capacityCompare(newShift, newSize) > 0); + } + if (newShift == mShift) + return; + + // Allocate new arrays. + size_t newCapacity = 1U << newShift; + KeyType* newKeys = static_cast( + ::calloc(sizeof(newKeys[0]), newCapacity)); + void** newValues = static_cast( + ::calloc(sizeof(newValues[0]), newCapacity)); + for (size_t n = 0; n < newCapacity; ++n) + newKeys[n] = kInvalidKey; + + // Copy old entries into new arrays. + for (size_t n = 0; n < oldCapacity; ++n) { + KeyType key = mKeys[n]; + if (isValidKey(key)) { + size_t newSlot = probeKeys(newKeys, newShift, key); + newKeys[newSlot] = key; + newValues[newSlot] = mValues[n]; + } + } + + // Swap arrays, and get rid of old ones. + ::free(mKeys); + ::free(mValues); + mKeys = newKeys; + mValues = newValues; + mShift = newShift; +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.h new file mode 100644 index 0000000..e3d0a81 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map.h @@ -0,0 +1,176 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_ID_TO_OBJECT_MAP_H +#define EMUGL_COMMON_ID_TO_OBJECT_MAP_H + +#include + +namespace emugl { + +// Base implementation class for IdToObjectMap template. +// Used to reduce template-instanciated code generation. +class IdToObjectMapBase { +public: + // The type of keys in this map. + typedef unsigned KeyType; + + // Values higher than kMaxId cannot be used as map keys. + enum { + kMaxId = 0xfffffffdU, + }; + + static inline bool isValidKey(KeyType key) { + return key <= kMaxId; + } + +protected: + IdToObjectMapBase(); + + ~IdToObjectMapBase(); + + void clear(); + + // Return size + inline size_t size() const { return mCount; } + + inline size_t capacity() const { return 1U << mShift; } + + // Return true iff the map contains a given key. + bool contains(KeyType key) const; + + // Find a value associated with a given |key| in the map. + // On success, return true and sets |*value| to the value/pointer, + // which is _still_ owned by the map. + // On failure, return false and sets |*value| to NULL. + bool find(KeyType key, void** value) const; + + // Associate a value with a given |key| in the map. + // Return the old value for the key, if any. Caller is responsible + // for freeing it. + void* set(KeyType key, void* value); + + // Remove the value associated with a given |key|. + // Return the old value, if any. Caller is responsible for + // freeing it. + void* remove(KeyType key); + + size_t mCount; + size_t mShift; + KeyType* mKeys; + void** mValues; + +private: + // Resize the map if needed to ensure it can hold at least |newSize| + // entries. + void resize(size_t newSize); +}; + +// A templated data container that acts as a dictionary mapping unsigned +// integer keys to heap-allocated objects of type T. The dictionary +// owns the objects associated with its keys, and automatically destroys +// them when it is destroyed, or during replacement or removal. +template +class IdToObjectMap : public IdToObjectMapBase { +public: + // Initialize an empty instance. + IdToObjectMap() : IdToObjectMapBase() {} + + // Destroy this instance. + ~IdToObjectMap() { + clear(); + } + + // Return the number of items in this map. + inline size_t size() const { return IdToObjectMapBase::size(); } + + // Return true iff the map is empty. + inline bool empty() const { return !IdToObjectMapBase::size(); } + + // Remove all items from the map. + void clear(); + + // Returns true iff the dictionary contains a value for |key|. + inline bool contains(KeyType key) const { + return IdToObjectMapBase::contains(key); + } + + // Find the value corresponding to |key| in this map. + // On success, return true, and sets |*value| to point to the + // value (still owned by the instance). On failure, return false. + inline bool find(KeyType key, T** value) const { + return IdToObjectMapBase::find(key, reinterpret_cast(value)); + } + + // Return the value associated with a given |key|, or NULL if it is + // not in the map. Result is still owned by the map. + inline T* get(KeyType key) const { + T* result = NULL; + this->find(key, &result); + return result; + } + + // Associate |value| with a given |key|. Returns true if a previous + // value was replaced, and false if this is the first time a value + // was associated with the given key. IMPORTANT: This transfers + // ownership of |value| to the map instance. In case of replacement, + // the old value is automatically destroyed. Using NULL as the value + // is equivalent to calling remove(). + bool set(KeyType key, T* value); + + // Remove any value associated with |key|. + // Return true iff a value was associated with the key and destroyed + // by this function, false if there was no value associated with the + // key (or if it was NULL). + bool remove(KeyType key); +}; + +template +void IdToObjectMap::clear() { + size_t n = capacity(); + while (n > 0) { + --n; + if (!isValidKey(mKeys[n])) + continue; + + delete static_cast(mValues[n]); + mValues[n] = NULL; + mKeys[n] = kMaxId + 1U; + } + mCount = 0; +} + +template +bool IdToObjectMap::set(KeyType key, T* value) { + T* oldValue = static_cast(IdToObjectMapBase::set(key, value)); + if (!oldValue) { + return false; + } + delete oldValue; + return true; +} + +template +bool IdToObjectMap::remove(KeyType key) { + T* oldValue = static_cast(IdToObjectMapBase::remove(key)); + if (!oldValue) + return false; + delete oldValue; + return true; +} + +} // namespace emugl + + +#endif // EMUGL_COMMON_ID_TO_OBJECT_MAP_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map_unittest.cpp new file mode 100644 index 0000000..50740be --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/id_to_object_map_unittest.cpp @@ -0,0 +1,116 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/id_to_object_map.h" + +#include + +namespace emugl { + +namespace { + +typedef IdToObjectMapBase::KeyType KeyType; + +class Foo { +public: + Foo() : mVal(0) {} + Foo(int val) : mVal(val) {} + ~Foo() {} + int val() const { return mVal; } + void setVal(int val) { mVal = val; } +private: + int mVal; +}; + +} // namespace + +TEST(IdToObjectMap, Empty) { + IdToObjectMap map; + EXPECT_TRUE(map.empty()); + EXPECT_EQ(0U, map.size()); +} + +TEST(IdToObjectMap, SetIntegerRange) { + IdToObjectMap map; + KeyType kMax = 10000; + + // Add all items in the map. + for (KeyType n = 0; n < kMax; ++n) { + EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n; + } + + // Check final size. + EXPECT_EQ(static_cast(kMax), map.size()); + + // Find all items in the map. + for (KeyType n = 0; n < kMax; ++n) { + EXPECT_TRUE(map.contains(n)) << "For key " << n; + Foo* foo = NULL; + EXPECT_TRUE(map.find(n, &foo)) << "For key " << n; + if (foo) { + EXPECT_EQ(static_cast(n), foo->val()) << "For key " << n; + } + } +} + +TEST(IdToObjectMap, RemoveAll) { + IdToObjectMap map; + KeyType kMax = 10000; + + // Add all items in the map. + for (KeyType n = 0; n < kMax; ++n) { + EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n; + } + + EXPECT_EQ(static_cast(kMax), map.size()); + + for (KeyType n = 0; n < kMax; ++n) { + EXPECT_TRUE(map.remove(n)) << "For key " << n; + } + EXPECT_EQ(0U, map.size()); +} + +TEST(IdToObjectMap, RemoveOdd) { + IdToObjectMap map; + KeyType kMax = 10000; + + // Add all items in the map. + for (KeyType n = 0; n < kMax; ++n) { + EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n; + } + + EXPECT_EQ(static_cast(kMax), map.size()); + + for (KeyType n = 0; n < kMax; ++n) { + if (n & 1) { + EXPECT_TRUE(map.remove(n)) << "For key " << n; + } + } + EXPECT_EQ(static_cast(kMax / 2), map.size()); + + for (KeyType n = 0; n < kMax; ++n) { + if (n & 1) { + EXPECT_FALSE(map.contains(n)) << "For key " << n; + } else { + EXPECT_TRUE(map.contains(n)) << "For key " << n; + Foo* foo = NULL; + EXPECT_TRUE(map.find(n, &foo)) << "For key " << n; + if (foo) { + EXPECT_EQ(static_cast(n), foo->val()); + } + } + } +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.cpp new file mode 100644 index 0000000..c8984d0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.cpp @@ -0,0 +1,101 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/lazy_instance.h" + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN 1 +# include +#else +# include +#endif + +namespace emugl { +namespace internal { + +typedef LazyInstanceState::AtomicType AtomicType; + +#if defined(__GNUC__) +static inline void compilerBarrier() { + __asm__ __volatile__ ("" : : : "memory"); +} +#else +#error "Your compiler is not supported" +#endif + +#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) +# define acquireBarrier() compilerBarrier() +# define releaseBarrier() compilerBarrier() +#else +# error "Your CPU is not supported" +#endif + +static inline AtomicType loadAcquire(AtomicType volatile* ptr) { + AtomicType ret = *ptr; + acquireBarrier(); + return ret; +} + +static inline void storeRelease(AtomicType volatile* ptr, AtomicType value) { + releaseBarrier(); + *ptr = value; +} + +static int atomicCompareAndSwap(AtomicType volatile* ptr, + int expected, + int value) { +#ifdef _WIN32 + return InterlockedCompareExchange(ptr, value, expected); +#elif defined(__GNUC__) + return __sync_val_compare_and_swap(ptr, expected, value); +#else +#error "Your compiler is not supported" +#endif +} + +static void yieldThread() { +#ifdef _WIN32 + ::Sleep(0); +#else + sched_yield(); +#endif +} + +bool LazyInstanceState::inInitState() { + return loadAcquire(&mState) == STATE_INIT; +} + +bool LazyInstanceState::needConstruction() { + AtomicType state = loadAcquire(&mState); + if (mState == STATE_DONE) + return false; + + state = atomicCompareAndSwap(&mState, STATE_INIT, STATE_CONSTRUCTING); + if (state == STATE_INIT) + return true; + + do { + yieldThread(); + state = loadAcquire(&mState); + } while (state != STATE_DONE); + + return false; +} + +void LazyInstanceState::doneConstructing() { + storeRelease(&mState, STATE_DONE); +} + +} // namespace internal +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.h new file mode 100644 index 0000000..6641c93 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance.h @@ -0,0 +1,156 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_LAZY_INSTANCE_H +#define EMUGL_COMMON_LAZY_INSTANCE_H + +#include + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN 1 +# include +#endif + +namespace emugl { +namespace internal { + +// A LazyInstance is a helper template that can be used to perform +// thread-safe lazy initialization of static C++ objects without forcing +// the generation of C++ static constructors in the final executable. +// +// In a nutshell, you can replace a statement like: +// +// static Foo gFoo; +// +// With: +// +// static LazyInstance gFoo = LAZY_INSTANCE_INIT; +// +// In the first case, a hidden static C++ constructor is embedded in the +// final executable, and executed at *load* *time* to call the Foo::Foo +// constructor on the gFoo object. +// +// On the second case, gFoo will only be initialized lazily, i.e. the first +// time any code actually tries to access the variable. +// +// Note that access is slightly different, i.e.: +// +// gFoo.get() returns a reference to the lazy-initialized object. +// gFoo.ptr() returns a pointer to it. +// gFoo->Something() is equivalent to doing gFoo.ptr()->Something(). +// +// 'gFoo' is stored in the .bss section and this doesn't use heap allocation. +// This class can only be used to perform lazy initialization through the +// class' default constructor. For more specialized cases, you will have +// to create a derived class, e.g.: +// +// class FoorWithDefaultParams : public Foo { +// public: +// FooWithDefaultParams() : Foo() {} +// }; +// +// LazyInstance gFoo = LAZY_INSTANCE_INIT; +// +// The implementation of LazyInstance relies on atomic operations and +// POD-struct class definitions, i.e. one that doesn't have any constructor, +// destructor, virtual members, or private ones, and that can be +// zero-initialized at link time. +// +// You can also use LazyInstance<> instances as static local variables, +// e.g.: +// +// Foo* getFooSingleton() { +// static LazyInstance sFoo = LAZY_INSTANCE_INIT; +// return sFoo.ptr(); +// } +// +// This is useful on Windows which doesn't support thread-safe lazy +// initialization of static C++ local variables, or when the code is +// compiled with -fno-threadsafe-statics. +// +// This class is heavily inspired by Chromium's implementation of the +// same-named class (see $CHROMIUM/src/base/lazy_instance.h). + +// Atomic state variable type. Used to ensure to synchronize concurrent +// initialization and access without incurring the full cost of a mutex +// lock/unlock. +struct LazyInstanceState { + enum { + STATE_INIT = 0, + STATE_CONSTRUCTING = 1, + STATE_DONE = 2, + }; + + bool inInitState(); + bool needConstruction(); + void doneConstructing(); + +#ifdef _WIN32 + typedef LONG volatile AtomicType; +#else + typedef int volatile AtomicType; +#endif + + volatile AtomicType mState; +}; + +#define LAZY_INSTANCE_STATE_INIT \ + { ::emugl::internal::LazyInstanceState::STATE_INIT } + +} // namespace internal + +// LazyInstance template definition, see comment above for usage +// instructions. It is crucial to make this a POD-struct compatible +// type [1]. +// +// [1] http://en.wikipedia.org/wiki/Plain_Old_Data_Structures +// +template +struct LazyInstance { + bool hasInstance() const { return !mState.inInitState(); } + + T& get() const { return *ptr(); } + + T* ptr() const; + + const T* operator->() const { return ptr(); } + + T* operator->() { return ptr(); } + + T& operator*() { return get(); } + + // Really private, do not use. + union { + mutable internal::LazyInstanceState mState; + double mPadding; + }; + mutable char mStorage[sizeof(T)]; +}; + +// Initialization value, must resolve to all-0 to ensure the object +// instance is actually placed in the .bss +#define LAZY_INSTANCE_INIT { { LAZY_INSTANCE_STATE_INIT }, { 0 } } + +template +T* LazyInstance::ptr() const { + if (mState.needConstruction()) { + new (mStorage) T(); + mState.doneConstructing(); + } + return reinterpret_cast(mStorage); +} + +} // namespace emugl + +#endif // EMUGL_COMMON_LAZY_INSTANCE_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance_unittest.cpp new file mode 100644 index 0000000..824845f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/lazy_instance_unittest.cpp @@ -0,0 +1,146 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/lazy_instance.h" + +#include "emugl/common/mutex.h" +#include "emugl/common/testing/test_thread.h" + +#include + +namespace emugl { + +namespace { + +class Foo { +public: + Foo() : mValue(42) {} + int get() const { return mValue; } + void set(int value) { mValue = value; } + ~Foo() { mValue = 13; } +private: + int mValue; +}; + +class StaticCounter { +public: + StaticCounter() { + Mutex::AutoLock lock(mMutex); + mCounter++; + } + + int getValue() const { + Mutex::AutoLock lock(mMutex); + return mCounter; + } + +private: + static Mutex mMutex; + static int mCounter; +}; + +// NOTE: This introduces a static C++ constructor for this object file, +// but that's ok because a LazyInstance should not be used to +// test the behaviour of LazyInstance :-) +Mutex StaticCounter::mMutex; +int StaticCounter::mCounter = 0; + +} // namespace + +TEST(LazyInstance, HasInstance) { + LazyInstance foo_instance = LAZY_INSTANCE_INIT; + EXPECT_FALSE(foo_instance.hasInstance()); + EXPECT_FALSE(foo_instance.hasInstance()); + foo_instance.ptr(); + EXPECT_TRUE(foo_instance.hasInstance()); +} + +TEST(LazyInstance, Simple) { + LazyInstance foo_instance = LAZY_INSTANCE_INIT; + Foo* foo1 = foo_instance.ptr(); + EXPECT_TRUE(foo1); + EXPECT_EQ(42, foo_instance->get()); + foo1->set(10); + EXPECT_EQ(10, foo_instance->get()); + EXPECT_EQ(foo1, foo_instance.ptr()); +} + +// For the following test, launch 1000 threads that each try to get +// the instance pointer of a lazy instance. Then verify that they're all +// the same value. +// +// The lazy instance has a special constructor that will increment a +// global counter. This allows us to ensure that it is only called once. +// + +namespace { + +// The following is the shared structure between all threads. +struct MultiState { + MultiState(LazyInstance* staticCounter) : + mMutex(), mStaticCounter(staticCounter), mCount(0) {} + + enum { + kMaxThreads = 1000, + }; + + Mutex mMutex; + LazyInstance* mStaticCounter; + size_t mCount; + void* mValues[kMaxThreads]; + TestThread* mThreads[kMaxThreads]; +}; + +// The thread function for the test below. +static void* threadFunc(void* param) { + MultiState* state = static_cast(param); + Mutex::AutoLock lock(state->mMutex); + if (state->mCount < MultiState::kMaxThreads) { + state->mValues[state->mCount++] = state->mStaticCounter->ptr(); + } + return NULL; +} + +} // namespace + +TEST(LazyInstance, MultipleThreads) { + LazyInstance counter_instance = LAZY_INSTANCE_INIT; + MultiState state(&counter_instance); + const size_t kNumThreads = MultiState::kMaxThreads; + + // Create all threads. + for (size_t n = 0; n < kNumThreads; ++n) { + state.mThreads[n] = new TestThread(threadFunc, &state); + } + + // Wait for their completion. + for (size_t n = 0; n < kNumThreads; ++n) { + state.mThreads[n]->join(); + } + + // Now check that the constructor was only called once. + EXPECT_EQ(1, counter_instance->getValue()); + + // Now compare all the store values, they should be the same. + StaticCounter* expectedValue = counter_instance.ptr(); + for (size_t n = 0; n < kNumThreads; ++n) { + EXPECT_EQ(expectedValue, state.mValues[n]) << "For thread " << n; + } + + for (size_t n = 0; n < kNumThreads; ++n) { + delete state.mThreads[n]; + } +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.cpp new file mode 100644 index 0000000..69a24da --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.cpp @@ -0,0 +1,38 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "emugl/common/logging.h" + +void default_logger(const emugl::LogLevel &level, const char* fmt, ...) { } + +logger_t emugl_logger = default_logger; +logger_t emugl_cxt_logger = default_logger; + +void set_emugl_logger(logger_t f) { + if (!f) { + emugl_logger = default_logger; + } else { + emugl_logger = f; + } +} + +void set_emugl_cxt_logger(logger_t f) { + if (!f) { + emugl_cxt_logger = default_logger; + } else { + emugl_cxt_logger = f; + } +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.h new file mode 100644 index 0000000..2fc1f15 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/logging.h @@ -0,0 +1,58 @@ +/* +* Copyright (C) 2016 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef EMUGL_COMMON_LOGGING_H_ +#define EMUGL_COMMON_LOGGING_H_ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wredundant-decls" + +namespace emugl { +enum class LogLevel { + TRACE, + DEBUG, + INFO, + WARNING, + ERROR, + FATAL, +}; +} // namespace emugl + +typedef void (*logger_t)(const emugl::LogLevel &level, const char* fmt, ...); +extern logger_t emugl_logger; +extern logger_t emugl_cxt_logger; +void set_emugl_logger(logger_t f); +void set_emugl_cxt_logger(logger_t f); + +#define GL_LOGGING 1 + +#if GL_LOGGING + +#define GL_LOG(...) do { \ + emugl_logger(__VA_ARGS__); \ +} while (0) + +#define GL_CXT_LOG(...) do { \ + emugl_cxt_logger(__VA_ARGS__); \ +} while (0) + +#else +#define GL_LOG(...) 0 +#endif + +#pragma GCC diagnostic pop + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.cpp new file mode 100644 index 0000000..da4d711 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.cpp @@ -0,0 +1,64 @@ +// Copyright 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/message_channel.h" + +namespace emugl { + +MessageChannelBase::MessageChannelBase(size_t capacity) : + mPos(0U), + mCount(0U), + mCapacity(capacity), + mLock(), + mCanRead(), + mCanWrite() {} + +MessageChannelBase::~MessageChannelBase() {} + +size_t MessageChannelBase::beforeWrite() { + mLock.lock(); + while (mCount >= mCapacity) { + mCanWrite.wait(&mLock); + } + size_t result = mPos + mCount; + if (result >= mCapacity) { + result -= mCapacity; + } + return result; +} + +void MessageChannelBase::afterWrite() { + mCount++; + mCanRead.signal(); + mLock.unlock(); +} + +size_t MessageChannelBase::beforeRead() { + mLock.lock(); + while (mCount == 0) { + mCanRead.wait(&mLock); + } + return mPos; +} + +void MessageChannelBase::afterRead() { + if (++mPos == mCapacity) { + mPos = 0U; + } + mCount--; + mCanWrite.signal(); + mLock.unlock(); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.h new file mode 100644 index 0000000..3f463a9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel.h @@ -0,0 +1,98 @@ +// Copyright 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_MESSAGE_CHANNEL_H +#define EMUGL_COMMON_MESSAGE_CHANNEL_H + +#include "emugl/common/condition_variable.h" +#include "emugl/common/mutex.h" + +#include + +namespace emugl { + +// Base non-templated class used to reduce the amount of template +// specialization. +class MessageChannelBase { +public: + // Constructor. |capacity| is the buffer capacity in messages. + MessageChannelBase(size_t capacity); + + // Destructor. + ~MessageChannelBase(); + +protected: + // Call this method in the sender thread before writing a new message. + // This returns the position of the available slot in the message array + // where to copy the new fixed-size message. After the copy, call + // afterWrite(). + size_t beforeWrite(); + + // To be called after beforeWrite() and copying a new fixed-size message + // into the array. This signal the receiver thread that there is a new + // incoming message. + void afterWrite(); + + // Call this method in the receiver thread before reading a new message. + // This returns the position in the message array where the new message + // can be read. Caller must process the message, then call afterRead(). + size_t beforeRead(); + + // To be called in the receiver thread after beforeRead() and processing + // the corresponding message. + void afterRead(); + +private: + size_t mPos; + size_t mCount; + size_t mCapacity; + Mutex mLock; + ConditionVariable mCanRead; + ConditionVariable mCanWrite; +}; + +// Helper class used to implement an uni-directional IPC channel between +// two threads. The channel can be used to send fixed-size messages of type +// |T|, with an internal buffer size of |CAPACITY| items. All calls are +// blocking. +// +// Usage is pretty straightforward: +// +// - From the sender thread, call send(msg); +// - From the receiver thread, call receive(&msg); +// +template +class MessageChannel : public MessageChannelBase { +public: + MessageChannel() : MessageChannelBase(CAPACITY) {} + + void send(const T& msg) { + size_t pos = beforeWrite(); + mItems[pos] = msg; + afterWrite(); + } + + void receive(T* msg) { + size_t pos = beforeRead(); + *msg = mItems[pos]; + afterRead(); + } + +private: + T mItems[CAPACITY]; +}; + +} // namespace emugl + +#endif // EMUGL_COMMON_MESSAGE_CHANNEL_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel_unittest.cpp new file mode 100644 index 0000000..2e9d55e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/message_channel_unittest.cpp @@ -0,0 +1,101 @@ +// Copyright 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/message_channel.h" + +#include "emugl/common/testing/test_thread.h" + +#include + +#include + +namespace emugl { + +namespace { + +struct PingPongState { + MessageChannel in; + MessageChannel out; +}; + +void* pingPongFunction(void* param) { + for (;;) { + PingPongState* s = static_cast(param); + std::string str; + s->in.receive(&str); + s->out.send(str); + if (str == "quit") { + break; + } + } + return 0; +} + +} // namespace + +TEST(MessageChannel, SingleThreadWithInt) { + MessageChannel channel; + channel.send(1); + channel.send(2); + channel.send(3); + + int ret; + channel.receive(&ret); + EXPECT_EQ(1, ret); + channel.receive(&ret); + EXPECT_EQ(2, ret); + channel.receive(&ret); + EXPECT_EQ(3, ret); +} + +TEST(MessageChannel, SingleThreadWithStdString) { + MessageChannel channel; + channel.send(std::string("foo")); + channel.send(std::string("bar")); + channel.send(std::string("zoo")); + + std::string str; + channel.receive(&str); + EXPECT_STREQ("foo", str.c_str()); + channel.receive(&str); + EXPECT_STREQ("bar", str.c_str()); + channel.receive(&str); + EXPECT_STREQ("zoo", str.c_str()); +} + +TEST(MessageChannel, TwoThreadsPingPong) { + PingPongState state; + TestThread* thread = new TestThread(pingPongFunction, &state); + + std::string str; + const size_t kCount = 100; + for (size_t n = 0; n < kCount; ++n) { + state.in.send(std::string("foo")); + state.in.send(std::string("bar")); + state.in.send(std::string("zoo")); + state.out.receive(&str); + EXPECT_STREQ("foo", str.c_str()); + state.out.receive(&str); + EXPECT_STREQ("bar", str.c_str()); + state.out.receive(&str); + EXPECT_STREQ("zoo", str.c_str()); + } + state.in.send(std::string("quit")); + state.out.receive(&str); + EXPECT_STREQ("quit", str.c_str()); + + thread->join(); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex.h new file mode 100644 index 0000000..6a161ae --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex.h @@ -0,0 +1,95 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_MUTEX_H +#define EMUGL_MUTEX_H + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN 1 +# include +#else +# include +#endif + +namespace emugl { + +class ConditionVariable; + +// Simple wrapper class for mutexes. +class Mutex { +public: + // Constructor. + Mutex() { +#ifdef _WIN32 + ::InitializeCriticalSection(&mLock); +#else + ::pthread_mutex_init(&mLock, NULL); +#endif + } + + // Destructor. + ~Mutex() { +#ifdef _WIN32 + ::DeleteCriticalSection(&mLock); +#else + ::pthread_mutex_destroy(&mLock); +#endif + } + + // Acquire the mutex. + void lock() { +#ifdef _WIN32 + ::EnterCriticalSection(&mLock); +#else + ::pthread_mutex_lock(&mLock); +#endif + } + + // Release the mutex. + void unlock() { +#ifdef _WIN32 + ::LeaveCriticalSection(&mLock); +#else + ::pthread_mutex_unlock(&mLock); +#endif + } + + // Helper class to lock / unlock a mutex automatically on scope + // entry and exit. + class AutoLock { + public: + AutoLock(Mutex& mutex) : mMutex(&mutex) { + mMutex->lock(); + } + + ~AutoLock() { + mMutex->unlock(); + } + private: + Mutex* mMutex; + }; + +private: +#ifdef _WIN32 + CRITICAL_SECTION mLock; +#else + friend class ConditionVariable; + pthread_mutex_t mLock; +#endif + +}; + +} // namespace emugl + +#endif // EMUGL_MUTEX_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex_unittest.cpp new file mode 100644 index 0000000..e952d75 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/mutex_unittest.cpp @@ -0,0 +1,108 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/mutex.h" + +#include "emugl/common/testing/test_thread.h" + +#include + +namespace emugl { + +// Check that construction and destruction doesn't crash. +TEST(Mutex, ConstructionDestruction) { + Mutex lock; +} + +// Check that a simple lock + unlock works. +TEST(Mutex, LockUnlock) { + Mutex lock; + lock.lock(); + lock.unlock(); +} + +// Check that AutoLock compiles and doesn't crash. +TEST(Mutex, AutoLock) { + Mutex mutex; + Mutex::AutoLock lock(mutex); +} + +// Wrapper class for threads. Does not use emugl::Thread intentionally. +// Common data type used by the following tests below. +struct ThreadParams { + ThreadParams() : mutex(), counter(0) {} + + Mutex mutex; + int counter; +}; + +// This thread function uses Mutex::lock/unlock to synchronize a counter +// increment operation. +static void* threadFunction(void* param) { + ThreadParams* p = static_cast(param); + + p->mutex.lock(); + p->counter++; + p->mutex.unlock(); + return NULL; +} + +TEST(Mutex, Synchronization) { + const size_t kNumThreads = 2000; + TestThread* threads[kNumThreads]; + ThreadParams p; + + // Create and launch all threads. + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n] = new TestThread(threadFunction, &p); + } + + // Wait until their completion. + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n]->join(); + delete threads[n]; + } + + EXPECT_EQ(static_cast(kNumThreads), p.counter); +} + +// This thread function uses a Mutex::AutoLock to protect the counter. +static void* threadAutoLockFunction(void* param) { + ThreadParams* p = static_cast(param); + + Mutex::AutoLock lock(p->mutex); + p->counter++; + return NULL; +} + +TEST(Mutex, AutoLockSynchronization) { + const size_t kNumThreads = 2000; + TestThread* threads[kNumThreads]; + ThreadParams p; + + // Create and launch all threads. + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n] = new TestThread(threadAutoLockFunction, &p); + } + + // Wait until their completion. + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n]->join(); + delete threads[n]; + } + + EXPECT_EQ(static_cast(kNumThreads), p.counter); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.cpp new file mode 100644 index 0000000..c8ec3a6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.cpp @@ -0,0 +1,150 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/pod_vector.h" + +#include +#include + +#define USE_MALLOC_USABLE_SIZE 0 + +namespace emugl { + +static inline void swapPointers(char** p1, char** p2) { + char* tmp = *p1; + *p1 = *p2; + *p2 = tmp; +} + +PodVectorBase::PodVectorBase(const PodVectorBase& other) { + initFrom(other.begin(), other.byteSize()); +} + +PodVectorBase& PodVectorBase::operator=(const PodVectorBase& other) { + initFrom(other.begin(), other.byteSize()); + return *this; +} + +PodVectorBase::~PodVectorBase() { + if (mBegin) { + // Sanity. + ::memset(mBegin, 0xee, byteSize()); + ::free(mBegin); + mBegin = NULL; + mEnd = NULL; + mLimit = NULL; + } +} + +void PodVectorBase::initFrom(const void* from, size_t fromLen) { + if (!fromLen || !from) { + mBegin = NULL; + mEnd = NULL; + mLimit = NULL; + } else { + mBegin = static_cast(::malloc(fromLen)); + mEnd = mLimit = mBegin + fromLen; + ::memcpy(mBegin, from, fromLen); + } +} + +void PodVectorBase::assignFrom(const PodVectorBase& other) { + resize(other.byteSize(), 1U); + ::memmove(begin(), other.begin(), byteSize()); +} + +void PodVectorBase::resize(size_t newSize, size_t itemSize) { + const size_t kMaxSize = maxItemCapacity(itemSize); + size_t oldCapacity = itemCapacity(itemSize); + const size_t kMinCapacity = 256 / itemSize; + + if (newSize < oldCapacity) { + // Only shrink if the new size is really small. + if (newSize < oldCapacity / 2 && oldCapacity > kMinCapacity) { + reserve(newSize, itemSize); + } + } else if (newSize > oldCapacity) { + size_t newCapacity = oldCapacity; + while (newCapacity < newSize) { + size_t newCapacity2 = newCapacity + (newCapacity >> 2) + 8; + if (newCapacity2 < newCapacity || newCapacity > kMaxSize) { + newCapacity = kMaxSize; + } else { + newCapacity = newCapacity2; + } + } + reserve(newCapacity, itemSize); + } + mEnd = mBegin + newSize * itemSize; +} + +void PodVectorBase::reserve(size_t newSize, size_t itemSize) { + if (newSize == 0) { + ::free(mBegin); + mBegin = NULL; + mEnd = NULL; + mLimit = NULL; + return; + } + + size_t oldByteSize = byteSize(); + size_t newByteCapacity = newSize * itemSize; + char* newBegin = static_cast(::realloc(mBegin, newByteCapacity)); + mBegin = newBegin; + mEnd = newBegin + oldByteSize; +#if USE_MALLOC_USABLE_SIZE + size_t usableSize = malloc_usable_size(mBegin); + if (usableSize > newByteCapacity) { + newByteCapacity = usableSize - (usableSize % itemSize); + } +#endif + mLimit = newBegin + newByteCapacity; + // Sanity. + if (newByteCapacity > oldByteSize) { + ::memset(mBegin + oldByteSize, 0, newByteCapacity - oldByteSize); + } +} + +void PodVectorBase::removeAt(size_t itemPos, size_t itemSize) { + size_t count = itemCount(itemSize); + if (itemPos < count) { + size_t pos = itemPos * itemSize; + ::memmove(mBegin + pos, + mBegin + pos + itemSize, + byteSize() - pos - itemSize); + resize(count - 1U, itemSize); + } +} + +void* PodVectorBase::insertAt(size_t itemPos, size_t itemSize) { + size_t count = this->itemCount(itemSize); + resize(count + 1, itemSize); + size_t pos = itemPos * itemSize; + if (itemPos < count) { + ::memmove(mBegin + pos + itemSize, + mBegin + pos, + count * itemSize - pos); + // Sanity to avoid copying pointers and other bad stuff. + ::memset(mBegin + pos, 0, itemSize); + } + return mBegin + pos; +} + +void PodVectorBase::swapAll(PodVectorBase* other) { + swapPointers(&mBegin, &other->mBegin); + swapPointers(&mEnd, &other->mEnd); + swapPointers(&mLimit, &other->mLimit); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.h new file mode 100644 index 0000000..c4e184b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector.h @@ -0,0 +1,265 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_POD_VECTOR_H +#define EMUGL_COMMON_POD_VECTOR_H + + +#include + +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS 1 +#endif +#include + +#ifndef SIZE_MAX +#error "You must define __STDC_LIMIT_MACROS before including " +#endif + +namespace emugl { + +// A PodVector is a templated vector-like type that is used to store +// POD-struct compatible items only. This allows the implementation to +// use ::memmove() to move items, and also malloc_usable_size() to +// determine the best capacity. +// +// std::vector<> is capable of doing this in theory, using horrible +// templating tricks that make error messages very difficult to +// understand. +// +// Note that a PodVector can be used to store items that contain pointers, +// as long as these do not point to items in the same container. +// +// The PodVector provides methods that also follow the std::vector<> +// conventions, i.e. push_back() is an alias for append(). +// + +// NOTE: This is a re-implementation of +// external/qemu/android/base/containers/PodVector.h for emugl. + +// PodVectorBase is a base, non-templated, implementation class that all +// PodVector instances derive from. This is used to reduce template +// specialization. Do not use directly, i..e it's an implementation detail. +class PodVectorBase { +protected: + PodVectorBase() : mBegin(NULL), mEnd(NULL), mLimit(NULL) {} + explicit PodVectorBase(const PodVectorBase& other); + PodVectorBase& operator=(const PodVectorBase& other); + ~PodVectorBase(); + + bool empty() const { return mEnd == mBegin; } + + size_t byteSize() const { return mEnd - mBegin; } + + size_t byteCapacity() const { return mLimit - mBegin; } + + void* begin() { return mBegin; } + const void* begin() const { return mBegin; } + void* end() { return mEnd; } + const void* end() const { return mEnd; } + + void* itemAt(size_t pos, size_t itemSize) { + return mBegin + pos * itemSize; + } + + const void* itemAt(size_t pos, size_t itemSize) const { + return mBegin + pos * itemSize; + } + + void assignFrom(const PodVectorBase& other); + + inline size_t itemCount(size_t itemSize) const { + return byteSize() / itemSize; + } + + inline size_t itemCapacity(size_t itemSize) const { + return byteCapacity() / itemSize; + } + + inline size_t maxItemCapacity(size_t itemSize) const { + return SIZE_MAX / itemSize; + } + + void resize(size_t newSize, size_t itemSize); + void reserve(size_t newSize, size_t itemSize); + + void removeAt(size_t index, size_t itemSize); + void* insertAt(size_t index, size_t itemSize); + void swapAll(PodVectorBase* other); + + char* mBegin; + char* mEnd; + char* mLimit; + +private: + void initFrom(const void* from, size_t fromLen); +}; + + +// A PodVector holds a vector (dynamically resizable array) or items +// that must be POD-struct compatible (i.e. they cannot have constructors, +// destructors, or virtual members). This allows the implementation to be +// small, fast and efficient, memory-wise. +// +// If you want to implement a vector of C++ objects, consider using +// std::vector<> instead, but keep in mind that this implies a non-trivial +// cost when appending, inserting, removing items in the collection. +// +template +class PodVector : public PodVectorBase { +public: + // Default constructor for an empty PodVector + PodVector() : PodVectorBase() {} + + // Copy constructor. This copies all items from |other| into + // the new instance with ::memmove(). + PodVector(const PodVector& other) : PodVectorBase(other) {} + + // Assignment operator. + PodVector& operator=(const PodVector& other) { + this->assignFrom(other); + return *this; + } + + // Destructor, this simply releases the internal storage block that + // holds all the items, but doesn't touch them otherwise. + ~PodVector() {} + + // Return true iff the PodVector instance is empty, i.e. does not + // have any items. + bool empty() const { return PodVectorBase::empty(); } + + // Return the number of items in the current PodVector instance. + size_t size() const { return PodVectorBase::itemCount(sizeof(T)); } + + // Return the current capacity in the current PodVector instance. + // Do not use directly, except if you know what you're doing. Try to + // use resize() or reserve() instead. + size_t capacity() const { + return PodVectorBase::itemCapacity(sizeof(T)); + } + + // Return the maximum capacity of any PodVector instance. + static inline size_t maxCapacity() { return SIZE_MAX / sizeof(T); } + + // Resize the vector to ensure it can hold |newSize| + // items. This may or may not call reserve() under the hood. + // It's a fatal error to try to resize above maxCapacity(). + void resize(size_t newSize) { + PodVectorBase::resize(newSize, sizeof(T)); + } + + // Resize the vector's storage array to ensure that it can hold at + // least |newSize| items. It's a fatal error to try to resize above + // maxCapacity(). + void reserve(size_t newSize) { + PodVectorBase::reserve(newSize, sizeof(T)); + } + + // Return a pointer to the first item in the vector. This is only + // valid until the next call to any function that changes the size + // or capacity of the vector. Can be NULL if the vector is empty. + T* begin() { + return reinterpret_cast(PodVectorBase::begin()); + } + + // Return a constant pointer to the first item in the vector. This is + // only valid until the next call to any function that changes the + // size of capacity of the vector. + const T* begin() const { + return reinterpret_cast(PodVectorBase::begin()); + } + + // Return a pointer past the last item in the vector. I.e. if the + // result is not NULL, then |result - 1| points to the last item. + // Can be NULL if the vector is empty. + T* end() { + return reinterpret_cast(PodVectorBase::end()); + } + + // Return a constant pointer past the last item in the vector. I.e. if + // the result is not NULL, then |result - 1| points to the last item. + // Can be NULL if the vector is empty. + const T* end() const { + return reinterpret_cast(PodVectorBase::end()); + } + + // Returns a reference to the item a position |index| in the vector. + // It may be a fatal error to access an out-of-bounds position. + T& operator[](size_t index) { + return *reinterpret_cast( + PodVectorBase::itemAt(index, sizeof(T))); + } + + const T& operator[](size_t index) const { + return *reinterpret_cast( + PodVectorBase::itemAt(index, sizeof(T))); + } + + // Increase the vector's size by 1, then move all items past a given + // position to the right. Return the position of the insertion point + // to let the caller copy the content it desires there. It's preferrable + // to use insert() directly, which will do the item copy for you. + T* emplace(size_t index) { + return reinterpret_cast( + PodVectorBase::insertAt(index, sizeof(T))); + } + + // Insert an item at a given position. |index| is the insertion position + // which must be between 0 and size() included, or a fatal error may + // occur. |item| is a reference to an item to copy into the array, + // byte-by-byte. + void insert(size_t index, const T& item) { + *(this->emplace(index)) = item; + } + + // Prepend an item at the start of a vector. This moves all vector items + // to the right, and is thus costly. |item| is a reference to an item + // to copy to the start of the vector. + void prepend(const T& item) { + *(this->emplace(0U)) = item; + } + + // Append an item at the end of a vector. Specialized version of insert() + // which always uses size() as the insertion position. + void append(const T& item) { + *(this->emplace(this->size())) = item; + } + + // Remove the item at a given position. |index| is the position of the + // item to delete. It must be between 0 and size(), included, or + // a fatal error may occur. Deleting the item at position size() + // doesn't do anything. + void remove(size_t index) { + PodVectorBase::removeAt(index, sizeof(T)); + } + + void swap(PodVector* other) { + PodVectorBase::swapAll(other); + } + + // Compatibility methods for std::vector<> + void push_back(const T& item) { append(item); } + void pop() { remove(0U); } + + typedef T* iterator; + typedef const T* const_iterator; +}; + +} // namespace emugl + +#endif // EMUGL_COMMON_POD_VECTOR_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector_unittest.cpp new file mode 100644 index 0000000..9ce509a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/pod_vector_unittest.cpp @@ -0,0 +1,127 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/pod_vector.h" + +#include + +namespace emugl { + +static int hashIndex(size_t n) { + return static_cast(((n >> 14) * 13773) + (n * 51)); +} + +TEST(PodVector, Empty) { + PodVector v; + EXPECT_TRUE(v.empty()); + EXPECT_EQ(0U, v.size()); +} + +TEST(PodVector, AppendOneItem) { + PodVector v; + v.append(10234); + EXPECT_FALSE(v.empty()); + EXPECT_EQ(1U, v.size()); + EXPECT_EQ(10234, v[0]); +} + +TEST(PodVector, AppendLotsOfItems) { + PodVector v; + const size_t kMaxCount = 10000; + for (size_t n = 0; n < kMaxCount; ++n) { + v.append(hashIndex(n)); + } + EXPECT_EQ(kMaxCount, v.size()); + for (size_t n = 0; n < kMaxCount; ++n) { + EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n; + } +} + +TEST(PodVector, RemoveFrontItems) { + PodVector v; + const size_t kMaxCount = 100; + for (size_t n = 0; n < kMaxCount; ++n) { + v.append(hashIndex(n)); + } + EXPECT_EQ(kMaxCount, v.size()); + for (size_t n = 0; n < kMaxCount; ++n) { + EXPECT_EQ(hashIndex(n), v[0]) << "At index " << n; + v.remove(0U); + EXPECT_EQ(kMaxCount - n - 1U, v.size()) << "At index " << n; + } +} + +TEST(PodVector, PrependItems) { + PodVector v; + const size_t kMaxCount = 100; + for (size_t n = 0; n < kMaxCount; ++n) { + v.prepend(hashIndex(n)); + } + EXPECT_EQ(kMaxCount, v.size()); + for (size_t n = 0; n < kMaxCount; ++n) { + EXPECT_EQ(hashIndex(kMaxCount - n - 1), v[n]) << "At index " << n; + } +} + +TEST(PodVector, ResizeExpands) { + PodVector v; + const size_t kMaxCount = 100; + const size_t kMaxCount2 = 10000; + for (size_t n = 0; n < kMaxCount; ++n) { + v.append(hashIndex(n)); + } + EXPECT_EQ(kMaxCount, v.size()); + v.resize(kMaxCount2); + EXPECT_EQ(kMaxCount2, v.size()); + for (size_t n = 0; n < kMaxCount; ++n) { + EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n; + } +} + +TEST(PodVector, ResizeTruncates) { + PodVector v; + const size_t kMaxCount = 10000; + const size_t kMaxCount2 = 10; + for (size_t n = 0; n < kMaxCount; ++n) { + v.append(hashIndex(n)); + } + EXPECT_EQ(kMaxCount, v.size()); + v.resize(kMaxCount2); + EXPECT_EQ(kMaxCount2, v.size()); + for (size_t n = 0; n < kMaxCount2; ++n) { + EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n; + } +} + + +TEST(PodVector, AssignmentOperator) { + PodVector v1; + const size_t kMaxCount = 10000; + for (size_t n = 0; n < kMaxCount; ++n) { + v1.append(hashIndex(n)); + } + EXPECT_EQ(kMaxCount, v1.size()); + + PodVector v2; + v2 = v1; + + v1.reserve(0); + + EXPECT_EQ(kMaxCount, v2.size()); + for (size_t n = 0; n < kMaxCount; ++n) { + EXPECT_EQ(hashIndex(n), v2[n]) << "At index " << n; + } +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/scoped_pointer_vector.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/scoped_pointer_vector.h new file mode 100644 index 0000000..3d263e9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/scoped_pointer_vector.h @@ -0,0 +1,27 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_SCOPED_POINTER_VECTOR_H +#define EMUGL_COMMON_SCOPED_POINTER_VECTOR_H + +namespace emugl { + +template +class ScopedPointerVector { + ScopedPointerVector +}; + +} // namespace emugl + +#endif // EMUGL_COMMON_SCOPED_POINTER_VECTOR_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.cpp new file mode 100644 index 0000000..86622f1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.cpp @@ -0,0 +1,169 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/shared_library.h" + +#include +#include +#include + +#ifndef _WIN32 +#include +#include +#endif + +namespace emugl { + +// static +SharedLibrary* SharedLibrary::open(const char* libraryName) { + char error[1]; + return open(libraryName, error, sizeof(error)); +} + +#ifdef _WIN32 + +// static +SharedLibrary* SharedLibrary::open(const char* libraryName, + char* error, + size_t errorSize) { + HMODULE lib = LoadLibrary(libraryName); + if (lib) { + return new SharedLibrary(lib); + } + + if (errorSize == 0) { + return NULL; + } + + // Convert error into human-readable message. + DWORD errorCode = ::GetLastError(); + LPSTR message = NULL; + size_t messageLen = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + errorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR) &message, + 0, + NULL); + + int ret = snprintf(error, errorSize, "%.*s", (int)messageLen, message); + if (ret < 0 || ret == static_cast(errorSize)) { + // snprintf() on Windows doesn't behave as expected by C99, + // this path is to ensure that the result is always properly + // zero-terminated. + ret = static_cast(errorSize - 1); + error[ret] = '\0'; + } + // Remove any trailing \r\n added by FormatMessage + if (ret > 0 && error[ret - 1] == '\n') { + error[--ret] = '\0'; + } + if (ret > 0 && error[ret - 1] == '\r') { + error[--ret] = '\0'; + } + return NULL; +} + +SharedLibrary::SharedLibrary(HandleType lib) : mLib(lib) {} + +SharedLibrary::~SharedLibrary() { + if (mLib) { + FreeLibrary(mLib); + } +} + +SharedLibrary::FunctionPtr SharedLibrary::findSymbol( + const char* symbolName) const { + if (!mLib || !symbolName) { + return NULL; + } + return reinterpret_cast( + GetProcAddress(mLib, symbolName)); +} + +#else // !_WIN32 + +// static +SharedLibrary* SharedLibrary::open(const char* libraryName, + char* error, + size_t errorSize) { + const char* libPath = libraryName; + char* path = NULL; + + const char* libBaseName = strrchr(libraryName, '/'); + if (!libBaseName) { + libBaseName = libraryName; + } + + if (!strchr(libBaseName, '.')) { + // There is no extension in this library name, so append one. +#ifdef __APPLE__ + static const char kDllExtension[] = ".dylib"; +#else + static const char kDllExtension[] = ".so"; +#endif + size_t pathLen = strlen(libraryName) + sizeof(kDllExtension); + path = static_cast(malloc(pathLen)); + snprintf(path, pathLen, "%s%s", libraryName, kDllExtension); + libPath = path; + } + + dlerror(); // clear error. + +#ifdef __APPLE__ + // On OSX, some libraries don't include an extension (notably OpenGL) + // On OSX we try to open |libraryName| first. If that doesn't exist, + // we try |libraryName|.dylib + void* lib = dlopen(libraryName, RTLD_NOW); + if (lib == NULL) { + lib = dlopen(libPath, RTLD_NOW); + } +#else + void* lib = dlopen(libPath, RTLD_NOW); +#endif + + if (path) { + free(path); + } + + if (lib) { + return new SharedLibrary(lib); + } + + snprintf(error, errorSize, "%s", dlerror()); + return NULL; +} + +SharedLibrary::SharedLibrary(HandleType lib) : mLib(lib) {} + +SharedLibrary::~SharedLibrary() { + if (mLib) { + dlclose(mLib); + } +} + +SharedLibrary::FunctionPtr SharedLibrary::findSymbol( + const char* symbolName) const { + if (!mLib || !symbolName) { + return NULL; + } + return reinterpret_cast(dlsym(mLib, symbolName)); +} + +#endif // !_WIN32 + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.h new file mode 100644 index 0000000..55304a7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library.h @@ -0,0 +1,100 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_SHARED_LIBRARY_H +#define EMUGL_COMMON_SHARED_LIBRARY_H + +#include + +#ifdef _WIN32 +#include +#endif + +namespace emugl { + +// A class used to open a platform-specific shared library, and probe +// it for symbols. Usage is the following: +// +// // Open the library. +// SharedLibrary* library = SharedLibrary::open("libFoo"); +// if (!library) { +// ... could not find / open library! +// } +// +// //Probe for function symbol. +// FunctionPtr my_func = library->findSymbol("my_func"); +// +// // Closes library/ +// delete library; +// +class SharedLibrary { +public: + // Open a given library. If |libraryName| has no extension, a + // platform-appropriate extension is added and that path is opened. + // If the |libraryName| has an extension, that form is opened. + // + // On OSX, some libraries don't include an extension (notably OpenGL) + // On OSX we try to open |libraryName| first. If that doesn't exist, + // we try |libraryName|.dylib + // + // On success, returns a new SharedLibrary instance that must be + // deleted by the caller. + static SharedLibrary* open(const char* libraryName); + + // A variant of open() that can report a human-readable error if loading + // the library fails. |error| is a caller-provided buffer of |errorSize| + // bytes that will be filled with snprintf() and always zero terminated. + // + // On success, return a new SharedLibrary instance, and do not touch + // the content of |error|. On failure, return NULL, and sets the content + // of |error|. + static SharedLibrary* open(const char* libraryName, + char* error, + size_t errorSize); + + // Closes an existing SharedLibrary instance. + ~SharedLibrary(); + + // Generic function pointer type, for values returned by the + // findSymbol() method. + typedef void (*FunctionPtr)(void); + + // Probe a given SharedLibrary instance to find a symbol named + // |symbolName| in it. Return its address as a FunctionPtr, or + // NULL if the symbol is not found. + FunctionPtr findSymbol(const char* symbolName) const; + +private: +#ifdef _WIN32 + typedef HMODULE HandleType; +#else + typedef void* HandleType; +#endif + + // Constructor intentionally hidden. + SharedLibrary(HandleType); + + HandleType mLib; +}; + +// Macro to compose emugl shared library name under various OS and bitness +// eg. +// on x86_64, EMUGL_LIBNAME("foo") --> "lib64foo" + + +# define EMUGL_LIBNAME(name) "lib" name + +} // namespace emugl + +#endif // EMUGL_COMMON_SHARED_LIBRARY_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library_unittest.cpp new file mode 100644 index 0000000..c946cca --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/shared_library_unittest.cpp @@ -0,0 +1,177 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/shared_library.h" + +#include + +#include + +#include +#include + +// Hack to get the current executable's full path. +namespace testing { +namespace internal { + +extern std::string g_executable_path; + +} // namespace internal +} // namespace testing + +namespace emugl { + +namespace { + +// Return the name/path of the test shared library to load. +// Note that this doesn't include a platform-specific extension. +// This assumes that the test shared library is under the lib/ sub-directory +// of the current executable's path! +std::string GetTestLibraryName() { +#ifdef __x86_64__ + static const char kLibraryPrefix[] = "lib64"; + static const char kSubDir[] = "lib64/"; +#else + static const char kLibraryPrefix[] = "lib"; + static const char kSubDir[] = "lib/"; +#endif + static const char kTestLibrarySuffix[] = "emugl_test_shared_library"; + + const char* exec_path = testing::internal::g_executable_path.c_str(); + +#ifdef _WIN32 + const char* p = strrchr(exec_path, '/'); + const char* p2 = strrchr(exec_path, '\\'); + if (p2) { + if (!p || p2 > p) { + p = p2; + } + } +#else + const char* p = strrchr(exec_path, '/'); +#endif + + std::string path; + + if (!p) { + path = "./"; + } else { + path = std::string(exec_path, p - exec_path + 1U); + } + path += kSubDir; + path += kLibraryPrefix; + path += kTestLibrarySuffix; + printf("Library path: %s\n", path.c_str()); + return path; +} + +class SharedLibraryTest : public testing::Test { +public: + SharedLibraryTest() { + // Locate the shared library + mLibraryPath = GetTestLibraryName(); + } + + ~SharedLibraryTest() {} + + const char* library_path() const { return mLibraryPath.c_str(); } + +private: + std::string mLibraryPath; +}; + +class ScopedSharedLibrary { +public: + explicit ScopedSharedLibrary(const SharedLibrary* lib) : mLib(lib) {} + ~ScopedSharedLibrary() { + delete mLib; + } + const SharedLibrary* get() const { return mLib; } + + const SharedLibrary* operator->() { return mLib; } + + void release() { + delete mLib; + mLib = NULL; + } + +private: + const SharedLibrary* mLib; +}; + +} // namespace + +TEST_F(SharedLibraryTest, Open) { + ScopedSharedLibrary lib(SharedLibrary::open(library_path())); + EXPECT_TRUE(lib.get()); +} + +TEST_F(SharedLibraryTest, OpenFailureWithError) { + char error[256]; + error[0] = '\0'; + SharedLibrary* lib = SharedLibrary::open("/tmp/does/not/exists", + error, + sizeof(error)); + EXPECT_FALSE(lib); + EXPECT_TRUE(error[0]) + << "Could not get error string when failing to load library"; + printf("Expected library load failure: [%s]\n", error); +} + +TEST_F(SharedLibraryTest, OpenLibraryWithExtension) { + std::string path = library_path(); + + // test extension append + ScopedSharedLibrary libNoExtension(SharedLibrary::open(path.c_str())); + EXPECT_TRUE(libNoExtension.get()); + libNoExtension.release(); + +#ifdef _WIN32 + path += ".dll"; +#elif defined(__APPLE__) + // try to open the library without an extension + + path += ".dylib"; +#else + path += ".so"; +#endif + + // test open with prepended extension + ScopedSharedLibrary lib(SharedLibrary::open(path.c_str())); + EXPECT_TRUE(lib.get()); +} + +#ifdef __APPLE__ +TEST_F(SharedLibraryTest, OpenLibraryWithoutExtension) { + const char* library = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; + ScopedSharedLibrary lib(SharedLibrary::open(library)); + EXPECT_TRUE(lib.get()); +} +#endif + +TEST_F(SharedLibraryTest, FindSymbol) { + ScopedSharedLibrary lib(SharedLibrary::open(library_path())); + EXPECT_TRUE(lib.get()); + + if (lib.get()) { + typedef int (*FooFunction)(void); + + FooFunction foo_func = reinterpret_cast( + lib->findSymbol("foo_function")); + EXPECT_TRUE(foo_func); + EXPECT_EQ(42, (*foo_func)()); + } +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.cpp new file mode 100644 index 0000000..703487d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.cpp @@ -0,0 +1,113 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/smart_ptr.h" + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + +namespace emugl { + +// Thread-safe atomic reference-counting type. +class RefCount { +public: + RefCount() : mCount(1) {} + ~RefCount() {} + + // Technically not thread-safe, use only for testing. + int count() const { return (int)mCount; } + + void increment() { +#ifdef _WIN32 + InterlockedIncrement(&mCount); +#else + __sync_fetch_and_add(&mCount, 1); +#endif + } + + bool decrement() { +#ifdef _WIN32 + return InterlockedDecrement(&mCount) == 0; +#else + return __sync_add_and_fetch(&mCount, -1) == 0; +#endif + } + +private: +#ifdef _WIN32 + LONG mCount; +#else + int mCount; +#endif +}; + + +// SmartPtrBase implementation. + +SmartPtrBase::SmartPtrBase(void* ptr) : mPtr(ptr), mRefCount(NULL) { + if (mPtr) + mRefCount = new RefCount(); +} + + +SmartPtrBase::SmartPtrBase(const SmartPtrBase& other) + : mPtr(other.mPtr), mRefCount(other.mRefCount) { + if (mRefCount) + mRefCount->increment(); +} + + +int SmartPtrBase::getRefCount() const { + return mRefCount ? mRefCount->count() : 0; +} + + +void SmartPtrBase::addRef() { + if (mRefCount) + mRefCount->increment(); +} + + +void* SmartPtrBase::copyFrom(const SmartPtrBase& other) { + void* old_ptr = release(); + + mPtr = other.mPtr; + mRefCount = other.mRefCount; + if (mRefCount) + mRefCount->increment(); + + return old_ptr; +} + + +void* SmartPtrBase::release() { + void* old_ptr = mPtr; + RefCount* old_refcount = mRefCount; + + if (old_refcount) { + mPtr = NULL; + mRefCount = NULL; + + if (old_refcount->decrement()) { + delete old_refcount; + return old_ptr; + } + } + + return NULL; +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.h new file mode 100644 index 0000000..73efdd6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr.h @@ -0,0 +1,150 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef EMUGL_SMART_PTR_H +#define EMUGL_SMART_PTR_H + +#include + +namespace emugl { + +// Hidden atomic ref-counting implementation. +class RefCount; + +// Base class for all templated SmartPtr<> instances. Reduces +// template expansion and code. Consider this to be an implementation +// detail of SmartPtr<>, so don't rely on anything here. +class SmartPtrBase { +public: + // Defrault constructor. + SmartPtrBase() : mPtr(NULL), mRefCount(NULL) {} + + // Normal constructor. This takes ownership of |ptr|, though only + // template instances are capable of destroying the object. + explicit SmartPtrBase(void* ptr); + + // Copy-constructor, this increments the reference count. + SmartPtrBase(const SmartPtrBase& other); + + // Assignment operator, also increments the reference count. + SmartPtrBase& operator=(const SmartPtrBase& other); + + // Nothing happens in this destructor, the real work must be performed + // in subclasses. + ~SmartPtrBase() {} + + + // Used to enable 'if (smart_ptr) { ... }' properly. + operator void*() const { + return mPtr; + } + + // Return internal reference count value, only use for unit testing. + int getRefCount() const; + +protected: + // Used internally to increment the reference count. + void addRef(); + + // Copy the |other| into this instance, returns the old pointer value + // if it needs to be destroyed by the caller, or NULL otherwise. + void* copyFrom(const SmartPtrBase& other); + + // Used internally to decrement the reference count, if it reaches 0, + // returns the pointer to be destroyed, NULL otherwise. + void* release(); + + void* mPtr; + RefCount* mRefCount; +}; + + +// The real template class to be used for smart pointers. +// Typical uses: +// +// SmartPtr ptr(new Foo()); // takes ownership. +// SmartPtr ptr2; // empty pointer. +// ptr2 = ptr; // copies pointer + increment reference count. +// Foo* obj = ptr.Ptr(); // access pointed object. +// ptr->DoStuff(); // operate directly on pointed object. +// (*ptr)->DoStuff(); // same here. +// +// On scope exit, the internal reference count is decremented and the +// object is deleted automatically when it reaches 0, indicating that +// there are no more owners. +// +// IMPORTANT: You need to be sure that only one 'chain' of smart pointers +// own a given object. I.e. the following is incorrect: +// +// Foo* foo = new Foo(); // create new instance. +// SmartPtr ptr(foo); // |ptr| takes ownership of |foo|. +// SmartPtr ptr2(foo); // |ptr2| takes also ownership of |foo|. +// +// The problem is that |ptr| and |ptr2| don't know anything about each +// other, and will not share the same reference count. Once a smart pointer +// owns an object, only use other smart pointers that are copy-constructed +// or assigned with the initial one to keep everything consistent. +template +class SmartPtr : public emugl::SmartPtrBase { +public: + // Default constructor. The instance holds a NULL pointer. + SmartPtr() : SmartPtrBase() {} + + // Regular constructor, takes ownership of |ptr|. + explicit SmartPtr(T* ptr) : SmartPtrBase(ptr) {} + + // Copy-constructor, |this| and |other| will share the same internal + // reference count, which is incremented by 1. + SmartPtr(const SmartPtr& other) + : SmartPtrBase(reinterpret_cast(other)) {} + + // Assignment operator, same semantics as copy-constructor. + SmartPtr& operator=(const SmartPtr& other) { + void* old_ptr = copyFrom(static_cast(other)); + if (old_ptr) + delete reinterpret_cast(old_ptr); + return *this; + } + + // Destructor, decrements reference count and destroys the object + // if it reaches 0 (indicating this was the last owning smart pointer). + ~SmartPtr() { + void* ptr = release(); + if (ptr) + delete reinterpret_cast(ptr); + } + + // Return owned object instance, or NULL. + T* Ptr() const { + return reinterpret_cast(mPtr); + } + + // Return owned object instance, or NULL + const T* constPtr() const { + return reinterpret_cast(mPtr); + } + + // Operate directly on owned object. + T* operator->() const { + return Ptr(); + } + + // Return reference to owned object. + T& operator*() const { + return *Ptr(); + } +}; + +} // namespace emugl + +#endif // EMUGL_SMART_PTR_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr_unittest.cpp new file mode 100644 index 0000000..db9e5f2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/smart_ptr_unittest.cpp @@ -0,0 +1,140 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/smart_ptr.h" + +#include + +namespace emugl { + +// This Test sub-class is used to track allocations and deallocations of +// the MyTestClass instances that are created through newInstance(). +// See below for typical usage. +class SmartPtrTest : public testing::Test { +public: + SmartPtrTest() : mNewCount(0), mDeleteCount(0), mDoCount(0) {} + + ~SmartPtrTest() { + mNewCount = 0; + mDoCount = 0; + mDeleteCount = 0; + } + + class MyClass; + + MyClass* newInstance() { + return new MyClass(this); + } + + class MyClass { + public: + MyClass(SmartPtrTest* test) : mTest(test) { + mTest->mNewCount++; + } + + void doStuff() { + mTest->mDoCount++; + } + + ~MyClass() { + mTest->mDeleteCount++; + } + private: + SmartPtrTest* mTest; + }; + + int mNewCount; + int mDeleteCount; + int mDoCount; +}; + + +TEST_F(SmartPtrTest, Empty) { + SmartPtr ptr; + EXPECT_FALSE(ptr.Ptr()); + + EXPECT_EQ(0, mNewCount); + EXPECT_EQ(0, mDeleteCount); + EXPECT_EQ(0, mDoCount); +} + + +TEST_F(SmartPtrTest, SingleRef) { + MyClass* obj = newInstance(); + EXPECT_EQ(1, mNewCount); + + { + SmartPtr ptr(obj); + EXPECT_EQ(obj, ptr.Ptr()); + + EXPECT_EQ(1, mNewCount); + EXPECT_EQ(0, mDeleteCount); + EXPECT_EQ(0, mDoCount); + } + // Check that the object was deleted. + EXPECT_EQ(1, mDeleteCount); +} + + +TEST_F(SmartPtrTest, CopyConstructor) { + MyClass* obj = newInstance(); + EXPECT_EQ(1, mNewCount); + + { + SmartPtr ptr1(obj); + { + SmartPtr ptr2(ptr1); + EXPECT_EQ(2, ptr1.getRefCount()); + EXPECT_EQ(2, ptr2.getRefCount()); + EXPECT_EQ(1, mNewCount); + EXPECT_EQ(0, mDeleteCount); + EXPECT_EQ(0, mDoCount); + } + EXPECT_EQ(1, mNewCount); + EXPECT_EQ(0, mDeleteCount); + EXPECT_EQ(0, mDoCount); + } + EXPECT_EQ(1, mNewCount); + EXPECT_EQ(1, mDeleteCount); + EXPECT_EQ(0, mDoCount); +} + + +TEST_F(SmartPtrTest, AssignmentOperator) { + SmartPtr ptr1(newInstance()); + SmartPtr ptr2(newInstance()); + EXPECT_EQ(2, mNewCount); + EXPECT_EQ(0, mDeleteCount); + EXPECT_EQ(0, mDoCount); + + ptr2 = ptr1; + EXPECT_EQ(2, mNewCount); + EXPECT_EQ(1, mDeleteCount); + + EXPECT_EQ(ptr1.Ptr(), ptr2.Ptr()); + EXPECT_EQ(2, ptr1.getRefCount()); + EXPECT_EQ(2, ptr2.getRefCount()); +} + + +TEST_F(SmartPtrTest, ArrowOperator) { + SmartPtr ptr(newInstance()); + ptr->doStuff(); + EXPECT_EQ(1, mDoCount); + + (*ptr).doStuff(); + EXPECT_EQ(2, mDoCount); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.cpp new file mode 100644 index 0000000..b38a4be --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.cpp @@ -0,0 +1,247 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/sockets.h" + +#include + +#ifdef _WIN32 +#include +#include +#else +#include +#include +#include +#include +#include +#endif + +#include +#include +#include +#include + +namespace emugl { + +namespace { + +static void socketSetDontLinger(int s) { +#ifdef _WIN32 + // TODO: Verify default behavior on WINDOWS +#else + // Ungraceful shutdown, no reason to linger at all + struct linger so_linger; + so_linger.l_onoff = 1; + so_linger.l_linger = 0; + if(setsockopt(s, SOL_SOCKET, SO_LINGER, &so_linger, sizeof so_linger) < 0) + perror("Setting socket option SO_LINGER={on, 0} failed"); +#endif +} + +static void socketSetReuseAddress(int s) { +#ifdef _WIN32 + // The default behaviour on Windows is equivalent to SO_REUSEADDR + // so we don't need to set this option. Moreover, one should never + // set this option with WinSock because it's badly implemented and + // generates a huge security issue. See: + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621(v=vs.85).aspx +#else + int val = 1; + if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) + perror("Setting socket option SO_REUSEADDR failed"); +#endif +} + +// Helper union to store a socket address. +struct SockAddr { + socklen_t len; + union { + sockaddr generic; + sockaddr_in inet; +#ifndef _WIN32 + sockaddr_un local; +#endif + }; + + int getFamily() const { return generic.sa_family; } + + void initEmpty() { + ::memset(this, 0, sizeof(*this)); + this->len = static_cast(sizeof(*this)); + } + + int initFromInet(uint32_t ip_address, int port) { + if (port < 0 || port >= 65536) + return -EINVAL; + + ::memset(this, 0, sizeof(*this)); + this->inet.sin_family = AF_INET; + this->inet.sin_port = htons(port); + this->inet.sin_addr.s_addr = htonl(ip_address); + this->len = sizeof(this->inet); + return 0; + } + + int initFromLocalhost(int port) { + return initFromInet(0x7f000001, port); + } + +#ifndef _WIN32 + // Initialize the SockAddr from a Unix path. Returns 0 on success, + // or -errno code on failure. + int initFromUnixPath(const char* path) { + if (!path || !path[0]) + return -EINVAL; + + size_t pathLen = ::strlen(path); + if (pathLen >= sizeof(local.sun_path)) + return -E2BIG; + + ::memset(this, 0, sizeof(*this)); + this->local.sun_family = AF_LOCAL; + ::memcpy(this->local.sun_path, path, pathLen + 1U); + this->len = pathLen + offsetof(sockaddr_un, sun_path); + return 0; + } +#endif +}; + +int socketBindInternal(const SockAddr* addr, int socketType) { + int s = ::socket(addr->getFamily(), socketType, 0); + if (s < 0) { + perror("Could not create socket to bind"); + return -errno; + } + + socketSetDontLinger(s); + socketSetReuseAddress(s); + + // Bind to the socket. + if (::bind(s, &addr->generic, addr->len) < 0 || + ::listen(s, 5) < 0) { + int ret = -errno; + perror("Could not bind or listen to socket"); + ::close(s); + return ret; + } + + return s; +} + +int socketConnectInternal(const SockAddr* addr, int socketType) { + int s = ::socket(addr->getFamily(), socketType, 0); + if (s < 0) { + perror("Could not create socket to connect"); + return -errno; + } + + socketSetDontLinger(s); + socketSetReuseAddress(s); + + int ret; + do { + ret = ::connect(s, &addr->generic, addr->len); + } while (ret < 0 && errno == EINTR); + + if (ret < 0) { + ret = -errno; + ::close(s); + return ret; + } + + return s; +} + +} // namespace + +void socketTcpDisableNagle(int s) { + // disable Nagle algorithm to improve bandwidth of small + // packets which are quite common in our implementation. +#ifdef _WIN32 + DWORD flag; +#else + int flag; +#endif + flag = 1; + setsockopt(s, IPPROTO_TCP, TCP_NODELAY, + (const char*)&flag, sizeof(flag)); +} + +int socketGetPort(int s) { + SockAddr addr; + addr.initEmpty(); + if (getsockname(s, &addr.generic, &addr.len) < 0) { + return -errno; + } + switch (addr.generic.sa_family) { + case AF_INET: + return ntohs(addr.inet.sin_port); + default: + ; + } + return -EINVAL; +} + +#ifndef _WIN32 +int socketLocalServer(const char* path, int socketType) { + SockAddr addr; + int ret = addr.initFromUnixPath(path); + if (ret < 0) { + return ret; + } + return socketBindInternal(&addr, socketType); +} + +int socketLocalClient(const char* path, int socketType) { + SockAddr addr; + int ret = addr.initFromUnixPath(path); + if (ret < 0) { + return ret; + } + return socketConnectInternal(&addr, socketType); +} +#endif // !_WIN32 + +int socketTcpLoopbackServer(int port, int socketType) { + SockAddr addr; + int ret = addr.initFromLocalhost(port); + if (ret < 0) { + return ret; + } + return socketBindInternal(&addr, socketType); +} + +int socketTcpLoopbackClient(int port, int socketType) { + SockAddr addr; + int ret = addr.initFromLocalhost(port); + if (ret < 0) { + return ret; + } + return socketConnectInternal(&addr, socketType); +} + +int socketTcpClient(const char* hostname, int port, int socketType) { + // TODO(digit): Implement this. + return -ENOSYS; +} + +int socketAccept(int serverSocket) { + int ret; + do { + ret = ::accept(serverSocket, NULL, NULL); + } while (ret < 0 && errno == EINTR); + return ret; +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.h new file mode 100644 index 0000000..11e7ac7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/sockets.h @@ -0,0 +1,57 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_SOCKETS_H +#define EMUGL_COMMON_SOCKETS_H + +// A set of helper functions used to deal with sockets in a portable way. + +namespace emugl { + +// Disable Nagle's algorithm for socket descriptor |s|. This assumes +// that |s| is a TCP socket descriptor. +void socketTcpDisableNagle(int s); + +// Return the port associated with a given IP or IPv6 socket, +// or -errno code on failure. +int socketGetPort(int s); + +// Bind to a local/Unix path, and return its socket descriptor on success, +// or -errno code on failure. +int socketLocalServer(const char* path, int socketType); + +// Connect to a Unix local path, and return a new socket descriptor +// on success, or -errno code on failure. +int socketLocalClient(const char* path, int socketType); + +// Bind to a localhost TCP socket, and return its socket descriptor on +// success, or -errno code on failure. +int socketTcpLoopbackServer(int port, int socketType); + +// Connect to a localhost TCP port, and return a new socket descriptor on +// success, or -errno code on failure. +int socketTcpLoopbackClient(int port, int socketType); + +// Connect to a TCP host, and return a new socket descriptor on +// success, or -errno code on failure. +int socketTcpClient(const char* hostname, int port, int socketType); + +// Accept a new connection. |serverSocket| must be a bound server socket +// descriptor. Returns new socket descriptor on success, or -errno code +// on failure. +int socketAccept(int serverSocket); + +} // namespace emugl + +#endif // EMUGL_COMMON_SOCKETS_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_shared_library.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_shared_library.cpp new file mode 100644 index 0000000..598a963 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_shared_library.cpp @@ -0,0 +1,22 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This source file must be compiled into a simple shared library which +// will be used by shared_library_unittest.cpp to verify that the +// emugl::SharedLibrary class works properly. + + +extern "C" int foo_function(void) { + return 42; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_thread.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_thread.h new file mode 100644 index 0000000..adc8e5f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/testing/test_thread.h @@ -0,0 +1,78 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_TESTING_TEST_THREAD_H +#define EMUGL_COMMON_TESTING_TEST_THREAD_H + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN 1 +# include +#else +# include +#endif + +namespace emugl { + +// Very basic platform thread wrapper that only uses a tiny stack. +// This shall only be used during unit testing, and allows test code +// to not depend on the implementation of emugl::Thread. +class TestThread { +public: + // Main thread function type. + typedef void* (ThreadFunction)(void* param); + + // Constructor actually launches a new platform thread. + TestThread(ThreadFunction* func, void* funcParam) { +#ifdef _WIN32 + mThread = CreateThread(NULL, + 16384, + (DWORD WINAPI (*)(void*))func, + funcParam, + 0, + NULL); +#else + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setstacksize(&attr, 16384); + pthread_create(&mThread, &attr, func, funcParam); + pthread_attr_destroy(&attr); +#endif + } + + ~TestThread() { +#ifdef _WIN32 + CloseHandle(mThread); +#endif + } + + void join() { +#ifdef _WIN32 + WaitForSingleObject(mThread, INFINITE); +#else + void* ret = NULL; + pthread_join(mThread, &ret); +#endif + } + +private: +#ifdef _WIN32 + HANDLE mThread; +#else + pthread_t mThread; +#endif +}; + +} // namespace emugl + +#endif // EMUGL_COMMON_TESTING_TEST_THREAD_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread.h new file mode 100644 index 0000000..f524512 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread.h @@ -0,0 +1,103 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_THREAD_H +#define EMUGL_COMMON_THREAD_H + +#ifdef _WIN32 +#include +#else +#include +#endif + +#include + +namespace emugl { + +// Wrapper class for platform-specific threads. +// To create your own thread, define a sub-class of emugl::Thread +// and override its main() method. +// +// For example: +// +// class MyThread : public emugl::Thread { +// public: +// MyThread() : Thread() {} +// +// virtual intptr_t main() { +// ... main thread loop implementation +// return 0; +// } +// }; +// +// ... +// +// // Create new instance, but does not start it. +// MyThread* thread = new MyThread(); +// +// // Start the thread. +// thread->start(); +// +// // Wait for thread completion, and gets result into |exitStatus|. +// int exitStatus; +// thread->wait(&exitStatus); +// +class Thread { +public: + // Public constructor. + Thread(); + + // Virtual destructor. + virtual ~Thread(); + + // Override this method in your own thread sub-classes. This will + // be called when start() is invoked on the Thread instance. + virtual intptr_t main() = 0; + + // Start a thread instance. Return true on success, false otherwise + // (e.g. if the thread was already started or terminated). + bool start(); + + // Wait for thread termination and retrieve exist status into + // |*exitStatus|. Return true on success, false otherwise. + // NOTE: |exitStatus| can be NULL. + bool wait(intptr_t *exitStatus); + + // Check whether a thread has terminated. On success, return true + // and sets |*exitStatus|. On failure, return false. + // NOTE: |exitStatus| can be NULL. + bool tryWait(intptr_t *exitStatus); + +private: +#ifdef _WIN32 + static DWORD WINAPI thread_main(void* arg); + + HANDLE mThread; + DWORD mThreadId; + CRITICAL_SECTION mLock; +#else // !WIN32 + static void* thread_main(void* arg); + + pthread_t mThread; + pthread_mutex_t mLock; + bool mJoined; +#endif + intptr_t mExitStatus; + bool mIsRunning; +}; + +} // namespace emugl + +#endif // EMUGL_COMMON_THREAD_H + diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_pthread.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_pthread.cpp new file mode 100644 index 0000000..edd1f6a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_pthread.cpp @@ -0,0 +1,136 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/thread.h" + +#include "emugl/common/thread_store.h" + +#include +#include + +namespace emugl { + +namespace { + +class ScopedLocker { +public: + ScopedLocker(pthread_mutex_t* mutex) : mMutex(mutex) { + pthread_mutex_lock(mMutex); + } + + ~ScopedLocker() { + pthread_mutex_unlock(mMutex); + } +private: + pthread_mutex_t* mMutex; +}; + +} // namespace + +Thread::Thread() : + mThread((pthread_t)NULL), + mLock(), + mJoined(false), + mExitStatus(0), + mIsRunning(false) { + pthread_mutex_init(&mLock, NULL); +} + +Thread::~Thread() { + assert(!mIsRunning); + assert(mJoined); + pthread_mutex_destroy(&mLock); +} + +bool Thread::start() { + bool ret = true; + pthread_mutex_lock(&mLock); + mIsRunning = true; + if (pthread_create(&mThread, NULL, thread_main, this)) { + ret = false; + mIsRunning = false; + } + pthread_mutex_unlock(&mLock); + return ret; +} + +bool Thread::wait(intptr_t *exitStatus) { + { + ScopedLocker locker(&mLock); + if (!mIsRunning) { + // Thread already stopped. + if (exitStatus) { + *exitStatus = mExitStatus; + } + if (!mJoined) { + // reclaim thread stack + pthread_join(mThread, NULL); + mJoined = true; + } + return true; + } + } + + // NOTE: Do not hold the lock when waiting for the thread to ensure + // it can update mIsRunning and mExitStatus properly in thread_main + // without blocking. + void *retval; + if (pthread_join(mThread, &retval)) { + return false; + } + if (exitStatus) { + *exitStatus = (intptr_t)retval; + } + // Note: Updating mJoined must be performed inside the lock to avoid + // race conditions between two threads waiting for the same thread + // that just completed its execution. + { + ScopedLocker locker(&mLock); + mJoined = true; + } + return true; +} + +bool Thread::tryWait(intptr_t *exitStatus) { + ScopedLocker locker(&mLock); + if (mIsRunning) { + return false; + } + if (!mJoined) { + // Reclaim stack. + pthread_join(mThread, NULL); + mJoined = true; + } + if (exitStatus) { + *exitStatus = mExitStatus; + } + return true; +} + +// static +void* Thread::thread_main(void *arg) { + Thread* self = reinterpret_cast(arg); + intptr_t ret = self->main(); + + pthread_mutex_lock(&self->mLock); + self->mIsRunning = false; + self->mExitStatus = ret; + pthread_mutex_unlock(&self->mLock); + + ::emugl::ThreadStore::OnThreadExit(); + + return (void*)ret; +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.cpp new file mode 100644 index 0000000..ea64c6f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.cpp @@ -0,0 +1,242 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/thread_store.h" + +#ifdef _WIN32 +#include "emugl/common/lazy_instance.h" +#endif + +#include +#include +#include +#include + +// Set to 1 to print debug messages. +#define DEBUG_THREAD_STORE 0 + +#if DEBUG_THREAD_STORE +# define D(...) do { printf("%s:%d: ", __FUNCTION__, __LINE__); printf(__VA_ARGS__); fflush(stdout); } while (0) +#else +# define D(...) ((void)0) +#endif + +namespace emugl { + +#ifdef _WIN32 + +namespace { + +// The ThreadStore implementation on Windows is very tricky, because +// TlsAlloc() doesn't allow one to provide a destructor function. As +// such threads are expected to destroy all TLS values explicitely. +// +// To solve this issue, this source file provides a static method called +// ThreadStore::OnThreadExit() that must be called when a thread exits, +// which will cleanup all values for the current thread. +// +// But this forces us to track thread-specific values ourselves. + +// Maximum amount of thread-specific slots supported by this implementation. +enum { + kMaxTlsSlots = 64 +}; + +// TlsSlotArray is a thread-specific array of values. Instances will +// be stored in a Win32 TLS value controlled by a single master TLS +// key. +// +typedef void* TlsSlotArray[kMaxTlsSlots]; + +// Global state shared by all threads +class GlobalState { +public: + GlobalState() { + D("Entering\n"); + mMasterTls = TlsAlloc(); + D("Master TLS = %d\n", (int)mMasterTls); + InitializeCriticalSection(&mSection); + mLastIndex = 0; + ::memset(mDestructors, 0, sizeof(mDestructors)); + D("Exiting\n"); + } + + // Register a new TLS key, or return -1 on error (too many keys). + // |destroy| is the destructor function for the key. + int registerKey(ThreadStore::Destructor* destroy) { + D("Entering destroy=%p\n", destroy); + int ret = -1; + EnterCriticalSection(&mSection); + if (mLastIndex < kMaxTlsSlots) { + ret = mLastIndex++; + mDestructors[ret] = destroy; + } + LeaveCriticalSection(&mSection); + D("Exiting newKey=%d\n", ret); + return ret; + } + + void unregisterKey(int key) { + D("key=%d\n", key); + if (key < 0 || key >= kMaxTlsSlots) { + D("Invalid key\n"); + return; + } + + // Note: keys are not reusable, but remove the destructor to avoid + // crashes in leaveCurrentThread() when it points to a function that + // is going to be unloaded from the process' address space. + EnterCriticalSection(&mSection); + mDestructors[key] = NULL; + LeaveCriticalSection(&mSection); + D("Exiting\n"); + } + + // Get the current thread-local value for a given |key|. + void* getValue(int key) const { + D("Entering key=%d\n", key); + if (key < 0 || key >= kMaxTlsSlots) { + D("Invalid key, result=NULL\n"); + return NULL; + } + + TlsSlotArray* array = getArray(); + void* ret = (*array)[key]; + D("Exiting keyValue=%p\n", ret); + return ret; + } + + // Set the current thread-local |value| for a given |key|. + void setValue(int key, void* value) { + D("Entering key=%d\n",key); + if (key < 0 || key >= kMaxTlsSlots) { + D("Invalid key, returning\n"); + return; + } + + TlsSlotArray* array = getArray(); + (*array)[key] = value; + D("Exiting\n"); + } + + // Call this when a thread exits to destroy all its thread-local values. + void leaveCurrentThread() { + D("Entering\n"); + TlsSlotArray* array = + reinterpret_cast(TlsGetValue(mMasterTls)); + if (!array) { + D("Exiting, no thread-local data in this thread\n"); + return; + } + + for (size_t n = 0; n < kMaxTlsSlots; ++n) { + void* value = array[n]; + if (value) { + (*array)[n] = NULL; + // NOTE: In theory, a destructor could reset the slot to + // a new value, and we would have to loop in this function + // in interesting ways. In practice, ignore the issue. + EnterCriticalSection(&mSection); + ThreadStore::Destructor* destroy = mDestructors[n]; + LeaveCriticalSection(&mSection); + if (destroy) { + D("Calling destructor %p for key=%d, with value=%p\n", + destroy, (int)n, value); + (*destroy)(value); + } + } + } + TlsSetValue(mMasterTls, NULL); + ::free(array); + D("Exiting\n"); + } + +private: + // Return the thread-local array of TLS slots for the current thread. + // Cannot return NULL. + TlsSlotArray* getArray() const { + D("Entering\n"); + TlsSlotArray* array = + reinterpret_cast(TlsGetValue(mMasterTls)); + if (!array) { + array = reinterpret_cast( + ::calloc(sizeof(*array), 1)); + TlsSetValue(mMasterTls, array); + D("Allocated new array at %p\n", array); + } else { + D("Retrieved array at %p\n", array); + } + return array; + } + + DWORD mMasterTls; + CRITICAL_SECTION mSection; + int mLastIndex; + ThreadStore::Destructor* mDestructors[kMaxTlsSlots]; +}; + +LazyInstance gGlobalState = LAZY_INSTANCE_INIT; + +} // namespace + +ThreadStore::ThreadStore(Destructor* destroy) { + D("Entering this=%p destroy=%p\n", this, destroy); + mKey = gGlobalState->registerKey(destroy); + D("Exiting this=%p key=%d\n", this, mKey); +} + +ThreadStore::~ThreadStore() { + D("Entering this=%p\n", this); + GlobalState* state = gGlobalState.ptr(); + state->unregisterKey(mKey); + D("Exiting this=%p\n", this); +} + +void* ThreadStore::get() const { + D("Entering this=%p\n", this); + void* ret = gGlobalState->getValue(mKey); + D("Exiting this=%p value=%p\n", this, ret); + return ret; +} + +void ThreadStore::set(void* value) { + D("Entering this=%p value=%p\n", this, value); + gGlobalState->setValue(mKey, value); + D("Exiting this=%p\n", this); +} + +// static +void ThreadStore::OnThreadExit() { + gGlobalState->leaveCurrentThread(); +} + +#else // !_WIN32 + +ThreadStore::ThreadStore(Destructor* destroy) { + int ret = pthread_key_create(&mKey, destroy); + if (ret != 0) { + fprintf(stderr, + "Could not create thread store key: %s\n", + strerror(ret)); + exit(1); + } +} + +ThreadStore::~ThreadStore() { + pthread_key_delete(mKey); +} + +#endif // !_WIN32 + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.h new file mode 100644 index 0000000..5fd08bd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store.h @@ -0,0 +1,110 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_THREAD_STORE_H +#define EMUGL_COMMON_THREAD_STORE_H + +#ifdef _WIN32 +# define WIN32_LEAN_AND_MEAN 1 +# include +#else +# include +#endif + +namespace emugl { + +// A class to model storage of thread-specific values, that can be +// destroyed on thread exit. +// +// Note that on Windows, a thread must call OnThreadExit() explicitly +// here to ensure that the values are probably discarded. This is an +// unfortunate requirement of the Win32 API, which doesn't support +// destructors at all. +// +// There are various hacks on the web to try to achieve this automatically +// (e.g. [1]) but they rely on using the Microsoft build tools, +// which doesn't work for us. +// +// Note another important issue with ThreadStore instances: if you create +// one instance in a shared library, you need to make sure that it is +// always destroyed before the library is unloaded. Otherwise, future +// thread exit will likely crash, due to calling a destructor function +// that is no longer in the process' address space. +// +// Finally, destroying an instance does _not_ free the corresponding values, +// because doing so properly requires coordinating all participating threads, +// which is impossible to achieve in the most general case. Thus, consider +// that thread-local values are always leaked on library unload, or on +// program exit. +// +// [1] http://stackoverflow.com/questions/14538159/about-tls-callback-in-windows + +class ThreadStore { +public: + // Type of a function used to destroy a thread-specific value that + // was previously assigned by calling set(). + typedef void (Destructor)(void* value); + + // Initialize instance so that is hold keys that must be destroyed + // on thread exit by calling |destroy|. + explicit ThreadStore(Destructor* destroy); + + // NOTE: Destructor don't free the thread-local values, but are required + // to avoid crashes (see note above). + ~ThreadStore(); + + // Retrieve current thread-specific value from store. +#ifdef _WIN32 + void* get() const; +#else + inline void* get() const { + return pthread_getspecific(mKey); + } +#endif + + // Set the new thread-specific value. +#ifdef _WIN32 + void set(void* value); +#else + inline void set(void* value) { + pthread_setspecific(mKey, value); + } +#endif + +#ifdef _WIN32 + // Each thread should call this function on exit to ensure that + // all corresponding TLS values are properly freed. + static void OnThreadExit(); +#else + // Nothing to do on Posix. + static inline void OnThreadExit() {} +#endif + +private: + // Ensure you can't create an empty ThreadStore instance, or simply + // copy it in any way. + ThreadStore(); + ThreadStore(const ThreadStore&); + ThreadStore& operator=(const ThreadStore&); + +#ifdef _WIN32 + int mKey; +#else + pthread_key_t mKey; +#endif +}; + +} // namespace emugl + +#endif // EMUGL_COMMON_THREAD_STORE_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store_unittest.cpp new file mode 100644 index 0000000..6b5dddb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_store_unittest.cpp @@ -0,0 +1,146 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/thread_store.h" + +#include "emugl/common/mutex.h" +#include "emugl/common/testing/test_thread.h" + +#include + +namespace emugl { + +namespace { + +// Helper class used to count instance creation and destruction. +class StaticCounter { +public: + enum { + kMaxInstances = 1000, + }; + + StaticCounter() { + Mutex::AutoLock lock(mMutex); + if (mCreationCount < kMaxInstances) + mInstances[mCreationCount] = this; + mCreationCount++; + } + + ~StaticCounter() { + Mutex::AutoLock lock(mMutex); + mDestructionCount++; + } + + static void reset() { + Mutex::AutoLock lock(mMutex); + mCreationCount = 0; + mDestructionCount = 0; + } + + static size_t getCreationCount() { + Mutex::AutoLock lock(mMutex); + return mCreationCount; + } + + static size_t getDestructionCount() { + Mutex::AutoLock lock(mMutex); + return mDestructionCount; + } + + static void freeAll() { + for (size_t n = 0; n < kMaxInstances; ++n) + delete mInstances[n]; + } + +private: + static Mutex mMutex; + static size_t mCreationCount; + static size_t mDestructionCount; + static StaticCounter* mInstances[kMaxInstances]; +}; + +Mutex StaticCounter::mMutex; +size_t StaticCounter::mCreationCount = 0; +size_t StaticCounter::mDestructionCount = 0; +StaticCounter* StaticCounter::mInstances[kMaxInstances]; + +} // namespace + +// Just check that we can create a new ThreadStore with an empty +// destructor, and use it in the current thread. +TEST(ThreadStore, MainThreadWithoutDestructor) { + ThreadStore store(NULL); + static int x = 42; + store.set(&x); + EXPECT_EQ(&x, store.get()); +} + +// The following test checks that exiting a thread correctly deletes +// any thread-local value stored in it. +static void simplyDestroy(void* value) { + delete (StaticCounter*) value; +} + +static void* simpleThreadFunc(void* param) { + ThreadStore* store = static_cast(param); + store->set(new StaticCounter()); + ThreadStore::OnThreadExit(); + return NULL; +} + +TEST(ThreadStore, ThreadsWithDestructor) { + ThreadStore store(simplyDestroy); + const size_t kNumThreads = 1000; + TestThread* threads[kNumThreads]; + StaticCounter::reset(); + + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n] = new TestThread(&simpleThreadFunc, &store); + } + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n]->join(); + } + + EXPECT_EQ(kNumThreads, StaticCounter::getCreationCount()); + EXPECT_EQ(kNumThreads, StaticCounter::getDestructionCount()); + + for (size_t n = 0; n < kNumThreads; ++n) { + delete threads[n]; + } +} + +TEST(ThreadStore, ThreadsWithoutDestructor) { + ThreadStore store(NULL); + const size_t kNumThreads = 1000; + TestThread* threads[kNumThreads]; + StaticCounter::reset(); + + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n] = new TestThread(&simpleThreadFunc, &store); + } + for (size_t n = 0; n < kNumThreads; ++n) { + threads[n]->join(); + } + + EXPECT_EQ(kNumThreads, StaticCounter::getCreationCount()); + EXPECT_EQ(0U, StaticCounter::getDestructionCount()); + + StaticCounter::freeAll(); + + for (size_t n = 0; n < kNumThreads; ++n) { + delete threads[n]; + } +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_unittest.cpp new file mode 100644 index 0000000..efc2c6e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_unittest.cpp @@ -0,0 +1,164 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/thread.h" + +#include "emugl/common/mutex.h" + +#include + +namespace emugl { + +namespace { + +// A simple thread instance that does nothing at all and exits immediately. +class EmptyThread : public ::emugl::Thread { +public: + intptr_t main() { return 42; } +}; + +class CountingThread : public ::emugl::Thread { +public: + class State { + public: + State() : mLock(), mCount(0) {} + ~State() {} + + void increment() { + mLock.lock(); + mCount++; + mLock.unlock(); + } + + int count() const { + int ret; + mLock.lock(); + ret = mCount; + mLock.unlock(); + return ret; + } + + private: + mutable Mutex mLock; + int mCount; + }; + + CountingThread(State* state) : mState(state) {} + + intptr_t main() { + mState->increment(); + return 0; + } + +private: + State* mState; +}; + +class WaitingThread : public ::emugl::Thread { +public: + WaitingThread(Mutex* lock) : mLock(lock) {} + + intptr_t main() { + // Try to acquire lock. + mLock->lock(); + + // Then try to release it. + mLock->unlock(); + return 0; + } +private: + Mutex* mLock; +}; + +} // namespace + +TEST(ThreadTest, WaitForSimpleThread) { + Thread* thread = new EmptyThread(); + EXPECT_TRUE(thread); + EXPECT_TRUE(thread->start()); + intptr_t status; + EXPECT_TRUE(thread->wait(&status)); + EXPECT_EQ(42, status); +} + +TEST(ThreadTest, WaitForMultipleThreads) { + CountingThread::State state; + const size_t kMaxThreads = 100; + Thread* threads[kMaxThreads]; + + // Create all threads. + for (size_t n = 0; n < kMaxThreads; ++n) { + threads[n] = new CountingThread(&state); + EXPECT_TRUE(threads[n]) << "thread " << n; + } + + // Start them all. + for (size_t n = 0; n < kMaxThreads; ++n) { + EXPECT_TRUE(threads[n]->start()) << "thread " << n; + } + + // Wait for them all. + for (size_t n = 0; n < kMaxThreads; ++n) { + EXPECT_TRUE(threads[n]->wait(NULL)) << "thread " << n; + } + + // Check state. + EXPECT_EQ((int)kMaxThreads, state.count()); + + // Delete them all. + for (size_t n = 0; n < kMaxThreads; ++n) { + delete threads[n]; + } +} + +TEST(ThreadTest, TryWaitForMultipleThreads) { + Mutex lock; + const size_t kMaxThreads = 100; + Thread* threads[kMaxThreads]; + + // Create all threads. + for (size_t n = 0; n < kMaxThreads; ++n) { + threads[n] = new WaitingThread(&lock); + EXPECT_TRUE(threads[n]) << "thread " << n; + } + + // Acquire the lock, this will block all threads. + lock.lock(); + + // Start them all. + for (size_t n = 0; n < kMaxThreads; ++n) { + EXPECT_TRUE(threads[n]->start()) << "thread " << n; + } + + // Check that tryWait() fails for all threads. + for (size_t n = 0; n < kMaxThreads; ++n) { + EXPECT_FALSE(threads[n]->tryWait(NULL)) << "thread" << n; + } + + // Release the lock, this will unblock all threads. + lock.unlock(); + + // Wait for them all. + for (size_t n = 0; n < kMaxThreads; ++n) { + EXPECT_TRUE(threads[n]->wait(NULL)) << "thread " << n; + EXPECT_TRUE(threads[n]->tryWait(NULL)) << "thread " << n; + } + + // Delete them all. + for (size_t n = 0; n < kMaxThreads; ++n) { + delete threads[n]; + } +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_win32.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_win32.cpp new file mode 100644 index 0000000..bd8b37f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/thread_win32.cpp @@ -0,0 +1,121 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/thread.h" + +#include "emugl/common/thread_store.h" + +namespace emugl { + +namespace { + +class ScopedLocker { +public: + ScopedLocker(CRITICAL_SECTION* section) : mSection(section) { + EnterCriticalSection(mSection); + } + + ~ScopedLocker() { + LeaveCriticalSection(mSection); + } +private: + CRITICAL_SECTION* mSection; +}; + +} // namespace + +Thread::Thread() : + mThread(INVALID_HANDLE_VALUE), + mThreadId(0), + mExitStatus(0), + mIsRunning(false) { + InitializeCriticalSection(&mLock); +} + +Thread::~Thread() { + if(mThread != INVALID_HANDLE_VALUE) { + CloseHandle(mThread); + } + DeleteCriticalSection(&mLock); +} + +bool Thread::start() { + ScopedLocker locker(&mLock); + + bool ret = true; + mIsRunning = true; + mThread = CreateThread(NULL, 0, &Thread::thread_main, this, 0, &mThreadId); + if (!mThread) { + ret = false; + mIsRunning = false; + } + return ret; +} + +bool Thread::wait(intptr_t* exitStatus) { + { + ScopedLocker locker(&mLock); + if (!mIsRunning) { + // Thread already stopped. + if (exitStatus) { + *exitStatus = mExitStatus; + } + return true; + } + } + + // NOTE: Do not hold lock during wait to aloow thread_main to + // properly update mIsRunning and mExitStatus on thread exit. + if (WaitForSingleObject(mThread, INFINITE) == WAIT_FAILED) { + return false; + } + + if (exitStatus) { + ScopedLocker locker(&mLock); + *exitStatus = mExitStatus; + } + return true; +} + +bool Thread::tryWait(intptr_t* exitStatus) { + ScopedLocker locker(&mLock); + + if (mIsRunning && WaitForSingleObject(mThread, 0) != WAIT_OBJECT_0) { + return false; + } + + if (exitStatus) { + *exitStatus = mExitStatus; + } + return true; +} + +// static +DWORD WINAPI Thread::thread_main(void *arg) +{ + Thread* self = reinterpret_cast(arg); + intptr_t ret = self->main(); + + EnterCriticalSection(&self->mLock); + self->mIsRunning = false; + self->mExitStatus = ret; + LeaveCriticalSection(&self->mLock); + + // Ensure all thread-local values are released for this thread. + ::emugl::ThreadStore::OnThreadExit(); + + return static_cast(ret); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map.h b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map.h new file mode 100644 index 0000000..720aceb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map.h @@ -0,0 +1,225 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef EMUGL_COMMON_UNIQUE_INTEGER_MAP_H +#define EMUGL_COMMON_UNIQUE_INTEGER_MAP_H + +#include "emugl/common/pod_vector.h" + +#include + +namespace emugl { + +// Helper template class that implements a bi-directional mapping between +// two integer types |A| and |B|. More specifically: +// +// - The map allocates values of type |B| when a key of type |A| is entered +// in the map. +// +// - keys and values cannot be 0, which is reserved (i.e. means 'invalid'). +// +// This is used in EmuGL to map liberal 'void*' values (e.g. EGLimages ones) +// to unique 32-bit IDs that can be written to / read from the wire protocol. +template +class UniqueIntegerMap { +public: + UniqueIntegerMap() : mForwardPairs(), mBackwardPairs() {} + ~UniqueIntegerMap() {} + + // Return true iff the map is empty. + const bool empty() const { return mForwardPairs.empty(); } + + // Return the number of (key,value) pairs in the map. + size_t size() const { return mForwardPairs.size(); } + + // Find the value associated with |key| in the map. + // Returns 0 in case of failure, or if |key| is 0. + B find(const A key) const; + + // Find the key associated with a given |value| in the map. + // Returns 0 if |value| is 0, or in case of failure. + A findKeyFor(const B value) const; + + // Add |key| to the map and return an automatically-allocated + // unique value for it. Return 0 if |key| is 0. + B add(const A key); + + // Delete the entry associated with a given |key|. The + // corresponding value may be recycled by future calls to add(). + void del(const A key); + +private: + typedef struct { + A first; + B second; + } ForwardPair; + + typedef struct { + B first; + A second; + } BackwardPair; + + size_t findKeyIndexPlusOne(const A key) const; + size_t findValueIndexPlusOne(const B value) const; + + B allocValue(); + void freeValue(B value); + + PodVector mForwardPairs; + PodVector mBackwardPairs; + + B mLastValue; + PodVector mFreeValues; +}; + +template +B UniqueIntegerMap::find(const A key) const { + size_t keyIndex = findKeyIndexPlusOne(key); + if (!keyIndex) { + return 0; + } + return mForwardPairs[keyIndex - 1U].second; +} + +template +A UniqueIntegerMap::findKeyFor(const B value) const { + size_t valueIndex = findValueIndexPlusOne(value); + if (!valueIndex) { + return 0; + } + return mBackwardPairs[valueIndex - 1U].second; +} + +template +B UniqueIntegerMap::add(const A key) { + // Binary search to find the proper insertion point for the key. + // Also checks that the key isn't already in the set. + size_t min = 0; + size_t max = mForwardPairs.size(); + while (min < max) { + size_t mid = min + ((max - min) >> 1); + A midKey = mForwardPairs[mid].first; + if (midKey < key) { + min = mid + 1U; + } else if (midKey > key) { + max = mid; + } else { + // Already in the set. + return 0; + } + } + + // Generate new unique value + B value = allocValue(); + + ForwardPair* pair = mForwardPairs.emplace(min); + pair->first = key; + pair->second = value; + + // Binary search to find proper insertion point for the value. + min = 0; + max = mBackwardPairs.size(); + while (min < max) { + size_t mid = min + ((max - min) >> 1); + B midValue = mBackwardPairs[mid].first; + if (midValue < value) { + min = mid + 1U; + } else { + max = mid; + } + } + + BackwardPair* backPair = mBackwardPairs.emplace(min); + backPair->first = value; + backPair->second = key; + + return value; +} + +template +void UniqueIntegerMap::del(const A key) { + size_t keyIndex = findKeyIndexPlusOne(key); + if (!keyIndex) { + return; + } + B value = mForwardPairs[keyIndex - 1U].second; + size_t valueIndex = findValueIndexPlusOne(value); + mForwardPairs.remove(keyIndex - 1U); + mBackwardPairs.remove(valueIndex - 1U); + freeValue(value); +} + +template +size_t UniqueIntegerMap::findKeyIndexPlusOne(const A key) const { + // Binary search in forward pair array. + size_t min = 0; + size_t max = mForwardPairs.size(); + while (min < max) { + size_t mid = min + ((max - min) >> 1); + A midKey = mForwardPairs[mid].first; + if (midKey < key) { + min = mid + 1U; + } else if (midKey > key) { + max = mid; + } else { + return mid + 1U; + } + } + return 0U; +} + +template +size_t UniqueIntegerMap::findValueIndexPlusOne(const B value) const { + // Binary search in revere pair array. + size_t min = 0; + size_t max = mBackwardPairs.size(); + while (min < max) { + size_t mid = min + ((max - min) >> 1); + B midValue = mBackwardPairs[mid].first; + if (midValue < value) { + min = mid + 1U; + } else if (midValue > value) { + max = mid; + } else { + return mid + 1U; + } + } + return 0U; +} + +template +B UniqueIntegerMap::allocValue() { + if (!mFreeValues.empty()) { + B result = mFreeValues[0]; + mFreeValues.pop(); + return result; + } + return ++mLastValue; +} + +template +void UniqueIntegerMap::freeValue(B value) { + if (!value) { + return; + } + if (value == mLastValue) { + mLastValue--; + return; + } + mFreeValues.append(value); +} + +} // namespace emugl + +#endif // EMUGL_COMMON_INTEGER_MAP_H diff --git a/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map_unittest.cpp b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map_unittest.cpp new file mode 100644 index 0000000..8aee013 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/android-emugl/shared/emugl/common/unique_integer_map_unittest.cpp @@ -0,0 +1,103 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "emugl/common/unique_integer_map.h" + +#include + +#include + +namespace emugl { + +typedef UniqueIntegerMap MyMap; + +TEST(UniqueIntegerMap, Empty) { + MyMap map; + + EXPECT_TRUE(map.empty()); + EXPECT_EQ(0U, map.size()); + EXPECT_EQ(0U, map.find(0U)); + EXPECT_EQ(0U, map.find(1U)); + EXPECT_EQ(0U, map.find(2U)); + EXPECT_EQ(0U, map.find(4U)); +} + +TEST(UniqueIntegerMap, AddOne) { + MyMap map; + uintptr_t key1 = 1U; + uint32_t val1 = map.add(key1); + + EXPECT_NE(0U, val1); + EXPECT_EQ(val1, map.find(key1)); + EXPECT_EQ(key1, map.findKeyFor(val1)); + + EXPECT_FALSE(map.empty()); + EXPECT_EQ(1U, map.size()); + + EXPECT_EQ(0U, map.find(0)); + EXPECT_EQ(0U, map.findKeyFor(0)); + + EXPECT_EQ(0U, map.find(key1 + 1)); + EXPECT_EQ(0U, map.findKeyFor(val1 + 1)); +} + +TEST(UniqueIntegerMap, AddMultiple) { + MyMap map; + const size_t kCount = 100; + const size_t kKeyMultiplier = 3U; // must be >= 2. + uint32_t values[kCount]; + + for (size_t n = 0; n < kCount; ++n) { + uintptr_t key = 1U + n * kKeyMultiplier; + values[n] = map.add(key); + EXPECT_NE(0U, values[n]) << "key #" << n; + } + + EXPECT_EQ(kCount, map.size()); + + for (size_t n = 0; n < kCount; ++n) { + uintptr_t key = 1U + n * kKeyMultiplier; + EXPECT_EQ(values[n], map.find(key)) << "key #" << n; + EXPECT_EQ(0U, map.find(key + 1U)) << "key #" << n; + } + + for (size_t n = 0; n < kCount; ++n) { + uintptr_t key = 1U + n * kKeyMultiplier; + EXPECT_EQ(key, map.findKeyFor(values[n])); + } +} + +TEST(UniqueIntegerMap, Del) { + MyMap map; + const size_t kCount = 100; + const size_t kKeyMultiplier = 3U; // must be >= 2. + uint32_t values[kCount]; + + for (size_t n = 0; n < kCount; ++n) { + uintptr_t key = 1U + n * kKeyMultiplier; + values[n] = map.add(key); + } + + for (size_t n = 0; n < kCount; ++n) { + uintptr_t key = 1U + n * kKeyMultiplier; + map.del(key); + EXPECT_EQ(kCount - 1U - n, map.size()); + EXPECT_EQ(0U, map.find(key)); + EXPECT_EQ(0U, map.findKeyFor(values[n])); + } + + EXPECT_TRUE(map.empty()); +} + +} // namespace emugl diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/.gitignore b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/.gitignore new file mode 100644 index 0000000..70fb602 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/.gitignore @@ -0,0 +1,2 @@ +build*/ +*.pyc diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/.travis.yml b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/.travis.yml new file mode 100644 index 0000000..8d85b5a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/.travis.yml @@ -0,0 +1,25 @@ +language: cpp +compiler: + - gcc + - clang + +addons: + apt: + packages: + - valgrind + +install: + - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} + - CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz" + - mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake + - export PATH=${DEPS_DIR}/cmake/bin:${PATH} + - pip install --user conan && export PATH=$PATH:$HOME/.local/bin + - cd ${TRAVIS_BUILD_DIR} + - mkdir build && cd build + - cmake .. -DBACKWARD_TESTS=ON + - cmake --build . + +script: + - valgrind ctest .. --verbose + - cd ${TRAVIS_BUILD_DIR} && conan create . Manu343726/testing --build=outdated diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/BackwardConfig.cmake b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/BackwardConfig.cmake new file mode 100644 index 0000000..6cff86c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/BackwardConfig.cmake @@ -0,0 +1,202 @@ +# +# BackwardMacros.cmake +# Copyright 2013 Google Inc. All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +############################################################################### +# OPTIONS +############################################################################### + +set(STACK_WALKING_UNWIND TRUE CACHE BOOL + "Use compiler's unwind API") +set(STACK_WALKING_BACKTRACE FALSE CACHE BOOL + "Use backtrace from (e)glibc for stack walking") + +set(STACK_DETAILS_AUTO_DETECT TRUE CACHE BOOL + "Auto detect backward's stack details dependencies") + +set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE CACHE BOOL + "Use backtrace from (e)glibc for symbols resolution") +set(STACK_DETAILS_DW FALSE CACHE BOOL + "Use libdw to read debug info") +set(STACK_DETAILS_BFD FALSE CACHE BOOL + "Use libbfd to read debug info") +set(STACK_DETAILS_DWARF FALSE CACHE BOOL + "Use libdwarf/libelf to read debug info") + +set(BACKWARD_TESTS FALSE CACHE BOOL "Enable tests") + +############################################################################### +# CONFIGS +############################################################################### +if (${STACK_DETAILS_AUTO_DETECT}) + include(FindPackageHandleStandardArgs) + + # find libdw + find_path(LIBDW_INCLUDE_DIR NAMES "elfutils/libdw.h" "elfutils/libdwfl.h") + find_library(LIBDW_LIBRARY dw) + set(LIBDW_INCLUDE_DIRS ${LIBDW_INCLUDE_DIR} ) + set(LIBDW_LIBRARIES ${LIBDW_LIBRARY} ) + find_package_handle_standard_args(libdw DEFAULT_MSG + LIBDW_LIBRARY LIBDW_INCLUDE_DIR) + mark_as_advanced(LIBDW_INCLUDE_DIR LIBDW_LIBRARY) + + # find libbfd + find_path(LIBBFD_INCLUDE_DIR NAMES "bfd.h") + find_path(LIBDL_INCLUDE_DIR NAMES "dlfcn.h") + find_library(LIBBFD_LIBRARY bfd) + find_library(LIBDL_LIBRARY dl) + set(LIBBFD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR}) + set(LIBBFD_LIBRARIES ${LIBBFD_LIBRARY} ${LIBDL_LIBRARY}) + find_package_handle_standard_args(libbfd DEFAULT_MSG + LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR + LIBDL_LIBRARY LIBDL_INCLUDE_DIR) + mark_as_advanced(LIBBFD_INCLUDE_DIR LIBBFD_LIBRARY + LIBDL_INCLUDE_DIR LIBDL_LIBRARY) + + # find libdwarf + find_path(LIBDWARF_INCLUDE_DIR NAMES "libdwarf.h" PATH_SUFFIXES libdwarf) + find_path(LIBELF_INCLUDE_DIR NAMES "libelf.h") + find_path(LIBDL_INCLUDE_DIR NAMES "dlfcn.h") + find_library(LIBDWARF_LIBRARY dwarf) + find_library(LIBELF_LIBRARY elf) + find_library(LIBDL_LIBRARY dl) + set(LIBDWARF_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIR} ${LIBELF_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR}) + set(LIBDWARF_LIBRARIES ${LIBDWARF_LIBRARY} ${LIBELF_LIBRARY} ${LIBDL_LIBRARY}) + find_package_handle_standard_args(libdwarf DEFAULT_MSG + LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR + LIBELF_LIBRARY LIBELF_INCLUDE_DIR + LIBDL_LIBRARY LIBDL_INCLUDE_DIR) + mark_as_advanced(LIBDWARF_INCLUDE_DIR LIBDWARF_LIBRARY + LIBELF_INCLUDE_DIR LIBELF_LIBRARY + LIBDL_INCLUDE_DIR LIBDL_LIBRARY) + + if (LIBDW_FOUND) + LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDW_INCLUDE_DIRS}) + LIST(APPEND _BACKWARD_LIBRARIES ${LIBDW_LIBRARIES}) + set(STACK_DETAILS_DW TRUE) + set(STACK_DETAILS_BFD FALSE) + set(STACK_DETAILS_DWARF FALSE) + set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE) + elseif(LIBBFD_FOUND) + LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIRS}) + LIST(APPEND _BACKWARD_LIBRARIES ${LIBBFD_LIBRARIES}) + + # If we attempt to link against static bfd, make sure to link its dependencies, too + get_filename_component(bfd_lib_ext "${LIBBFD_LIBRARY}" EXT) + if (bfd_lib_ext STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}") + list(APPEND _BACKWARD_LIBRARIES iberty z) + endif() + + set(STACK_DETAILS_DW FALSE) + set(STACK_DETAILS_BFD TRUE) + set(STACK_DETAILS_DWARF FALSE) + set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE) + elseif(LIBDWARF_FOUND) + LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIRS}) + LIST(APPEND BACKWARD_LIBRARIES ${LIBDWARF_LIBRARIES}) + + set(STACK_DETAILS_DW FALSE) + set(STACK_DETAILS_BFD FALSE) + set(STACK_DETAILS_DWARF TRUE) + set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE) + else() + set(STACK_DETAILS_DW FALSE) + set(STACK_DETAILS_BFD FALSE) + set(STACK_DETAILS_DWARF FALSE) + set(STACK_DETAILS_BACKTRACE_SYMBOL TRUE) + endif() +else() + if (STACK_DETAILS_DW) + LIST(APPEND _BACKWARD_LIBRARIES dw) + endif() + + if (STACK_DETAILS_BFD) + LIST(APPEND _BACKWARD_LIBRARIES bfd dl) + endif() + + if (STACK_DETAILS_DWARF) + LIST(APPEND _BACKWARD_LIBRARIES dwarf elf) + endif() +endif() + +macro(map_definitions var_prefix define_prefix) + foreach(def ${ARGN}) + if (${${var_prefix}${def}}) + LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=1") + else() + LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=0") + endif() + endforeach() +endmacro() + +if (NOT _BACKWARD_DEFINITIONS) + map_definitions("STACK_WALKING_" "BACKWARD_HAS_" UNWIND BACKTRACE) + map_definitions("STACK_DETAILS_" "BACKWARD_HAS_" BACKTRACE_SYMBOL DW BFD DWARF) +endif() + +set(BACKWARD_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}") + +set(BACKWARD_HAS_EXTERNAL_LIBRARIES FALSE) +set(FIND_PACKAGE_REQUIRED_VARS BACKWARD_INCLUDE_DIR) +if(DEFINED _BACKWARD_LIBRARIES) + set(BACKWARD_HAS_EXTERNAL_LIBRARIES TRUE) + list(APPEND FIND_PACKAGE_REQUIRED_VARS _BACKWARD_LIBRARIES) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Backward + REQUIRED_VARS ${FIND_PACKAGE_REQUIRED_VARS} +) +list(APPEND _BACKWARD_INCLUDE_DIRS ${BACKWARD_INCLUDE_DIR}) + +macro(add_backward target) + target_include_directories(${target} PRIVATE ${BACKWARD_INCLUDE_DIRS}) + set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS ${BACKWARD_DEFINITIONS}) + set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES ${BACKWARD_LIBRARIES}) +endmacro() + +set(BACKWARD_INCLUDE_DIRS ${_BACKWARD_INCLUDE_DIRS} CACHE INTERNAL "_BACKWARD_INCLUDE_DIRS") +set(BACKWARD_DEFINITIONS ${_BACKWARD_DEFINITIONS} CACHE INTERNAL "BACKWARD_DEFINITIONS") +set(BACKWARD_LIBRARIES ${_BACKWARD_LIBRARIES} CACHE INTERNAL "BACKWARD_LIBRARIES") +mark_as_advanced(BACKWARD_INCLUDE_DIRS BACKWARD_DEFINITIONS BACKWARD_LIBRARIES) + +# Expand each definition in BACKWARD_DEFINITIONS to its own cmake var and export +# to outer scope +foreach(var ${BACKWARD_DEFINITIONS}) + string(REPLACE "=" ";" var_as_list ${var}) + list(GET var_as_list 0 var_name) + list(GET var_as_list 1 var_value) + set(${var_name} ${var_value}) + mark_as_advanced(${var_name}) +endforeach() + +if (NOT TARGET Backward::Backward) + add_library(Backward::Backward INTERFACE IMPORTED) + set_target_properties(Backward::Backward PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${BACKWARD_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${BACKWARD_DEFINITIONS}" + ) + if(BACKWARD_HAS_EXTERNAL_LIBRARIES) + set_target_properties(Backward::Backward PROPERTIES + INTERFACE_LINK_LIBRARIES "${BACKWARD_LIBRARIES}" + ) + endif() +endif() diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/CMakeLists.txt new file mode 100644 index 0000000..49ab3fd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/CMakeLists.txt @@ -0,0 +1,130 @@ +# +# CMakeLists.txt +# Copyright 2013 Google Inc. All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +cmake_minimum_required(VERSION 2.8.12) +project(backward CXX) + +include(BackwardConfig.cmake) + +# check if compiler is nvcc or nvcc_wrapper +set(COMPILER_IS_NVCC false) +get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME) +if (COMPILER_NAME MATCHES "^nvcc") + set(COMPILER_IS_NVCC true) +endif() + +# set CXX standard +set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_CXX_STANDARD 11) +if (${COMPILER_IS_NVCC}) + # GNU CXX extensions are not supported by nvcc + set(CMAKE_CXX_EXTENSIONS OFF) +endif() + +############################################################################### +# COMPILER FLAGS +############################################################################### + +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") + if (NOT ${COMPILER_IS_NVCC}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +endif() + +# Anbox: allow old-style cast, unknown pragmas +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=old-style-cast -Wno-error=unknown-pragmas -Wno-error=switch-default") + +############################################################################### +# BACKWARD OBJECT +############################################################################### + +add_library(backward_object OBJECT backward.cpp) +target_compile_definitions(backward_object PRIVATE ${BACKWARD_DEFINITIONS}) +target_include_directories(backward_object PRIVATE ${BACKWARD_INCLUDE_DIRS}) +set(BACKWARD_ENABLE $ CACHE STRING + "Link with this object to setup backward automatically") + + +############################################################################### +# BACKWARD LIBRARY (Includes backward.cpp) +############################################################################### +option(BACKWARD_SHARED "Build dynamic backward-cpp shared lib" OFF) + +if(BACKWARD_SHARED) + set(libtype SHARED) +endif() +add_library(backward ${libtype} backward.cpp) +target_compile_definitions(backward PUBLIC ${BACKWARD_DEFINITIONS}) +target_include_directories(backward PUBLIC ${BACKWARD_INCLUDE_DIRS}) + +############################################################################### +# TESTS +############################################################################### + +if(BACKWARD_TESTS) + enable_testing() + + add_library(test_main SHARED test/_test_main.cpp) + + macro(backward_add_test src) + get_filename_component(name ${src} NAME_WE) + set(test_name "test_${name}") + + add_executable(${test_name} ${src} ${ARGN}) + + target_link_libraries(${test_name} PRIVATE Backward::Backward test_main) + + add_test(NAME ${name} COMMAND ${test_name}) + endmacro() + + # Tests without backward.cpp + set(TESTS + test + stacktrace + rectrace + select_signals + ) + + foreach(test ${TESTS}) + backward_add_test(test/${test}.cpp) + endforeach() + + # Tests with backward.cpp + set(TESTS + suicide + ) + + foreach(test ${TESTS}) + backward_add_test(test/${test}.cpp ${BACKWARD_ENABLE}) + endforeach() +endif() + +install( + FILES "backward.hpp" + DESTINATION ${CMAKE_INSTALL_PREFIX}/include +) +install( + FILES "BackwardConfig.cmake" + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/backward +) diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/LICENSE.txt b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/LICENSE.txt new file mode 100644 index 0000000..269e8ab --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/LICENSE.txt @@ -0,0 +1,21 @@ +Copyright 2013 Google Inc. All Rights Reserved. + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/README.md b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/README.md new file mode 100644 index 0000000..0eaab31 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/README.md @@ -0,0 +1,411 @@ +Backward-cpp [![badge](https://img.shields.io/badge/conan.io-backward%2F1.3.0-green.svg?logo=data:image/png;base64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAMAAAAolt3jAAAA1VBMVEUAAABhlctjlstkl8tlmMtlmMxlmcxmmcxnmsxpnMxpnM1qnc1sn85voM91oM11oc1xotB2oc56pNF6pNJ2ptJ8ptJ8ptN9ptN8p9N5qNJ9p9N9p9R8qtOBqdSAqtOAqtR%2BrNSCrNJ/rdWDrNWCsNWCsNaJs9eLs9iRvNuVvdyVv9yXwd2Zwt6axN6dxt%2Bfx%2BChyeGiyuGjyuCjyuGly%2BGlzOKmzOGozuKoz%2BKqz%2BOq0OOv1OWw1OWw1eWx1eWy1uay1%2Baz1%2Baz1%2Bez2Oe02Oe12ee22ujUGwH3AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgBQkREyOxFIh/AAAAiklEQVQI12NgAAMbOwY4sLZ2NtQ1coVKWNvoc/Eq8XDr2wB5Ig62ekza9vaOqpK2TpoMzOxaFtwqZua2Bm4makIM7OzMAjoaCqYuxooSUqJALjs7o4yVpbowvzSUy87KqSwmxQfnsrPISyFzWeWAXCkpMaBVIC4bmCsOdgiUKwh3JojLgAQ4ZCE0AMm2D29tZwe6AAAAAElFTkSuQmCC)](http://www.conan.io/source/backward/1.3.0/Manu343726/testing) [![Build Status](https://travis-ci.org/bombela/backward-cpp.svg?branch=master)](https://travis-ci.org/bombela/backward-cpp) +============ + +Backward is a beautiful stack trace pretty printer for C++. + +If you are bored to see this: + +![default trace](doc/rude.png) + +Backward will spice it up for you: + +![pretty stackstrace](doc/pretty.png) + +There is not much to say. Of course it will be able to display the code +snippets only if the source files are accessible (else see trace #4 in the +example). + +All "Source" lines and code snippet prefixed by a pipe "|" are frames inline +the next frame. +You can see that for the trace #1 in the example, the function +`you_shall_not_pass()` was inlined in the function `...read2::do_test()` by the +compiler. + +## Installation + +#### Install backward.hpp + +Backward is a header only library. So installing Backward is easy, simply drop +a copy of `backward.hpp` along with your other source files in your C++ project. +You can also use a git submodule or really any other way that best fits your +environment, as long as you can include `backward.hpp`. + +#### Install backward.cpp + +If you want Backward to automatically print a stack trace on most common fatal +errors (segfault, abort, un-handled exception...), simply add a copy of +`backward.cpp` to your project, and don't forget to tell your build system. + +The code in `backward.cpp` is trivial anyway, you can simply copy what it's +doing at your convenience. + +## Configuration & Dependencies + +### Integration with CMake + +If you are using CMake and want to use its configuration abilities to save +you the trouble, you can easily integrate Backward, depending on how you obtained +the library. + +#### As a subdirectory: + +In this case you have a subdirectory containing the whole repository of Backward +(eg.: using git-submodules), in this case you can do: + +``` +add_subdirectory(/path/to/backward-cpp) + +# This will add backward.cpp to your target +add_executable(mytarget mysource.cpp ${BACKWARD_ENABLE}) + +# This will add libraries, definitions and include directories needed by backward +# by setting each property on the target. +add_backward(mytarget) +``` + +#### Modifying CMAKE_MODULE_PATH + +In this case you can have Backward installed as a subdirectory: + +``` +list(APPEND CMAKE_MODULE_PATH /path/to/backward-cpp) +find_package(Backward) + +# This will add libraries, definitions and include directories needed by backward +# through an IMPORTED target. +target_link_libraries(mytarget PUBLIC Backward::Backward) +``` + +Notice that this is equivalent to using the the approach that uses `add_subdirectory()`, +however it uses cmake's [imported target](https://cmake.org/Wiki/CMake/Tutorials/Exporting_and_Importing_Targets) mechanism. + +#### Installation through a regular package manager + +In this case you have obtained Backward through a package manager. + +Packages currently available: +- [conda-forge](https://anaconda.org/conda-forge/backward-cpp) + +``` +find_package(Backward) + +# This will add libraries, definitions and include directories needed by backward +# through an IMPORTED target. +target_link_libraries(mytarget PUBLIC Backward::Backward) +``` + +### Compile with debug info + +You need to compile your project with generation of debug symbols enabled, +usually `-g` with clang++ and g++. + +Note that you can use `-g` with any level of optimization, with modern debug +information encoding like DWARF, it only takes space in the binary (it's not +loaded in memory until your debugger or Backward makes use of it, don't worry), +and it doesn't impact the code generation (at least on GNU/Linux x86\_64 for +what I know). + +If you are missing debug information, the stack trace will lack details about +your sources. + +### Libraries to read the debug info + +Backward support pretty printed stack traces on GNU/Linux only, it will compile +fine under other platforms but will not do anything. **Pull requests are +welcome :)** + +Also, by default you will get a really basic stack trace, based on the +`backtrace_symbols` API: + +![default trace](doc/nice.png) + +You will need to install some dependencies to get the ultimate stack trace. Two +libraries are currently supported, the only difference is which one is the +easiest for you to install, so pick your poison: + +#### libbfd from the [GNU/binutils](http://www.gnu.org/software/binutils/) + + apt-get install binutils-dev (or equivalent) + +And do not forget to link with the lib: `g++/clang++ -lbfd -ldl ...` + +This library requires dynamic loading. Which is provided by the library `dl`. +Hence why we also link with `-ldl`. + +Then define the following before every inclusion of `backward.hpp` (don't +forget to update `backward.cpp` as well): + + #define BACKWARD_HAS_BFD 1 + +#### libdw from the [elfutils](https://fedorahosted.org/elfutils/) + + apt-get install libdw-dev (or equivalent) + +And do not forget to link with the lib and inform Backward to use it: + + #define BACKWARD_HAS_DW 1 + +Of course you can simply add the define (`-DBACKWARD_HAS_...=1`) and the +linkage details in your build system and even auto-detect which library is +installed, it's up to you. + +#### [libdwarf](https://sourceforge.net/projects/libdwarf/) and [libelf](http://www.mr511.de/software/english.html) + + apt-get install libdwarf-dev (or equivalent) + +And do not forget to link with the lib and inform Backward to use it: + + #define BACKWARD_HAS_DWARF 1 + +There are several alternative implementations of libdwarf and libelf that +are API compatible so it's possible, although it hasn't been tested, to +replace the ones used when developing backward (in bold, below): + +* **_libelf_** by [Michael "Tired" Riepe](http://www.mr511.de/software/english.html) +* **_libdwarf_** by [David Anderson](https://www.prevanders.net/dwarf.html) +* libelf from [elfutils](https://fedorahosted.org/elfutils/) +* libelf and libdwarf from FreeBSD's [ELF Tool Chain](https://sourceforge.net/p/elftoolchain/wiki/Home/) project + + +Of course you can simply add the define (`-DBACKWARD_HAS_...=1`) and the +linkage details in your build system and even auto-detect which library is +installed, it's up to you. + +That's it, you are all set, you should be getting nice stack traces like the +one at the beginning of this document. + +## API + +If you don't want to limit yourself to the defaults offered by `backward.cpp`, +and you want to take some random stack traces for whatever reason and pretty +print them the way you love or you decide to send them all to your buddies over +the Internet, you will appreciate the simplicity of Backward's API. + +### Stacktrace + +The StackTrace class lets you take a "snapshot" of the current stack. +You can use it like this: + +```c++ +using namespace backward; +StackTrace st; st.load_here(32); +Printer p; p.print(st); +``` + +The public methods are: + +```c++ +class StackTrace { public: + // Take a snapshot of the current stack, with at most "trace_cnt_max" + // traces in it. The first trace is the most recent (ie the current + // frame). You can also provide a trace address to load_from() assuming + // the address is a valid stack frame (useful for signal handling traces). + // Both function return size(). + size_t load_here(size_t trace_cnt_max) + size_t load_from(void* address, size_t trace_cnt_max) + + // The number of traces loaded. This can be less than "trace_cnt_max". + size_t size() const + + // A unique id for the thread in which the trace was taken. The value + // 0 means the stack trace comes from the main thread. + size_t thread_id() const + + // Retrieve a trace by index. 0 is the most recent trace, size()-1 is + // the oldest one. + Trace operator[](size_t trace_idx) +}; +``` + +### TraceResolver + +The `TraceResolver` does the heavy lifting, and intends to transform a simple +`Trace` from its address into a fully detailed `ResolvedTrace` with the +filename of the source, line numbers, inlined functions and so on. + +You can use it like this: + +```c++ +using namespace backward; +StackTrace st; st.load_here(32); + +TraceResolver tr; tr.load_stacktrace(st); +for (size_t i = 0; i < st.size(); ++i) { + ResolvedTrace trace = tr.resolve(st[i]); + std::cout << "#" << i + << " " << trace.object_filename + << " " << trace.object_function + << " [" << trace.addr << "]" + << std::endl; +} +``` + +The public methods are: + +```c++ +class TraceResolver { public: + // Pre-load whatever is necessary from the stack trace. + template + void load_stacktrace(ST&) + + // Resolve a trace. It takes a ResolvedTrace, because a `Trace` is + // implicitly convertible to it. + ResolvedTrace resolve(ResolvedTrace t) +}; +``` + +### SnippetFactory + +The SnippetFactory is a simple helper class to automatically load and cache +source files in order to extract code snippets. + +```c++ +class SnippetFactory { public: + // A snippet is a list of line numbers and line contents. + typedef std::vector > lines_t; + + // Return a snippet starting at line_start with up to context_size lines. + lines_t get_snippet(const std::string& filename, + size_t line_start, size_t context_size) + + // Return a combined snippet from two different locations and combine them. + // context_size / 2 lines will be extracted from each location. + lines_t get_combined_snippet( + const std::string& filename_a, size_t line_a, + const std::string& filename_b, size_t line_b, + size_t context_size) + + // Tries to return a unified snippet if the two locations from the same + // file are close enough to fit inside one context_size, else returns + // the equivalent of get_combined_snippet(). + lines_t get_coalesced_snippet(const std::string& filename, + size_t line_a, size_t line_b, size_t context_size) +``` + +### Printer + +A simpler way to pretty print a stack trace to the terminal. It will +automatically resolve the traces for you: + +```c++ +using namespace backward; +StackTrace st; st.load_here(32); +Printer p; +p.object = true; +p.color_mode = ColorMode::always; +p.address = true; +p.print(st, stderr); +``` + +You can set a few options: + +```c++ +class Printer { public: + // Print a little snippet of code if possible. + bool snippet = true; + + // Colorize the trace + // - ColorMode::automatic: Activate colors if possible. For example, when using a TTY on linux. + // - ColorMode::always: Always use colors. + // - ColorMode::never: Never use colors. + bool color_mode = ColorMode::automatic; + + // Add the addresses of every source location to the trace. + bool address = false; + + // Even if there is a source location, also prints the object + // from where the trace came from. + bool object = false; + + // Resolve and print a stack trace to the given C FILE* object. + // On linux, if the FILE* object is attached to a TTY, + // color will be used if color_mode is set to automatic. + template + FILE* print(StackTrace& st, FILE* fp = stderr); + + // Resolve and print a stack trace to the given std::ostream object. + // Color will only be used if color_mode is set to always. + template + std::ostream& print(ST& st, std::ostream& os); +``` + + +### SignalHandling + +A simple helper class that registers for you the most common signals and other +callbacks to segfault, hardware exception, un-handled exception etc. + +`backward.cpp` simply uses it like that: + +```c++ +backward::SignalHandling sh; +``` + +Creating the object registers all the different signals and hooks. Destroying +this object doesn't do anything. It exposes only one method: + +```c++ +bool loaded() const // true if loaded with success +``` + +### Trace object + +To keep the memory footprint of a loaded `StackTrace` on the low-side, there a +hierarchy of trace object, from a minimal `Trace `to a `ResolvedTrace`. + +#### Simple trace + +```c++ +struct Trace { + void* addr; // address of the trace + size_t idx; // its index (0 == most recent) +}; +``` + +#### Resolved trace + +A `ResolvedTrace` should contains a maximum of details about the location of +the trace in the source code. Note that not all fields might be set. + +```c++ +struct ResolvedTrace: public Trace { + + struct SourceLoc { + std::string function; + std::string filename; + size_t line; + size_t col; + }; + + // In which binary object this trace is located. + std::string object_filename; + + // The function in the object that contains the trace. This is not the same + // as source.function which can be an function inlined in object_function. + std::string object_function; + + // The source location of this trace. It is possible for filename to be + // empty and for line/col to be invalid (value 0) if this information + // couldn't be deduced, for example if there is no debug information in the + // binary object. + SourceLoc source; + + // An optional list of "inliners". All of these sources locations where + // inlined in the source location of the trace (the attribute right above). + // This is especially useful when you compile with optimizations turned on. + typedef std::vector source_locs_t; + source_locs_t inliners; +}; +``` + +## Contact and copyright + +François-Xavier Bourlet + +Copyright 2013-2017 Google Inc. All Rights Reserved. +MIT License. + +### Disclaimer + +Although this project is owned by Google Inc. this is not a Google supported or +affiliated project. diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.cpp new file mode 100644 index 0000000..4c68284 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.cpp @@ -0,0 +1,32 @@ +// Pick your poison. +// +// On GNU/Linux, you have few choices to get the most out of your stack trace. +// +// By default you get: +// - object filename +// - function name +// +// In order to add: +// - source filename +// - line and column numbers +// - source code snippet (assuming the file is accessible) + +// Install one of the following library then uncomment one of the macro (or +// better, add the detection of the lib and the macro definition in your build +// system) + +// - apt-get install libdw-dev ... +// - g++/clang++ -ldw ... +// #define BACKWARD_HAS_DW 1 + +// - apt-get install binutils-dev ... +// - g++/clang++ -lbfd ... +// #define BACKWARD_HAS_BFD 1 + +#include "backward.hpp" + +namespace backward { + +backward::SignalHandling sh; + +} // namespace backward diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.hpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.hpp new file mode 100644 index 0000000..c9a922f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/backward.hpp @@ -0,0 +1,3796 @@ +/* + * backward.hpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef H_6B9572DA_A64B_49E6_B234_051480991C89 +#define H_6B9572DA_A64B_49E6_B234_051480991C89 + +#ifndef __cplusplus +# error "It's not going to compile without a C++ compiler..." +#endif + +#if defined(BACKWARD_CXX11) +#elif defined(BACKWARD_CXX98) +#else +# if __cplusplus >= 201103L +# define BACKWARD_CXX11 +# define BACKWARD_ATLEAST_CXX11 +# define BACKWARD_ATLEAST_CXX98 +# else +# define BACKWARD_CXX98 +# define BACKWARD_ATLEAST_CXX98 +# endif +#endif + +// You can define one of the following (or leave it to the auto-detection): +// +// #define BACKWARD_SYSTEM_LINUX +// - specialization for linux +// +// #define BACKWARD_SYSTEM_DARWIN +// - specialization for Mac OS X 10.5 and later. +// +// #define BACKWARD_SYSTEM_UNKNOWN +// - placebo implementation, does nothing. +// +#if defined(BACKWARD_SYSTEM_LINUX) +#elif defined(BACKWARD_SYSTEM_DARWIN) +#elif defined(BACKWARD_SYSTEM_UNKNOWN) +#else +# if defined(__linux) || defined(__linux__) +# define BACKWARD_SYSTEM_LINUX +# elif defined(__APPLE__) +# define BACKWARD_SYSTEM_DARWIN +# else +# define BACKWARD_SYSTEM_UNKNOWN +# endif +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(BACKWARD_SYSTEM_LINUX) + +// On linux, backtrace can back-trace or "walk" the stack using the following +// libraries: +// +// #define BACKWARD_HAS_UNWIND 1 +// - unwind comes from libgcc, but I saw an equivalent inside clang itself. +// - with unwind, the stacktrace is as accurate as it can possibly be, since +// this is used by the C++ runtine in gcc/clang for stack unwinding on +// exception. +// - normally libgcc is already linked to your program by default. +// +// #define BACKWARD_HAS_BACKTRACE == 1 +// - backtrace seems to be a little bit more portable than libunwind, but on +// linux, it uses unwind anyway, but abstract away a tiny information that is +// sadly really important in order to get perfectly accurate stack traces. +// - backtrace is part of the (e)glib library. +// +// The default is: +// #define BACKWARD_HAS_UNWIND == 1 +// +// Note that only one of the define should be set to 1 at a time. +// +# if BACKWARD_HAS_UNWIND == 1 +# elif BACKWARD_HAS_BACKTRACE == 1 +# else +# undef BACKWARD_HAS_UNWIND +# define BACKWARD_HAS_UNWIND 1 +# undef BACKWARD_HAS_BACKTRACE +# define BACKWARD_HAS_BACKTRACE 0 +# endif + +// On linux, backward can extract detailed information about a stack trace +// using one of the following libraries: +// +// #define BACKWARD_HAS_DW 1 +// - libdw gives you the most juicy details out of your stack traces: +// - object filename +// - function name +// - source filename +// - line and column numbers +// - source code snippet (assuming the file is accessible) +// - variables name and values (if not optimized out) +// - You need to link with the lib "dw": +// - apt-get install libdw-dev +// - g++/clang++ -ldw ... +// +// #define BACKWARD_HAS_BFD 1 +// - With libbfd, you get a fair amount of details: +// - object filename +// - function name +// - source filename +// - line numbers +// - source code snippet (assuming the file is accessible) +// - You need to link with the lib "bfd": +// - apt-get install binutils-dev +// - g++/clang++ -lbfd ... +// +// #define BACKWARD_HAS_DWARF 1 +// - libdwarf gives you the most juicy details out of your stack traces: +// - object filename +// - function name +// - source filename +// - line and column numbers +// - source code snippet (assuming the file is accessible) +// - variables name and values (if not optimized out) +// - You need to link with the lib "dwarf": +// - apt-get install libdwarf-dev +// - g++/clang++ -ldwarf ... +// +// #define BACKWARD_HAS_BACKTRACE_SYMBOL 1 +// - backtrace provides minimal details for a stack trace: +// - object filename +// - function name +// - backtrace is part of the (e)glib library. +// +// The default is: +// #define BACKWARD_HAS_BACKTRACE_SYMBOL == 1 +// +// Note that only one of the define should be set to 1 at a time. +// +# if BACKWARD_HAS_DW == 1 +# elif BACKWARD_HAS_BFD == 1 +# elif BACKWARD_HAS_DWARF == 1 +# elif BACKWARD_HAS_BACKTRACE_SYMBOL == 1 +# else +# undef BACKWARD_HAS_DW +# define BACKWARD_HAS_DW 0 +# undef BACKWARD_HAS_BFD +# define BACKWARD_HAS_BFD 0 +# undef BACKWARD_HAS_DWARF +# define BACKWARD_HAS_DWARF 0 +# undef BACKWARD_HAS_BACKTRACE_SYMBOL +# define BACKWARD_HAS_BACKTRACE_SYMBOL 1 +# endif + +# include +# include +# ifdef __ANDROID__ +// Old Android API levels define _Unwind_Ptr in both link.h and unwind.h +// Rename the one in link.h as we are not going to be using it +# define _Unwind_Ptr _Unwind_Ptr_Custom +# include +# undef _Unwind_Ptr +# else +# include +# endif +# include +# include +# include +# include + +# if BACKWARD_HAS_BFD == 1 +// NOTE: defining PACKAGE{,_VERSION} is required before including +// bfd.h on some platforms, see also: +// https://sourceware.org/bugzilla/show_bug.cgi?id=14243 +# ifndef PACKAGE +# define PACKAGE +# endif +# ifndef PACKAGE_VERSION +# define PACKAGE_VERSION +# endif +# include +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# include +# undef _GNU_SOURCE +# else +# include +# endif +# endif + +# if BACKWARD_HAS_DW == 1 +# include +# include +# include +# endif + +# if BACKWARD_HAS_DWARF == 1 +# include +# include +# include +# include +# include +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# include +# undef _GNU_SOURCE +# else +# include +# endif +# endif + +# if (BACKWARD_HAS_BACKTRACE == 1) || (BACKWARD_HAS_BACKTRACE_SYMBOL == 1) + // then we shall rely on backtrace +# include +# endif + +#endif // defined(BACKWARD_SYSTEM_LINUX) + +#if defined(BACKWARD_SYSTEM_DARWIN) +// On Darwin, backtrace can back-trace or "walk" the stack using the following +// libraries: +// +// #define BACKWARD_HAS_UNWIND 1 +// - unwind comes from libgcc, but I saw an equivalent inside clang itself. +// - with unwind, the stacktrace is as accurate as it can possibly be, since +// this is used by the C++ runtine in gcc/clang for stack unwinding on +// exception. +// - normally libgcc is already linked to your program by default. +// +// #define BACKWARD_HAS_BACKTRACE == 1 +// - backtrace is available by default, though it does not produce as much information +// as another library might. +// +// The default is: +// #define BACKWARD_HAS_UNWIND == 1 +// +// Note that only one of the define should be set to 1 at a time. +// +# if BACKWARD_HAS_UNWIND == 1 +# elif BACKWARD_HAS_BACKTRACE == 1 +# else +# undef BACKWARD_HAS_UNWIND +# define BACKWARD_HAS_UNWIND 1 +# undef BACKWARD_HAS_BACKTRACE +# define BACKWARD_HAS_BACKTRACE 0 +# endif + +// On Darwin, backward can extract detailed information about a stack trace +// using one of the following libraries: +// +// #define BACKWARD_HAS_BACKTRACE_SYMBOL 1 +// - backtrace provides minimal details for a stack trace: +// - object filename +// - function name +// +// The default is: +// #define BACKWARD_HAS_BACKTRACE_SYMBOL == 1 +// +# if BACKWARD_HAS_BACKTRACE_SYMBOL == 1 +# else +# undef BACKWARD_HAS_BACKTRACE_SYMBOL +# define BACKWARD_HAS_BACKTRACE_SYMBOL 1 +# endif + +# include +# include +# include +# include +# include +# include + +# if (BACKWARD_HAS_BACKTRACE == 1) || (BACKWARD_HAS_BACKTRACE_SYMBOL == 1) +# include +# endif +#endif // defined(BACKWARD_SYSTEM_DARWIN) + +#if BACKWARD_HAS_UNWIND == 1 + +# include +// while gcc's unwind.h defines something like that: +// extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *); +// extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *); +// +// clang's unwind.h defines something like this: +// uintptr_t _Unwind_GetIP(struct _Unwind_Context* __context); +// +// Even if the _Unwind_GetIPInfo can be linked to, it is not declared, worse we +// cannot just redeclare it because clang's unwind.h doesn't define _Unwind_Ptr +// anyway. +// +// Luckily we can play on the fact that the guard macros have a different name: +#ifdef __CLANG_UNWIND_H +// In fact, this function still comes from libgcc (on my different linux boxes, +// clang links against libgcc). +# include +extern "C" uintptr_t _Unwind_GetIPInfo(_Unwind_Context*, int*); +#endif + +#endif // BACKWARD_HAS_UNWIND == 1 + +#ifdef BACKWARD_ATLEAST_CXX11 +# include +# include // for std::swap + namespace backward { + namespace details { + template + struct hashtable { + typedef std::unordered_map type; + }; + using std::move; + } // namespace details + } // namespace backward +#else // NOT BACKWARD_ATLEAST_CXX11 +# define nullptr NULL +# define override +# include + namespace backward { + namespace details { + template + struct hashtable { + typedef std::map type; + }; + template + const T& move(const T& v) { return v; } + template + T& move(T& v) { return v; } + } // namespace details + } // namespace backward +#endif // BACKWARD_ATLEAST_CXX11 + +namespace backward { + +namespace system_tag { + struct linux_tag; // seems that I cannot call that "linux" because the name + // is already defined... so I am adding _tag everywhere. + struct darwin_tag; + struct unknown_tag; + +#if defined(BACKWARD_SYSTEM_LINUX) + typedef linux_tag current_tag; +#elif defined(BACKWARD_SYSTEM_DARWIN) + typedef darwin_tag current_tag; +#elif defined(BACKWARD_SYSTEM_UNKNOWN) + typedef unknown_tag current_tag; +#else +# error "May I please get my system defines?" +#endif +} // namespace system_tag + + +namespace trace_resolver_tag { +#if defined(BACKWARD_SYSTEM_LINUX) + struct libdw; + struct libbfd; + struct libdwarf; + struct backtrace_symbol; + +# if BACKWARD_HAS_DW == 1 + typedef libdw current; +# elif BACKWARD_HAS_BFD == 1 + typedef libbfd current; +# elif BACKWARD_HAS_DWARF == 1 + typedef libdwarf current; +# elif BACKWARD_HAS_BACKTRACE_SYMBOL == 1 + typedef backtrace_symbol current; +# else +# error "You shall not pass, until you know what you want." +# endif +#elif defined(BACKWARD_SYSTEM_DARWIN) + struct backtrace_symbol; + +# if BACKWARD_HAS_BACKTRACE_SYMBOL == 1 + typedef backtrace_symbol current; +# else +# error "You shall not pass, until you know what you want." +# endif +#endif +} // namespace trace_resolver_tag + + +namespace details { + +template + struct rm_ptr { typedef T type; }; + +template + struct rm_ptr { typedef T type; }; + +template + struct rm_ptr { typedef const T type; }; + +template +struct deleter { + template + void operator()(U& ptr) const { + (*F)(ptr); + } +}; + +template +struct default_delete { + void operator()(T& ptr) const { + delete ptr; + } +}; + +template > +class handle { + struct dummy; + T _val; + bool _empty; + +#ifdef BACKWARD_ATLEAST_CXX11 + handle(const handle&) = delete; + handle& operator=(const handle&) = delete; +#endif + +public: + ~handle() { + if (!_empty) { + Deleter()(_val); + } + } + + explicit handle(): _val(), _empty(true) {} + explicit handle(T val): _val(val), _empty(false) { if(!_val) _empty = true; } + +#ifdef BACKWARD_ATLEAST_CXX11 + handle(handle&& from): _empty(true) { + swap(from); + } + handle& operator=(handle&& from) { + swap(from); return *this; + } +#else + explicit handle(const handle& from): _empty(true) { + // some sort of poor man's move semantic. + swap(const_cast(from)); + } + handle& operator=(const handle& from) { + // some sort of poor man's move semantic. + swap(const_cast(from)); return *this; + } +#endif + + void reset(T new_val) { + handle tmp(new_val); + swap(tmp); + } + operator const dummy*() const { + if (_empty) { + return nullptr; + } + return reinterpret_cast(_val); + } + T get() { + return _val; + } + T release() { + _empty = true; + return _val; + } + void swap(handle& b) { + using std::swap; + swap(b._val, _val); // can throw, we are safe here. + swap(b._empty, _empty); // should not throw: if you cannot swap two + // bools without throwing... It's a lost cause anyway! + } + + T operator->() { return _val; } + const T operator->() const { return _val; } + + typedef typename rm_ptr::type& ref_t; + typedef const typename rm_ptr::type& const_ref_t; + ref_t operator*() { return *_val; } + const_ref_t operator*() const { return *_val; } + ref_t operator[](size_t idx) { return _val[idx]; } + + // Watch out, we've got a badass over here + T* operator&() { + _empty = false; + return &_val; + } +}; + +// Default demangler implementation (do nothing). +template +struct demangler_impl { + static std::string demangle(const char* funcname) { + return funcname; + } +}; + +#if defined(BACKWARD_SYSTEM_LINUX) || defined(BACKWARD_SYSTEM_DARWIN) + +template <> +struct demangler_impl { + demangler_impl(): _demangle_buffer_length(0) {} + + std::string demangle(const char* funcname) { + using namespace details; + char* result = abi::__cxa_demangle(funcname, + _demangle_buffer.release(), &_demangle_buffer_length, nullptr); + if(result) { + _demangle_buffer.reset(result); + return result; + } + return funcname; + } + +private: + details::handle _demangle_buffer; + size_t _demangle_buffer_length; +}; + +#endif // BACKWARD_SYSTEM_LINUX || BACKWARD_SYSTEM_DARWIN + +struct demangler: + public demangler_impl {}; + +} // namespace details + +/*************** A TRACE ***************/ + +struct Trace { + void* addr; + size_t idx; + + Trace(): + addr(nullptr), idx(0) {} + + explicit Trace(void* _addr, size_t _idx): + addr(_addr), idx(_idx) {} +}; + +struct ResolvedTrace: public Trace { + + struct SourceLoc { + std::string function; + std::string filename; + unsigned line; + unsigned col; + + SourceLoc(): line(0), col(0) {} + + bool operator==(const SourceLoc& b) const { + return function == b.function + && filename == b.filename + && line == b.line + && col == b.col; + } + + bool operator!=(const SourceLoc& b) const { + return !(*this == b); + } + }; + + // In which binary object this trace is located. + std::string object_filename; + + // The function in the object that contain the trace. This is not the same + // as source.function which can be an function inlined in object_function. + std::string object_function; + + // The source location of this trace. It is possible for filename to be + // empty and for line/col to be invalid (value 0) if this information + // couldn't be deduced, for example if there is no debug information in the + // binary object. + SourceLoc source; + + // An optionals list of "inliners". All the successive sources location + // from where the source location of the trace (the attribute right above) + // is inlined. It is especially useful when you compiled with optimization. + typedef std::vector source_locs_t; + source_locs_t inliners; + + ResolvedTrace(): + Trace() {} + ResolvedTrace(const Trace& mini_trace): + Trace(mini_trace) {} +}; + +/*************** STACK TRACE ***************/ + +// default implemention. +template +class StackTraceImpl { +public: + size_t size() const { return 0; } + Trace operator[](size_t) { return Trace(); } + size_t load_here(size_t=0) { return 0; } + size_t load_from(void*, size_t=0) { return 0; } + size_t thread_id() const { return 0; } + void skip_n_firsts(size_t) { } +}; + +class StackTraceImplBase { +public: + StackTraceImplBase(): _thread_id(0), _skip(0) {} + + size_t thread_id() const { + return _thread_id; + } + + void skip_n_firsts(size_t n) { _skip = n; } + +protected: + void load_thread_info() { +#ifdef BACKWARD_SYSTEM_LINUX +#ifndef __ANDROID__ + _thread_id = static_cast(syscall(SYS_gettid)); +#else + _thread_id = static_cast(gettid()); +#endif + if (_thread_id == static_cast(getpid())) { + // If the thread is the main one, let's hide that. + // I like to keep little secret sometimes. + _thread_id = 0; + } +#elif defined(BACKWARD_SYSTEM_DARWIN) + _thread_id = reinterpret_cast(pthread_self()); + if (pthread_main_np() == 1) { + // If the thread is the main one, let's hide that. + _thread_id = 0; + } +#endif + } + + size_t skip_n_firsts() const { return _skip; } + +private: + size_t _thread_id; + size_t _skip; +}; + +class StackTraceImplHolder: public StackTraceImplBase { +public: + size_t size() const { + return _stacktrace.size() ? _stacktrace.size() - skip_n_firsts() : 0; + } + Trace operator[](size_t idx) const { + if (idx >= size()) { + return Trace(); + } + return Trace(_stacktrace[idx + skip_n_firsts()], idx); + } + void* const* begin() const { + if (size()) { + return &_stacktrace[skip_n_firsts()]; + } + return nullptr; + } + +protected: + std::vector _stacktrace; +}; + + +#if BACKWARD_HAS_UNWIND == 1 + +namespace details { + +template +class Unwinder { +public: + size_t operator()(F& f, size_t depth) { + _f = &f; + _index = -1; + _depth = depth; + _Unwind_Backtrace(&this->backtrace_trampoline, this); + return static_cast(_index); + } + +private: + F* _f; + ssize_t _index; + size_t _depth; + + static _Unwind_Reason_Code backtrace_trampoline( + _Unwind_Context* ctx, void *self) { + return (static_cast(self))->backtrace(ctx); + } + + _Unwind_Reason_Code backtrace(_Unwind_Context* ctx) { + if (_index >= 0 && static_cast(_index) >= _depth) + return _URC_END_OF_STACK; + + int ip_before_instruction = 0; + uintptr_t ip = _Unwind_GetIPInfo(ctx, &ip_before_instruction); + + if (!ip_before_instruction) { + // calculating 0-1 for unsigned, looks like a possible bug to sanitiziers, so let's do it explicitly: + if (ip==0) { + ip = std::numeric_limits::max(); // set it to 0xffff... (as from casting 0-1) + } else { + ip -= 1; // else just normally decrement it (no overflow/underflow will happen) + } + } + + if (_index >= 0) { // ignore first frame. + (*_f)(static_cast(_index), reinterpret_cast(ip)); + } + _index += 1; + return _URC_NO_REASON; + } +}; + +template +size_t unwind(F f, size_t depth) { + Unwinder unwinder; + return unwinder(f, depth); +} + +} // namespace details + + +template <> +class StackTraceImpl: public StackTraceImplHolder { +public: + __attribute__ ((noinline)) // TODO use some macro + size_t load_here(size_t depth=32) { + load_thread_info(); + if (depth == 0) { + return 0; + } + _stacktrace.resize(depth); + size_t trace_cnt = details::unwind(callback(*this), depth); + _stacktrace.resize(trace_cnt); + skip_n_firsts(0); + return size(); + } + size_t load_from(void* addr, size_t depth=32) { + load_here(depth + 8); + + for (size_t i = 0; i < _stacktrace.size(); ++i) { + if (_stacktrace[i] == addr) { + skip_n_firsts(i); + break; + } + } + + _stacktrace.resize(std::min(_stacktrace.size(), + skip_n_firsts() + depth)); + return size(); + } + +private: + struct callback { + StackTraceImpl& self; + callback(StackTraceImpl& _self): self(_self) {} + + void operator()(size_t idx, void* addr) { + self._stacktrace[idx] = addr; + } + }; +}; + + +#else // BACKWARD_HAS_UNWIND == 0 + +template <> +class StackTraceImpl: public StackTraceImplHolder { +public: + __attribute__ ((noinline)) // TODO use some macro + size_t load_here(size_t depth=32) { + load_thread_info(); + if (depth == 0) { + return 0; + } + _stacktrace.resize(depth + 1); + size_t trace_cnt = backtrace(&_stacktrace[0], _stacktrace.size()); + _stacktrace.resize(trace_cnt); + skip_n_firsts(1); + return size(); + } + + size_t load_from(void* addr, size_t depth=32) { + load_here(depth + 8); + + for (size_t i = 0; i < _stacktrace.size(); ++i) { + if (_stacktrace[i] == addr) { + skip_n_firsts(i); + _stacktrace[i] = (void*)( (uintptr_t)_stacktrace[i] + 1); + break; + } + } + + _stacktrace.resize(std::min(_stacktrace.size(), + skip_n_firsts() + depth)); + return size(); + } +}; + +#endif // BACKWARD_HAS_UNWIND + +class StackTrace: + public StackTraceImpl {}; + +/*************** TRACE RESOLVER ***************/ + +template +class TraceResolverImpl; + +#ifdef BACKWARD_SYSTEM_UNKNOWN + +template <> +class TraceResolverImpl { +public: + template + void load_stacktrace(ST&) {} + ResolvedTrace resolve(ResolvedTrace t) { + return t; + } +}; + +#endif + +class TraceResolverImplBase { +protected: + std::string demangle(const char* funcname) { + return _demangler.demangle(funcname); + } + +private: + details::demangler _demangler; +}; + +#ifdef BACKWARD_SYSTEM_LINUX + +template +class TraceResolverLinuxImpl; + +#if BACKWARD_HAS_BACKTRACE_SYMBOL == 1 + +template <> +class TraceResolverLinuxImpl: + public TraceResolverImplBase { +public: + template + void load_stacktrace(ST& st) { + using namespace details; + if (st.size() == 0) { + return; + } + _symbols.reset( + backtrace_symbols(st.begin(), (int)st.size()) + ); + } + + ResolvedTrace resolve(ResolvedTrace trace) { + char* filename = _symbols[trace.idx]; + char* funcname = filename; + while (*funcname && *funcname != '(') { + funcname += 1; + } + trace.object_filename.assign(filename, funcname); // ok even if funcname is the ending \0 (then we assign entire string) + + if (*funcname) { // if it's not end of string (e.g. from last frame ip==0) + funcname += 1; + char* funcname_end = funcname; + while (*funcname_end && *funcname_end != ')' && *funcname_end != '+') { + funcname_end += 1; + } + *funcname_end = '\0'; + trace.object_function = this->demangle(funcname); + trace.source.function = trace.object_function; // we cannot do better. + } + return trace; + } + +private: + details::handle _symbols; +}; + +#endif // BACKWARD_HAS_BACKTRACE_SYMBOL == 1 + +#if BACKWARD_HAS_BFD == 1 + +template <> +class TraceResolverLinuxImpl: + public TraceResolverImplBase { + static std::string read_symlink(std::string const & symlink_path) { + std::string path; + path.resize(100); + + while(true) { + ssize_t len = ::readlink(symlink_path.c_str(), &*path.begin(), path.size()); + if(len < 0) { + return ""; + } + if (static_cast(len) == path.size()) { + path.resize(path.size() * 2); + } + else { + path.resize(static_cast(len)); + break; + } + } + + return path; + } +public: + TraceResolverLinuxImpl(): _bfd_loaded(false) {} + + template + void load_stacktrace(ST&) {} + + ResolvedTrace resolve(ResolvedTrace trace) { + Dl_info symbol_info; + + // trace.addr is a virtual address in memory pointing to some code. + // Let's try to find from which loaded object it comes from. + // The loaded object can be yourself btw. + if (!dladdr(trace.addr, &symbol_info)) { + return trace; // dat broken trace... + } + + std::string argv0; + { + std::ifstream ifs("/proc/self/cmdline"); + std::getline(ifs, argv0, '\0'); + } + std::string tmp; + if(symbol_info.dli_fname == argv0) { + tmp = read_symlink("/proc/self/exe"); + symbol_info.dli_fname = tmp.c_str(); + } + + // Now we get in symbol_info: + // .dli_fname: + // pathname of the shared object that contains the address. + // .dli_fbase: + // where the object is loaded in memory. + // .dli_sname: + // the name of the nearest symbol to trace.addr, we expect a + // function name. + // .dli_saddr: + // the exact address corresponding to .dli_sname. + + if (symbol_info.dli_sname) { + trace.object_function = demangle(symbol_info.dli_sname); + } + + if (!symbol_info.dli_fname) { + return trace; + } + + trace.object_filename = symbol_info.dli_fname; + bfd_fileobject& fobj = load_object_with_bfd(symbol_info.dli_fname); + if (!fobj.handle) { + return trace; // sad, we couldn't load the object :( + } + + + find_sym_result* details_selected; // to be filled. + + // trace.addr is the next instruction to be executed after returning + // from the nested stack frame. In C++ this usually relate to the next + // statement right after the function call that leaded to a new stack + // frame. This is not usually what you want to see when printing out a + // stacktrace... + find_sym_result details_call_site = find_symbol_details(fobj, + trace.addr, symbol_info.dli_fbase); + details_selected = &details_call_site; + +#if BACKWARD_HAS_UNWIND == 0 + // ...this is why we also try to resolve the symbol that is right + // before the return address. If we are lucky enough, we will get the + // line of the function that was called. But if the code is optimized, + // we might get something absolutely not related since the compiler + // can reschedule the return address with inline functions and + // tail-call optimisation (among other things that I don't even know + // or cannot even dream about with my tiny limited brain). + find_sym_result details_adjusted_call_site = find_symbol_details(fobj, + (void*) (uintptr_t(trace.addr) - 1), + symbol_info.dli_fbase); + + // In debug mode, we should always get the right thing(TM). + if (details_call_site.found && details_adjusted_call_site.found) { + // Ok, we assume that details_adjusted_call_site is a better estimation. + details_selected = &details_adjusted_call_site; + trace.addr = (void*) (uintptr_t(trace.addr) - 1); + } + + if (details_selected == &details_call_site && details_call_site.found) { + // we have to re-resolve the symbol in order to reset some + // internal state in BFD... so we can call backtrace_inliners + // thereafter... + details_call_site = find_symbol_details(fobj, trace.addr, + symbol_info.dli_fbase); + } +#endif // BACKWARD_HAS_UNWIND + + if (details_selected->found) { + if (details_selected->filename) { + trace.source.filename = details_selected->filename; + } + trace.source.line = details_selected->line; + + if (details_selected->funcname) { + // this time we get the name of the function where the code is + // located, instead of the function were the address is + // located. In short, if the code was inlined, we get the + // function correspoding to the code. Else we already got in + // trace.function. + trace.source.function = demangle(details_selected->funcname); + + if (!symbol_info.dli_sname) { + // for the case dladdr failed to find the symbol name of + // the function, we might as well try to put something + // here. + trace.object_function = trace.source.function; + } + } + + // Maybe the source of the trace got inlined inside the function + // (trace.source.function). Let's see if we can get all the inlined + // calls along the way up to the initial call site. + trace.inliners = backtrace_inliners(fobj, *details_selected); + +#if 0 + if (trace.inliners.size() == 0) { + // Maybe the trace was not inlined... or maybe it was and we + // are lacking the debug information. Let's try to make the + // world better and see if we can get the line number of the + // function (trace.source.function) now. + // + // We will get the location of where the function start (to be + // exact: the first instruction that really start the + // function), not where the name of the function is defined. + // This can be quite far away from the name of the function + // btw. + // + // If the source of the function is the same as the source of + // the trace, we cannot say if the trace was really inlined or + // not. However, if the filename of the source is different + // between the function and the trace... we can declare it as + // an inliner. This is not 100% accurate, but better than + // nothing. + + if (symbol_info.dli_saddr) { + find_sym_result details = find_symbol_details(fobj, + symbol_info.dli_saddr, + symbol_info.dli_fbase); + + if (details.found) { + ResolvedTrace::SourceLoc diy_inliner; + diy_inliner.line = details.line; + if (details.filename) { + diy_inliner.filename = details.filename; + } + if (details.funcname) { + diy_inliner.function = demangle(details.funcname); + } else { + diy_inliner.function = trace.source.function; + } + if (diy_inliner != trace.source) { + trace.inliners.push_back(diy_inliner); + } + } + } + } +#endif + } + + return trace; + } + +private: + bool _bfd_loaded; + + typedef details::handle + > bfd_handle_t; + + typedef details::handle bfd_symtab_t; + + + struct bfd_fileobject { + bfd_handle_t handle; + bfd_vma base_addr; + bfd_symtab_t symtab; + bfd_symtab_t dynamic_symtab; + }; + + typedef details::hashtable::type + fobj_bfd_map_t; + fobj_bfd_map_t _fobj_bfd_map; + + bfd_fileobject& load_object_with_bfd(const std::string& filename_object) { + using namespace details; + + if (!_bfd_loaded) { + using namespace details; + bfd_init(); + _bfd_loaded = true; + } + + fobj_bfd_map_t::iterator it = + _fobj_bfd_map.find(filename_object); + if (it != _fobj_bfd_map.end()) { + return it->second; + } + + // this new object is empty for now. + bfd_fileobject& r = _fobj_bfd_map[filename_object]; + + // we do the work temporary in this one; + bfd_handle_t bfd_handle; + + int fd = open(filename_object.c_str(), O_RDONLY); + bfd_handle.reset( + bfd_fdopenr(filename_object.c_str(), "default", fd) + ); + if (!bfd_handle) { + close(fd); + return r; + } + + if (!bfd_check_format(bfd_handle.get(), bfd_object)) { + return r; // not an object? You lose. + } + + if ((bfd_get_file_flags(bfd_handle.get()) & HAS_SYMS) == 0) { + return r; // that's what happen when you forget to compile in debug. + } + + ssize_t symtab_storage_size = + bfd_get_symtab_upper_bound(bfd_handle.get()); + + ssize_t dyn_symtab_storage_size = + bfd_get_dynamic_symtab_upper_bound(bfd_handle.get()); + + if (symtab_storage_size <= 0 && dyn_symtab_storage_size <= 0) { + return r; // weird, is the file is corrupted? + } + + bfd_symtab_t symtab, dynamic_symtab; + ssize_t symcount = 0, dyn_symcount = 0; + + if (symtab_storage_size > 0) { + symtab.reset( + static_cast(malloc(static_cast(symtab_storage_size))) + ); + symcount = bfd_canonicalize_symtab( + bfd_handle.get(), symtab.get() + ); + } + + if (dyn_symtab_storage_size > 0) { + dynamic_symtab.reset( + static_cast(malloc(static_cast(dyn_symtab_storage_size))) + ); + dyn_symcount = bfd_canonicalize_dynamic_symtab( + bfd_handle.get(), dynamic_symtab.get() + ); + } + + + if (symcount <= 0 && dyn_symcount <= 0) { + return r; // damned, that's a stripped file that you got there! + } + + r.handle = move(bfd_handle); + r.symtab = move(symtab); + r.dynamic_symtab = move(dynamic_symtab); + return r; + } + + struct find_sym_result { + bool found; + const char* filename; + const char* funcname; + unsigned int line; + }; + + struct find_sym_context { + TraceResolverLinuxImpl* self; + bfd_fileobject* fobj; + void* addr; + void* base_addr; + find_sym_result result; + }; + + find_sym_result find_symbol_details(bfd_fileobject& fobj, void* addr, + void* base_addr) { + find_sym_context context; + context.self = this; + context.fobj = &fobj; + context.addr = addr; + context.base_addr = base_addr; + context.result.found = false; + bfd_map_over_sections(fobj.handle.get(), &find_in_section_trampoline, + static_cast(&context)); + return context.result; + } + + static void find_in_section_trampoline(bfd*, asection* section, + void* data) { + find_sym_context* context = static_cast(data); + context->self->find_in_section( + reinterpret_cast(context->addr), + reinterpret_cast(context->base_addr), + *context->fobj, + section, context->result + ); + } + + void find_in_section(bfd_vma addr, bfd_vma base_addr, + bfd_fileobject& fobj, asection* section, find_sym_result& result) + { + if (result.found) return; + + if ((bfd_get_section_flags(fobj.handle.get(), section) + & SEC_ALLOC) == 0) + return; // a debug section is never loaded automatically. + + bfd_vma sec_addr = bfd_get_section_vma(fobj.handle.get(), section); + bfd_size_type size = bfd_get_section_size(section); + + // are we in the boundaries of the section? + if (addr < sec_addr || addr >= sec_addr + size) { + addr -= base_addr; // oups, a relocated object, lets try again... + if (addr < sec_addr || addr >= sec_addr + size) { + return; + } + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" + if (!result.found && fobj.symtab) { + result.found = bfd_find_nearest_line(fobj.handle.get(), section, + fobj.symtab.get(), addr - sec_addr, &result.filename, + &result.funcname, &result.line); + } + + if (!result.found && fobj.dynamic_symtab) { + result.found = bfd_find_nearest_line(fobj.handle.get(), section, + fobj.dynamic_symtab.get(), addr - sec_addr, + &result.filename, &result.funcname, &result.line); + } +#pragma clang diagnostic pop + + } + + ResolvedTrace::source_locs_t backtrace_inliners(bfd_fileobject& fobj, + find_sym_result previous_result) { + // This function can be called ONLY after a SUCCESSFUL call to + // find_symbol_details. The state is global to the bfd_handle. + ResolvedTrace::source_locs_t results; + while (previous_result.found) { + find_sym_result result; + result.found = bfd_find_inliner_info(fobj.handle.get(), + &result.filename, &result.funcname, &result.line); + + if (result.found) /* and not ( + cstrings_eq(previous_result.filename, result.filename) + and cstrings_eq(previous_result.funcname, result.funcname) + and result.line == previous_result.line + )) */ { + ResolvedTrace::SourceLoc src_loc; + src_loc.line = result.line; + if (result.filename) { + src_loc.filename = result.filename; + } + if (result.funcname) { + src_loc.function = demangle(result.funcname); + } + results.push_back(src_loc); + } + previous_result = result; + } + return results; + } + + bool cstrings_eq(const char* a, const char* b) { + if (!a || !b) { + return false; + } + return strcmp(a, b) == 0; + } + +}; +#endif // BACKWARD_HAS_BFD == 1 + +#if BACKWARD_HAS_DW == 1 + +template <> +class TraceResolverLinuxImpl: + public TraceResolverImplBase { +public: + TraceResolverLinuxImpl(): _dwfl_handle_initialized(false) {} + + template + void load_stacktrace(ST&) {} + + ResolvedTrace resolve(ResolvedTrace trace) { + using namespace details; + + Dwarf_Addr trace_addr = (Dwarf_Addr) trace.addr; + + if (!_dwfl_handle_initialized) { + // initialize dwfl... + _dwfl_cb.reset(new Dwfl_Callbacks); + _dwfl_cb->find_elf = &dwfl_linux_proc_find_elf; + _dwfl_cb->find_debuginfo = &dwfl_standard_find_debuginfo; + _dwfl_cb->debuginfo_path = 0; + + _dwfl_handle.reset(dwfl_begin(_dwfl_cb.get())); + _dwfl_handle_initialized = true; + + if (!_dwfl_handle) { + return trace; + } + + // ...from the current process. + dwfl_report_begin(_dwfl_handle.get()); + int r = dwfl_linux_proc_report (_dwfl_handle.get(), getpid()); + dwfl_report_end(_dwfl_handle.get(), NULL, NULL); + if (r < 0) { + return trace; + } + } + + if (!_dwfl_handle) { + return trace; + } + + // find the module (binary object) that contains the trace's address. + // This is not using any debug information, but the addresses ranges of + // all the currently loaded binary object. + Dwfl_Module* mod = dwfl_addrmodule(_dwfl_handle.get(), trace_addr); + if (mod) { + // now that we found it, lets get the name of it, this will be the + // full path to the running binary or one of the loaded library. + const char* module_name = dwfl_module_info (mod, + 0, 0, 0, 0, 0, 0, 0); + if (module_name) { + trace.object_filename = module_name; + } + // We also look after the name of the symbol, equal or before this + // address. This is found by walking the symtab. We should get the + // symbol corresponding to the function (mangled) containing the + // address. If the code corresponding to the address was inlined, + // this is the name of the out-most inliner function. + const char* sym_name = dwfl_module_addrname(mod, trace_addr); + if (sym_name) { + trace.object_function = demangle(sym_name); + } + } + + // now let's get serious, and find out the source location (file and + // line number) of the address. + + // This function will look in .debug_aranges for the address and map it + // to the location of the compilation unit DIE in .debug_info and + // return it. + Dwarf_Addr mod_bias = 0; + Dwarf_Die* cudie = dwfl_module_addrdie(mod, trace_addr, &mod_bias); + +#if 1 + if (!cudie) { + // Sadly clang does not generate the section .debug_aranges, thus + // dwfl_module_addrdie will fail early. Clang doesn't either set + // the lowpc/highpc/range info for every compilation unit. + // + // So in order to save the world: + // for every compilation unit, we will iterate over every single + // DIEs. Normally functions should have a lowpc/highpc/range, which + // we will use to infer the compilation unit. + + // note that this is probably badly inefficient. + while ((cudie = dwfl_module_nextcu(mod, cudie, &mod_bias))) { + Dwarf_Die die_mem; + Dwarf_Die* fundie = find_fundie_by_pc(cudie, + trace_addr - mod_bias, &die_mem); + if (fundie) { + break; + } + } + } +#endif + +//#define BACKWARD_I_DO_NOT_RECOMMEND_TO_ENABLE_THIS_HORRIBLE_PIECE_OF_CODE +#ifdef BACKWARD_I_DO_NOT_RECOMMEND_TO_ENABLE_THIS_HORRIBLE_PIECE_OF_CODE + if (!cudie) { + // If it's still not enough, lets dive deeper in the shit, and try + // to save the world again: for every compilation unit, we will + // load the corresponding .debug_line section, and see if we can + // find our address in it. + + Dwarf_Addr cfi_bias; + Dwarf_CFI* cfi_cache = dwfl_module_eh_cfi(mod, &cfi_bias); + + Dwarf_Addr bias; + while ((cudie = dwfl_module_nextcu(mod, cudie, &bias))) { + if (dwarf_getsrc_die(cudie, trace_addr - bias)) { + + // ...but if we get a match, it might be a false positive + // because our (address - bias) might as well be valid in a + // different compilation unit. So we throw our last card on + // the table and lookup for the address into the .eh_frame + // section. + + handle frame; + dwarf_cfi_addrframe(cfi_cache, trace_addr - cfi_bias, &frame); + if (frame) { + break; + } + } + } + } +#endif + + if (!cudie) { + return trace; // this time we lost the game :/ + } + + // Now that we have a compilation unit DIE, this function will be able + // to load the corresponding section in .debug_line (if not already + // loaded) and hopefully find the source location mapped to our + // address. + Dwarf_Line* srcloc = dwarf_getsrc_die(cudie, trace_addr - mod_bias); + + if (srcloc) { + const char* srcfile = dwarf_linesrc(srcloc, 0, 0); + if (srcfile) { + trace.source.filename = srcfile; + } + int line = 0, col = 0; + dwarf_lineno(srcloc, &line); + dwarf_linecol(srcloc, &col); + trace.source.line = line; + trace.source.col = col; + } + + deep_first_search_by_pc(cudie, trace_addr - mod_bias, + inliners_search_cb(trace)); + if (trace.source.function.size() == 0) { + // fallback. + trace.source.function = trace.object_function; + } + + return trace; + } + +private: + typedef details::handle > + dwfl_handle_t; + details::handle > + _dwfl_cb; + dwfl_handle_t _dwfl_handle; + bool _dwfl_handle_initialized; + + // defined here because in C++98, template function cannot take locally + // defined types... grrr. + struct inliners_search_cb { + void operator()(Dwarf_Die* die) { + switch (dwarf_tag(die)) { + const char* name; + case DW_TAG_subprogram: + if ((name = dwarf_diename(die))) { + trace.source.function = name; + } + break; + + case DW_TAG_inlined_subroutine: + ResolvedTrace::SourceLoc sloc; + Dwarf_Attribute attr_mem; + + if ((name = dwarf_diename(die))) { + sloc.function = name; + } + if ((name = die_call_file(die))) { + sloc.filename = name; + } + + Dwarf_Word line = 0, col = 0; + dwarf_formudata(dwarf_attr(die, DW_AT_call_line, + &attr_mem), &line); + dwarf_formudata(dwarf_attr(die, DW_AT_call_column, + &attr_mem), &col); + sloc.line = (unsigned)line; + sloc.col = (unsigned)col; + + trace.inliners.push_back(sloc); + break; + }; + } + ResolvedTrace& trace; + inliners_search_cb(ResolvedTrace& t): trace(t) {} + }; + + + static bool die_has_pc(Dwarf_Die* die, Dwarf_Addr pc) { + Dwarf_Addr low, high; + + // continuous range + if (dwarf_hasattr(die, DW_AT_low_pc) && + dwarf_hasattr(die, DW_AT_high_pc)) { + if (dwarf_lowpc(die, &low) != 0) { + return false; + } + if (dwarf_highpc(die, &high) != 0) { + Dwarf_Attribute attr_mem; + Dwarf_Attribute* attr = dwarf_attr(die, DW_AT_high_pc, &attr_mem); + Dwarf_Word value; + if (dwarf_formudata(attr, &value) != 0) { + return false; + } + high = low + value; + } + return pc >= low && pc < high; + } + + // non-continuous range. + Dwarf_Addr base; + ptrdiff_t offset = 0; + while ((offset = dwarf_ranges(die, offset, &base, &low, &high)) > 0) { + if (pc >= low && pc < high) { + return true; + } + } + return false; + } + + static Dwarf_Die* find_fundie_by_pc(Dwarf_Die* parent_die, Dwarf_Addr pc, + Dwarf_Die* result) { + if (dwarf_child(parent_die, result) != 0) { + return 0; + } + + Dwarf_Die* die = result; + do { + switch (dwarf_tag(die)) { + case DW_TAG_subprogram: + case DW_TAG_inlined_subroutine: + if (die_has_pc(die, pc)) { + return result; + } + }; + bool declaration = false; + Dwarf_Attribute attr_mem; + dwarf_formflag(dwarf_attr(die, DW_AT_declaration, + &attr_mem), &declaration); + if (!declaration) { + // let's be curious and look deeper in the tree, + // function are not necessarily at the first level, but + // might be nested inside a namespace, structure etc. + Dwarf_Die die_mem; + Dwarf_Die* indie = find_fundie_by_pc(die, pc, &die_mem); + if (indie) { + *result = die_mem; + return result; + } + } + } while (dwarf_siblingof(die, result) == 0); + return 0; + } + + template + static bool deep_first_search_by_pc(Dwarf_Die* parent_die, + Dwarf_Addr pc, CB cb) { + Dwarf_Die die_mem; + if (dwarf_child(parent_die, &die_mem) != 0) { + return false; + } + + bool branch_has_pc = false; + Dwarf_Die* die = &die_mem; + do { + bool declaration = false; + Dwarf_Attribute attr_mem; + dwarf_formflag(dwarf_attr(die, DW_AT_declaration, &attr_mem), &declaration); + if (!declaration) { + // let's be curious and look deeper in the tree, function are + // not necessarily at the first level, but might be nested + // inside a namespace, structure, a function, an inlined + // function etc. + branch_has_pc = deep_first_search_by_pc(die, pc, cb); + } + if (!branch_has_pc) { + branch_has_pc = die_has_pc(die, pc); + } + if (branch_has_pc) { + cb(die); + } + } while (dwarf_siblingof(die, &die_mem) == 0); + return branch_has_pc; + } + + static const char* die_call_file(Dwarf_Die *die) { + Dwarf_Attribute attr_mem; + Dwarf_Sword file_idx = 0; + + dwarf_formsdata(dwarf_attr(die, DW_AT_call_file, &attr_mem), + &file_idx); + + if (file_idx == 0) { + return 0; + } + + Dwarf_Die die_mem; + Dwarf_Die* cudie = dwarf_diecu(die, &die_mem, 0, 0); + if (!cudie) { + return 0; + } + + Dwarf_Files* files = 0; + size_t nfiles; + dwarf_getsrcfiles(cudie, &files, &nfiles); + if (!files) { + return 0; + } + + return dwarf_filesrc(files, file_idx, 0, 0); + } + +}; +#endif // BACKWARD_HAS_DW == 1 + +#if BACKWARD_HAS_DWARF == 1 + +template <> +class TraceResolverLinuxImpl: + public TraceResolverImplBase { + static std::string read_symlink(std::string const & symlink_path) { + std::string path; + path.resize(100); + + while(true) { + ssize_t len = ::readlink(symlink_path.c_str(), + &*path.begin(), path.size()); + if(len < 0) { + return ""; + } + if ((size_t)len == path.size()) { + path.resize(path.size() * 2); + } + else { + path.resize(len); + break; + } + } + + return path; + } +public: + TraceResolverLinuxImpl(): _dwarf_loaded(false) {} + + template + void load_stacktrace(ST&) {} + + ResolvedTrace resolve(ResolvedTrace trace) { + // trace.addr is a virtual address in memory pointing to some code. + // Let's try to find from which loaded object it comes from. + // The loaded object can be yourself btw. + + Dl_info symbol_info; + int dladdr_result = 0; +#ifndef __ANDROID__ + link_map *link_map; + // We request the link map so we can get information about offsets + dladdr_result = dladdr1(trace.addr, &symbol_info, + reinterpret_cast(&link_map), RTLD_DL_LINKMAP); +#else + // Android doesn't have dladdr1. Don't use the linker map. + dladdr_result = dladdr(trace.addr, &symbol_info); +#endif + if (!dladdr_result) { + return trace; // dat broken trace... + } + + std::string argv0; + { + std::ifstream ifs("/proc/self/cmdline"); + std::getline(ifs, argv0, '\0'); + } + std::string tmp; + if(symbol_info.dli_fname == argv0) { + tmp = read_symlink("/proc/self/exe"); + symbol_info.dli_fname = tmp.c_str(); + } + + // Now we get in symbol_info: + // .dli_fname: + // pathname of the shared object that contains the address. + // .dli_fbase: + // where the object is loaded in memory. + // .dli_sname: + // the name of the nearest symbol to trace.addr, we expect a + // function name. + // .dli_saddr: + // the exact address corresponding to .dli_sname. + // + // And in link_map: + // .l_addr: + // difference between the address in the ELF file and the address + // in memory + // l_name: + // absolute pathname where the object was found + + if (symbol_info.dli_sname) { + trace.object_function = demangle(symbol_info.dli_sname); + } + + if (!symbol_info.dli_fname) { + return trace; + } + + trace.object_filename = symbol_info.dli_fname; + dwarf_fileobject& fobj = load_object_with_dwarf(symbol_info.dli_fname); + if (!fobj.dwarf_handle) { + return trace; // sad, we couldn't load the object :( + } + +#ifndef __ANDROID__ + // Convert the address to a module relative one by looking at + // the module's loading address in the link map + Dwarf_Addr address = reinterpret_cast(trace.addr) - + reinterpret_cast(link_map->l_addr); +#else + Dwarf_Addr address = reinterpret_cast(trace.addr); +#endif + + if (trace.object_function.empty()) { + symbol_cache_t::iterator it = + fobj.symbol_cache.lower_bound(address); + + if (it != fobj.symbol_cache.end()) { + if (it->first != address) { + if (it != fobj.symbol_cache.begin()) { + --it; + } + } + trace.object_function = demangle(it->second.c_str()); + } + } + + // Get the Compilation Unit DIE for the address + Dwarf_Die die = find_die(fobj, address); + + if (!die) { + return trace; // this time we lost the game :/ + } + + // libdwarf doesn't give us direct access to its objects, it always + // allocates a copy for the caller. We keep that copy alive in a cache + // and we deallocate it later when it's no longer required. + die_cache_entry& die_object = get_die_cache(fobj, die); + if (die_object.isEmpty()) + return trace; // We have no line section for this DIE + + die_linemap_t::iterator it = + die_object.line_section.lower_bound(address); + + if (it != die_object.line_section.end()) { + if (it->first != address) { + if (it == die_object.line_section.begin()) { + // If we are on the first item of the line section + // but the address does not match it means that + // the address is below the range of the DIE. Give up. + return trace; + } else { + --it; + } + } + } else { + return trace; // We didn't find the address. + } + + // Get the Dwarf_Line that the address points to and call libdwarf + // to get source file, line and column info. + Dwarf_Line line = die_object.line_buffer[it->second]; + Dwarf_Error error = DW_DLE_NE; + + char* filename; + if (dwarf_linesrc(line, &filename, &error) + == DW_DLV_OK) { + trace.source.filename = std::string(filename); + dwarf_dealloc(fobj.dwarf_handle.get(), filename, DW_DLA_STRING); + } + + Dwarf_Unsigned number = 0; + if (dwarf_lineno(line, &number, &error) == DW_DLV_OK) { + trace.source.line = number; + } else { + trace.source.line = 0; + } + + if (dwarf_lineoff_b(line, &number, &error) == DW_DLV_OK) { + trace.source.col = number; + } else { + trace.source.col = 0; + } + + std::vector namespace_stack; + deep_first_search_by_pc(fobj, die, address, namespace_stack, + inliners_search_cb(trace, fobj, die)); + + dwarf_dealloc(fobj.dwarf_handle.get(), die, DW_DLA_DIE); + + return trace; + } + +public: + static int close_dwarf(Dwarf_Debug dwarf) { + return dwarf_finish(dwarf, NULL); + } + +private: + bool _dwarf_loaded; + + typedef details::handle + > dwarf_file_t; + + typedef details::handle + > dwarf_elf_t; + + typedef details::handle + > dwarf_handle_t; + + typedef std::map die_linemap_t; + + typedef std::map die_specmap_t; + + struct die_cache_entry { + die_specmap_t spec_section; + die_linemap_t line_section; + Dwarf_Line* line_buffer; + Dwarf_Signed line_count; + Dwarf_Line_Context line_context; + + inline bool isEmpty() { + return line_buffer == NULL || + line_count == 0 || + line_context == NULL || + line_section.empty(); + } + + die_cache_entry() : + line_buffer(0), line_count(0), line_context(0) {} + + ~die_cache_entry() + { + if (line_context) { + dwarf_srclines_dealloc_b(line_context); + } + } + }; + + typedef std::map die_cache_t; + + typedef std::map symbol_cache_t; + + struct dwarf_fileobject { + dwarf_file_t file_handle; + dwarf_elf_t elf_handle; + dwarf_handle_t dwarf_handle; + symbol_cache_t symbol_cache; + + // Die cache + die_cache_t die_cache; + die_cache_entry* current_cu; + }; + + typedef details::hashtable::type + fobj_dwarf_map_t; + fobj_dwarf_map_t _fobj_dwarf_map; + + static bool cstrings_eq(const char* a, const char* b) { + if (!a || !b) { + return false; + } + return strcmp(a, b) == 0; + } + + dwarf_fileobject& load_object_with_dwarf( + const std::string& filename_object) { + + if (!_dwarf_loaded) { + // Set the ELF library operating version + // If that fails there's nothing we can do + _dwarf_loaded = elf_version(EV_CURRENT) != EV_NONE; + } + + fobj_dwarf_map_t::iterator it = + _fobj_dwarf_map.find(filename_object); + if (it != _fobj_dwarf_map.end()) { + return it->second; + } + + // this new object is empty for now + dwarf_fileobject& r = _fobj_dwarf_map[filename_object]; + + dwarf_file_t file_handle; + file_handle.reset(open(filename_object.c_str(), O_RDONLY)); + if (file_handle < 0) { + return r; + } + + // Try to get an ELF handle. We need to read the ELF sections + // because we want to see if there is a .gnu_debuglink section + // that points to a split debug file + dwarf_elf_t elf_handle; + elf_handle.reset(elf_begin(file_handle.get(), ELF_C_READ, NULL)); + if (!elf_handle) { + return r; + } + + const char* e_ident = elf_getident(elf_handle.get(), 0); + if (!e_ident) { + return r; + } + + // Get the number of sections + // We use the new APIs as elf_getshnum is deprecated + size_t shdrnum = 0; + if (elf_getshdrnum(elf_handle.get(), &shdrnum) == -1) { + return r; + } + + // Get the index to the string section + size_t shdrstrndx = 0; + if (elf_getshdrstrndx (elf_handle.get(), &shdrstrndx) == -1) { + return r; + } + + std::string debuglink; + // Iterate through the ELF sections to try to get a gnu_debuglink + // note and also to cache the symbol table. + // We go the preprocessor way to avoid having to create templated + // classes or using gelf (which might throw a compiler error if 64 bit + // is not supported +#define ELF_GET_DATA(ARCH) \ + Elf_Scn *elf_section = 0; \ + Elf_Data *elf_data = 0; \ + Elf##ARCH##_Shdr* section_header = 0; \ + Elf_Scn *symbol_section = 0; \ + size_t symbol_count = 0; \ + size_t symbol_strings = 0; \ + Elf##ARCH##_Sym *symbol = 0; \ + const char* section_name = 0; \ + \ + while ((elf_section = elf_nextscn(elf_handle.get(), elf_section)) \ + != NULL) { \ + section_header = elf##ARCH##_getshdr(elf_section); \ + if (section_header == NULL) { \ + return r; \ + } \ + \ + if ((section_name = elf_strptr( \ + elf_handle.get(), shdrstrndx, \ + section_header->sh_name)) == NULL) { \ + return r; \ + } \ + \ + if (cstrings_eq(section_name, ".gnu_debuglink")) { \ + elf_data = elf_getdata(elf_section, NULL); \ + if (elf_data && elf_data->d_size > 0) { \ + debuglink = std::string( \ + reinterpret_cast(elf_data->d_buf)); \ + } \ + } \ + \ + switch(section_header->sh_type) { \ + case SHT_SYMTAB: \ + symbol_section = elf_section; \ + symbol_count = section_header->sh_size / \ + section_header->sh_entsize; \ + symbol_strings = section_header->sh_link; \ + break; \ + \ + /* We use .dynsyms as a last resort, we prefer .symtab */ \ + case SHT_DYNSYM: \ + if (!symbol_section) { \ + symbol_section = elf_section; \ + symbol_count = section_header->sh_size / \ + section_header->sh_entsize; \ + symbol_strings = section_header->sh_link; \ + } \ + break; \ + } \ + } \ + \ + if (symbol_section && symbol_count && symbol_strings) { \ + elf_data = elf_getdata(symbol_section, NULL); \ + symbol = reinterpret_cast(elf_data->d_buf); \ + for (size_t i = 0; i < symbol_count; ++i) { \ + int type = ELF##ARCH##_ST_TYPE(symbol->st_info); \ + if (type == STT_FUNC && symbol->st_value > 0) { \ + r.symbol_cache[symbol->st_value] = std::string( \ + elf_strptr(elf_handle.get(), \ + symbol_strings, symbol->st_name)); \ + } \ + ++symbol; \ + } \ + } \ + + + if (e_ident[EI_CLASS] == ELFCLASS32) { + ELF_GET_DATA(32) + } else if (e_ident[EI_CLASS] == ELFCLASS64) { + // libelf might have been built without 64 bit support +#if __LIBELF64 + ELF_GET_DATA(64) +#endif + } + + if (!debuglink.empty()) { + // We have a debuglink section! Open an elf instance on that + // file instead. If we can't open the file, then return + // the elf handle we had already opened. + dwarf_file_t debuglink_file; + debuglink_file.reset(open(debuglink.c_str(), O_RDONLY)); + if (debuglink_file.get() > 0) { + dwarf_elf_t debuglink_elf; + debuglink_elf.reset( + elf_begin(debuglink_file.get(),ELF_C_READ, NULL) + ); + + // If we have a valid elf handle, return the new elf handle + // and file handle and discard the original ones + if (debuglink_elf) { + elf_handle = move(debuglink_elf); + file_handle = move(debuglink_file); + } + } + } + + // Ok, we have a valid ELF handle, let's try to get debug symbols + Dwarf_Debug dwarf_debug; + Dwarf_Error error = DW_DLE_NE; + dwarf_handle_t dwarf_handle; + + int dwarf_result = dwarf_elf_init(elf_handle.get(), + DW_DLC_READ, NULL, NULL, &dwarf_debug, &error); + + // We don't do any special handling for DW_DLV_NO_ENTRY specially. + // If we get an error, or the file doesn't have debug information + // we just return. + if (dwarf_result != DW_DLV_OK) { + return r; + } + + dwarf_handle.reset(dwarf_debug); + + r.file_handle = move(file_handle); + r.elf_handle = move(elf_handle); + r.dwarf_handle = move(dwarf_handle); + + return r; + } + + die_cache_entry& get_die_cache(dwarf_fileobject& fobj, Dwarf_Die die) + { + Dwarf_Error error = DW_DLE_NE; + + // Get the die offset, we use it as the cache key + Dwarf_Off die_offset; + if (dwarf_dieoffset(die, &die_offset, &error) != DW_DLV_OK) { + die_offset = 0; + } + + die_cache_t::iterator it = fobj.die_cache.find(die_offset); + + if (it != fobj.die_cache.end()) { + fobj.current_cu = &it->second; + return it->second; + } + + die_cache_entry& de = fobj.die_cache[die_offset]; + fobj.current_cu = &de; + + Dwarf_Addr line_addr; + Dwarf_Small table_count; + + // The addresses in the line section are not fully sorted (they might + // be sorted by block of code belonging to the same file), which makes + // it necessary to do so before searching is possible. + // + // As libdwarf allocates a copy of everything, let's get the contents + // of the line section and keep it around. We also create a map of + // program counter to line table indices so we can search by address + // and get the line buffer index. + // + // To make things more difficult, the same address can span more than + // one line, so we need to keep the index pointing to the first line + // by using insert instead of the map's [ operator. + + // Get the line context for the DIE + if (dwarf_srclines_b(die, 0, &table_count, &de.line_context, &error) + == DW_DLV_OK) { + // Get the source lines for this line context, to be deallocated + // later + if (dwarf_srclines_from_linecontext( + de.line_context, &de.line_buffer, &de.line_count, &error) + == DW_DLV_OK) { + + // Add all the addresses to our map + for (int i = 0; i < de.line_count; i++) { + if (dwarf_lineaddr(de.line_buffer[i], &line_addr, &error) + != DW_DLV_OK) { + line_addr = 0; + } + de.line_section.insert( + std::pair(line_addr, i)); + } + } + } + + // For each CU, cache the function DIEs that contain the + // DW_AT_specification attribute. When building with -g3 the function + // DIEs are separated in declaration and specification, with the + // declaration containing only the name and parameters and the + // specification the low/high pc and other compiler attributes. + // + // We cache those specifications so we don't skip over the declarations, + // because they have no pc, and we can do namespace resolution for + // DWARF function names. + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + Dwarf_Die current_die = 0; + if (dwarf_child(die, ¤t_die, &error) == DW_DLV_OK) { + for(;;) { + Dwarf_Die sibling_die = 0; + + Dwarf_Half tag_value; + dwarf_tag(current_die, &tag_value, &error); + + if (tag_value == DW_TAG_subprogram || + tag_value == DW_TAG_inlined_subroutine) { + + Dwarf_Bool has_attr = 0; + if (dwarf_hasattr(current_die, DW_AT_specification, + &has_attr, &error) == DW_DLV_OK) { + if (has_attr) { + Dwarf_Attribute attr_mem; + if (dwarf_attr(current_die, DW_AT_specification, + &attr_mem, &error) == DW_DLV_OK) { + Dwarf_Off spec_offset = 0; + if (dwarf_formref(attr_mem, + &spec_offset, &error) == DW_DLV_OK) { + Dwarf_Off spec_die_offset; + if (dwarf_dieoffset(current_die, + &spec_die_offset, &error) + == DW_DLV_OK) { + de.spec_section[spec_offset] = + spec_die_offset; + } + } + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + } + } + + int result = dwarf_siblingof( + dwarf, current_die, &sibling_die, &error); + if (result == DW_DLV_ERROR) { + break; + } else if (result == DW_DLV_NO_ENTRY) { + break; + } + + if (current_die != die) { + dwarf_dealloc(dwarf, current_die, DW_DLA_DIE); + current_die = 0; + } + + current_die = sibling_die; + } + } + return de; + } + + static Dwarf_Die get_referenced_die( + Dwarf_Debug dwarf, Dwarf_Die die, Dwarf_Half attr, bool global) { + Dwarf_Error error = DW_DLE_NE; + Dwarf_Attribute attr_mem; + + Dwarf_Die found_die = NULL; + if (dwarf_attr(die, attr, &attr_mem, &error) == DW_DLV_OK) { + Dwarf_Off offset; + int result = 0; + if (global) { + result = dwarf_global_formref(attr_mem, &offset, &error); + } else { + result = dwarf_formref(attr_mem, &offset, &error); + } + + if (result == DW_DLV_OK) { + if (dwarf_offdie(dwarf, offset, &found_die, &error) + != DW_DLV_OK) { + found_die = NULL; + } + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + return found_die; + } + + static std::string get_referenced_die_name( + Dwarf_Debug dwarf, Dwarf_Die die, Dwarf_Half attr, bool global) { + Dwarf_Error error = DW_DLE_NE; + std::string value; + + Dwarf_Die found_die = get_referenced_die(dwarf, die, attr, global); + + if (found_die) { + char *name; + if (dwarf_diename(found_die, &name, &error) == DW_DLV_OK) { + if (name) { + value = std::string(name); + } + dwarf_dealloc(dwarf, name, DW_DLA_STRING); + } + dwarf_dealloc(dwarf, found_die, DW_DLA_DIE); + } + + return value; + } + + // Returns a spec DIE linked to the passed one. The caller should + // deallocate the DIE + static Dwarf_Die get_spec_die(dwarf_fileobject& fobj, Dwarf_Die die) { + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + Dwarf_Error error = DW_DLE_NE; + Dwarf_Off die_offset; + if (fobj.current_cu && dwarf_die_CU_offset(die, &die_offset, &error) + == DW_DLV_OK) { + die_specmap_t::iterator it = + fobj.current_cu->spec_section.find(die_offset); + + // If we have a DIE that completes the current one, check if + // that one has the pc we are looking for + if (it != fobj.current_cu->spec_section.end()) { + Dwarf_Die spec_die = 0; + if (dwarf_offdie(dwarf, it->second, &spec_die, &error) + == DW_DLV_OK) { + return spec_die; + } + } + } + + // Maybe we have an abstract origin DIE with the function information? + return get_referenced_die( + fobj.dwarf_handle.get(), die, DW_AT_abstract_origin, true); + + } + + static bool die_has_pc(dwarf_fileobject& fobj, Dwarf_Die die, Dwarf_Addr pc) + { + Dwarf_Addr low_pc = 0, high_pc = 0; + Dwarf_Half high_pc_form = 0; + Dwarf_Form_Class return_class; + Dwarf_Error error = DW_DLE_NE; + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + bool has_lowpc = false; + bool has_highpc = false; + bool has_ranges = false; + + if (dwarf_lowpc(die, &low_pc, &error) == DW_DLV_OK) { + // If we have a low_pc check if there is a high pc. + // If we don't have a high pc this might mean we have a base + // address for the ranges list or just an address. + has_lowpc = true; + + if (dwarf_highpc_b( + die, &high_pc, &high_pc_form, &return_class, &error) + == DW_DLV_OK) { + // We do have a high pc. In DWARF 4+ this is an offset from the + // low pc, but in earlier versions it's an absolute address. + + has_highpc = true; + // In DWARF 2/3 this would be a DW_FORM_CLASS_ADDRESS + if (return_class == DW_FORM_CLASS_CONSTANT) { + high_pc = low_pc + high_pc; + } + + // We have low and high pc, check if our address + // is in that range + return pc >= low_pc && pc < high_pc; + } + } else { + // Reset the low_pc, in case dwarf_lowpc failing set it to some + // undefined value. + low_pc = 0; + } + + // Check if DW_AT_ranges is present and search for the PC in the + // returned ranges list. We always add the low_pc, as it not set it will + // be 0, in case we had a DW_AT_low_pc and DW_AT_ranges pair + bool result = false; + + Dwarf_Attribute attr; + if (dwarf_attr(die, DW_AT_ranges, &attr, &error) == DW_DLV_OK) { + + Dwarf_Off offset; + if (dwarf_global_formref(attr, &offset, &error) == DW_DLV_OK) { + Dwarf_Ranges *ranges; + Dwarf_Signed ranges_count = 0; + Dwarf_Unsigned byte_count = 0; + + if (dwarf_get_ranges_a(dwarf, offset, die, &ranges, + &ranges_count, &byte_count, &error) == DW_DLV_OK) { + has_ranges = ranges_count != 0; + for (int i = 0; i < ranges_count; i++) { + if (ranges[i].dwr_addr1 != 0 && + pc >= ranges[i].dwr_addr1 + low_pc && + pc < ranges[i].dwr_addr2 + low_pc) { + result = true; + break; + } + } + dwarf_ranges_dealloc(dwarf, ranges, ranges_count); + } + } + } + + // Last attempt. We might have a single address set as low_pc. + if (!result && low_pc != 0 && pc == low_pc) { + result = true; + } + + // If we don't have lowpc, highpc and ranges maybe this DIE is a + // declaration that relies on a DW_AT_specification DIE that happens + // later. Use the specification cache we filled when we loaded this CU. + if (!result && (!has_lowpc && !has_highpc && !has_ranges)) { + Dwarf_Die spec_die = get_spec_die(fobj, die); + if (spec_die) { + result = die_has_pc(fobj, spec_die, pc); + dwarf_dealloc(dwarf, spec_die, DW_DLA_DIE); + } + } + + return result; + } + + static void get_type(Dwarf_Debug dwarf, Dwarf_Die die, std::string& type) { + Dwarf_Error error = DW_DLE_NE; + + Dwarf_Die child = 0; + if (dwarf_child(die, &child, &error) == DW_DLV_OK) { + get_type(dwarf, child, type); + } + + if (child) { + type.insert(0, "::"); + dwarf_dealloc(dwarf, child, DW_DLA_DIE); + } + + char *name; + if (dwarf_diename(die, &name, &error) == DW_DLV_OK) { + type.insert(0, std::string(name)); + dwarf_dealloc(dwarf, name, DW_DLA_STRING); + } else { + type.insert(0,""); + } + } + + static std::string get_type_by_signature(Dwarf_Debug dwarf, Dwarf_Die die) { + Dwarf_Error error = DW_DLE_NE; + + Dwarf_Sig8 signature; + Dwarf_Bool has_attr = 0; + if (dwarf_hasattr(die, DW_AT_signature, + &has_attr, &error) == DW_DLV_OK) { + if (has_attr) { + Dwarf_Attribute attr_mem; + if (dwarf_attr(die, DW_AT_signature, + &attr_mem, &error) == DW_DLV_OK) { + if (dwarf_formsig8(attr_mem, &signature, &error) + != DW_DLV_OK) { + return std::string(""); + } + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + } + + Dwarf_Unsigned next_cu_header; + Dwarf_Sig8 tu_signature; + std::string result; + bool found = false; + + while (dwarf_next_cu_header_d(dwarf, 0, 0, 0, 0, 0, 0, 0, &tu_signature, + 0, &next_cu_header, 0, &error) == DW_DLV_OK) { + + if (strncmp(signature.signature, tu_signature.signature, 8) == 0) { + Dwarf_Die type_cu_die = 0; + if (dwarf_siblingof_b(dwarf, 0, 0, &type_cu_die, &error) + == DW_DLV_OK) { + Dwarf_Die child_die = 0; + if (dwarf_child(type_cu_die, &child_die, &error) + == DW_DLV_OK) { + get_type(dwarf, child_die, result); + found = !result.empty(); + dwarf_dealloc(dwarf, child_die, DW_DLA_DIE); + } + dwarf_dealloc(dwarf, type_cu_die, DW_DLA_DIE); + } + } + } + + if (found) { + while (dwarf_next_cu_header_d(dwarf, 0, 0, 0, 0, 0, 0, 0, 0, 0, + &next_cu_header, 0, &error) == DW_DLV_OK) { + // Reset the cu header state. Unfortunately, libdwarf's + // next_cu_header API keeps its own iterator per Dwarf_Debug + // that can't be reset. We need to keep fetching elements until + // the end. + } + } else { + // If we couldn't resolve the type just print out the signature + std::ostringstream string_stream; + string_stream << "<0x" << + std::hex << std::setfill('0'); + for (int i = 0; i < 8; ++i) { + string_stream << std::setw(2) << std::hex + << (int)(unsigned char)(signature.signature[i]); + } + string_stream << ">"; + result = string_stream.str(); + } + return result; + } + + struct type_context_t { + bool is_const; + bool is_typedef; + bool has_type; + bool has_name; + std::string text; + + type_context_t() : + is_const(false), is_typedef(false), + has_type(false), has_name(false) {} + }; + + // Types are resolved from right to left: we get the variable name first + // and then all specifiers (like const or pointer) in a chain of DW_AT_type + // DIEs. Call this function recursively until we get a complete type + // string. + static void set_parameter_string( + dwarf_fileobject& fobj, Dwarf_Die die, type_context_t &context) { + char *name; + Dwarf_Error error = DW_DLE_NE; + + // typedefs contain also the base type, so we skip it and only + // print the typedef name + if (!context.is_typedef) { + if (dwarf_diename(die, &name, &error) == DW_DLV_OK) { + if (!context.text.empty()) { + context.text.insert(0, " "); + } + context.text.insert(0, std::string(name)); + dwarf_dealloc(fobj.dwarf_handle.get(), name, DW_DLA_STRING); + } + } else { + context.is_typedef = false; + context.has_type = true; + if (context.is_const) { + context.text.insert(0, "const "); + context.is_const = false; + } + } + + bool next_type_is_const = false; + bool is_keyword = true; + + Dwarf_Half tag = 0; + Dwarf_Bool has_attr = 0; + if (dwarf_tag(die, &tag, &error) == DW_DLV_OK) { + switch(tag) { + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + case DW_TAG_enumeration_type: + context.has_type = true; + if (dwarf_hasattr(die, DW_AT_signature, + &has_attr, &error) == DW_DLV_OK) { + // If we have a signature it means the type is defined + // in .debug_types, so we need to load the DIE pointed + // at by the signature and resolve it + if (has_attr) { + std::string type = + get_type_by_signature(fobj.dwarf_handle.get(), die); + if (context.is_const) + type.insert(0, "const "); + + if (!context.text.empty()) + context.text.insert(0, " "); + context.text.insert(0, type); + } + + // Treat enums like typedefs, and skip printing its + // base type + context.is_typedef = (tag == DW_TAG_enumeration_type); + } + break; + case DW_TAG_const_type: + next_type_is_const = true; + break; + case DW_TAG_pointer_type: + context.text.insert(0, "*"); + break; + case DW_TAG_reference_type: + context.text.insert(0, "&"); + break; + case DW_TAG_restrict_type: + context.text.insert(0, "restrict "); + break; + case DW_TAG_rvalue_reference_type: + context.text.insert(0, "&&"); + break; + case DW_TAG_volatile_type: + context.text.insert(0, "volatile "); + break; + case DW_TAG_typedef: + // Propagate the const-ness to the next type + // as typedefs are linked to its base type + next_type_is_const = context.is_const; + context.is_typedef = true; + context.has_type = true; + break; + case DW_TAG_base_type: + context.has_type = true; + break; + case DW_TAG_formal_parameter: + context.has_name = true; + break; + default: + is_keyword = false; + break; + } + } + + if (!is_keyword && context.is_const) { + context.text.insert(0, "const "); + } + + context.is_const = next_type_is_const; + + Dwarf_Die ref = get_referenced_die( + fobj.dwarf_handle.get(), die, DW_AT_type, true); + if (ref) { + set_parameter_string(fobj, ref, context); + dwarf_dealloc(fobj.dwarf_handle.get(), ref, DW_DLA_DIE); + } + + if (!context.has_type && context.has_name) { + context.text.insert(0, "void "); + context.has_type = true; + } + } + + // Resolve the function return type and parameters + static void set_function_parameters(std::string& function_name, + std::vector& ns, + dwarf_fileobject& fobj, Dwarf_Die die) { + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + Dwarf_Error error = DW_DLE_NE; + Dwarf_Die current_die = 0; + std::string parameters; + bool has_spec = true; + // Check if we have a spec DIE. If we do we use it as it contains + // more information, like parameter names. + Dwarf_Die spec_die = get_spec_die(fobj, die); + if (!spec_die) { + has_spec = false; + spec_die = die; + } + + std::vector::const_iterator it = ns.begin(); + std::string ns_name; + for (it = ns.begin(); it < ns.end(); ++it) { + ns_name.append(*it).append("::"); + } + + if (!ns_name.empty()) { + function_name.insert(0, ns_name); + } + + // See if we have a function return type. It can be either on the + // current die or in its spec one (usually true for inlined functions) + std::string return_type = + get_referenced_die_name(dwarf, die, DW_AT_type, true); + if (return_type.empty()) { + return_type = + get_referenced_die_name(dwarf, spec_die, DW_AT_type, true); + } + if (!return_type.empty()) { + return_type.append(" "); + function_name.insert(0, return_type); + } + + if (dwarf_child(spec_die, ¤t_die, &error) == DW_DLV_OK) { + for(;;) { + Dwarf_Die sibling_die = 0; + + Dwarf_Half tag_value; + dwarf_tag(current_die, &tag_value, &error); + + if (tag_value == DW_TAG_formal_parameter) { + // Ignore artificial (ie, compiler generated) parameters + bool is_artificial = false; + Dwarf_Attribute attr_mem; + if (dwarf_attr( + current_die, DW_AT_artificial, &attr_mem, &error) + == DW_DLV_OK) { + Dwarf_Bool flag = 0; + if (dwarf_formflag(attr_mem, &flag, &error) + == DW_DLV_OK) { + is_artificial = flag != 0; + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + + if (!is_artificial) { + type_context_t context; + set_parameter_string(fobj, current_die, context); + + if (parameters.empty()) { + parameters.append("("); + } else { + parameters.append(", "); + } + parameters.append(context.text); + } + } + + int result = dwarf_siblingof( + dwarf, current_die, &sibling_die, &error); + if (result == DW_DLV_ERROR) { + break; + } else if (result == DW_DLV_NO_ENTRY) { + break; + } + + if (current_die != die) { + dwarf_dealloc(dwarf, current_die, DW_DLA_DIE); + current_die = 0; + } + + current_die = sibling_die; + } + } + if (parameters.empty()) + parameters = "("; + parameters.append(")"); + + // If we got a spec DIE we need to deallocate it + if (has_spec) + dwarf_dealloc(dwarf, spec_die, DW_DLA_DIE); + + function_name.append(parameters); + } + + // defined here because in C++98, template function cannot take locally + // defined types... grrr. + struct inliners_search_cb { + void operator()(Dwarf_Die die, std::vector& ns) { + Dwarf_Error error = DW_DLE_NE; + Dwarf_Half tag_value; + Dwarf_Attribute attr_mem; + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + + dwarf_tag(die, &tag_value, &error); + + switch (tag_value) { + char* name; + case DW_TAG_subprogram: + if (!trace.source.function.empty()) + break; + if (dwarf_diename(die, &name, &error) == DW_DLV_OK) { + trace.source.function = std::string(name); + dwarf_dealloc(dwarf, name, DW_DLA_STRING); + } else { + // We don't have a function name in this DIE. + // Check if there is a referenced non-defining + // declaration. + trace.source.function = get_referenced_die_name( + dwarf, die, DW_AT_abstract_origin, true); + if (trace.source.function.empty()) { + trace.source.function = get_referenced_die_name( + dwarf, die, DW_AT_specification, true); + } + } + + // Append the function parameters, if available + set_function_parameters( + trace.source.function, ns, fobj, die); + + // If the object function name is empty, it's possible that + // there is no dynamic symbol table (maybe the executable + // was stripped or not built with -rdynamic). See if we have + // a DWARF linkage name to use instead. We try both + // linkage_name and MIPS_linkage_name because the MIPS tag + // was the unofficial one until it was adopted in DWARF4. + // Old gcc versions generate MIPS_linkage_name + if (trace.object_function.empty()) { + details::demangler demangler; + + if (dwarf_attr(die, DW_AT_linkage_name, + &attr_mem, &error) != DW_DLV_OK) { + if (dwarf_attr(die, DW_AT_MIPS_linkage_name, + &attr_mem, &error) != DW_DLV_OK) { + break; + } + } + + char* linkage; + if (dwarf_formstring(attr_mem, &linkage, &error) + == DW_DLV_OK) { + trace.object_function = demangler.demangle(linkage); + dwarf_dealloc(dwarf, linkage, DW_DLA_STRING); + } + dwarf_dealloc(dwarf, name, DW_DLA_ATTR); + } + break; + + case DW_TAG_inlined_subroutine: + ResolvedTrace::SourceLoc sloc; + + if (dwarf_diename(die, &name, &error) == DW_DLV_OK) { + sloc.function = std::string(name); + dwarf_dealloc(dwarf, name, DW_DLA_STRING); + } else { + // We don't have a name for this inlined DIE, it could + // be that there is an abstract origin instead. + // Get the DW_AT_abstract_origin value, which is a + // reference to the source DIE and try to get its name + sloc.function = get_referenced_die_name( + dwarf, die, DW_AT_abstract_origin, true); + } + + set_function_parameters(sloc.function, ns, fobj, die); + + std::string file = die_call_file(dwarf, die, cu_die); + if (!file.empty()) + sloc.filename = file; + + Dwarf_Unsigned number = 0; + if (dwarf_attr(die, DW_AT_call_line, &attr_mem, &error) + == DW_DLV_OK) { + if (dwarf_formudata(attr_mem, &number, &error) + == DW_DLV_OK) { + sloc.line = number; + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + + if (dwarf_attr(die, DW_AT_call_column, &attr_mem, &error) + == DW_DLV_OK) { + if (dwarf_formudata(attr_mem, &number, &error) + == DW_DLV_OK) { + sloc.col = number; + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + + trace.inliners.push_back(sloc); + break; + }; + } + ResolvedTrace& trace; + dwarf_fileobject& fobj; + Dwarf_Die cu_die; + inliners_search_cb(ResolvedTrace& t, dwarf_fileobject& f, Dwarf_Die c) + : trace(t), fobj(f), cu_die(c) {} + }; + + static Dwarf_Die find_fundie_by_pc(dwarf_fileobject& fobj, + Dwarf_Die parent_die, Dwarf_Addr pc, Dwarf_Die result) { + Dwarf_Die current_die = 0; + Dwarf_Error error = DW_DLE_NE; + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + + if (dwarf_child(parent_die, ¤t_die, &error) != DW_DLV_OK) { + return NULL; + } + + for(;;) { + Dwarf_Die sibling_die = 0; + Dwarf_Half tag_value; + dwarf_tag(current_die, &tag_value, &error); + + switch (tag_value) { + case DW_TAG_subprogram: + case DW_TAG_inlined_subroutine: + if (die_has_pc(fobj, current_die, pc)) { + return current_die; + } + }; + bool declaration = false; + Dwarf_Attribute attr_mem; + if (dwarf_attr(current_die, DW_AT_declaration, &attr_mem, &error) + == DW_DLV_OK) { + Dwarf_Bool flag = 0; + if (dwarf_formflag(attr_mem, &flag, &error) == DW_DLV_OK) { + declaration = flag != 0; + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + + if (!declaration) { + // let's be curious and look deeper in the tree, functions are + // not necessarily at the first level, but might be nested + // inside a namespace, structure, a function, an inlined + // function etc. + Dwarf_Die die_mem = 0; + Dwarf_Die indie = find_fundie_by_pc( + fobj, current_die, pc, die_mem); + if (indie) { + result = die_mem; + return result; + } + } + + int res = dwarf_siblingof( + dwarf, current_die, &sibling_die, &error); + if (res == DW_DLV_ERROR) { + return NULL; + } else if (res == DW_DLV_NO_ENTRY) { + break; + } + + if (current_die != parent_die) { + dwarf_dealloc(dwarf, current_die, DW_DLA_DIE); + current_die = 0; + } + + current_die = sibling_die; + } + return NULL; + } + + template + static bool deep_first_search_by_pc(dwarf_fileobject& fobj, + Dwarf_Die parent_die, Dwarf_Addr pc, + std::vector& ns, CB cb) { + Dwarf_Die current_die = 0; + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + Dwarf_Error error = DW_DLE_NE; + + if (dwarf_child(parent_die, ¤t_die, &error) != DW_DLV_OK) { + return false; + } + + bool branch_has_pc = false; + bool has_namespace = false; + for(;;) { + Dwarf_Die sibling_die = 0; + + Dwarf_Half tag; + if (dwarf_tag(current_die, &tag, &error) == DW_DLV_OK) { + if (tag == DW_TAG_namespace || tag == DW_TAG_class_type) { + char* ns_name = NULL; + if (dwarf_diename(current_die, &ns_name, &error) + == DW_DLV_OK) { + if (ns_name) { + ns.push_back(std::string(ns_name)); + } else { + ns.push_back(""); + } + dwarf_dealloc(dwarf, ns_name, DW_DLA_STRING); + } else { + ns.push_back(""); + } + has_namespace = true; + } + } + + bool declaration = false; + Dwarf_Attribute attr_mem; + if (tag != DW_TAG_class_type && + dwarf_attr(current_die, DW_AT_declaration, &attr_mem, &error) + == DW_DLV_OK) { + Dwarf_Bool flag = 0; + if (dwarf_formflag(attr_mem, &flag, &error) == DW_DLV_OK) { + declaration = flag != 0; + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + } + + if (!declaration) { + // let's be curious and look deeper in the tree, function are + // not necessarily at the first level, but might be nested + // inside a namespace, structure, a function, an inlined + // function etc. + branch_has_pc = deep_first_search_by_pc( + fobj, current_die, pc, ns, cb); + } + + if (!branch_has_pc) { + branch_has_pc = die_has_pc(fobj, current_die, pc); + } + + if (branch_has_pc) { + cb(current_die, ns); + } + + int result = dwarf_siblingof( + dwarf, current_die, &sibling_die, &error); + if (result == DW_DLV_ERROR) { + return false; + } else if (result == DW_DLV_NO_ENTRY) { + break; + } + + if (current_die != parent_die) { + dwarf_dealloc(dwarf, current_die, DW_DLA_DIE); + current_die = 0; + } + + if (has_namespace) { + has_namespace = false; + ns.pop_back(); + } + current_die = sibling_die; + } + + if (has_namespace) { + ns.pop_back(); + } + return branch_has_pc; + } + + static std::string die_call_file( + Dwarf_Debug dwarf, Dwarf_Die die, Dwarf_Die cu_die) { + Dwarf_Attribute attr_mem; + Dwarf_Error error = DW_DLE_NE; + Dwarf_Signed file_index; + + std::string file; + + if (dwarf_attr(die, DW_AT_call_file, &attr_mem, &error) == DW_DLV_OK) { + if (dwarf_formsdata(attr_mem, &file_index, &error) != DW_DLV_OK) { + file_index = 0; + } + dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR); + + if (file_index == 0) { + return file; + } + + char **srcfiles = 0; + Dwarf_Signed file_count = 0; + if (dwarf_srcfiles(cu_die, &srcfiles, &file_count, &error) + == DW_DLV_OK) { + if (file_index <= file_count) + file = std::string(srcfiles[file_index - 1]); + + // Deallocate all strings! + for (int i = 0; i < file_count; ++i) { + dwarf_dealloc(dwarf, srcfiles[i], DW_DLA_STRING); + } + dwarf_dealloc(dwarf, srcfiles, DW_DLA_LIST); + } + } + return file; + } + + + Dwarf_Die find_die(dwarf_fileobject& fobj, Dwarf_Addr addr) + { + // Let's get to work! First see if we have a debug_aranges section so + // we can speed up the search + + Dwarf_Debug dwarf = fobj.dwarf_handle.get(); + Dwarf_Error error = DW_DLE_NE; + Dwarf_Arange *aranges; + Dwarf_Signed arange_count; + + Dwarf_Die returnDie; + bool found = false; + if (dwarf_get_aranges( + dwarf, &aranges, &arange_count, &error) != DW_DLV_OK) { + aranges = NULL; + } + + if (aranges) { + // We have aranges. Get the one where our address is. + Dwarf_Arange arange; + if (dwarf_get_arange( + aranges, arange_count, addr, &arange, &error) + == DW_DLV_OK) { + + // We found our address. Get the compilation-unit DIE offset + // represented by the given address range. + Dwarf_Off cu_die_offset; + if (dwarf_get_cu_die_offset(arange, &cu_die_offset, &error) + == DW_DLV_OK) { + // Get the DIE at the offset returned by the aranges search. + // We set is_info to 1 to specify that the offset is from + // the .debug_info section (and not .debug_types) + int dwarf_result = dwarf_offdie_b( + dwarf, cu_die_offset, 1, &returnDie, &error); + + found = dwarf_result == DW_DLV_OK; + } + dwarf_dealloc(dwarf, arange, DW_DLA_ARANGE); + } + } + + if (found) + return returnDie; // The caller is responsible for freeing the die + + // The search for aranges failed. Try to find our address by scanning + // all compilation units. + Dwarf_Unsigned next_cu_header; + Dwarf_Half tag = 0; + returnDie = 0; + + while (!found && dwarf_next_cu_header_d(dwarf, 1, 0, 0, 0, 0, 0, 0, 0, 0, + &next_cu_header, 0, &error) == DW_DLV_OK) { + + if (returnDie) + dwarf_dealloc(dwarf, returnDie, DW_DLA_DIE); + + if (dwarf_siblingof(dwarf, 0, &returnDie, &error) == DW_DLV_OK) { + if ((dwarf_tag(returnDie, &tag, &error) == DW_DLV_OK) + && tag == DW_TAG_compile_unit) { + if (die_has_pc(fobj, returnDie, addr)) { + found = true; + } + } + } + } + + if (found) { + while (dwarf_next_cu_header_d(dwarf, 1, 0, 0, 0, 0, 0, 0, 0, 0, + &next_cu_header, 0, &error) == DW_DLV_OK) { + // Reset the cu header state. Libdwarf's next_cu_header API + // keeps its own iterator per Dwarf_Debug that can't be reset. + // We need to keep fetching elements until the end. + } + } + + if (found) + return returnDie; + + // We couldn't find any compilation units with ranges or a high/low pc. + // Try again by looking at all DIEs in all compilation units. + Dwarf_Die cudie; + while (dwarf_next_cu_header_d(dwarf, 1, 0, 0, 0, 0, 0, 0, 0, 0, + &next_cu_header, 0, &error) == DW_DLV_OK) { + if (dwarf_siblingof(dwarf, 0, &cudie, &error) == DW_DLV_OK) { + Dwarf_Die die_mem = 0; + Dwarf_Die resultDie = find_fundie_by_pc( + fobj, cudie, addr, die_mem); + + if (resultDie) { + found = true; + break; + } + } + } + + if (found) { + while (dwarf_next_cu_header_d(dwarf, 1, 0, 0, 0, 0, 0, 0, 0, 0, + &next_cu_header, 0, &error) == DW_DLV_OK) { + // Reset the cu header state. Libdwarf's next_cu_header API + // keeps its own iterator per Dwarf_Debug that can't be reset. + // We need to keep fetching elements until the end. + } + } + + if (found) + return cudie; + + // We failed. + return NULL; + } +}; +#endif // BACKWARD_HAS_DWARF == 1 + +template<> +class TraceResolverImpl: + public TraceResolverLinuxImpl {}; + +#endif // BACKWARD_SYSTEM_LINUX + +#ifdef BACKWARD_SYSTEM_DARWIN + +template +class TraceResolverDarwinImpl; + +template <> +class TraceResolverDarwinImpl: + public TraceResolverImplBase { +public: + template + void load_stacktrace(ST& st) { + using namespace details; + if (st.size() == 0) { + return; + } + _symbols.reset( + backtrace_symbols(st.begin(), st.size()) + ); + } + + ResolvedTrace resolve(ResolvedTrace trace) { + // parse: + // + + char* filename = _symbols[trace.idx]; + + // skip " " + while(*filename && *filename != ' ') filename++; + while(*filename == ' ') filename++; + + // find start of from end ( may contain a space) + char* p = filename + strlen(filename) - 1; + // skip to start of " + " + while(p > filename && *p != ' ') p--; + while(p > filename && *p == ' ') p--; + while(p > filename && *p != ' ') p--; + while(p > filename && *p == ' ') p--; + char *funcname_end = p + 1; + + // skip to start of "" + while(p > filename && *p != ' ') p--; + char *funcname = p + 1; + + // skip to start of " " + while(p > filename && *p == ' ') p--; + while(p > filename && *p != ' ') p--; + while(p > filename && *p == ' ') p--; + + // skip "", handling the case where it contains a + char* filename_end = p + 1; + if (p == filename) { + // something went wrong, give up + filename_end = filename + strlen(filename); + funcname = filename_end; + } + trace.object_filename.assign(filename, filename_end); // ok even if filename_end is the ending \0 (then we assign entire string) + + if (*funcname) { // if it's not end of string + *funcname_end = '\0'; + + trace.object_function = this->demangle(funcname); + trace.object_function += " "; + trace.object_function += (funcname_end + 1); + trace.source.function = trace.object_function; // we cannot do better. + } + return trace; + } + +private: + details::handle _symbols; +}; + +template<> +class TraceResolverImpl: + public TraceResolverDarwinImpl {}; + +#endif // BACKWARD_SYSTEM_DARWIN + +class TraceResolver: + public TraceResolverImpl {}; + +/*************** CODE SNIPPET ***************/ + +class SourceFile { +public: + typedef std::vector > lines_t; + + SourceFile() {} + SourceFile(const std::string& path): _file(new std::ifstream(path.c_str())) {} + bool is_open() const { return _file->is_open(); } + + lines_t& get_lines(unsigned line_start, unsigned line_count, lines_t& lines) { + using namespace std; + // This function make uses of the dumbest algo ever: + // 1) seek(0) + // 2) read lines one by one and discard until line_start + // 3) read line one by one until line_start + line_count + // + // If you are getting snippets many time from the same file, it is + // somewhat a waste of CPU, feel free to benchmark and propose a + // better solution ;) + + _file->clear(); + _file->seekg(0); + string line; + unsigned line_idx; + + for (line_idx = 1; line_idx < line_start; ++line_idx) { + std::getline(*_file, line); + if (!*_file) { + return lines; + } + } + + // think of it like a lambda in C++98 ;) + // but look, I will reuse it two times! + // What a good boy am I. + struct isspace { + bool operator()(char c) { + return std::isspace(c); + } + }; + + bool started = false; + for (; line_idx < line_start + line_count; ++line_idx) { + getline(*_file, line); + if (!*_file) { + return lines; + } + if (!started) { + if (std::find_if(line.begin(), line.end(), + not_isspace()) == line.end()) + continue; + started = true; + } + lines.push_back(make_pair(line_idx, line)); + } + + lines.erase( + std::find_if(lines.rbegin(), lines.rend(), + not_isempty()).base(), lines.end() + ); + return lines; + } + + lines_t get_lines(unsigned line_start, unsigned line_count) { + lines_t lines; + return get_lines(line_start, line_count, lines); + } + + // there is no find_if_not in C++98, lets do something crappy to + // workaround. + struct not_isspace { + bool operator()(char c) { + return !std::isspace(c); + } + }; + // and define this one here because C++98 is not happy with local defined + // struct passed to template functions, fuuuu. + struct not_isempty { + bool operator()(const lines_t::value_type& p) { + return !(std::find_if(p.second.begin(), p.second.end(), + not_isspace()) == p.second.end()); + } + }; + + void swap(SourceFile& b) { + _file.swap(b._file); + } + +#ifdef BACKWARD_ATLEAST_CXX11 + SourceFile(SourceFile&& from): _file(nullptr) { + swap(from); + } + SourceFile& operator=(SourceFile&& from) { + swap(from); return *this; + } +#else + explicit SourceFile(const SourceFile& from) { + // some sort of poor man's move semantic. + swap(const_cast(from)); + } + SourceFile& operator=(const SourceFile& from) { + // some sort of poor man's move semantic. + swap(const_cast(from)); return *this; + } +#endif + +private: + details::handle + > _file; + +#ifdef BACKWARD_ATLEAST_CXX11 + SourceFile(const SourceFile&) = delete; + SourceFile& operator=(const SourceFile&) = delete; +#endif +}; + +class SnippetFactory { +public: + typedef SourceFile::lines_t lines_t; + + lines_t get_snippet(const std::string& filename, + unsigned line_start, unsigned context_size) { + + SourceFile& src_file = get_src_file(filename); + unsigned start = line_start - context_size / 2; + return src_file.get_lines(start, context_size); + } + + lines_t get_combined_snippet( + const std::string& filename_a, unsigned line_a, + const std::string& filename_b, unsigned line_b, + unsigned context_size) { + SourceFile& src_file_a = get_src_file(filename_a); + SourceFile& src_file_b = get_src_file(filename_b); + + lines_t lines = src_file_a.get_lines(line_a - context_size / 4, + context_size / 2); + src_file_b.get_lines(line_b - context_size / 4, context_size / 2, + lines); + return lines; + } + + lines_t get_coalesced_snippet(const std::string& filename, + unsigned line_a, unsigned line_b, unsigned context_size) { + SourceFile& src_file = get_src_file(filename); + + using std::min; using std::max; + unsigned a = min(line_a, line_b); + unsigned b = max(line_a, line_b); + + if ((b - a) < (context_size / 3)) { + return src_file.get_lines((a + b - context_size + 1) / 2, + context_size); + } + + lines_t lines = src_file.get_lines(a - context_size / 4, + context_size / 2); + src_file.get_lines(b - context_size / 4, context_size / 2, lines); + return lines; + } + + +private: + typedef details::hashtable::type src_files_t; + src_files_t _src_files; + + SourceFile& get_src_file(const std::string& filename) { + src_files_t::iterator it = _src_files.find(filename); + if (it != _src_files.end()) { + return it->second; + } + SourceFile& new_src_file = _src_files[filename]; + new_src_file = SourceFile(filename); + return new_src_file; + } +}; + +/*************** PRINTER ***************/ + +namespace ColorMode { + enum type { + automatic, + never, + always + }; +} + +class cfile_streambuf: public std::streambuf { +public: + cfile_streambuf(FILE *_sink): sink(_sink) {} + int_type underflow() override { return traits_type::eof(); } + int_type overflow(int_type ch) override { + if (traits_type::not_eof(ch) && fwrite(&ch, sizeof ch, 1, sink) == 1) { + return ch; + } + return traits_type::eof(); + } + + std::streamsize xsputn(const char_type* s, std::streamsize count) override { + return static_cast(fwrite(s, sizeof *s, static_cast(count), sink)); + } + +#ifdef BACKWARD_ATLEAST_CXX11 +public: + cfile_streambuf(const cfile_streambuf&) = delete; + cfile_streambuf& operator=(const cfile_streambuf&) = delete; +#else +private: + cfile_streambuf(const cfile_streambuf &); + cfile_streambuf &operator= (const cfile_streambuf &); +#endif + +private: + FILE *sink; + std::vector buffer; +}; + +#ifdef BACKWARD_SYSTEM_LINUX + +namespace Color { + enum type { + yellow = 33, + purple = 35, + reset = 39 + }; +} // namespace Color + +class Colorize { +public: + Colorize(std::ostream& os): + _os(os), _reset(false), _enabled(false) {} + + void activate(ColorMode::type mode) { + _enabled = mode == ColorMode::always; + } + + void activate(ColorMode::type mode, FILE* fp) { + activate(mode, fileno(fp)); + } + + void set_color(Color::type ccode) { + if (!_enabled) return; + + // I assume that the terminal can handle basic colors. Seriously I + // don't want to deal with all the termcap shit. + _os << "\033[" << static_cast(ccode) << "m"; + _reset = (ccode != Color::reset); + } + + ~Colorize() { + if (_reset) { + set_color(Color::reset); + } + } + +private: + void activate(ColorMode::type mode, int fd) { + activate(mode == ColorMode::automatic && isatty(fd) ? ColorMode::always : mode); + } + + std::ostream& _os; + bool _reset; + bool _enabled; +}; + +#else // ndef BACKWARD_SYSTEM_LINUX + +namespace Color { + enum type { + yellow = 0, + purple = 0, + reset = 0 + }; +} // namespace Color + +class Colorize { +public: + Colorize(std::ostream&) {} + void activate(ColorMode::type) {} + void activate(ColorMode::type, FILE*) {} + void set_color(Color::type) {} +}; + +#endif // BACKWARD_SYSTEM_LINUX + +class Printer { +public: + + bool snippet; + ColorMode::type color_mode; + bool address; + bool object; + int inliner_context_size; + int trace_context_size; + + Printer(): + snippet(true), + color_mode(ColorMode::automatic), + address(false), + object(false), + inliner_context_size(5), + trace_context_size(7) + {} + + template + FILE* print(ST& st, FILE* fp = stderr) { + cfile_streambuf obuf(fp); + std::ostream os(&obuf); + Colorize colorize(os); + colorize.activate(color_mode, fp); + print_stacktrace(st, os, colorize); + return fp; + } + + template + std::ostream& print(ST& st, std::ostream& os) { + Colorize colorize(os); + colorize.activate(color_mode); + print_stacktrace(st, os, colorize); + return os; + } + + template + FILE* print(IT begin, IT end, FILE* fp = stderr, size_t thread_id = 0) { + cfile_streambuf obuf(fp); + std::ostream os(&obuf); + Colorize colorize(os); + colorize.activate(color_mode, fp); + print_stacktrace(begin, end, os, thread_id, colorize); + return fp; + } + + template + std::ostream& print(IT begin, IT end, std::ostream& os, size_t thread_id = 0) { + Colorize colorize(os); + colorize.activate(color_mode); + print_stacktrace(begin, end, os, thread_id, colorize); + return os; + } + +private: + TraceResolver _resolver; + SnippetFactory _snippets; + + template + void print_stacktrace(ST& st, std::ostream& os, Colorize& colorize) { + print_header(os, st.thread_id()); + _resolver.load_stacktrace(st); + for (size_t trace_idx = st.size(); trace_idx > 0; --trace_idx) { + print_trace(os, _resolver.resolve(st[trace_idx-1]), colorize); + } + } + + template + void print_stacktrace(IT begin, IT end, std::ostream& os, size_t thread_id, Colorize& colorize) { + print_header(os, thread_id); + for (; begin != end; ++begin) { + print_trace(os, *begin, colorize); + } + } + + void print_header(std::ostream& os, size_t thread_id) { + os << "Stack trace (most recent call last)"; + if (thread_id) { + os << " in thread " << thread_id; + } + os << ":\n"; + } + + void print_trace(std::ostream& os, const ResolvedTrace& trace, + Colorize& colorize) { + os << "#" + << std::left << std::setw(2) << trace.idx + << std::right; + bool already_indented = true; + + if (!trace.source.filename.size() || object) { + os << " Object \"" + << trace.object_filename + << "\", at " + << trace.addr + << ", in " + << trace.object_function + << "\n"; + already_indented = false; + } + + for (size_t inliner_idx = trace.inliners.size(); + inliner_idx > 0; --inliner_idx) { + if (!already_indented) { + os << " "; + } + const ResolvedTrace::SourceLoc& inliner_loc + = trace.inliners[inliner_idx-1]; + print_source_loc(os, " | ", inliner_loc); + if (snippet) { + print_snippet(os, " | ", inliner_loc, + colorize, Color::purple, inliner_context_size); + } + already_indented = false; + } + + if (trace.source.filename.size()) { + if (!already_indented) { + os << " "; + } + print_source_loc(os, " ", trace.source, trace.addr); + if (snippet) { + print_snippet(os, " ", trace.source, + colorize, Color::yellow, trace_context_size); + } + } + } + + void print_snippet(std::ostream& os, const char* indent, + const ResolvedTrace::SourceLoc& source_loc, + Colorize& colorize, Color::type color_code, + int context_size) + { + using namespace std; + typedef SnippetFactory::lines_t lines_t; + + lines_t lines = _snippets.get_snippet(source_loc.filename, + source_loc.line, static_cast(context_size)); + + for (lines_t::const_iterator it = lines.begin(); + it != lines.end(); ++it) { + if (it-> first == source_loc.line) { + colorize.set_color(color_code); + os << indent << ">"; + } else { + os << indent << " "; + } + os << std::setw(4) << it->first + << ": " + << it->second + << "\n"; + if (it-> first == source_loc.line) { + colorize.set_color(Color::reset); + } + } + } + + void print_source_loc(std::ostream& os, const char* indent, + const ResolvedTrace::SourceLoc& source_loc, + void* addr=nullptr) { + os << indent + << "Source \"" + << source_loc.filename + << "\", line " + << source_loc.line + << ", in " + << source_loc.function; + + if (address && addr != nullptr) { + os << " [" << addr << "]"; + } + os << "\n"; + } +}; + +/*************** SIGNALS HANDLING ***************/ + +#if defined(BACKWARD_SYSTEM_LINUX) || defined(BACKWARD_SYSTEM_DARWIN) + + +class SignalHandling { +public: + static std::vector make_default_signals() { + const int posix_signals[] = { + // Signals for which the default action is "Core". + SIGABRT, // Abort signal from abort(3) + SIGBUS, // Bus error (bad memory access) + SIGFPE, // Floating point exception + SIGILL, // Illegal Instruction + SIGIOT, // IOT trap. A synonym for SIGABRT + SIGQUIT, // Quit from keyboard + SIGSEGV, // Invalid memory reference + SIGSYS, // Bad argument to routine (SVr4) + SIGTRAP, // Trace/breakpoint trap + SIGXCPU, // CPU time limit exceeded (4.2BSD) + SIGXFSZ, // File size limit exceeded (4.2BSD) +#if defined(BACKWARD_SYSTEM_DARWIN) + SIGEMT, // emulation instruction executed +#endif + }; + return std::vector(posix_signals, posix_signals + sizeof posix_signals / sizeof posix_signals[0] ); + } + + SignalHandling(const std::vector& posix_signals = make_default_signals()): + _loaded(false) { + bool success = true; + + const size_t stack_size = 1024 * 1024 * 8; + _stack_content.reset(static_cast(malloc(stack_size))); + if (_stack_content) { + stack_t ss; + ss.ss_sp = _stack_content.get(); + ss.ss_size = stack_size; + ss.ss_flags = 0; + if (sigaltstack(&ss, nullptr) < 0) { + success = false; + } + } else { + success = false; + } + + for (size_t i = 0; i < posix_signals.size(); ++i) { + struct sigaction action; + memset(&action, 0, sizeof action); + action.sa_flags = static_cast(SA_SIGINFO | SA_ONSTACK | SA_NODEFER | + SA_RESETHAND); + sigfillset(&action.sa_mask); + sigdelset(&action.sa_mask, posix_signals[i]); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdisabled-macro-expansion" + action.sa_sigaction = &sig_handler; +#pragma clang diagnostic pop + + int r = sigaction(posix_signals[i], &action, nullptr); + if (r < 0) success = false; + } + + _loaded = success; + } + + bool loaded() const { return _loaded; } + + static void handleSignal(int, siginfo_t* info, void* _ctx) { + ucontext_t *uctx = static_cast(_ctx); + + StackTrace st; + void* error_addr = nullptr; +#ifdef REG_RIP // x86_64 + error_addr = reinterpret_cast(uctx->uc_mcontext.gregs[REG_RIP]); +#elif defined(REG_EIP) // x86_32 + error_addr = reinterpret_cast(uctx->uc_mcontext.gregs[REG_EIP]); +#elif defined(__arm__) + error_addr = reinterpret_cast(uctx->uc_mcontext.arm_pc); +#elif defined(__aarch64__) + error_addr = reinterpret_cast(uctx->uc_mcontext.pc); +#elif defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) + error_addr = reinterpret_cast(uctx->uc_mcontext.regs->nip); +#elif defined(__s390x__) + error_addr = reinterpret_cast(uctx->uc_mcontext.psw.addr); +#elif defined(__APPLE__) && defined(__x86_64__) + error_addr = reinterpret_cast(uctx->uc_mcontext->__ss.__rip); +#elif defined(__APPLE__) + error_addr = reinterpret_cast(uctx->uc_mcontext->__ss.__eip); +#else +# warning ":/ sorry, ain't know no nothing none not of your architecture!" +#endif + if (error_addr) { + st.load_from(error_addr, 32); + } else { + st.load_here(32); + } + + Printer printer; + printer.address = true; + printer.print(st, stderr); + +#if _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L + psiginfo(info, nullptr); +#else + (void)info; +#endif + } + +private: + details::handle _stack_content; + bool _loaded; + +#ifdef __GNUC__ + __attribute__((noreturn)) +#endif + static void sig_handler(int signo, siginfo_t* info, void* _ctx) { + handleSignal(signo, info, _ctx); + + // try to forward the signal. + raise(info->si_signo); + + // terminate the process immediately. + puts("watf? exit"); + _exit(EXIT_FAILURE); + } +}; + +#endif // BACKWARD_SYSTEM_LINUX || BACKWARD_SYSTEM_DARWIN + +#ifdef BACKWARD_SYSTEM_UNKNOWN + +class SignalHandling { +public: + SignalHandling(const std::vector& = std::vector()) {} + bool init() { return false; } + bool loaded() { return false; } +}; + +#endif // BACKWARD_SYSTEM_UNKNOWN + +} // namespace backward + +#endif /* H_GUARD */ diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/builds.sh b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/builds.sh new file mode 100644 index 0000000..6e1fb20 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/builds.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +COMPILERS_CXX98=`cat</dev/null + ( + cd "$builddir" + cmake -DCMAKE_BUILD_TYPE=$buildtype -DBACKWARD_TESTS=ON .. + ) +} + +function build() { + local builddir=$1 + shift + make -C "$builddir" $@ +} + +function dotest() { + local builddir=$1 + shift + make -C "$builddir" test $@ + return 0 +} + +function do_action() { + local lang=$1 + local action=$2 + shift 2 + + for compiler in $COMPILERS; do + local builddir="build_${lang}_${compiler}" + + if [[ $action == "cmake" ]]; then + buildtype=$1 + mkbuild $compiler $lang "$buildtype" "$builddir" + [[ $? != 0 ]] && exit + elif [[ $action == "make" ]]; then + build "$builddir" $@ + [[ $? != 0 ]] && exit + elif [[ $action == "test" ]]; then + dotest "$builddir" $@ + [[ $? != 0 ]] && exit + elif [[ $action == "clean" ]]; then + rm -r "$builddir" + else + echo "usage: $0 cmake [debug|release|relwithdbg]|make|test|clean" + exit 255 + fi + done +} + +COMPILERS=$COMPILERS_CXX98 +do_action c++98 $@ +COMPILERS=$COMPILERS_CXX11 +do_action c++11 $@ diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/conanfile.py b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/conanfile.py new file mode 100644 index 0000000..d174b25 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/conanfile.py @@ -0,0 +1,45 @@ +from conans import ConanFile, CMake +import os + +class BackwardCpp(ConanFile): + settings = 'os', 'compiler', 'build_type', 'arch' + name = 'backward' + url = 'https://github.com/bombela/backward-cpp' + license = 'MIT' + version = '1.3.0' + options = { + 'stack_walking_unwind': [True, False], + 'stack_walking_backtrace': [True, False], + 'stack_details_auto_detect': [True, False], + 'stack_details_backtrace_symbol': [True, False], + 'stack_details_dw': [True, False], + 'stack_details_bfd': [True, False], + 'shared': [True, False] + } + default_options = ( + 'stack_walking_unwind=True', + 'stack_walking_backtrace=False', + 'stack_details_auto_detect=True', + 'stack_details_backtrace_symbol=False', + 'stack_details_dw=False', + 'stack_details_bfd=False', + 'shared=False' + ) + exports = 'backward.cpp', 'backward.hpp', 'test/*', 'CMakeLists.txt', 'BackwardConfig.cmake' + generators = 'cmake' + + def build(self): + cmake = CMake(self) + + cmake.configure(defs={'BACKWARD_' + name.upper(): value for name, value in self.options.values.as_list()}) + cmake.build() + + def package(self): + self.copy('backward.hpp', os.path.join('include', 'backward')) + self.copy('*.a', dst='lib') + self.copy('*.so', dst='lib') + self.copy('*.lib', dst='lib') + self.copy('*.dll', dst='lib') + + def package_info(self): + self.cpp_info.libs = ['backward'] diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/doc/nice.png b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/doc/nice.png new file mode 100644 index 0000000000000000000000000000000000000000..42147e5947b7fcfa852a571f47d9c36d9e31fcd5 GIT binary patch literal 40904 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 rm81GE!8#VGu$Pho_;sb6S@6FAF^e|a literal 0 HcmV?d00001 diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/doc/pretty.png b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/doc/pretty.png new file mode 100644 index 0000000000000000000000000000000000000000..f95d66ee0be9e821dcc7f97f05443ff5e889ee59 GIT binary patch literal 105498 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
I+M7TnYg*;R1m)mRSLg-afM&- zR!jsCSNb*PUXGej(G=_KUKy(}@jtYfv|6|j!WgW6k=)gJ_(UAI{-v{LZRS9yF~JUg z<>VH=UaRe}@~$|)+gSZ?T6%9Fj0mLQxW(z7Hz70MZ$A^p z?7upb`8>IXye+ddJ0_l95U`naWn^6c+fZvI>0}BDvPX4cimN;DnybsG^B#>!mRCEH z2$ZzX*-tw|Vy`O!cm9C^fGwE*PBNWG=xVuAg^ZAh^YdrsbAiY~u_w)fwpA}dg$vTy zpB`fmWFFmbl>+}*BX!u$|7l@1ly-4A2!vjlv7~5%HkpNODks8+as>v`wp*<_Sp3rY z)``A()&Ck~8cs@Lzf6`m%0t&28779d=c%G)TZ1EOFdqtfq6dafz}XVG1Z`AzU{FQQeBmWLNNGr@bRZx2FH`uWgmRx3?+WUzbmmOy+7{mG0&!>XQY( zSVG(#V?@i016XYv%3g9MH}npoE`N0i*^3dpU-@EYeB(IFfM~**Rd%B+V7jY5v(=+K z`Iug~Uhx%nUDR{?>AhxMsn(ottL!8+0rRy>deW;=w=WIflPq?Q*J9?r4Y4?3n*g8M z2CD6#lBI~6=8AEl{PjATQ30e=tLdY?*>UWz(;_tFj7N4!09mow$cGt!cL|$4qb71n zT=NqE3aZomi(4QRi(2Nzk&!PoQ9)8*4jh*5@KG(p9C|8uTLPH05pSL;Goyv5bxHwv zP`F0~Lo~}H7E`wCs^Xc?WhH9;$T%lNUX3rSrloo)4ZI8!5Zad+_ANdZCoSC>{y=L| zn$=+Fb3u}<(CRG?@_B?^DMr9|i(MbU2ts4hiAp!CcDKUk&Z*=OVg3t|1zRSL$(G{rza>5Xh@jw1gWK5hPieJjs_@{UIaOWfp;JS?y~5>>ouEk{>eu(7zsmN`Mo)_5lv1frVBcmvuCmGi zZ7XUQw|5~kBi~Q~1ghpzngg)`d1R!>R@xgz=o5~r7eNRH8m(0Ms=4H5Ock>S;hTwG z7}c_4!_M8ke;tqia~5u zojiyu-7VS$<|um%+5&;8_%Dc`Ee~Nxe0GW)Z@X5~ZLsEY(N?Y_329bMhAmbLZ>O%< z4|wgZ6~7vu%v&7&&&H>tQP&n;X_P#~u!TDJwm$amPnI(%kFvSqN$aP*x#q)bcTen) zh)O10hF#BQM2ju-fI*c1W!`^9ecD9?O_ghlm)pvFaLO+?3o40lLG8ZJn1z^K;F;?R ziyB!`U(+jTOKs`F^<$C8yPnANbG-BMLMWfH_LbjlQUKYFd$G3}M}rvP){#;@M)jSd^_kX z0?yt!iBMp~-Br$|xstfG!C_n$SuOYhLjJ+bQMykLLq#a6P+R7s%ndw)oA30WAn zdaCttItMZqnot8rIK6N$+hg8JD2;5dtq(v!93K1_4x z3Upk|DXBLaLOl!4VGwEFfwF%vT+%gXXfSI0-wKR1v&7XvTEPQMI*jvfN>1E|aZ-%Z zKfGmk7oa<)F%hm_V*-x6Db?m`R(jv@PVWU0Tk8H^=ijpR&>L_WO!&I)KHG~+Oymy; v(a?zH)V#iTUDE_pl>evVh+X#kdWOrkiKUwOU6pygijSwMs;5$~WE1^A1DQmn literal 0 HcmV?d00001 diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/_test_main.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/_test_main.cpp new file mode 100644 index 0000000..829bfcd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/_test_main.cpp @@ -0,0 +1,146 @@ +/* + * _test_main.cpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "test.hpp" +#include +#include +#ifndef __APPLE__ +#include +#endif +#include +#include + +#ifdef __APPLE__ +#include + +void error(int status, int errnum, const char *format, ...) { + fflush(stdout); + fprintf(stderr, "%s: ", getprogname()); + + va_list args; + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + + if (errnum != 0) { + fprintf(stderr, ": %s\n", strerror(errnum)); + } else { + fprintf(stderr, "\n"); + } + if (status != 0) { + exit(status); + } +} +#endif + +test::test_registry_t test::test_registry; +using namespace test; + +bool run_test(TestBase& test) { + printf("-- running test case: %s\n", test.name); + + fflush(stdout); + pid_t child_pid = fork(); + if (child_pid == 0) { + exit(static_cast(test.run())); + } + if (child_pid == -1) { + error(EXIT_FAILURE, 0, "unable to fork"); + } + + int child_status = 0; + waitpid(child_pid, &child_status, 0); + + test::TestStatus status; + + if (WIFEXITED(child_status)) { + int exit_status = WEXITSTATUS(child_status); + if (exit_status & ~test::STATUS_MASK) { + status = test::FAILED; + } else { + status = static_cast(exit_status); + } + } else if (WIFSIGNALED(child_status)) { + const int signum = WTERMSIG(child_status); + printf("!! signal (%d) %s\n", signum, strsignal(signum)); + switch (signum) { + case SIGABRT: + status = test::SIGNAL_ABORT; break; + case SIGSEGV: + case SIGBUS: + status = test::SIGNAL_SEGFAULT; break; + case SIGFPE: + status = test::SIGNAL_DIVZERO; break; + default: + status = test::SIGNAL_UNCAUGHT; + } + } else { + status = test::SUCCESS; + } + + if (test.expected_status == test::FAILED) { + return (status & test::FAILED); + } + + if (test.expected_status == test::SIGNAL_UNCAUGHT) { + return (status & test::SIGNAL_UNCAUGHT); + } + + return status == test.expected_status; +} + +int main(int argc, const char* const argv[]) { + + size_t success_cnt = 0; + size_t total_cnt = 0; + for (test_registry_t::iterator it = test_registry.begin(); + it != test_registry.end(); ++it) { + TestBase& test = **it; + + bool consider_test = (argc <= 1); + for (int i = 1; i < argc; ++i) { + if (strcasecmp(argv[i], test.name) == 0) { + consider_test = true; + break; + } + } + if (not consider_test) { + continue; + } + + total_cnt += 1; + if (run_test(test)) { + printf("-- test case success: %s\n", test.name); + success_cnt += 1; + } else { + printf("** test case FAILED : %s\n", test.name); + } + } + printf("-- tests passing: %lu/%lu", success_cnt, total_cnt); + if (total_cnt) { + printf(" (%lu%%)\n", success_cnt * 100 / total_cnt); + } else { + printf("\n"); + } + return (success_cnt == total_cnt) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/rectrace.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/rectrace.cpp new file mode 100644 index 0000000..bde82ba --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/rectrace.cpp @@ -0,0 +1,99 @@ +/* + * test/rectrace.cpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "backward.hpp" +#include +#include "test/test.hpp" + +using namespace backward; + +typedef StackTrace stacktrace_t; + +void end_of_our_journey(stacktrace_t& st) { + if (not st.size()) { + st.load_here(); + } +} + +int rec(stacktrace_t& st, int level) { + if (level <= 1) { + end_of_our_journey(st); + return 0; + } + return rec(st, level - 1); +} + +namespace toto { + +namespace titi { + + struct foo { + + union bar { + __attribute__((noinline)) + static int trampoline(stacktrace_t& st, int level) { + return rec(st, level); + } + }; + }; + +} // namespace titi + +} // namespace toto + +TEST (recursion) { + { // lexical scope. + stacktrace_t st; + const int input = 3; + int r = toto::titi::foo::bar::trampoline(st, input); + + std::cout << "rec(" << input << ") == " << r << std::endl; + + Printer printer; + // printer.address = true; + printer.object = true; + printer.print(st, stdout); + } +} + +int fib(StackTrace& st, int level) { + if (level == 2) { + return 1; + } + if (level <= 1) { + end_of_our_journey(st); + return 0; + } + return fib(st, level - 1) + fib(st, level - 2); +} + +TEST (fibrecursive) { + StackTrace st; + const int input = 6; + int r = fib(st, input); + + std::cout << "fib(" << input << ") == " << r << std::endl; + + Printer printer; + printer.print(st, stdout); +} diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/select_signals.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/select_signals.cpp new file mode 100644 index 0000000..ef3499b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/select_signals.cpp @@ -0,0 +1,51 @@ +/* + * test/segfault.cpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "backward.hpp" + +#include +#include +#include "test/test.hpp" + +using namespace backward; + +void badass_function() { + char* ptr = (char*)42; + *ptr = 42; +} + +TEST_SEGFAULT (pprint_sigsev) { + std::vector signals; + signals.push_back(SIGSEGV); + SignalHandling sh(signals); + std::cout << std::boolalpha << "sh.loaded() == " << sh.loaded() << std::endl; + badass_function(); +} + +TEST_SEGFAULT (wont_pprint) { + std::vector signals; + signals.push_back(SIGABRT); + SignalHandling sh(signals); + std::cout << std::boolalpha << "sh.loaded() == " << sh.loaded() << std::endl; + badass_function(); +} diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/stacktrace.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/stacktrace.cpp new file mode 100644 index 0000000..76cbc60 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/stacktrace.cpp @@ -0,0 +1,65 @@ +/* + * test/stacktrace.cpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "backward.hpp" +#include +#include "test/test.hpp" + +using namespace backward; + +void collect_trace(StackTrace& st) { + st.load_here(); +} + +TEST (minitrace) { + StackTrace st; + collect_trace(st); + + Printer printer; + printer.print(st, stdout); +} + +void d(StackTrace& st) { + st.load_here(); +} + +void c(StackTrace& st) { + return d(st); +} + +void b(StackTrace& st) { + return c(st); +} + +__attribute__ ((noinline)) +void a(StackTrace& st) { + return b(st); +} + +TEST (smalltrace) { + StackTrace st; + a(st); + + Printer printer; + printer.print(st, stdout); +} diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/suicide.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/suicide.cpp new file mode 100644 index 0000000..d238bce --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/suicide.cpp @@ -0,0 +1,99 @@ +/* + * test/suicide.cpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "backward.hpp" + +#include +#include +#include "test/test.hpp" + +using namespace backward; + +void badass_function() +{ + char* ptr = (char*)42; + *ptr = 42; +} + +TEST_SEGFAULT (invalid_write) +{ + badass_function(); +} + +int you_shall_not_pass() +{ + char* ptr = (char*)42; + int v = *ptr; + return v; +} + +TEST_SEGFAULT(invalid_read) +{ + int v = you_shall_not_pass(); + std::cout << "v=" << v << std::endl; +} + +void abort_abort_I_repeat_abort_abort() +{ + std::cout << "Jumping off the boat!" << std::endl; + abort(); +} + +TEST_ABORT (calling_abort) +{ + abort_abort_I_repeat_abort_abort(); +} + +// aarch64 does not trap Division by zero +#ifndef __aarch64__ +volatile int zero = 0; + +int divide_by_zero() +{ + std::cout << "And the wild black hole appears..." << std::endl; + int v = 42 / zero; + return v; +} + +TEST_DIVZERO (divide_by_zero) +{ + int v = divide_by_zero(); + std::cout << "v=" << v << std::endl; +} +#endif + +// Darwin does not allow RLIMIT_STACK to be reduced +#ifndef __APPLE__ +int bye_bye_stack(int i) { + return bye_bye_stack(i + 1) + bye_bye_stack(i * 2); +} + +TEST_SEGFAULT(stackoverflow) +{ + struct rlimit limit; + limit.rlim_max = 8096; + setrlimit(RLIMIT_STACK, &limit); + int r = bye_bye_stack(42); + std::cout << "r=" << r << std::endl; +} +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.cpp new file mode 100644 index 0000000..6c5bbff --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.cpp @@ -0,0 +1,75 @@ +/* + * test/test.cpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include +#include +#include +#include "test/test.hpp" + +TEST (empty_test) { } + +TEST_FAIL_ASSERT (fail_assert) { + ASSERT(1 == 2); +} + +TEST_FAIL_ASSERT (fail_assert_ge) { + ASSERT_GE(4, 5); +} + +TEST_UNCAUGHT_EXCEPTION (uncaught_exception) { + throw std::runtime_error("some random runtime error"); +} + +TEST_UNCAUGHT_EXCEPTION (uncaught_exception_int) { + throw 42; +} + +TEST_SEGFAULT (segfault) { + char* a = 0; + char b = a[42]; + std::cout << "result: " << b << std::endl; +} + +TEST_ABORT (abort) { + abort(); +} + +TEST (catch_int) { + ASSERT_THROW({throw 42;}, int); +} + +TEST_FAIL_ASSERT (fail_catch_int) { + ASSERT_THROW({}, int); +} + +TEST_FAIL_ASSERT (fail_no_throw) { + ASSERT_NO_THROW({throw 42;}); +} + +TEST (any_throw) { + ASSERT_ANY_THROW({throw 42;}); +} + +TEST_FAIL_ASSERT (fail_any_throw) { + ASSERT_ANY_THROW({}); +} diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.hpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.hpp new file mode 100644 index 0000000..e3fb544 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test/test.hpp @@ -0,0 +1,170 @@ +/* + * test/test.hpp + * Copyright 2013 Google Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once +#ifndef H_54E531F7_9154_454B_BEB9_257408429470 +#define H_54E531F7_9154_454B_BEB9_257408429470 + +#include +#include +#include +#include +#include +#include + +namespace test { + +struct AssertFailedError: std::exception { + ~AssertFailedError() throw() {} + + AssertFailedError(const char* filename, int _line, const char* _errmsg): + basename(_basename(filename)), line(_line), errmsg(_errmsg) {} + + const char* what() const throw() { + if (not _what.size()) { + std::ostringstream ss; + ss << "assertion failed (" << basename << ":" << line; + ss << ") " << errmsg; + _what = ss.str(); + } + return _what.c_str(); + } + + const char* basename; + int line; + const char* errmsg; + + mutable std::string _what; + + static const char* _basename(const char* filename) { + const char* basename = filename + strlen(filename); + while (basename != filename && *basename != '/') { + basename -= 1; + } + return basename + 1; + } +}; + +enum TestStatus { + SUCCESS = 0<<0, + FAILED = 1<<0, + + ASSERT_FAIL = FAILED | 1<<1, + EXCEPTION_UNCAUGHT = FAILED | 2<<1, + SIGNAL_UNCAUGHT = FAILED | 3<<1, + SIGNAL_SEGFAULT = SIGNAL_UNCAUGHT | 1<<3, + SIGNAL_ABORT = SIGNAL_UNCAUGHT | 2<<3, + SIGNAL_DIVZERO = SIGNAL_UNCAUGHT | 2<<3, + + STATUS_MASK = 0x1F +}; + +struct TestBase { + const char* name; + TestStatus expected_status; + + virtual ~TestBase() {} + TestBase(const char*, TestStatus); + virtual void do_test() = 0; + + TestStatus run() { + try { + do_test(); + return SUCCESS; + } catch(const AssertFailedError& e) { + printf("!! %s\n", e.what()); + return ASSERT_FAIL; + } catch(const std::exception& e) { + printf("!! exception: %s\n", e.what()); + return EXCEPTION_UNCAUGHT; + } catch(...) { + printf("!! unknown exception\n"); + return EXCEPTION_UNCAUGHT; + } + } +}; + +typedef std::vector test_registry_t; +extern test_registry_t test_registry; + +TestBase::TestBase(const char* n, TestStatus s): name(n), expected_status(s) { + test_registry.push_back(this); +} + +} // namespace test + +#define _TEST_STATUS(name, status) \ + struct TEST_##name: ::test::TestBase { \ + TEST_##name(): TestBase(#name, status) {} \ + void do_test(); \ + } TEST_##name; \ + void TEST_##name::do_test() + +#define TEST(name) _TEST_STATUS(name, ::test::SUCCESS) +#define TEST_FAIL(name) _TEST_STATUS(name, ::test::FAILED) +#define TEST_FAIL_ASSERT(name) _TEST_STATUS(name, ::test::ASSERT_FAIL) +#define TEST_UNCAUGHT_EXCEPTION(name) _TEST_STATUS(name, ::test::EXCEPTION_UNCAUGHT) +#define TEST_UNCAUGHT_SIGNAL(name) _TEST_STATUS(name, ::test::SIGNAL_UNCAUGHT) +#define TEST_SEGFAULT(name) _TEST_STATUS(name, ::test::SIGNAL_SEGFAULT) +#define TEST_ABORT(name) _TEST_STATUS(name, ::test::SIGNAL_ABORT) +#define TEST_DIVZERO(name) _TEST_STATUS(name, ::test::SIGNAL_DIVZERO) + +#define ASSERT(expr) \ + (expr) ? static_cast(0) \ + : throw ::test::AssertFailedError( \ + __FILE__, __LINE__, #expr) + +#define _ASSERT_BINOP(a, b, cmp) \ + (not (a cmp b)) ? static_cast(0) \ + : throw ::test::AssertFailedError( \ + __FILE__, __LINE__, "because " #a " " #cmp " " #b) + +#define ASSERT_EQ(a, b) _ASSERT_BINOP(a, b, !=) +#define ASSERT_NE(a, b) _ASSERT_BINOP(a, b, ==) +#define ASSERT_LT(a, b) _ASSERT_BINOP(a, b, >=) +#define ASSERT_LE(a, b) _ASSERT_BINOP(a, b, >) +#define ASSERT_GT(a, b) _ASSERT_BINOP(a, b, <=) +#define ASSERT_GE(a, b) _ASSERT_BINOP(a, b, <) + +#define ASSERT_THROW(expr, e_type) \ + do { try { expr } \ + catch (const e_type&) { break; } \ + throw ::test::AssertFailedError( \ + __FILE__, __LINE__, "expected exception " #e_type); \ + } while(0) + +#define ASSERT_ANY_THROW(expr) \ + do { try { expr } \ + catch (...) { break; } \ + throw ::test::AssertFailedError( \ + __FILE__, __LINE__, "expected any exception"); \ + } while(0) + +#define ASSERT_NO_THROW(expr) \ + try { expr } \ + catch (...) { \ + throw ::test::AssertFailedError( \ + __FILE__, __LINE__, "no exception expected"); \ + } + +#endif /* H_GUARD */ diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/CMakeLists.txt new file mode 100644 index 0000000..90cf190 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +project(backward-package-test) +cmake_minimum_required(VERSION 2.8) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_executable(example main.cpp) +target_link_libraries(example PRIVATE ${CONAN_TARGETS}) diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/conanfile.py b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/conanfile.py new file mode 100644 index 0000000..e509dd5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/conanfile.py @@ -0,0 +1,14 @@ +from conans import ConanFile, CMake +import os + +class TestBackward(ConanFile): + settings = 'os', 'compiler', 'build_type', 'arch' + generators = 'cmake' + + def build(self): + cmake = CMake(self) + cmake.configure(defs={'CMAKE_VERBOSE_MAKEFILE': 'ON'}) + cmake.build() + + def test(self): + self.run(os.path.join('.', 'bin', 'example')) diff --git a/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/main.cpp b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/main.cpp new file mode 100644 index 0000000..aa3cd11 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/backward-cpp/test_package/main.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +using namespace backward; + +class TracedException : public std::runtime_error +{ +public: + TracedException() : + std::runtime_error(_get_trace()) + {} + +private: + std::string _get_trace() + { + std::ostringstream ss; + + StackTrace stackTrace; + TraceResolver resolver; + stackTrace.load_here(); + resolver.load_stacktrace(stackTrace); + + for(std::size_t i = 0; i < stackTrace.size(); ++i) + { + const ResolvedTrace trace = resolver.resolve(stackTrace[i]); + + ss << "#" << i << " at " << trace.object_function << "\n"; + } + + return ss.str(); + } +}; + +void f(int i) +{ + if(i >= 42) + { + throw TracedException(); + } + else + { + std::cout << "i=" << i << "\n"; + f(i + 1); + } +} + +int main() +{ + try + { + f(0); + } catch (const TracedException& ex) + { + std::cout << ex.what(); + } +} + + diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/.clang-format b/src/type3_AndroidCloud/anbox-master/external/cpu_features/.clang-format new file mode 100644 index 0000000..06ea346 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/.clang-format @@ -0,0 +1,4 @@ +--- +Language: Cpp +BasedOnStyle: Google +... diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/.gitignore b/src/type3_AndroidCloud/anbox-master/external/cpu_features/.gitignore new file mode 100644 index 0000000..0690aa4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/.gitignore @@ -0,0 +1 @@ +cmake_build/ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/.travis.yml b/src/type3_AndroidCloud/anbox-master/external/cpu_features/.travis.yml new file mode 100644 index 0000000..deafdfa --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/.travis.yml @@ -0,0 +1,91 @@ +language: c + +sudo: false + +cache: + directories: + - $HOME/cpu_features_archives + +matrix: + include: + - os: linux + compiler: gcc + env: + TOOLCHAIN=NATIVE + TARGET=native + - os: linux + compiler: clang + env: + TOOLCHAIN=NATIVE + TARGET=native + - os: osx + compiler: gcc + env: + TOOLCHAIN=NATIVE + TARGET=native + - os: osx + compiler: clang + env: + TOOLCHAIN=NATIVE + TARGET=native + - os: linux-ppc64le + compiler: gcc + env: + TOOLCHAIN=NATIVE + TARGET=native + - os: linux-ppc64le + compiler: clang + env: + TOOLCHAIN=NATIVE + TARGET=native + # Toolchains for little-endian, 64-bit ARMv8 for GNU/Linux systems + - os: linux + env: + TOOLCHAIN=LINARO + TARGET=aarch64-linux-gnu + QEMU_ARCH=aarch64 + # Toolchains for little-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems + - os: linux + env: + TOOLCHAIN=LINARO + TARGET=arm-linux-gnueabihf + QEMU_ARCH=arm + # Toolchains for little-endian, 32-bit ARMv8 for GNU/Linux systems + - os: linux + env: + TOOLCHAIN=LINARO + TARGET=armv8l-linux-gnueabihf + QEMU_ARCH=arm + # Toolchains for little-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems + - os: linux + env: + TOOLCHAIN=LINARO + TARGET=arm-linux-gnueabi + QEMU_ARCH=arm + # Toolchains for big-endian, 64-bit ARMv8 for GNU/Linux systems + - os: linux + env: + TOOLCHAIN=LINARO + TARGET=aarch64_be-linux-gnu + QEMU_ARCH=DISABLED + # Toolchains for big-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems + - os: linux + env: + TOOLCHAIN=LINARO + TARGET=armeb-linux-gnueabihf + QEMU_ARCH=DISABLED + # Toolchains for big-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems + - os: linux + env: + TOOLCHAIN=LINARO + TARGET=armeb-linux-gnueabi + QEMU_ARCH=DISABLED + - os: linux + env: + TOOLCHAIN=CODESCAPE + TARGET=mips-mti-linux-gnu + QEMU_ARCH=DISABLED + +script: + - cmake --version + - bash -e -x ./scripts/run_integration.sh diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/cpu_features/CMakeLists.txt new file mode 100644 index 0000000..b978e97 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/CMakeLists.txt @@ -0,0 +1,174 @@ +cmake_minimum_required(VERSION 3.0) + +project(CpuFeatures VERSION 0.1.0) + +# ANBOX allow to build in our more strict build environment +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=switch-default -Wno-error=unused-parameter -Wno-error=overflow") + +if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=cast-align") +endif() + +# Default Build Type to be Release +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." + FORCE) +endif(NOT CMAKE_BUILD_TYPE) + +# BUILD_TESTING is a standard CMake variable, but we declare it here to make it +# prominent in the GUI. +option(BUILD_TESTING "Enable test (depends on googletest)." OFF) +# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make +# it prominent in the GUI. +option(BUILD_SHARED_LIBS "Build library as shared." OFF) + +# +# library : cpu_features +# + +set(_HDRS + include/cpuinfo_aarch64.h + include/cpuinfo_arm.h + include/cpuinfo_mips.h + include/cpuinfo_ppc.h + include/cpuinfo_x86.h + include/cpu_features_macros.h +) + +add_library(cpu_features + ${_HDRS} + include/internal/bit_utils.h + include/internal/linux_features_aggregator.h + include/internal/cpuid_x86.h + include/internal/filesystem.h + include/internal/hwcaps.h + include/internal/stack_line_reader.h + include/internal/string_view.h + include/cpu_features_macros.h + src/linux_features_aggregator.c + src/cpuid_x86_clang_gcc.c + src/cpuid_x86_msvc.c + src/cpuinfo_aarch64.c + src/cpuinfo_arm.c + src/cpuinfo_mips.c + src/cpuinfo_ppc.c + src/cpuinfo_x86.c + src/filesystem.c + src/hwcaps.c + src/stack_line_reader.c + src/string_view.c +) + +target_include_directories(cpu_features + PUBLIC + $ + $ + PRIVATE + include/internal +) +set_target_properties(cpu_features PROPERTIES PUBLIC_HEADER "${_HDRS}") +target_compile_definitions(cpu_features + PUBLIC STACK_LINE_READER_BUFFER_SIZE=1024) +target_link_libraries(cpu_features PUBLIC ${CMAKE_DL_LIBS}) + +# The use of shared libraries is discouraged. +# For API / ABI compatibility reasons, it is recommended to build and use +# cpu_features in a subdirectory of your project or as an embedded dependency. +if(BUILD_SHARED_LIBS) + set_property(TARGET cpu_features PROPERTY POSITION_INDEPENDENT_CODE ON) +endif() +add_library(CpuFeature::cpu_features ALIAS cpu_features) + +# +# program : list_cpu_features +# + +add_executable(list_cpu_features src/utils/list_cpu_features.c) +target_link_libraries(list_cpu_features PRIVATE cpu_features) +add_executable(CpuFeature::list_cpu_features ALIAS list_cpu_features) + +# +# tests +# + +include(CTest) +# ANBOX: disable building tests +set(BUILD_TESTING OFF) +if(BUILD_TESTING) + # Automatically incorporate googletest into the CMake Project if target not + # found. + if(NOT TARGET gtest OR NOT TARGET gmock_main) + # Download and unpack googletest at configure time. + configure_file( + cmake/googletest.CMakeLists.txt.in + googletest-download/CMakeLists.txt + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) + + if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) + + if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") + endif() + + # Prevent overriding the parent project's compiler/linker settings on + # Windows. + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + + # Add googletest directly to our build. This defines the gtest and + # gtest_main targets. + add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src + ${CMAKE_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL) + endif() + + add_subdirectory(test) +endif() + +# +# Install +# + +include(GNUInstallDirs) +install(TARGETS cpu_features list_cpu_features + EXPORT CpuFeaturesTargets + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cpu_features + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) +install(EXPORT CpuFeaturesTargets + NAMESPACE CpuFeatures:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures + COMPONENT Devel +) +include(CMakePackageConfigHelpers) +configure_package_config_file(cmake/CpuFeaturesConfig.cmake.in + "${PROJECT_BINARY_DIR}/CpuFeaturesConfig.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) +write_basic_package_version_file( + "${PROJECT_BINARY_DIR}/CpuFeaturesConfigVersion.cmake" + COMPATIBILITY SameMajorVersion +) +install( + FILES + "${PROJECT_BINARY_DIR}/CpuFeaturesConfig.cmake" + "${PROJECT_BINARY_DIR}/CpuFeaturesConfigVersion.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CpuFeatures" + COMPONENT Devel +) diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/CONTRIBUTING.md b/src/type3_AndroidCloud/anbox-master/external/cpu_features/CONTRIBUTING.md new file mode 100644 index 0000000..c980350 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/CONTRIBUTING.md @@ -0,0 +1,23 @@ +# How to Contribute + +We'd love to accept your patches and contributions to this project. There are +just a few small guidelines you need to follow. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution; +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions, including submissions by project members, require review. We +use GitHub pull requests for this purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on using pull requests. diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/LICENSE b/src/type3_AndroidCloud/anbox-master/external/cpu_features/LICENSE new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/README.md b/src/type3_AndroidCloud/anbox-master/external/cpu_features/README.md new file mode 100644 index 0000000..039175b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/README.md @@ -0,0 +1,165 @@ +# cpu_features [![Build Status](https://travis-ci.org/google/cpu_features.svg?branch=master)](https://travis-ci.org/google/cpu_features) [![Build status](https://ci.appveyor.com/api/projects/status/46d1owsj7n8dsylq/branch/master?svg=true)](https://ci.appveyor.com/project/gchatelet/cpu-features/branch/master) + +A cross-platform C library to retrieve CPU features (such as available +instructions) at runtime. + +## Table of Contents + +- [Design Rationale](#rationale) +- [Code samples](#codesample) +- [Running sample code](#usagesample) +- [What's supported](#support) +- [License](#license) +- [Build with cmake](#cmake) + +
+## Design Rationale + +- **Simple to use.** See the snippets below for examples. +- **Extensible.** Easy to add missing features or architectures. +- **Compatible with old compilers** and available on many architectures so it + can be used widely. To ensure that cpu_features works on as many platforms + as possible, we implemented it in a highly portable version of C: C99. +- **Sandbox-compatible.** The library uses a variety of strategies to cope + with sandboxed environments or when `cpuid` is unavailable. This is useful + when running integration tests in hermetic environments. +- **Thread safe, no memory allocation, and raises no exceptions.** + cpu_features is suitable for implementing fundamental libc functions like + `malloc`, `memcpy`, and `memcmp`. +- **Unit tested.** + + +### Checking features at runtime + +Here's a simple example that executes a codepath if the CPU supports both the +AES and the SSE4.2 instruction sets: + +```c +#include "cpuinfo_x86.h" + +static const X86Features features = GetX86Info().features; + +void Compute(void) { + if (features.aes && features.sse4_2) { + // Run optimized code. + } else { + // Run standard code. + } +} +``` + +### Caching for faster evaluation of complex checks + +If you wish, you can read all the features at once into a global variable, and +then query for the specific features you care about. Below, we store all the ARM +features and then check whether AES and NEON are supported. + +```c +#include +#include "cpuinfo_arm.h" + +static const ArmFeatures features = GetArmInfo().features; +static const bool has_aes_and_neon = features.aes && features.neon; + +// use has_aes_and_neon. +``` + +This is a good approach to take if you're checking for combinations of features +when using a compiler that is slow to extract individual bits from bit-packed +structures. + +### Checking compile time flags + +The following code determines whether the compiler was told to use the AVX +instruction set (e.g., `g++ -mavx`) and sets `has_avx` accordingly. + +```c +#include +#include "cpuinfo_x86.h" + +static const X86Features features = GetX86Info().features; +static const bool has_avx = CPU_FEATURES_COMPILED_X86_AVX || features.avx; + +// use has_avx. +``` + +`CPU_FEATURES_COMPILED_X86_AVX` is set to 1 if the compiler was instructed to +use AVX and 0 otherwise, combining compile time and runtime knowledge. + +### Rejecting poor hardware implementations based on microarchitecture + +On x86, the first incarnation of a feature in a microarchitecture might not be +the most efficient (e.g. AVX on Sandy Bridge). We provide a function to retrieve +the underlying microarchitecture so you can decide whether to use it. + +Below, `has_fast_avx` is set to 1 if the CPU supports the AVX instruction +set—but only if it's not Sandy Bridge. + +```c +#include +#include "cpuinfo_x86.h" + +static const X86Info info = GetX86Info(); +static const X86Microarchitecture uarch = GetX86Microarchitecture(&info); +static const bool has_fast_avx = info.features.avx && uarch != INTEL_SNB; + +// use has_fast_avx. +``` + +This feature is currently available only for x86 microarchitectures. + + +### Running sample code + +Building `cpu_features` brings a small executable to test the library. + +```shell + % ./build/list_cpu_features +arch : x86 +brand : Intel(R) Xeon(R) CPU E5-1650 0 @ 3.20GHz +family : 6 (0x06) +model : 45 (0x2D) +stepping : 7 (0x07) +uarch : INTEL_SNB +flags : aes,avx,cx16,smx,sse4_1,sse4_2,ssse3 +``` + +```shell +% ./build/list_cpu_features --json +{"arch":"x86","brand":" Intel(R) Xeon(R) CPU E5-1650 0 @ 3.20GHz","family":6,"model":45,"stepping":7,"uarch":"INTEL_SNB","flags":["aes","avx","cx16","smx","sse4_1","sse4_2","ssse3"]} +``` + + +## What's supported + +| | x86³ | ARM | AArch64 | MIPSel | POWER | +|---------|:----:|:-------:|:-------:|:------:|:-------:| +| Android | yes² | yes¹ | yes¹ | yes¹ | N/A | +| iOS | N/A | not yet | not yet | N/A | N/A | +| Linux | yes² | yes¹ | yes¹ | yes¹ | yes¹ | +| MacOs | yes² | N/A | not yet | N/A | no | +| Windows | yes² | not yet | not yet | N/A | N/A | + +1. **Features revealed from Linux.** We gather data from several sources + depending on availability: + + from glibc's + [getauxval](https://www.gnu.org/software/libc/manual/html_node/Auxiliary-Vector.html) + + by parsing `/proc/self/auxv` + + by parsing `/proc/cpuinfo` +2. **Features revealed from CPU.** features are retrieved by using the `cpuid` + instruction. +3. **Microarchitecture detection.** On x86 some features are not always + implemented efficiently in hardware (e.g. AVX on Sandybridge). Exposing the + microarchitecture allows the client to reject particular microarchitectures. + + + +## License + +The cpu_features library is licensed under the terms of the Apache license. +See [LICENSE](LICENSE) for more information. + + +## Build with CMake + +Please check the [CMake build instructions](cmake/README.md). diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/WORKSPACE b/src/type3_AndroidCloud/anbox-master/external/cpu_features/WORKSPACE new file mode 100644 index 0000000..8ea8a8b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/WORKSPACE @@ -0,0 +1,7 @@ +# ===== googletest ===== + +git_repository( + name = "com_google_googletest", + remote = "https://github.com/google/googletest.git", + commit = "c3f65335b79f47b05629e79a54685d899bc53b93", +) diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/appveyor.yml b/src/type3_AndroidCloud/anbox-master/external/cpu_features/appveyor.yml new file mode 100644 index 0000000..f18635a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/appveyor.yml @@ -0,0 +1,24 @@ +version: '{build}' +shallow_clone: true + +platform: x64 + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CMAKE_GENERATOR: "Visual Studio 15 2017 Win64" + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CMAKE_GENERATOR: "Visual Studio 14 2015 Win64" + +matrix: + fast_finish: true + +before_build: + - cmake --version + - cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -H. -Bcmake_build -G "%CMAKE_GENERATOR%" + +build_script: + - cmake --build cmake_build --config Debug --target ALL_BUILD + +test_script: + - cmake --build cmake_build --config Debug --target RUN_TESTS diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/CpuFeaturesConfig.cmake.in b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/CpuFeaturesConfig.cmake.in new file mode 100644 index 0000000..e0bf10e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/CpuFeaturesConfig.cmake.in @@ -0,0 +1,3 @@ +# CpuFeatures CMake configuration file + +include("${CMAKE_CURRENT_LIST_DIR}/CpuFeaturesTargets.cmake") diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/README.md b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/README.md new file mode 100644 index 0000000..b6baeaa --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/README.md @@ -0,0 +1,28 @@ +# CMake build instructions + +## Recommended usage : Incorporating cpu_features into a CMake project + + For API / ABI compatibility reasons, it is recommended to build and use + cpu_features in a subdirectory of your project or as an embedded dependency. + + This is similar to the recommended usage of the googletest framework + ( https://github.com/google/googletest/blob/master/googletest/README.md ) + + Build and use step-by-step + + + 1- Download cpu_features and copy it in a sub-directory in your project. + or add cpu_features as a git-submodule in your project + + 2- You can then use the cmake command `add_subdirectory()` to include + cpu_features directly and use the `cpu_features` target in your project. + + 3- Add the `cpu_features` target to the `target_link_libraries()` section of + your executable or of your library. + +## Enabling tests + + CMake default options for cpu_features is Release built type with tests + disabled. To enable testing set cmake `BUILD_TESTING` variable to `ON`, + [.travis.yml](../.travis.yml) and [appveyor.yml](../appveyor.yml) have up to + date examples. diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/googletest.CMakeLists.txt.in b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/googletest.CMakeLists.txt.in new file mode 100644 index 0000000..d60a33e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/googletest.CMakeLists.txt.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8.2) + +project(googletest-download NONE) + +include(ExternalProject) +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG master + SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/mips32-linux-gcc.cmake b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/mips32-linux-gcc.cmake new file mode 100644 index 0000000..dcfab7c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/cmake/mips32-linux-gcc.cmake @@ -0,0 +1,34 @@ +set(CMAKE_SYSTEM_NAME "Linux") +set(CMAKE_SYSTEM_PROCESSOR "mips32") + +if (ENABLE_DSPR2 AND ENABLE_MSA) + message(FATAL_ERROR "ENABLE_DSPR2 and ENABLE_MSA cannot be combined.") +endif () + +if (ENABLE_DSPR2) + set(HAVE_DSPR2 1 CACHE BOOL "" FORCE) + set(MIPS_CFLAGS "-mdspr2") + set(MIPS_CXXFLAGS "-mdspr2") +elseif (ENABLE_MSA) + set(HAVE_MSA 1 CACHE BOOL "" FORCE) + set(MIPS_CFLAGS "-mmsa") + set(MIPS_CXXFLAGS "-mmsa") +endif () + +if ("${MIPS_CPU}" STREQUAL "") + set(MIPS_CFLAGS "${MIPS_CFLAGS} -mips32r2") + set(MIPS_CXXFLAGS "${MIPS_CXXFLAGS} -mips32r2") +elseif ("${MIPS_CPU}" STREQUAL "p5600") + set(P56_FLAGS "-mips32r5 -mload-store-pairs -msched-weight -mhard-float -mfp64") + set(MIPS_CFLAGS "${MIPS_CFLAGS} ${P56_FLAGS}") + set(MIPS_CXXFLAGS "${MIPS_CXXFLAGS} ${P56_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "-mfp64 ${CMAKE_EXE_LINKER_FLAGS}") +endif () + +set(CMAKE_C_COMPILER ${CROSS}gcc) +set(CMAKE_CXX_COMPILER ${CROSS}g++) +set(AS_EXECUTABLE ${CROSS}as) +set(CMAKE_C_COMPILER_ARG1 "-EL ${MIPS_CFLAGS}") +set(CMAKE_CXX_COMPILER_ARG1 "-EL ${MIPS_CXXFLAGS}") + +set(THREADS_PTHREAD_ARG "2" CACHE STRING "Forcibly set by CMakeLists.txt." FORCE) diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpu_features_macros.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpu_features_macros.h new file mode 100644 index 0000000..f8220e1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpu_features_macros.h @@ -0,0 +1,125 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ +#define CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ + +//////////////////////////////////////////////////////////////////////////////// +// Architectures +//////////////////////////////////////////////////////////////////////////////// + +#if ((defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || \ + defined(__x86_64__)) && \ + !defined(__pnacl__) && !defined(__CLR_VER)) +#define CPU_FEATURES_ARCH_X86 +#endif + +#if (defined(__arm__) || defined(_M_ARM)) +#define CPU_FEATURES_ARCH_ARM +#endif + +#if defined(__aarch64__) +#define CPU_FEATURES_ARCH_AARCH64 +#endif + +#if (defined(CPU_FEATURES_ARCH_AARCH64) || defined(CPU_FEATURES_ARCH_ARM)) +#define CPU_FEATURES_ARCH_ANY_ARM +#endif + +#if defined(__mips__) +#define CPU_FEATURES_ARCH_MIPS +#endif + +#if defined(__powerpc__) +#define CPU_FEATURES_ARCH_PPC +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Os +//////////////////////////////////////////////////////////////////////////////// + +#if defined(__linux__) +#define CPU_FEATURES_OS_LINUX_OR_ANDROID +#endif + +#if defined(__ANDROID__) +#define CPU_FEATURES_OS_ANDROID +#endif + +#if (defined(_WIN64) || defined(_WIN32)) +#define CPU_FEATURES_OS_WINDOWS +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Compilers +//////////////////////////////////////////////////////////////////////////////// + +#if defined(__clang__) +#define CPU_FEATURES_COMPILER_CLANG +#endif + +#if defined(__GNUC__) && !defined(__clang__) +#define CPU_FEATURES_COMPILER_GCC +#endif + +#if defined(_MSC_VER) +#define CPU_FEATURES_COMPILER_MSC +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Cpp +//////////////////////////////////////////////////////////////////////////////// + +#if defined(__cplusplus) +#define CPU_FEATURES_START_CPP_NAMESPACE \ + namespace cpu_features { \ + extern "C" { +#define CPU_FEATURES_END_CPP_NAMESPACE \ + } \ + } +#else +#define CPU_FEATURES_START_CPP_NAMESPACE +#define CPU_FEATURES_END_CPP_NAMESPACE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Compiler flags +//////////////////////////////////////////////////////////////////////////////// + +// Use the following to check if a feature is known to be available at compile +// time. See README.md for an example. +#if defined(CPU_FEATURES_ARCH_X86) +#define CPU_FEATURES_COMPILED_X86_AES defined(__AES__) +#define CPU_FEATURES_COMPILED_X86_F16C defined(__F16C__) +#define CPU_FEATURES_COMPILED_X86_BMI defined(__BMI__) +#define CPU_FEATURES_COMPILED_X86_BMI2 defined(__BMI2__) +#define CPU_FEATURES_COMPILED_X86_SSE (defined(__SSE__) || (_M_IX86_FP >= 1)) +#define CPU_FEATURES_COMPILED_X86_SSE2 (defined(__SSE2__) || (_M_IX86_FP >= 2)) +#define CPU_FEATURES_COMPILED_X86_SSE3 defined(__SSE3__) +#define CPU_FEATURES_COMPILED_X86_SSSE3 defined(__SSSE3__) +#define CPU_FEATURES_COMPILED_X86_SSE4_1 defined(__SSE4_1__) +#define CPU_FEATURES_COMPILED_X86_SSE4_2 defined(__SSE4_2__) +#define CPU_FEATURES_COMPILED_X86_AVX defined(__AVX__) +#define CPU_FEATURES_COMPILED_x86_AVX2 defined(__AVX2__) +#endif + +#if defined(CPU_FEATURES_ARCH_ANY_ARM) +#define CPU_FEATURES_COMPILED_ANY_ARM_NEON defined(__ARM_NEON__) +#endif + +#if defined(CPU_FEATURES_ARCH_MIPS) +#define CPU_FEATURES_COMPILED_MIPS_MSA defined(__mips_msa) +#endif + +#endif // CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_aarch64.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_aarch64.h new file mode 100644 index 0000000..b8826ed --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_aarch64.h @@ -0,0 +1,65 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ +#define CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ + +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct { + int fp : 1; // Floating-point. + int asimd : 1; // Advanced SIMD. + int aes : 1; // Hardware-accelerated Advanced Encryption Standard. + int pmull : 1; // Polynomial multiply long. + int sha1 : 1; // Hardware-accelerated SHA1. + int sha2 : 1; // Hardware-accelerated SHA2-256. + int crc32 : 1; // Hardware-accelerated CRC-32. + + // Make sure to update Aarch64FeaturesEnum below if you add a field here. +} Aarch64Features; + +typedef struct { + Aarch64Features features; + int implementer; + int variant; + int part; + int revision; +} Aarch64Info; + +Aarch64Info GetAarch64Info(void); + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +typedef enum { + AARCH64_FP, + AARCH64_ASIMD, + AARCH64_AES, + AARCH64_PMULL, + AARCH64_SHA1, + AARCH64_SHA2, + AARCH64_CRC32, + AARCH64_LAST_, +} Aarch64FeaturesEnum; + +int GetAarch64FeaturesEnumValue(const Aarch64Features* features, + Aarch64FeaturesEnum value); + +const char* GetAarch64FeaturesEnumName(Aarch64FeaturesEnum); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_arm.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_arm.h new file mode 100644 index 0000000..7a94bb0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_arm.h @@ -0,0 +1,80 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_ +#define CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_ + +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct { + int vfp : 1; // Vector Floating Point. + int iwmmxt : 1; // Intel Wireless MMX Technology. + int neon : 1; // Advanced SIMD. + int vfpv3 : 1; // VFP version 3 + int vfpv3d16 : 1; // VFP version 3 with 16 D-registers + int vfpv4 : 1; // VFP version 4 with fast context switching + int idiva : 1; // SDIV and UDIV hardware division in ARM mode. + int idivt : 1; // SDIV and UDIV hardware division in Thumb mode. + int aes : 1; // Hardware-accelerated Advanced Encryption Standard. + int pmull : 1; // Polynomial multiply long. + int sha1 : 1; // Hardware-accelerated SHA1. + int sha2 : 1; // Hardware-accelerated SHA2-256. + int crc32 : 1; // Hardware-accelerated CRC-32. + + // Make sure to update ArmFeaturesEnum below if you add a field here. +} ArmFeatures; + +typedef struct { + ArmFeatures features; + int implementer; + int architecture; + int variant; + int part; + int revision; +} ArmInfo; + +// TODO(user): Add macros to know which features are present at compile +// time. + +ArmInfo GetArmInfo(void); + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +typedef enum { + ARM_VFP, + ARM_IWMMXT, + ARM_NEON, + ARM_VFPV3, + ARM_VFPV3D16, + ARM_VFPV4, + ARM_IDIVA, + ARM_IDIVT, + ARM_AES, + ARM_PMULL, + ARM_SHA1, + ARM_SHA2, + ARM_CRC32, + ARM_LAST_, +} ArmFeaturesEnum; + +int GetArmFeaturesEnumValue(const ArmFeatures* features, ArmFeaturesEnum value); + +const char* GetArmFeaturesEnumName(ArmFeaturesEnum); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_CPUINFO_ARM_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_mips.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_mips.h new file mode 100644 index 0000000..48c23a1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_mips.h @@ -0,0 +1,53 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_ +#define CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_ + +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct { + int msa : 1; // MIPS SIMD Architecture + // https://www.mips.com/products/architectures/ase/simd/ + int eva : 1; // Enhanced Virtual Addressing + // https://www.mips.com/products/architectures/mips64/ + + // Make sure to update MipsFeaturesEnum below if you add a field here. +} MipsFeatures; + +typedef struct { + MipsFeatures features; +} MipsInfo; + +MipsInfo GetMipsInfo(void); + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +typedef enum { + MIPS_MSA, + MIPS_EVA, + MIPS_LAST_, +} MipsFeaturesEnum; + +int GetMipsFeaturesEnumValue(const MipsFeatures* features, + MipsFeaturesEnum value); + +const char* GetMipsFeaturesEnumName(MipsFeaturesEnum); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_ppc.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_ppc.h new file mode 100644 index 0000000..654155d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_ppc.h @@ -0,0 +1,141 @@ +// Copyright 2018 IBM +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ +#define CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ + +#include "cpu_features_macros.h" +#include "internal/hwcaps.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct { + int ppc32 : 1; + int ppc64 : 1; + int ppc601 : 1; + int altivec : 1; + int fpu : 1; + int mmu : 1; + int mac_4xx : 1; + int unifiedcache : 1; + int spe : 1; + int efpsingle : 1; + int efpdouble : 1; + int no_tb : 1; + int power4 : 1; + int power5 : 1; + int power5plus : 1; + int cell : 1; + int booke : 1; + int smt : 1; + int icachesnoop : 1; + int arch205 : 1; + int pa6t : 1; + int dfp : 1; + int power6ext : 1; + int arch206 : 1; + int vsx : 1; + int pseries_perfmon_compat : 1; + int truele : 1; + int ppcle : 1; + int arch207 : 1; + int htm : 1; + int dscr : 1; + int ebb : 1; + int isel : 1; + int tar : 1; + int vcrypto : 1; + int htm_nosc : 1; + int arch300 : 1; + int ieee128 : 1; + int darn : 1; + int scv : 1; + int htm_no_suspend : 1; + + // Make sure to update PPCFeaturesEnum below if you add a field here. +} PPCFeatures; + +typedef struct { + PPCFeatures features; +} PPCInfo; + +// This function is guaranteed to be malloc, memset and memcpy free. +PPCInfo GetPPCInfo(void); + +typedef struct { + char platform[64]; // 0 terminated string + char model[64]; // 0 terminated string + char machine[64]; // 0 terminated string + char cpu[64]; // 0 terminated string + PlatformType type; +} PPCPlatformStrings; + +PPCPlatformStrings GetPPCPlatformStrings(void); + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +typedef enum { + PPC_32, /* 32 bit mode execution */ + PPC_64, /* 64 bit mode execution */ + PPC_601_INSTR, /* Old POWER ISA */ + PPC_HAS_ALTIVEC, /* SIMD Unit*/ + PPC_HAS_FPU, /* Floating Point Unit */ + PPC_HAS_MMU, /* Memory management unit */ + PPC_HAS_4xxMAC, + PPC_UNIFIED_CACHE, /* Unified instruction and data cache */ + PPC_HAS_SPE, /* Signal processing extention unit */ + PPC_HAS_EFP_SINGLE, /* SPE single precision fpu */ + PPC_HAS_EFP_DOUBLE, /* SPE double precision fpu */ + PPC_NO_TB, /* No timebase */ + PPC_POWER4, + PPC_POWER5, + PPC_POWER5_PLUS, + PPC_CELL, /* Cell broadband engine */ + PPC_BOOKE, /* Embedded ISA */ + PPC_SMT, /* Simultaneous multi-threading */ + PPC_ICACHE_SNOOP, + PPC_ARCH_2_05, /* ISA 2.05 - POWER6 */ + PPC_PA6T, /* PA Semi 6T core ISA */ + PPC_HAS_DFP, /* Decimal floating point unit */ + PPC_POWER6_EXT, + PPC_ARCH_2_06, /* ISA 2.06 - POWER7 */ + PPC_HAS_VSX, /* Vector-scalar extension */ + PPC_PSERIES_PERFMON_COMPAT, /* Set of backwards compatibile performance + monitoring events */ + PPC_TRUE_LE, + PPC_PPC_LE, + PPC_ARCH_2_07, /* ISA 2.07 - POWER8 */ + PPC_HTM, /* Hardware Transactional Memory */ + PPC_DSCR, /* Data stream control register */ + PPC_EBB, /* Event base branching */ + PPC_ISEL, /* Integer select instructions */ + PPC_TAR, /* Target address register */ + PPC_VEC_CRYPTO, /* Vector cryptography instructions */ + PPC_HTM_NOSC, /* Transactions aborted when syscall made*/ + PPC_ARCH_3_00, /* ISA 3.00 - POWER9 */ + PPC_HAS_IEEE128, /* VSX IEEE Binary Float 128-bit */ + PPC_DARN, /* Deliver a random number instruction */ + PPC_SCV, /* scv syscall */ + PPC_HTM_NO_SUSPEND, /* TM w/out suspended state */ + PPC_LAST_, +} PPCFeaturesEnum; + +int GetPPCFeaturesEnumValue(const PPCFeatures* features, PPCFeaturesEnum value); + +const char* GetPPCFeaturesEnumName(PPCFeaturesEnum); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_x86.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_x86.h new file mode 100644 index 0000000..0123ddb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/cpuinfo_x86.h @@ -0,0 +1,154 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_CPUINFO_X86_H_ +#define CPU_FEATURES_INCLUDE_CPUINFO_X86_H_ + +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +// See https://en.wikipedia.org/wiki/CPUID for a list of x86 cpu features. +typedef struct { + int aes : 1; + int erms : 1; + int f16c : 1; + int fma3 : 1; + int vpclmulqdq : 1; + int bmi1 : 1; + int bmi2 : 1; + + int ssse3 : 1; + int sse4_1 : 1; + int sse4_2 : 1; + + int avx : 1; + int avx2 : 1; + + int avx512f : 1; + int avx512cd : 1; + int avx512er : 1; + int avx512pf : 1; + int avx512bw : 1; + int avx512dq : 1; + int avx512vl : 1; + int avx512ifma : 1; + int avx512vbmi : 1; + int avx512vbmi2 : 1; + int avx512vnni : 1; + int avx512bitalg : 1; + int avx512vpopcntdq : 1; + int avx512_4vnniw : 1; + int avx512_4vbmi2 : 1; + + int smx : 1; + int sgx : 1; + int cx16 : 1; // aka. CMPXCHG16B + + // Make sure to update X86FeaturesEnum below if you add a field here. +} X86Features; + +typedef struct { + X86Features features; + int family; + int model; + int stepping; + char vendor[13]; // 0 terminated string +} X86Info; + +// Calls cpuid and returns an initialized X86info. +// This function is guaranteed to be malloc, memset and memcpy free. +X86Info GetX86Info(void); + +typedef enum { + X86_UNKNOWN, + INTEL_CORE, // CORE + INTEL_PNR, // PENRYN + INTEL_NHM, // NEHALEM + INTEL_ATOM_BNL, // BONNELL + INTEL_WSM, // WESTMERE + INTEL_SNB, // SANDYBRIDGE + INTEL_IVB, // IVYBRIDGE + INTEL_ATOM_SMT, // SILVERMONT + INTEL_HSW, // HASWELL + INTEL_BDW, // BROADWELL + INTEL_SKL, // SKYLAKE + INTEL_ATOM_GMT, // GOLDMONT + INTEL_KBL, // KABY LAKE + INTEL_CFL, // COFFEE LAKE + INTEL_CNL, // CANNON LAKE + AMD_HAMMER, // K8 + AMD_K10, // K10 + AMD_BOBCAT, // K14 + AMD_BULLDOZER, // K15 + AMD_JAGUAR, // K16 + AMD_ZEN, // K17 +} X86Microarchitecture; + +// Returns the underlying microarchitecture by looking at X86Info's vendor, +// family and model. +X86Microarchitecture GetX86Microarchitecture(const X86Info* info); + +// Calls cpuid and fills the brand_string. +// - brand_string *must* be of size 49 (beware of array decaying). +// - brand_string will be zero terminated. +// - This function calls memcpy. +void FillX86BrandString(char brand_string[49]); + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +typedef enum { + X86_AES, + X86_ERMS, + X86_F16C, + X86_FMA3, + X86_VPCLMULQDQ, + X86_BMI1, + X86_BMI2, + X86_SSSE3, + X86_SSE4_1, + X86_SSE4_2, + X86_AVX, + X86_AVX2, + X86_AVX512F, + X86_AVX512CD, + X86_AVX512ER, + X86_AVX512PF, + X86_AVX512BW, + X86_AVX512DQ, + X86_AVX512VL, + X86_AVX512IFMA, + X86_AVX512VBMI, + X86_AVX512VBMI2, + X86_AVX512VNNI, + X86_AVX512BITALG, + X86_AVX512VPOPCNTDQ, + X86_AVX512_4VNNIW, + X86_AVX512_4VBMI2, + X86_SMX, + X86_SGX, + X86_CX16, + X86_LAST_, +} X86FeaturesEnum; + +int GetX86FeaturesEnumValue(const X86Features* features, X86FeaturesEnum value); + +const char* GetX86FeaturesEnumName(X86FeaturesEnum); + +const char* GetX86MicroarchitectureName(X86Microarchitecture); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_CPUINFO_X86_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/bit_utils.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/bit_utils.h new file mode 100644 index 0000000..75f0cdd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/bit_utils.h @@ -0,0 +1,39 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_ + +#include +#include +#include +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +inline static bool IsBitSet(uint32_t reg, uint32_t bit) { + return (reg >> bit) & 0x1; +} + +inline static uint32_t ExtractBitRange(uint32_t reg, uint32_t msb, + uint32_t lsb) { + const uint64_t bits = msb - lsb + 1; + const uint64_t mask = (1ULL << bits) - 1ULL; + assert(msb >= lsb); + return (reg >> lsb) & mask; +} + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/cpuid_x86.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/cpuid_x86.h new file mode 100644 index 0000000..9dcee0d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/cpuid_x86.h @@ -0,0 +1,37 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_ + +#include + +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +// A struct to hold the result of a call to cpuid. +typedef struct { + uint32_t eax, ebx, ecx, edx; +} Leaf; + +// Retrieves the leaf for a particular cpuid. +Leaf CpuId(uint32_t leaf_id); + +// Returns the eax value of the XCR0 register. +uint32_t GetXCR0Eax(void); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/filesystem.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/filesystem.h new file mode 100644 index 0000000..3378881 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/filesystem.h @@ -0,0 +1,38 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// An interface for the filesystem that allows mocking the filesystem in +// unittests. +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_ + +#include +#include +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +// Same as linux "open(filename, O_RDONLY)", retries automatically on EINTR. +int CpuFeatures_OpenFile(const char* filename); + +// Same as linux "read(file_descriptor, buffer, buffer_size)", retries +// automatically on EINTR. +int CpuFeatures_ReadFile(int file_descriptor, void* buffer, size_t buffer_size); + +// Same as linux "close(file_descriptor)". +void CpuFeatures_CloseFile(int file_descriptor); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/hwcaps.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/hwcaps.h new file mode 100644 index 0000000..830cde3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/hwcaps.h @@ -0,0 +1,131 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Interface to retrieve hardware capabilities. It relies on Linux's getauxval +// or `/proc/self/auxval` under the hood. +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_ + +#include +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +// To avoid depending on the linux kernel we reproduce the architecture specific +// constants here. + +// http://elixir.free-electrons.com/linux/latest/source/arch/arm64/include/uapi/asm/hwcap.h +#define AARCH64_HWCAP_FP (1UL << 0) +#define AARCH64_HWCAP_ASIMD (1UL << 1) +#define AARCH64_HWCAP_AES (1UL << 3) +#define AARCH64_HWCAP_PMULL (1UL << 4) +#define AARCH64_HWCAP_SHA1 (1UL << 5) +#define AARCH64_HWCAP_SHA2 (1UL << 6) +#define AARCH64_HWCAP_CRC32 (1UL << 7) + +// http://elixir.free-electrons.com/linux/latest/source/arch/arm/include/uapi/asm/hwcap.h +#define ARM_HWCAP_VFP (1UL << 6) +#define ARM_HWCAP_IWMMXT (1UL << 9) +#define ARM_HWCAP_NEON (1UL << 12) +#define ARM_HWCAP_VFPV3 (1UL << 13) +#define ARM_HWCAP_VFPV3D16 (1UL << 14) +#define ARM_HWCAP_VFPV4 (1UL << 16) +#define ARM_HWCAP_IDIVA (1UL << 17) +#define ARM_HWCAP_IDIVT (1UL << 18) +#define ARM_HWCAP2_AES (1UL << 0) +#define ARM_HWCAP2_PMULL (1UL << 1) +#define ARM_HWCAP2_SHA1 (1UL << 2) +#define ARM_HWCAP2_SHA2 (1UL << 3) +#define ARM_HWCAP2_CRC32 (1UL << 4) + +// http://elixir.free-electrons.com/linux/latest/source/arch/mips/include/uapi/asm/hwcap.h +#define MIPS_HWCAP_VZ (1UL << 0) +#define MIPS_HWCAP_EVA (1UL << 1) +#define MIPS_HWCAP_HTW (1UL << 2) +#define MIPS_HWCAP_FPU (1UL << 3) +#define MIPS_HWCAP_MIPS32R2 (1UL << 4) +#define MIPS_HWCAP_MIPS32R5 (1UL << 5) +#define MIPS_HWCAP_MIPS64R6 (1UL << 6) +#define MIPS_HWCAP_DSPR1 (1UL << 7) +#define MIPS_HWCAP_DSPR2 (1UL << 8) +#define MIPS_HWCAP_MSA (1UL << 9) + +// http://elixir.free-electrons.com/linux/latest/source/arch/powerpc/include/uapi/asm/cputable.h +#ifndef _UAPI__ASM_POWERPC_CPUTABLE_H +/* in AT_HWCAP */ +#define PPC_FEATURE_32 0x80000000 +#define PPC_FEATURE_64 0x40000000 +#define PPC_FEATURE_601_INSTR 0x20000000 +#define PPC_FEATURE_HAS_ALTIVEC 0x10000000 +#define PPC_FEATURE_HAS_FPU 0x08000000 +#define PPC_FEATURE_HAS_MMU 0x04000000 +#define PPC_FEATURE_HAS_4xxMAC 0x02000000 +#define PPC_FEATURE_UNIFIED_CACHE 0x01000000 +#define PPC_FEATURE_HAS_SPE 0x00800000 +#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 +#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 +#define PPC_FEATURE_NO_TB 0x00100000 +#define PPC_FEATURE_POWER4 0x00080000 +#define PPC_FEATURE_POWER5 0x00040000 +#define PPC_FEATURE_POWER5_PLUS 0x00020000 +#define PPC_FEATURE_CELL 0x00010000 +#define PPC_FEATURE_BOOKE 0x00008000 +#define PPC_FEATURE_SMT 0x00004000 +#define PPC_FEATURE_ICACHE_SNOOP 0x00002000 +#define PPC_FEATURE_ARCH_2_05 0x00001000 +#define PPC_FEATURE_PA6T 0x00000800 +#define PPC_FEATURE_HAS_DFP 0x00000400 +#define PPC_FEATURE_POWER6_EXT 0x00000200 +#define PPC_FEATURE_ARCH_2_06 0x00000100 +#define PPC_FEATURE_HAS_VSX 0x00000080 + +#define PPC_FEATURE_PSERIES_PERFMON_COMPAT 0x00000040 + +/* Reserved - do not use 0x00000004 */ +#define PPC_FEATURE_TRUE_LE 0x00000002 +#define PPC_FEATURE_PPC_LE 0x00000001 + +/* in AT_HWCAP2 */ +#define PPC_FEATURE2_ARCH_2_07 0x80000000 +#define PPC_FEATURE2_HTM 0x40000000 +#define PPC_FEATURE2_DSCR 0x20000000 +#define PPC_FEATURE2_EBB 0x10000000 +#define PPC_FEATURE2_ISEL 0x08000000 +#define PPC_FEATURE2_TAR 0x04000000 +#define PPC_FEATURE2_VEC_CRYPTO 0x02000000 +#define PPC_FEATURE2_HTM_NOSC 0x01000000 +#define PPC_FEATURE2_ARCH_3_00 0x00800000 +#define PPC_FEATURE2_HAS_IEEE128 0x00400000 +#define PPC_FEATURE2_DARN 0x00200000 +#define PPC_FEATURE2_SCV 0x00100000 +#define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000 +#endif + +typedef struct { + unsigned long hwcaps; + unsigned long hwcaps2; +} HardwareCapabilities; + +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void); + +typedef struct { + char platform[64]; // 0 terminated string + char base_platform[64]; // 0 terminated string +} PlatformType; + +PlatformType CpuFeatures_GetPlatformType(void); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/linux_features_aggregator.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/linux_features_aggregator.h new file mode 100644 index 0000000..77661d4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/linux_features_aggregator.h @@ -0,0 +1,60 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// CapabilityConfig provides a way to map cpu features to hardware caps and +// /proc/cpuinfo flags. We then provide functions to update capabilities from +// either source. +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_LINUX_FEATURES_AGGREGATOR_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_LINUX_FEATURES_AGGREGATOR_H_ + +#include +#include +#include "cpu_features_macros.h" +#include "internal/hwcaps.h" +#include "internal/string_view.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +// Use the following macro to declare setter functions to be used in +// CapabilityConfig. +#define DECLARE_SETTER(FeatureType, FeatureName) \ + static void set_##FeatureName(void* const features, bool value) { \ + ((FeatureType*)features)->FeatureName = value; \ + } + +// Describes the relationship between hardware caps and /proc/cpuinfo flags. +typedef struct { + const HardwareCapabilities hwcaps_mask; + const char* const proc_cpuinfo_flag; + void (*set_bit)(void* const, bool); // setter for the corresponding bit. +} CapabilityConfig; + +// For every config, looks into flags_line for the presence of the +// corresponding proc_cpuinfo_flag, calls `set_bit` accordingly. +// Note: features is a pointer to the underlying Feature struct. +void CpuFeatures_SetFromFlags(const size_t configs_size, + const CapabilityConfig* configs, + const StringView flags_line, + void* const features); + +// For every config, looks into hwcaps for the presence of the feature. Calls +// `set_bit` with true if the hardware capability is found. +// Note: features is a pointer to the underlying Feature struct. +void CpuFeatures_OverrideFromHwCaps(const size_t configs_size, + const CapabilityConfig* configs, + const HardwareCapabilities hwcaps, + void* const features); + +CPU_FEATURES_END_CPP_NAMESPACE +#endif // CPU_FEATURES_INCLUDE_INTERNAL_LINUX_FEATURES_AGGREGATOR_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/stack_line_reader.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/stack_line_reader.h new file mode 100644 index 0000000..c540f6b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/stack_line_reader.h @@ -0,0 +1,49 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Reads a file line by line and stores the data on the stack. This allows +// parsing files in one go without allocating. +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_ + +#include + +#include "cpu_features_macros.h" +#include "internal/string_view.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct { + char buffer[STACK_LINE_READER_BUFFER_SIZE]; + StringView view; + int fd; + bool skip_mode; +} StackLineReader; + +// Initializes a StackLineReader. +void StackLineReader_Initialize(StackLineReader* reader, int fd); + +typedef struct { + StringView line; // A view of the line. + bool eof; // Nothing more to read, we reached EOF. + bool full_line; // If false the line was truncated to + // STACK_LINE_READER_BUFFER_SIZE. +} LineResult; + +// Reads the file pointed to by fd and tries to read a full line. +LineResult StackLineReader_NextLine(StackLineReader* reader); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/string_view.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/string_view.h new file mode 100644 index 0000000..aa3779c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/include/internal/string_view.h @@ -0,0 +1,108 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// A view over a piece of string. The view is not 0 terminated. +#ifndef CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_ +#define CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_ + +#include +#include +#include +#include "cpu_features_macros.h" + +CPU_FEATURES_START_CPP_NAMESPACE + +typedef struct { + const char* ptr; + size_t size; +} StringView; + +#ifdef __cplusplus +static const StringView kEmptyStringView = {NULL, 0}; +#else +static const StringView kEmptyStringView; +#endif + +// Returns a StringView from the provided string. +// Passing NULL is valid only if size is 0. +static inline StringView view(const char* str, const size_t size) { + StringView view; + view.ptr = str; + view.size = size; + return view; +} + +static inline StringView str(const char* str) { return view(str, strlen(str)); } + +// Returns the index of the first occurrence of c in view or -1 if not found. +int CpuFeatures_StringView_IndexOfChar(const StringView view, char c); + +// Returns the index of the first occurrence of sub_view in view or -1 if not +// found. +int CpuFeatures_StringView_IndexOf(const StringView view, + const StringView sub_view); + +// Returns whether a is equal to b (same content). +bool CpuFeatures_StringView_IsEquals(const StringView a, const StringView b); + +// Returns whether a starts with b. +bool CpuFeatures_StringView_StartsWith(const StringView a, const StringView b); + +// Removes count characters from the beginning of view or kEmptyStringView if +// count if greater than view.size. +StringView CpuFeatures_StringView_PopFront(const StringView str_view, + size_t count); + +// Removes count characters from the end of view or kEmptyStringView if count if +// greater than view.size. +StringView CpuFeatures_StringView_PopBack(const StringView str_view, + size_t count); + +// Keeps the count first characters of view or view if count if greater than +// view.size. +StringView CpuFeatures_StringView_KeepFront(const StringView str_view, + size_t count); + +// Retrieves the first character of view. If view is empty the behavior is +// undefined. +char CpuFeatures_StringView_Front(const StringView view); + +// Retrieves the last character of view. If view is empty the behavior is +// undefined. +char CpuFeatures_StringView_Back(const StringView view); + +// Removes leading and tailing space characters. +StringView CpuFeatures_StringView_TrimWhitespace(StringView view); + +// Convert StringView to positive integer. e.g. "42", "0x2a". +// Returns -1 on error. +int CpuFeatures_StringView_ParsePositiveNumber(const StringView view); + +// Copies src StringView to dst buffer. +void CpuFeatures_StringView_CopyString(const StringView src, char* dst, + size_t dst_size); + +// Checks if line contains the specified whitespace separated word. +bool CpuFeatures_StringView_HasWord(const StringView line, + const char* const word); + +// Get key/value from line. key and value are separated by ": ". +// key and value are cleaned up from leading and trailing whitespaces. +bool CpuFeatures_StringView_GetAttributeKeyValue(const StringView line, + StringView* key, + StringView* value); + +CPU_FEATURES_END_CPP_NAMESPACE + +#endif // CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/run_integration.sh b/src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/run_integration.sh new file mode 100644 index 0000000..a1de0d1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/run_integration.sh @@ -0,0 +1,173 @@ +#!/bin/bash + +readonly SCRIPT_FOLDER=$(cd -P -- "$(dirname -- "$0")" && pwd -P) +readonly PROJECT_FOLDER="${SCRIPT_FOLDER}/.." +readonly ARCHIVE_FOLDER=~/cpu_features_archives +readonly QEMU_INSTALL=${ARCHIVE_FOLDER}/qemu +readonly DEFAULT_CMAKE_ARGS=" -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON" + +function extract() { + case $1 in + *.tar.bz2) tar xjf "$1" ;; + *.tar.xz) tar xJf "$1" ;; + *.tar.gz) tar xzf "$1" ;; + *) + echo "don't know how to extract '$1'..." + exit 1 + esac +} + +function unpackifnotexists() { + mkdir -p "${ARCHIVE_FOLDER}" + cd "${ARCHIVE_FOLDER}" || exit + local URL=$1 + local RELATIVE_FOLDER=$2 + local DESTINATION="${ARCHIVE_FOLDER}/${RELATIVE_FOLDER}" + if [[ ! -d "${DESTINATION}" ]] ; then + local ARCHIVE_NAME=$(echo ${URL} | sed 's/.*\///') + test -f "${ARCHIVE_NAME}" || wget -q "${URL}" + extract "${ARCHIVE_NAME}" + fi +} + +function installqemuifneeded() { + local VERSION=${QEMU_VERSION:=2.11.1} + local ARCHES=${QEMU_ARCHES:=arm aarch64 i386 x86_64 mips mipsel} + local TARGETS=${QEMU_TARGETS:=$(echo "$ARCHES" | sed 's#$# #;s#\([^ ]*\) #\1-linux-user #g')} + + if echo "${VERSION} ${TARGETS}" | cmp --silent ${QEMU_INSTALL}/.build -; then + echo "qemu ${VERSION} up to date!" + return 0 + fi + + echo "VERSION: ${VERSION}" + echo "TARGETS: ${TARGETS}" + + rm -rf ${QEMU_INSTALL} + + # Checking for a tarball before downloading makes testing easier :-) + local QEMU_URL="http://wiki.qemu-project.org/download/qemu-${VERSION}.tar.xz" + local QEMU_FOLDER="qemu-${VERSION}" + unpackifnotexists ${QEMU_URL} ${QEMU_FOLDER} + cd ${QEMU_FOLDER} || exit + + ./configure \ + --prefix="${QEMU_INSTALL}" \ + --target-list="${TARGETS}" \ + --disable-docs \ + --disable-sdl \ + --disable-gtk \ + --disable-gnutls \ + --disable-gcrypt \ + --disable-nettle \ + --disable-curses \ + --static + + make -j4 + make install + + echo "$VERSION $TARGETS" > ${QEMU_INSTALL}/.build +} + +function assert_defined(){ + local VALUE=${1} + : "${VALUE?"${1} needs to be defined"}" +} + +function integrate() { + cd "${PROJECT_FOLDER}" || exit + cmake -H. -B"${BUILD_DIR}" ${DEFAULT_CMAKE_ARGS} ${CMAKE_ADDITIONAL_ARGS} + cmake --build "${BUILD_DIR}" --target all + + if [[ -n "${QEMU_ARCH}" ]]; then + if [[ "${QEMU_ARCH}" == "DISABLED" ]]; then + QEMU="true || " + else + installqemuifneeded + QEMU="${QEMU_INSTALL}/bin/qemu-${QEMU_ARCH} ${QEMU_ARGS}" + fi + else + QEMU="" + fi + # Run tests + for test_binary in ${BUILD_DIR}/test/*_test; do ${QEMU} ${test_binary}; done + # Run demo program + ${QEMU} "${BUILD_DIR}/list_cpu_features" +} + +function expand_linaro_config() { + assert_defined TARGET + local LINARO_ROOT_URL=https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11 + + local GCC_URL=${LINARO_ROOT_URL}/${TARGET}/gcc-linaro-7.2.1-2017.11-x86_64_${TARGET}.tar.xz + local GCC_RELATIVE_FOLDER="gcc-linaro-7.2.1-2017.11-x86_64_${TARGET}" + unpackifnotexists "${GCC_URL}" "${GCC_RELATIVE_FOLDER}" + + local SYSROOT_URL=${LINARO_ROOT_URL}/${TARGET}/sysroot-glibc-linaro-2.25-2017.11-${TARGET}.tar.xz + local SYSROOT_RELATIVE_FOLDER=sysroot-glibc-linaro-2.25-2017.11-${TARGET} + unpackifnotexists "${SYSROOT_URL}" "${SYSROOT_RELATIVE_FOLDER}" + + local SYSROOT_FOLDER=${ARCHIVE_FOLDER}/${SYSROOT_RELATIVE_FOLDER} + local GCC_FOLDER=${ARCHIVE_FOLDER}/${GCC_RELATIVE_FOLDER} + + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_SYSROOT=${SYSROOT_FOLDER}" + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_C_COMPILER=${GCC_FOLDER}/bin/${TARGET}-gcc" + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_CXX_COMPILER=${GCC_FOLDER}/bin/${TARGET}-g++" + + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER" + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY" + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY" + + QEMU_ARGS+=" -L ${SYSROOT_FOLDER}" + QEMU_ARGS+=" -E LD_LIBRARY_PATH=/lib" +} + +function expand_codescape_config() { + assert_defined TARGET + local FLAVOUR=${QEMU_ARCH}-r2-hard + local DATE=2016.05-03 + local CODESCAPE_URL=http://codescape-mips-sdk.imgtec.com/components/toolchain/${DATE}/Codescape.GNU.Tools.Package.${DATE}.for.MIPS.MTI.Linux.CentOS-5.x86_64.tar.gz + local GCC_URL=${CODESCAPE_URL} + local GCC_RELATIVE_FOLDER=${TARGET}/${DATE} + unpackifnotexists "${GCC_URL}" "${GCC_RELATIVE_FOLDER}" + + local SYSROOT_URL=${CODESCAPE_URL} + local SYSROOT_FOLDER=${ARCHIVE_FOLDER}/${GCC_RELATIVE_FOLDER}/sysroot/${FLAVOUR} + unpackifnotexists "${SYSROOT_URL}" "${SYSROOT_RELATIVE_FOLDER}" + + CMAKE_ADDITIONAL_ARGS+=" -DENABLE_MSA=1" + CMAKE_ADDITIONAL_ARGS+=" -DMIPS_CPU=p5600" + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_TOOLCHAIN_FILE=cmake/mips32-linux-gcc.cmake" + CMAKE_ADDITIONAL_ARGS+=" -DCROSS=${TARGET}-" + CMAKE_ADDITIONAL_ARGS+=" -DCMAKE_FIND_ROOT_PATH=${ARCHIVE_FOLDER}/${GCC_RELATIVE_FOLDER}" + + QEMU_ARGS+=" -L ${SYSROOT_FOLDER}" + QEMU_ARGS+=" -E LD_LIBRARY_PATH=/lib" + QEMU_ARGS+=" -cpu P5600" +} + +function expand_environment_and_integrate() { + assert_defined PROJECT_FOLDER + assert_defined TARGET + + BUILD_DIR="${PROJECT_FOLDER}/cmake_build/${TARGET}" + mkdir -p "${BUILD_DIR}" + + CMAKE_ADDITIONAL_ARGS="" + QEMU_ARGS="" + + case ${TOOLCHAIN} in + LINARO) expand_linaro_config ;; + CODESCAPE) expand_codescape_config ;; + NATIVE) QEMU_ARCH="" ;; + *) + echo "Unknown toolchain '${TOOLCHAIN}'..." + exit 1 + esac + integrate +} + +if [ "${CONTINUOUS_INTEGRATION}" = "true" ]; then + QEMU_ARCHES=${QEMU_ARCH} + expand_environment_and_integrate +fi diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/test_integration.sh b/src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/test_integration.sh new file mode 100644 index 0000000..53d1d3b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/scripts/test_integration.sh @@ -0,0 +1,80 @@ +source "$(dirname -- "$0")"/run_integration.sh + +# Toolchains for little-endian, 64-bit ARMv8 for GNU/Linux systems +function set_aarch64-linux-gnu() { + TOOLCHAIN=LINARO + TARGET=aarch64-linux-gnu + QEMU_ARCH=aarch64 +} + +# Toolchains for little-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems +function set_arm-linux-gnueabihf() { + TOOLCHAIN=LINARO + TARGET=arm-linux-gnueabihf + QEMU_ARCH=arm +} + +# Toolchains for little-endian, 32-bit ARMv8 for GNU/Linux systems +function set_armv8l-linux-gnueabihf() { + TOOLCHAIN=LINARO + TARGET=armv8l-linux-gnueabihf + QEMU_ARCH=arm +} + +# Toolchains for little-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems +function set_arm-linux-gnueabi() { + TOOLCHAIN=LINARO + TARGET=arm-linux-gnueabi + QEMU_ARCH=arm +} + +# Toolchains for big-endian, 64-bit ARMv8 for GNU/Linux systems +function set_aarch64_be-linux-gnu() { + TOOLCHAIN=LINARO + TARGET=aarch64_be-linux-gnu + QEMU_ARCH="DISABLED" +} + +# Toolchains for big-endian, hard-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems +function set_armeb-linux-gnueabihf() { + TOOLCHAIN=LINARO + TARGET=armeb-linux-gnueabihf + QEMU_ARCH="DISABLED" +} + +# Toolchains for big-endian, soft-float, 32-bit ARMv7 (and earlier) for GNU/Linux systems +function set_armeb-linux-gnueabi() { + TOOLCHAIN=LINARO + TARGET=armeb-linux-gnueabi + QEMU_ARCH="DISABLED" +} + + +function set_mips() { + TOOLCHAIN=CODESCAPE + TARGET=mips-mti-linux-gnu + QEMU_ARCH="DISABLED" +} + +function set_native() { + TOOLCHAIN=NATIVE + TARGET=native + QEMU_ARCH="" +} + +ENVIRONMENTS=" + set_aarch64-linux-gnu + set_arm-linux-gnueabihf + set_armv8l-linux-gnueabihf + set_arm-linux-gnueabi + set_aarch64_be-linux-gnu + set_armeb-linux-gnueabihf + set_armeb-linux-gnueabi + set_native + set_mips +" + +for SET_ENVIRONMENT in ${ENVIRONMENTS}; do + ${SET_ENVIRONMENT} + expand_environment_and_integrate +done diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_clang_gcc.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_clang_gcc.c new file mode 100644 index 0000000..472e712 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_clang_gcc.c @@ -0,0 +1,36 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/cpuid_x86.h" + +#if defined(CPU_FEATURES_ARCH_X86) +#if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC) + +#include + +Leaf CpuId(uint32_t leaf_id) { + Leaf leaf; + __cpuid_count(leaf_id, 0, leaf.eax, leaf.ebx, leaf.ecx, leaf.edx); + return leaf; +} + +uint32_t GetXCR0Eax(void) { + uint32_t eax, edx; + __asm("XGETBV" : "=a"(eax), "=d"(edx) : "c"(0)); + return eax; +} + +#endif // defined(CPU_FEATURES_COMPILER_CLANG) || + // defined(CPU_FEATURES_COMPILER_GCC) +#endif // defined(CPU_FEATURES_ARCH_X86) diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_msvc.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_msvc.c new file mode 100644 index 0000000..cd8f19f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuid_x86_msvc.c @@ -0,0 +1,34 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/cpuid_x86.h" + +#if defined(CPU_FEATURES_ARCH_X86) && defined(CPU_FEATURES_COMPILER_MSC) +#include +#include // For __cpuidex() + +Leaf CpuId(uint32_t leaf_id) { + Leaf leaf; + int data[4]; + __cpuid(data, leaf_id); + leaf.eax = data[0]; + leaf.ebx = data[1]; + leaf.ecx = data[2]; + leaf.edx = data[3]; + return leaf; +} + +uint32_t GetXCR0Eax(void) { return _xgetbv(0); } + +#endif // defined(CPU_FEATURES_ARCH_X86) && defined(CPU_FEATURES_COMPILER_MSC) diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_aarch64.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_aarch64.c new file mode 100644 index 0000000..0d111ff --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_aarch64.c @@ -0,0 +1,141 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_aarch64.h" + +#include "internal/filesystem.h" +#include "internal/hwcaps.h" +#include "internal/linux_features_aggregator.h" +#include "internal/stack_line_reader.h" +#include "internal/string_view.h" + +#include + +DECLARE_SETTER(Aarch64Features, fp) +DECLARE_SETTER(Aarch64Features, asimd) +DECLARE_SETTER(Aarch64Features, aes) +DECLARE_SETTER(Aarch64Features, pmull) +DECLARE_SETTER(Aarch64Features, sha1) +DECLARE_SETTER(Aarch64Features, sha2) +DECLARE_SETTER(Aarch64Features, crc32) + +static const CapabilityConfig kConfigs[] = { + {{AARCH64_HWCAP_FP, 0}, "fp", &set_fp}, // + {{AARCH64_HWCAP_ASIMD, 0}, "asimd", &set_asimd}, // + {{AARCH64_HWCAP_AES, 0}, "aes", &set_aes}, // + {{AARCH64_HWCAP_PMULL, 0}, "pmull", &set_pmull}, // + {{AARCH64_HWCAP_SHA1, 0}, "sha1", &set_sha1}, // + {{AARCH64_HWCAP_SHA2, 0}, "sha2", &set_sha2}, // + {{AARCH64_HWCAP_CRC32, 0}, "crc32", &set_crc32}, // +}; + +static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig); + +static bool HandleAarch64Line(const LineResult result, + Aarch64Info* const info) { + StringView line = result.line; + StringView key, value; + if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)) { + if (CpuFeatures_StringView_IsEquals(key, str("Features"))) { + CpuFeatures_SetFromFlags(kConfigsSize, kConfigs, value, &info->features); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU implementer"))) { + info->implementer = CpuFeatures_StringView_ParsePositiveNumber(value); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU variant"))) { + info->variant = CpuFeatures_StringView_ParsePositiveNumber(value); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU part"))) { + info->part = CpuFeatures_StringView_ParsePositiveNumber(value); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU revision"))) { + info->revision = CpuFeatures_StringView_ParsePositiveNumber(value); + } + } + return !result.eof; +} + +static void FillProcCpuInfoData(Aarch64Info* const info) { + const int fd = CpuFeatures_OpenFile("/proc/cpuinfo"); + if (fd >= 0) { + StackLineReader reader; + StackLineReader_Initialize(&reader, fd); + for (;;) { + if (!HandleAarch64Line(StackLineReader_NextLine(&reader), info)) { + break; + } + } + CpuFeatures_CloseFile(fd); + } +} + +static const Aarch64Info kEmptyAarch64Info; + +Aarch64Info GetAarch64Info(void) { + // capabilities are fetched from both getauxval and /proc/cpuinfo so we can + // have some information if the executable is sandboxed (aka no access to + // /proc/cpuinfo). + Aarch64Info info = kEmptyAarch64Info; + + FillProcCpuInfoData(&info); + CpuFeatures_OverrideFromHwCaps(kConfigsSize, kConfigs, + CpuFeatures_GetHardwareCapabilities(), + &info.features); + + return info; +} + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +int GetAarch64FeaturesEnumValue(const Aarch64Features* features, + Aarch64FeaturesEnum value) { + switch (value) { + case AARCH64_FP: + return features->fp; + case AARCH64_ASIMD: + return features->asimd; + case AARCH64_AES: + return features->aes; + case AARCH64_PMULL: + return features->pmull; + case AARCH64_SHA1: + return features->sha1; + case AARCH64_SHA2: + return features->sha2; + case AARCH64_CRC32: + return features->crc32; + case AARCH64_LAST_: + break; + } + return false; +} + +const char* GetAarch64FeaturesEnumName(Aarch64FeaturesEnum value) { + switch (value) { + case AARCH64_FP: + return "fp"; + case AARCH64_ASIMD: + return "asimd"; + case AARCH64_AES: + return "aes"; + case AARCH64_PMULL: + return "pmull"; + case AARCH64_SHA1: + return "sha1"; + case AARCH64_SHA2: + return "sha2"; + case AARCH64_CRC32: + return "crc32"; + case AARCH64_LAST_: + break; + } + return "unknown feature"; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_arm.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_arm.c new file mode 100644 index 0000000..3ea0641 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_arm.c @@ -0,0 +1,259 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_arm.h" + +#include "internal/bit_utils.h" +#include "internal/filesystem.h" +#include "internal/hwcaps.h" +#include "internal/linux_features_aggregator.h" +#include "internal/stack_line_reader.h" +#include "internal/string_view.h" + +#include + +DECLARE_SETTER(ArmFeatures, vfp) +DECLARE_SETTER(ArmFeatures, iwmmxt) +DECLARE_SETTER(ArmFeatures, neon) +DECLARE_SETTER(ArmFeatures, vfpv3) +DECLARE_SETTER(ArmFeatures, vfpv3d16) +DECLARE_SETTER(ArmFeatures, vfpv4) +DECLARE_SETTER(ArmFeatures, idiva) +DECLARE_SETTER(ArmFeatures, idivt) +DECLARE_SETTER(ArmFeatures, aes) +DECLARE_SETTER(ArmFeatures, pmull) +DECLARE_SETTER(ArmFeatures, sha1) +DECLARE_SETTER(ArmFeatures, sha2) +DECLARE_SETTER(ArmFeatures, crc32) + +static const CapabilityConfig kConfigs[] = { + {{ARM_HWCAP_VFP, 0}, "vfp", &set_vfp}, // + {{ARM_HWCAP_IWMMXT, 0}, "iwmmxt", &set_iwmmxt}, // + {{ARM_HWCAP_NEON, 0}, "neon", &set_neon}, // + {{ARM_HWCAP_VFPV3, 0}, "vfpv3", &set_vfpv3}, // + {{ARM_HWCAP_VFPV3D16, 0}, "vfpv3d16", &set_vfpv3d16}, // + {{ARM_HWCAP_VFPV4, 0}, "vfpv4", &set_vfpv4}, // + {{ARM_HWCAP_IDIVA, 0}, "idiva", &set_idiva}, // + {{ARM_HWCAP_IDIVT, 0}, "idivt", &set_idivt}, // + {{0, ARM_HWCAP2_AES}, "aes", &set_aes}, // + {{0, ARM_HWCAP2_PMULL}, "pmull", &set_pmull}, // + {{0, ARM_HWCAP2_SHA1}, "sha1", &set_sha1}, // + {{0, ARM_HWCAP2_SHA2}, "sha2", &set_sha2}, // + {{0, ARM_HWCAP2_CRC32}, "crc32", &set_crc32}, // +}; + +static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig); + +typedef struct { + bool processor_reports_armv6; + bool hardware_reports_goldfish; +} ProcCpuInfoData; + +static int IndexOfNonDigit(StringView str) { + size_t index = 0; + while (str.size && isdigit(CpuFeatures_StringView_Front(str))) { + str = CpuFeatures_StringView_PopFront(str, 1); + ++index; + } + return index; +} + +static bool HandleArmLine(const LineResult result, ArmInfo* const info, + ProcCpuInfoData* const proc_info) { + StringView line = result.line; + StringView key, value; + if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)) { + if (CpuFeatures_StringView_IsEquals(key, str("Features"))) { + CpuFeatures_SetFromFlags(kConfigsSize, kConfigs, value, &info->features); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU implementer"))) { + info->implementer = CpuFeatures_StringView_ParsePositiveNumber(value); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU variant"))) { + info->variant = CpuFeatures_StringView_ParsePositiveNumber(value); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU part"))) { + info->part = CpuFeatures_StringView_ParsePositiveNumber(value); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU revision"))) { + info->revision = CpuFeatures_StringView_ParsePositiveNumber(value); + } else if (CpuFeatures_StringView_IsEquals(key, str("CPU architecture"))) { + // CPU architecture is a number that may be followed by letters. e.g. + // "6TEJ", "7". + const StringView digits = + CpuFeatures_StringView_KeepFront(value, IndexOfNonDigit(value)); + info->architecture = CpuFeatures_StringView_ParsePositiveNumber(digits); + } else if (CpuFeatures_StringView_IsEquals(key, str("Processor"))) { + proc_info->processor_reports_armv6 = + CpuFeatures_StringView_IndexOf(value, str("(v6l)")) >= 0; + } else if (CpuFeatures_StringView_IsEquals(key, str("Hardware"))) { + proc_info->hardware_reports_goldfish = + CpuFeatures_StringView_IsEquals(value, str("Goldfish")); + } + } + return !result.eof; +} + +static uint32_t GetCpuId(const ArmInfo* const info) { + return (ExtractBitRange(info->implementer, 7, 0) << 24) | + (ExtractBitRange(info->variant, 3, 0) << 20) | + (ExtractBitRange(info->part, 11, 0) << 4) | + (ExtractBitRange(info->revision, 3, 0) << 0); +} + +static void FixErrors(ArmInfo* const info, + ProcCpuInfoData* const proc_cpu_info_data) { + // Fixing Samsung kernel reporting invalid cpu architecture. + // http://code.google.com/p/android/issues/detail?id=10812 + if (proc_cpu_info_data->processor_reports_armv6 && info->architecture >= 7) { + info->architecture = 6; + } + + // Handle kernel configuration bugs that prevent the correct reporting of CPU + // features. + switch (GetCpuId(info)) { + case 0x4100C080: + // Special case: The emulator-specific Android 4.2 kernel fails to report + // support for the 32-bit ARM IDIV instruction. Technically, this is a + // feature of the virtual CPU implemented by the emulator. Note that it + // could also support Thumb IDIV in the future, and this will have to be + // slightly updated. + if (info->architecture >= 7 && + proc_cpu_info_data->hardware_reports_goldfish) { + info->features.idiva = true; + } + break; + case 0x511004D0: + // https://crbug.com/341598. + info->features.neon = false; + break; + case 0x510006F2: + case 0x510006F3: + // The Nexus 4 (Qualcomm Krait) kernel configuration forgets to report + // IDIV support. + info->features.idiva = true; + info->features.idivt = true; + break; + } + + // Propagate cpu features. + if (info->features.vfpv4) info->features.vfpv3 = true; + if (info->features.neon) info->features.vfpv3 = true; + if (info->features.vfpv3) info->features.vfp = true; +} + +static void FillProcCpuInfoData(ArmInfo* const info, + ProcCpuInfoData* proc_cpu_info_data) { + const int fd = CpuFeatures_OpenFile("/proc/cpuinfo"); + if (fd >= 0) { + StackLineReader reader; + StackLineReader_Initialize(&reader, fd); + for (;;) { + if (!HandleArmLine(StackLineReader_NextLine(&reader), info, + proc_cpu_info_data)) { + break; + } + } + CpuFeatures_CloseFile(fd); + } +} + +static const ArmInfo kEmptyArmInfo; + +static const ProcCpuInfoData kEmptyProcCpuInfoData; + +ArmInfo GetArmInfo(void) { + // capabilities are fetched from both getauxval and /proc/cpuinfo so we can + // have some information if the executable is sandboxed (aka no access to + // /proc/cpuinfo). + ArmInfo info = kEmptyArmInfo; + ProcCpuInfoData proc_cpu_info_data = kEmptyProcCpuInfoData; + + FillProcCpuInfoData(&info, &proc_cpu_info_data); + CpuFeatures_OverrideFromHwCaps(kConfigsSize, kConfigs, + CpuFeatures_GetHardwareCapabilities(), + &info.features); + + FixErrors(&info, &proc_cpu_info_data); + + return info; +} + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +int GetArmFeaturesEnumValue(const ArmFeatures* features, + ArmFeaturesEnum value) { + switch (value) { + case ARM_VFP: + return features->vfp; + case ARM_IWMMXT: + return features->iwmmxt; + case ARM_NEON: + return features->neon; + case ARM_VFPV3: + return features->vfpv3; + case ARM_VFPV3D16: + return features->vfpv3d16; + case ARM_VFPV4: + return features->vfpv4; + case ARM_IDIVA: + return features->idiva; + case ARM_IDIVT: + return features->idivt; + case ARM_AES: + return features->aes; + case ARM_PMULL: + return features->pmull; + case ARM_SHA1: + return features->sha1; + case ARM_SHA2: + return features->sha2; + case ARM_CRC32: + return features->crc32; + case ARM_LAST_: + break; + } + return false; +} + +const char* GetArmFeaturesEnumName(ArmFeaturesEnum value) { + switch (value) { + case ARM_VFP: + return "vfp"; + case ARM_IWMMXT: + return "iwmmxt"; + case ARM_NEON: + return "neon"; + case ARM_VFPV3: + return "vfpv3"; + case ARM_VFPV3D16: + return "vfpv3d16"; + case ARM_VFPV4: + return "vfpv4"; + case ARM_IDIVA: + return "idiva"; + case ARM_IDIVT: + return "idivt"; + case ARM_AES: + return "aes"; + case ARM_PMULL: + return "pmull"; + case ARM_SHA1: + return "sha1"; + case ARM_SHA2: + return "sha2"; + case ARM_CRC32: + return "crc32"; + case ARM_LAST_: + break; + } + return "unknown feature"; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_mips.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_mips.c new file mode 100644 index 0000000..a61cdd8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_mips.c @@ -0,0 +1,98 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_mips.h" + +#include "internal/filesystem.h" +#include "internal/linux_features_aggregator.h" +#include "internal/stack_line_reader.h" +#include "internal/string_view.h" + +DECLARE_SETTER(MipsFeatures, msa) +DECLARE_SETTER(MipsFeatures, eva) + +static const CapabilityConfig kConfigs[] = { + {{MIPS_HWCAP_MSA, 0}, "msa", &set_msa}, // + {{MIPS_HWCAP_EVA, 0}, "eva", &set_eva}, // +}; +static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig); + +static bool HandleMipsLine(const LineResult result, + MipsFeatures* const features) { + StringView key, value; + // See tests for an example. + if (CpuFeatures_StringView_GetAttributeKeyValue(result.line, &key, &value)) { + if (CpuFeatures_StringView_IsEquals(key, str("ASEs implemented"))) { + CpuFeatures_SetFromFlags(kConfigsSize, kConfigs, value, features); + } + } + return !result.eof; +} + +static void FillProcCpuInfoData(MipsFeatures* const features) { + const int fd = CpuFeatures_OpenFile("/proc/cpuinfo"); + if (fd >= 0) { + StackLineReader reader; + StackLineReader_Initialize(&reader, fd); + for (;;) { + if (!HandleMipsLine(StackLineReader_NextLine(&reader), features)) { + break; + } + } + CpuFeatures_CloseFile(fd); + } +} + +static const MipsInfo kEmptyMipsInfo; + +MipsInfo GetMipsInfo(void) { + // capabilities are fetched from both getauxval and /proc/cpuinfo so we can + // have some information if the executable is sandboxed (aka no access to + // /proc/cpuinfo). + MipsInfo info = kEmptyMipsInfo; + + FillProcCpuInfoData(&info.features); + CpuFeatures_OverrideFromHwCaps(kConfigsSize, kConfigs, + CpuFeatures_GetHardwareCapabilities(), + &info.features); + return info; +} + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +int GetMipsFeaturesEnumValue(const MipsFeatures* features, + MipsFeaturesEnum value) { + switch (value) { + case MIPS_MSA: + return features->msa; + case MIPS_EVA: + return features->eva; + case MIPS_LAST_: + break; + } + return false; +} + +const char* GetMipsFeaturesEnumName(MipsFeaturesEnum value) { + switch (value) { + case MIPS_MSA: + return "msa"; + case MIPS_EVA: + return "eva"; + case MIPS_LAST_: + break; + } + return "unknown feature"; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_ppc.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_ppc.c new file mode 100644 index 0000000..59b9ecc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_ppc.c @@ -0,0 +1,358 @@ +// Copyright 2018 IBM. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "cpuinfo_ppc.h" +#include "internal/bit_utils.h" +#include "internal/filesystem.h" +#include "internal/linux_features_aggregator.h" +#include "internal/stack_line_reader.h" +#include "internal/string_view.h" + +DECLARE_SETTER(PPCFeatures, ppc32) +DECLARE_SETTER(PPCFeatures, ppc64) +DECLARE_SETTER(PPCFeatures, ppc601) +DECLARE_SETTER(PPCFeatures, altivec) +DECLARE_SETTER(PPCFeatures, fpu) +DECLARE_SETTER(PPCFeatures, mmu) +DECLARE_SETTER(PPCFeatures, mac_4xx) +DECLARE_SETTER(PPCFeatures, unifiedcache) +DECLARE_SETTER(PPCFeatures, spe) +DECLARE_SETTER(PPCFeatures, efpsingle) +DECLARE_SETTER(PPCFeatures, efpdouble) +DECLARE_SETTER(PPCFeatures, no_tb) +DECLARE_SETTER(PPCFeatures, power4) +DECLARE_SETTER(PPCFeatures, power5) +DECLARE_SETTER(PPCFeatures, power5plus) +DECLARE_SETTER(PPCFeatures, cell) +DECLARE_SETTER(PPCFeatures, booke) +DECLARE_SETTER(PPCFeatures, smt) +DECLARE_SETTER(PPCFeatures, icachesnoop) +DECLARE_SETTER(PPCFeatures, arch205) +DECLARE_SETTER(PPCFeatures, pa6t) +DECLARE_SETTER(PPCFeatures, dfp) +DECLARE_SETTER(PPCFeatures, power6ext) +DECLARE_SETTER(PPCFeatures, arch206) +DECLARE_SETTER(PPCFeatures, vsx) +DECLARE_SETTER(PPCFeatures, pseries_perfmon_compat) +DECLARE_SETTER(PPCFeatures, truele) +DECLARE_SETTER(PPCFeatures, ppcle) +DECLARE_SETTER(PPCFeatures, arch207) +DECLARE_SETTER(PPCFeatures, htm) +DECLARE_SETTER(PPCFeatures, dscr) +DECLARE_SETTER(PPCFeatures, ebb) +DECLARE_SETTER(PPCFeatures, isel) +DECLARE_SETTER(PPCFeatures, tar) +DECLARE_SETTER(PPCFeatures, vcrypto) +DECLARE_SETTER(PPCFeatures, htm_nosc) +DECLARE_SETTER(PPCFeatures, arch300) +DECLARE_SETTER(PPCFeatures, ieee128) +DECLARE_SETTER(PPCFeatures, darn) +DECLARE_SETTER(PPCFeatures, scv) +DECLARE_SETTER(PPCFeatures, htm_no_suspend) + +static const CapabilityConfig kConfigs[] = { + {{PPC_FEATURE_32, 0}, "ppc32", &set_ppc32}, + {{PPC_FEATURE_64, 0}, "ppc64", &set_ppc64}, + {{PPC_FEATURE_601_INSTR, 0}, "ppc601", &set_ppc601}, + {{PPC_FEATURE_HAS_ALTIVEC, 0}, "altivec", &set_altivec}, + {{PPC_FEATURE_HAS_FPU, 0}, "fpu", &set_fpu}, + {{PPC_FEATURE_HAS_MMU, 0}, "mmu", &set_mmu}, + {{PPC_FEATURE_HAS_4xxMAC, 0}, "4xxmac", &set_mac_4xx}, + {{PPC_FEATURE_UNIFIED_CACHE, 0}, "ucache", &set_unifiedcache}, + {{PPC_FEATURE_HAS_SPE, 0}, "spe", &set_spe}, + {{PPC_FEATURE_HAS_EFP_SINGLE, 0}, "efpsingle", &set_efpsingle}, + {{PPC_FEATURE_HAS_EFP_DOUBLE, 0}, "efpdouble", &set_efpdouble}, + {{PPC_FEATURE_NO_TB, 0}, "notb", &set_no_tb}, + {{PPC_FEATURE_POWER4, 0}, "power4", &set_power4}, + {{PPC_FEATURE_POWER5, 0}, "power5", &set_power5}, + {{PPC_FEATURE_POWER5_PLUS, 0}, "power5+", &set_power5plus}, + {{PPC_FEATURE_CELL, 0}, "cellbe", &set_cell}, + {{PPC_FEATURE_BOOKE, 0}, "booke", &set_booke}, + {{PPC_FEATURE_SMT, 0}, "smt", &set_smt}, + {{PPC_FEATURE_ICACHE_SNOOP, 0}, "ic_snoop", &set_icachesnoop}, + {{PPC_FEATURE_ARCH_2_05, 0}, "arch_2_05", &set_arch205}, + {{PPC_FEATURE_PA6T, 0}, "pa6t", &set_pa6t}, + {{PPC_FEATURE_HAS_DFP, 0}, "dfp", &set_dfp}, + {{PPC_FEATURE_POWER6_EXT, 0}, "power6x", &set_power6ext}, + {{PPC_FEATURE_ARCH_2_06, 0}, "arch_2_06", &set_arch206}, + {{PPC_FEATURE_HAS_VSX, 0}, "vsx", &set_vsx}, + {{PPC_FEATURE_PSERIES_PERFMON_COMPAT, 0}, + "archpmu", + &set_pseries_perfmon_compat}, + {{PPC_FEATURE_TRUE_LE, 0}, "true_le", &set_truele}, + {{PPC_FEATURE_PPC_LE, 0}, "ppcle", &set_ppcle}, + {{0, PPC_FEATURE2_ARCH_2_07}, "arch_2_07", &set_arch207}, + {{0, PPC_FEATURE2_HTM}, "htm", &set_htm}, + {{0, PPC_FEATURE2_DSCR}, "dscr", &set_dscr}, + {{0, PPC_FEATURE2_EBB}, "ebb", &set_ebb}, + {{0, PPC_FEATURE2_ISEL}, "isel", &set_isel}, + {{0, PPC_FEATURE2_TAR}, "tar", &set_tar}, + {{0, PPC_FEATURE2_VEC_CRYPTO}, "vcrypto", &set_vcrypto}, + {{0, PPC_FEATURE2_HTM_NOSC}, "htm-nosc", &set_htm_nosc}, + {{0, PPC_FEATURE2_ARCH_3_00}, "arch_3_00", &set_arch300}, + {{0, PPC_FEATURE2_HAS_IEEE128}, "ieee128", &set_ieee128}, + {{0, PPC_FEATURE2_DARN}, "darn", &set_darn}, + {{0, PPC_FEATURE2_SCV}, "scv", &set_scv}, + {{0, PPC_FEATURE2_HTM_NO_SUSPEND}, "htm-no-suspend", &set_htm_no_suspend}, +}; +static const size_t kConfigsSize = sizeof(kConfigs) / sizeof(CapabilityConfig); + +static bool HandlePPCLine(const LineResult result, + PPCPlatformStrings* const strings) { + StringView line = result.line; + StringView key, value; + if (CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)) { + if (CpuFeatures_StringView_HasWord(key, "platform")) { + CpuFeatures_StringView_CopyString(value, strings->platform, + sizeof(strings->platform)); + } else if (CpuFeatures_StringView_IsEquals(key, str("model"))) { + CpuFeatures_StringView_CopyString(value, strings->model, + sizeof(strings->platform)); + } else if (CpuFeatures_StringView_IsEquals(key, str("machine"))) { + CpuFeatures_StringView_CopyString(value, strings->machine, + sizeof(strings->platform)); + } else if (CpuFeatures_StringView_IsEquals(key, str("cpu"))) { + CpuFeatures_StringView_CopyString(value, strings->cpu, + sizeof(strings->platform)); + } + } + return !result.eof; +} + +static void FillProcCpuInfoData(PPCPlatformStrings* const strings) { + const int fd = CpuFeatures_OpenFile("/proc/cpuinfo"); + if (fd >= 0) { + StackLineReader reader; + StackLineReader_Initialize(&reader, fd); + for (;;) { + if (!HandlePPCLine(StackLineReader_NextLine(&reader), strings)) { + break; + } + } + CpuFeatures_CloseFile(fd); + } +} + +static const PPCInfo kEmptyPPCInfo; + +PPCInfo GetPPCInfo(void) { + /* + * On Power feature flags aren't currently in cpuinfo so we only look at + * the auxilary vector. + */ + PPCInfo info = kEmptyPPCInfo; + + CpuFeatures_OverrideFromHwCaps(kConfigsSize, kConfigs, + CpuFeatures_GetHardwareCapabilities(), + &info.features); + return info; +} + +static const PPCPlatformStrings kEmptyPPCPlatformStrings; + +PPCPlatformStrings GetPPCPlatformStrings(void) { + PPCPlatformStrings strings = kEmptyPPCPlatformStrings; + + FillProcCpuInfoData(&strings); + strings.type = CpuFeatures_GetPlatformType(); + return strings; +} + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +int GetPPCFeaturesEnumValue(const PPCFeatures* features, + PPCFeaturesEnum value) { + switch (value) { + case PPC_32: + return features->ppc32; + case PPC_64: + return features->ppc64; + case PPC_601_INSTR: + return features->ppc601; + case PPC_HAS_ALTIVEC: + return features->altivec; + case PPC_HAS_FPU: + return features->fpu; + case PPC_HAS_MMU: + return features->mmu; + case PPC_HAS_4xxMAC: + return features->mac_4xx; + case PPC_UNIFIED_CACHE: + return features->unifiedcache; + case PPC_HAS_SPE: + return features->spe; + case PPC_HAS_EFP_SINGLE: + return features->efpsingle; + case PPC_HAS_EFP_DOUBLE: + return features->efpdouble; + case PPC_NO_TB: + return features->no_tb; + case PPC_POWER4: + return features->power4; + case PPC_POWER5: + return features->power5; + case PPC_POWER5_PLUS: + return features->power5plus; + case PPC_CELL: + return features->cell; + case PPC_BOOKE: + return features->booke; + case PPC_SMT: + return features->smt; + case PPC_ICACHE_SNOOP: + return features->icachesnoop; + case PPC_ARCH_2_05: + return features->arch205; + case PPC_PA6T: + return features->pa6t; + case PPC_HAS_DFP: + return features->dfp; + case PPC_POWER6_EXT: + return features->power6ext; + case PPC_ARCH_2_06: + return features->arch206; + case PPC_HAS_VSX: + return features->vsx; + case PPC_PSERIES_PERFMON_COMPAT: + return features->pseries_perfmon_compat; + case PPC_TRUE_LE: + return features->truele; + case PPC_PPC_LE: + return features->ppcle; + case PPC_ARCH_2_07: + return features->arch207; + case PPC_HTM: + return features->htm; + case PPC_DSCR: + return features->dscr; + case PPC_EBB: + return features->ebb; + case PPC_ISEL: + return features->isel; + case PPC_TAR: + return features->tar; + case PPC_VEC_CRYPTO: + return features->vcrypto; + case PPC_HTM_NOSC: + return features->htm_nosc; + case PPC_ARCH_3_00: + return features->arch300; + case PPC_HAS_IEEE128: + return features->ieee128; + case PPC_DARN: + return features->darn; + case PPC_SCV: + return features->scv; + case PPC_HTM_NO_SUSPEND: + return features->htm_no_suspend; + case PPC_LAST_: + break; + } + return false; +} + +/* Have used the same names as glibc */ +const char* GetPPCFeaturesEnumName(PPCFeaturesEnum value) { + switch (value) { + case PPC_32: + return "ppc32"; + case PPC_64: + return "ppc64"; + case PPC_601_INSTR: + return "ppc601"; + case PPC_HAS_ALTIVEC: + return "altivec"; + case PPC_HAS_FPU: + return "fpu"; + case PPC_HAS_MMU: + return "mmu"; + case PPC_HAS_4xxMAC: + return "4xxmac"; + case PPC_UNIFIED_CACHE: + return "ucache"; + case PPC_HAS_SPE: + return "spe"; + case PPC_HAS_EFP_SINGLE: + return "efpsingle"; + case PPC_HAS_EFP_DOUBLE: + return "efpdouble"; + case PPC_NO_TB: + return "notb"; + case PPC_POWER4: + return "power4"; + case PPC_POWER5: + return "power5"; + case PPC_POWER5_PLUS: + return "power5+"; + case PPC_CELL: + return "cellbe"; + case PPC_BOOKE: + return "booke"; + case PPC_SMT: + return "smt"; + case PPC_ICACHE_SNOOP: + return "ic_snoop"; + case PPC_ARCH_2_05: + return "arch_2_05"; + case PPC_PA6T: + return "pa6t"; + case PPC_HAS_DFP: + return "dfp"; + case PPC_POWER6_EXT: + return "power6x"; + case PPC_ARCH_2_06: + return "arch_2_06"; + case PPC_HAS_VSX: + return "vsx"; + case PPC_PSERIES_PERFMON_COMPAT: + return "archpmu"; + case PPC_TRUE_LE: + return "true_le"; + case PPC_PPC_LE: + return "ppcle"; + case PPC_ARCH_2_07: + return "arch_2_07"; + case PPC_HTM: + return "htm"; + case PPC_DSCR: + return "dscr"; + case PPC_EBB: + return "ebb"; + case PPC_ISEL: + return "isel"; + case PPC_TAR: + return "tar"; + case PPC_VEC_CRYPTO: + return "vcrypto"; + case PPC_HTM_NOSC: + return "htm-nosc"; + case PPC_ARCH_3_00: + return "arch_3_00"; + case PPC_HAS_IEEE128: + return "ieee128"; + case PPC_DARN: + return "darn"; + case PPC_SCV: + return "scv"; + case PPC_HTM_NO_SUSPEND: + return "htm-no-suspend"; + case PPC_LAST_: + break; + } + return "unknown_feature"; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_x86.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_x86.c new file mode 100644 index 0000000..390e8c9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/cpuinfo_x86.c @@ -0,0 +1,447 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_x86.h" +#include "internal/bit_utils.h" +#include "internal/cpuid_x86.h" + +#include +#include + +static const Leaf kEmptyLeaf; + +static Leaf SafeCpuId(uint32_t max_cpuid_leaf, uint32_t leaf_id) { + if (leaf_id <= max_cpuid_leaf) { + return CpuId(leaf_id); + } else { + return kEmptyLeaf; + } +} + +#define MASK_XMM 0x2 +#define MASK_YMM 0x4 +#define MASK_MASKREG 0x20 +#define MASK_ZMM0_15 0x40 +#define MASK_ZMM16_31 0x80 + +static bool HasMask(uint32_t value, uint32_t mask) { + return (value & mask) == mask; +} + +// Checks that operating system saves and restores xmm registers during context +// switches. +static bool HasXmmOsXSave(uint32_t xcr0_eax) { + return HasMask(xcr0_eax, MASK_XMM); +} + +// Checks that operating system saves and restores ymm registers during context +// switches. +static bool HasYmmOsXSave(uint32_t xcr0_eax) { + return HasMask(xcr0_eax, MASK_XMM | MASK_YMM); +} + +// Checks that operating system saves and restores zmm registers during context +// switches. +static bool HasZmmOsXSave(uint32_t xcr0_eax) { + return HasMask(xcr0_eax, MASK_XMM | MASK_YMM | MASK_MASKREG | MASK_ZMM0_15 | + MASK_ZMM16_31); +} + +static void SetVendor(const Leaf leaf, char* const vendor) { + *(uint32_t*)(vendor) = leaf.ebx; + *(uint32_t*)(vendor + 4) = leaf.edx; + *(uint32_t*)(vendor + 8) = leaf.ecx; + vendor[12] = '\0'; +} + +static int IsVendor(const Leaf leaf, const char* const name) { + const uint32_t ebx = *(const uint32_t*)(name); + const uint32_t edx = *(const uint32_t*)(name + 4); + const uint32_t ecx = *(const uint32_t*)(name + 8); + return leaf.ebx == ebx && leaf.ecx == ecx && leaf.edx == edx; +} + +// Reference https://en.wikipedia.org/wiki/CPUID. +static void ParseCpuId(const uint32_t max_cpuid_leaf, X86Info* info) { + const Leaf leaf_1 = SafeCpuId(max_cpuid_leaf, 1); + const Leaf leaf_7 = SafeCpuId(max_cpuid_leaf, 7); + + const bool have_xsave = IsBitSet(leaf_1.ecx, 26); + const bool have_osxsave = IsBitSet(leaf_1.ecx, 27); + const uint32_t xcr0_eax = (have_xsave && have_osxsave) ? GetXCR0Eax() : 0; + const bool have_sse_os_support = HasXmmOsXSave(xcr0_eax); + const bool have_avx_os_support = HasYmmOsXSave(xcr0_eax); + const bool have_avx512_os_support = HasZmmOsXSave(xcr0_eax); + + const uint32_t family = ExtractBitRange(leaf_1.eax, 11, 8); + const uint32_t extended_family = ExtractBitRange(leaf_1.eax, 27, 20); + const uint32_t model = ExtractBitRange(leaf_1.eax, 7, 4); + const uint32_t extended_model = ExtractBitRange(leaf_1.eax, 19, 16); + + X86Features* const features = &info->features; + + info->family = extended_family + family; + info->model = (extended_model << 4) + model; + info->stepping = ExtractBitRange(leaf_1.eax, 3, 0); + + features->smx = IsBitSet(leaf_1.ecx, 6); + features->cx16 = IsBitSet(leaf_1.ecx, 13); + features->aes = IsBitSet(leaf_1.ecx, 25); + features->f16c = IsBitSet(leaf_1.ecx, 29); + features->sgx = IsBitSet(leaf_7.ebx, 2); + features->bmi1 = IsBitSet(leaf_7.ebx, 3); + features->bmi2 = IsBitSet(leaf_7.ebx, 8); + features->erms = IsBitSet(leaf_7.ebx, 9); + features->vpclmulqdq = IsBitSet(leaf_7.ecx, 10); + + if (have_sse_os_support) { + features->ssse3 = IsBitSet(leaf_1.ecx, 9); + features->sse4_1 = IsBitSet(leaf_1.ecx, 19); + features->sse4_2 = IsBitSet(leaf_1.ecx, 20); + } + + if (have_avx_os_support) { + features->fma3 = IsBitSet(leaf_1.ecx, 12); + features->avx = IsBitSet(leaf_1.ecx, 28); + features->avx2 = IsBitSet(leaf_7.ebx, 5); + } + + if (have_avx512_os_support) { + features->avx512f = IsBitSet(leaf_7.ebx, 16); + features->avx512cd = IsBitSet(leaf_7.ebx, 28); + features->avx512er = IsBitSet(leaf_7.ebx, 27); + features->avx512pf = IsBitSet(leaf_7.ebx, 26); + features->avx512bw = IsBitSet(leaf_7.ebx, 30); + features->avx512dq = IsBitSet(leaf_7.ebx, 17); + features->avx512vl = IsBitSet(leaf_7.ebx, 31); + features->avx512ifma = IsBitSet(leaf_7.ebx, 21); + features->avx512vbmi = IsBitSet(leaf_7.ecx, 1); + features->avx512vbmi2 = IsBitSet(leaf_7.ecx, 6); + features->avx512vnni = IsBitSet(leaf_7.ecx, 11); + features->avx512bitalg = IsBitSet(leaf_7.ecx, 12); + features->avx512vpopcntdq = IsBitSet(leaf_7.ecx, 14); + features->avx512_4vnniw = IsBitSet(leaf_7.edx, 2); + features->avx512_4vbmi2 = IsBitSet(leaf_7.edx, 3); + } +} + +static const X86Info kEmptyX86Info; + +X86Info GetX86Info(void) { + X86Info info = kEmptyX86Info; + const Leaf leaf_0 = CpuId(0); + const uint32_t max_cpuid_leaf = leaf_0.eax; + SetVendor(leaf_0, info.vendor); + if (IsVendor(leaf_0, "GenuineIntel") || IsVendor(leaf_0, "AuthenticAMD")) { + ParseCpuId(max_cpuid_leaf, &info); + } + return info; +} + +#define CPUID(FAMILY, MODEL) (((FAMILY & 0xFF) << 8) | (MODEL & 0xFF)) + +X86Microarchitecture GetX86Microarchitecture(const X86Info* info) { + if (memcmp(info->vendor, "GenuineIntel", sizeof(info->vendor)) == 0) { + switch (CPUID(info->family, info->model)) { + case CPUID(0x06, 0x35): + case CPUID(0x06, 0x36): + // https://en.wikipedia.org/wiki/Bonnell_(microarchitecture) + return INTEL_ATOM_BNL; + case CPUID(0x06, 0x37): + case CPUID(0x06, 0x4C): + // https://en.wikipedia.org/wiki/Silvermont + return INTEL_ATOM_SMT; + case CPUID(0x06, 0x5C): + // https://en.wikipedia.org/wiki/Goldmont + return INTEL_ATOM_GMT; + case CPUID(0x06, 0x0F): + case CPUID(0x06, 0x16): + // https://en.wikipedia.org/wiki/Intel_Core_(microarchitecture) + return INTEL_CORE; + case CPUID(0x06, 0x17): + case CPUID(0x06, 0x1D): + // https://en.wikipedia.org/wiki/Penryn_(microarchitecture) + return INTEL_PNR; + case CPUID(0x06, 0x1A): + case CPUID(0x06, 0x1E): + case CPUID(0x06, 0x1F): + case CPUID(0x06, 0x2E): + // https://en.wikipedia.org/wiki/Nehalem_(microarchitecture) + return INTEL_NHM; + case CPUID(0x06, 0x25): + case CPUID(0x06, 0x2C): + case CPUID(0x06, 0x2F): + // https://en.wikipedia.org/wiki/Westmere_(microarchitecture) + return INTEL_WSM; + case CPUID(0x06, 0x2A): + case CPUID(0x06, 0x2D): + // https://en.wikipedia.org/wiki/Sandy_Bridge#Models_and_steppings + return INTEL_SNB; + case CPUID(0x06, 0x3A): + case CPUID(0x06, 0x3E): + // https://en.wikipedia.org/wiki/Ivy_Bridge_(microarchitecture)#Models_and_steppings + return INTEL_IVB; + case CPUID(0x06, 0x3C): + case CPUID(0x06, 0x3F): + case CPUID(0x06, 0x45): + case CPUID(0x06, 0x46): + // https://en.wikipedia.org/wiki/Haswell_(microarchitecture) + return INTEL_HSW; + case CPUID(0x06, 0x3D): + case CPUID(0x06, 0x47): + case CPUID(0x06, 0x4F): + case CPUID(0x06, 0x56): + // https://en.wikipedia.org/wiki/Broadwell_(microarchitecture) + return INTEL_BDW; + case CPUID(0x06, 0x4E): + case CPUID(0x06, 0x55): + case CPUID(0x06, 0x5E): + // https://en.wikipedia.org/wiki/Skylake_(microarchitecture) + return INTEL_SKL; + case CPUID(0x06, 0x8E): + case CPUID(0x06, 0x9E): + // https://en.wikipedia.org/wiki/Kaby_Lake + return INTEL_KBL; + default: + return X86_UNKNOWN; + } + } + if (memcmp(info->vendor, "AuthenticAMD", sizeof(info->vendor)) == 0) { + switch (info->family) { + // https://en.wikipedia.org/wiki/List_of_AMD_CPU_microarchitectures + case 0x0F: + return AMD_HAMMER; + case 0x10: + return AMD_K10; + case 0x14: + return AMD_BOBCAT; + case 0x15: + return AMD_BULLDOZER; + case 0x16: + return AMD_JAGUAR; + case 0x17: + return AMD_ZEN; + default: + return X86_UNKNOWN; + } + } + return X86_UNKNOWN; +} + +static void SetString(const uint32_t max_cpuid_ext_leaf, const uint32_t leaf_id, + char* buffer) { + const Leaf leaf = SafeCpuId(max_cpuid_ext_leaf, leaf_id); + // We allow calling memcpy from SetString which is only called when requesting + // X86BrandString. + memcpy(buffer, &leaf, sizeof(Leaf)); +} + +void FillX86BrandString(char brand_string[49]) { + const Leaf leaf_ext_0 = CpuId(0x80000000); + const uint32_t max_cpuid_leaf_ext = leaf_ext_0.eax; + SetString(max_cpuid_leaf_ext, 0x80000002, brand_string); + SetString(max_cpuid_leaf_ext, 0x80000003, brand_string + 16); + SetString(max_cpuid_leaf_ext, 0x80000004, brand_string + 32); + brand_string[48] = '\0'; +} + +//////////////////////////////////////////////////////////////////////////////// +// Introspection functions + +int GetX86FeaturesEnumValue(const X86Features* features, + X86FeaturesEnum value) { + switch (value) { + case X86_AES: + return features->aes; + case X86_ERMS: + return features->erms; + case X86_F16C: + return features->f16c; + case X86_FMA3: + return features->fma3; + case X86_VPCLMULQDQ: + return features->vpclmulqdq; + case X86_BMI1: + return features->bmi1; + case X86_BMI2: + return features->bmi2; + case X86_SSSE3: + return features->ssse3; + case X86_SSE4_1: + return features->sse4_1; + case X86_SSE4_2: + return features->sse4_2; + case X86_AVX: + return features->avx; + case X86_AVX2: + return features->avx2; + case X86_AVX512F: + return features->avx512f; + case X86_AVX512CD: + return features->avx512cd; + case X86_AVX512ER: + return features->avx512er; + case X86_AVX512PF: + return features->avx512pf; + case X86_AVX512BW: + return features->avx512bw; + case X86_AVX512DQ: + return features->avx512dq; + case X86_AVX512VL: + return features->avx512vl; + case X86_AVX512IFMA: + return features->avx512ifma; + case X86_AVX512VBMI: + return features->avx512vbmi; + case X86_AVX512VBMI2: + return features->avx512vbmi2; + case X86_AVX512VNNI: + return features->avx512vnni; + case X86_AVX512BITALG: + return features->avx512bitalg; + case X86_AVX512VPOPCNTDQ: + return features->avx512vpopcntdq; + case X86_AVX512_4VNNIW: + return features->avx512_4vnniw; + case X86_AVX512_4VBMI2: + return features->avx512_4vbmi2; + case X86_SMX: + return features->smx; + case X86_SGX: + return features->sgx; + case X86_CX16: + return features->cx16; + case X86_LAST_: + break; + } + return false; +} + +const char* GetX86FeaturesEnumName(X86FeaturesEnum value) { + switch (value) { + case X86_AES: + return "aes"; + case X86_ERMS: + return "erms"; + case X86_F16C: + return "f16c"; + case X86_FMA3: + return "fma3"; + case X86_VPCLMULQDQ: + return "vpclmulqdq"; + case X86_BMI1: + return "bmi1"; + case X86_BMI2: + return "bmi2"; + case X86_SSSE3: + return "ssse3"; + case X86_SSE4_1: + return "sse4_1"; + case X86_SSE4_2: + return "sse4_2"; + case X86_AVX: + return "avx"; + case X86_AVX2: + return "avx2"; + case X86_AVX512F: + return "avx512f"; + case X86_AVX512CD: + return "avx512cd"; + case X86_AVX512ER: + return "avx512er"; + case X86_AVX512PF: + return "avx512pf"; + case X86_AVX512BW: + return "avx512bw"; + case X86_AVX512DQ: + return "avx512dq"; + case X86_AVX512VL: + return "avx512vl"; + case X86_AVX512IFMA: + return "avx512ifma"; + case X86_AVX512VBMI: + return "avx512vbmi"; + case X86_AVX512VBMI2: + return "avx512vbmi2"; + case X86_AVX512VNNI: + return "avx512vnni"; + case X86_AVX512BITALG: + return "avx512bitalg"; + case X86_AVX512VPOPCNTDQ: + return "avx512vpopcntdq"; + case X86_AVX512_4VNNIW: + return "avx512_4vnniw"; + case X86_AVX512_4VBMI2: + return "avx512_4vbmi2"; + case X86_SMX: + return "smx"; + case X86_SGX: + return "sgx"; + case X86_CX16: + return "cx16"; + case X86_LAST_: + break; + } + return "unknown_feature"; +} + +const char* GetX86MicroarchitectureName(X86Microarchitecture uarch) { + switch (uarch) { + case X86_UNKNOWN: + return "X86_UNKNOWN"; + case INTEL_CORE: + return "INTEL_CORE"; + case INTEL_PNR: + return "INTEL_PNR"; + case INTEL_NHM: + return "INTEL_NHM"; + case INTEL_ATOM_BNL: + return "INTEL_ATOM_BNL"; + case INTEL_WSM: + return "INTEL_WSM"; + case INTEL_SNB: + return "INTEL_SNB"; + case INTEL_IVB: + return "INTEL_IVB"; + case INTEL_ATOM_SMT: + return "INTEL_ATOM_SMT"; + case INTEL_HSW: + return "INTEL_HSW"; + case INTEL_BDW: + return "INTEL_BDW"; + case INTEL_SKL: + return "INTEL_SKL"; + case INTEL_ATOM_GMT: + return "INTEL_ATOM_GMT"; + case INTEL_KBL: + return "INTEL_KBL"; + case INTEL_CFL: + return "INTEL_CFL"; + case INTEL_CNL: + return "INTEL_CNL"; + case AMD_HAMMER: + return "AMD_HAMMER"; + case AMD_K10: + return "AMD_K10"; + case AMD_BOBCAT: + return "AMD_BOBCAT"; + case AMD_BULLDOZER: + return "AMD_BULLDOZER"; + case AMD_JAGUAR: + return "AMD_JAGUAR"; + case AMD_ZEN: + return "AMD_ZEN"; + } + return "unknown microarchitecture"; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/filesystem.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/filesystem.c new file mode 100644 index 0000000..286a9cc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/filesystem.c @@ -0,0 +1,57 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/filesystem.h" + +#include +#include +#include +#include + +#if defined(_MSC_VER) +#include +int CpuFeatures_OpenFile(const char* filename) { + return _open(filename, _O_RDONLY); +} + +void CpuFeatures_CloseFile(int file_descriptor) { _close(file_descriptor); } + +int CpuFeatures_ReadFile(int file_descriptor, void* buffer, + size_t buffer_size) { + return _read(file_descriptor, buffer, buffer_size); +} + +#else +#include + +int CpuFeatures_OpenFile(const char* filename) { + int result; + do { + result = open(filename, O_RDONLY); + } while (result == -1L && errno == EINTR); + return result; +} + +void CpuFeatures_CloseFile(int file_descriptor) { close(file_descriptor); } + +int CpuFeatures_ReadFile(int file_descriptor, void* buffer, + size_t buffer_size) { + int result; + do { + result = read(file_descriptor, buffer, buffer_size); + } while (result == -1L && errno == EINTR); + return result; +} + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/hwcaps.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/hwcaps.c new file mode 100644 index 0000000..c67c5e6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/hwcaps.c @@ -0,0 +1,187 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "cpu_features_macros.h" +#include "internal/filesystem.h" +#include "internal/hwcaps.h" +#include "internal/string_view.h" + +#if defined(NDEBUG) +#define D(...) +#else +#include +#define D(...) \ + do { \ + printf(__VA_ARGS__); \ + fflush(stdout); \ + } while (0) +#endif + +#if defined(CPU_FEATURES_ARCH_MIPS) || defined(CPU_FEATURES_ARCH_ANY_ARM) +#define HWCAPS_ANDROID_MIPS_OR_ARM +#endif + +#if defined(CPU_FEATURES_OS_LINUX_OR_ANDROID) && \ + !defined(HWCAPS_ANDROID_MIPS_OR_ARM) +#define HWCAPS_REGULAR_LINUX +#endif + +#if defined(HWCAPS_ANDROID_MIPS_OR_ARM) || defined(HWCAPS_REGULAR_LINUX) +#define HWCAPS_SUPPORTED +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Implementation of GetElfHwcapFromGetauxval +//////////////////////////////////////////////////////////////////////////////// + +// On Linux we simply use getauxval. +#if defined(HWCAPS_REGULAR_LINUX) +#include +#include +static unsigned long GetElfHwcapFromGetauxval(uint32_t hwcap_type) { + return getauxval(hwcap_type); +} +#endif // defined(HWCAPS_REGULAR_LINUX) + +// On Android we probe the system's C library for a 'getauxval' function and +// call it if it exits, or return 0 for failure. This function is available +// since API level 20. +// +// This code does *NOT* check for '__ANDROID_API__ >= 20' to support the edge +// case where some NDK developers use headers for a platform that is newer than +// the one really targetted by their application. This is typically done to use +// newer native APIs only when running on more recent Android versions, and +// requires careful symbol management. +// +// Note that getauxval() can't really be re-implemented here, because its +// implementation does not parse /proc/self/auxv. Instead it depends on values +// that are passed by the kernel at process-init time to the C runtime +// initialization layer. +#if defined(HWCAPS_ANDROID_MIPS_OR_ARM) +#include +#define AT_HWCAP 16 +#define AT_HWCAP2 26 +#define AT_PLATFORM 15 +#define AT_BASE_PLATFORM 24 + +typedef unsigned long getauxval_func_t(unsigned long); + +static uint32_t GetElfHwcapFromGetauxval(uint32_t hwcap_type) { + uint32_t ret = 0; + void* libc_handle = NULL; + getauxval_func_t* func = NULL; + + dlerror(); // Cleaning error state before calling dlopen. + libc_handle = dlopen("libc.so", RTLD_NOW); + if (!libc_handle) { + D("Could not dlopen() C library: %s\n", dlerror()); + return 0; + } + func = (getauxval_func_t*)dlsym(libc_handle, "getauxval"); + if (!func) { + D("Could not find getauxval() in C library\n"); + } else { + // Note: getauxval() returns 0 on failure. Doesn't touch errno. + ret = (uint32_t)(*func)(hwcap_type); + } + dlclose(libc_handle); + return ret; +} +#endif // defined(HWCAPS_ANDROID_MIPS_OR_ARM) + +#if defined(HWCAPS_SUPPORTED) +//////////////////////////////////////////////////////////////////////////////// +// Implementation of GetHardwareCapabilities for Android and Linux +//////////////////////////////////////////////////////////////////////////////// + +// Fallback when getauxval is not available, retrieves hwcaps from +// "/proc/self/auxv". +static uint32_t GetElfHwcapFromProcSelfAuxv(uint32_t hwcap_type) { + struct { + uint32_t tag; + uint32_t value; + } entry; + uint32_t result = 0; + const char filepath[] = "/proc/self/auxv"; + const int fd = CpuFeatures_OpenFile(filepath); + if (fd < 0) { + D("Could not open %s\n", filepath); + return 0; + } + for (;;) { + const int ret = CpuFeatures_ReadFile(fd, (char*)&entry, sizeof entry); + if (ret < 0) { + D("Error while reading %s\n", filepath); + break; + } + // Detect end of list. + if (ret == 0 || (entry.tag == 0 && entry.value == 0)) { + break; + } + if (entry.tag == hwcap_type) { + result = entry.value; + break; + } + } + CpuFeatures_CloseFile(fd); + return result; +} + +// Retrieves hardware capabilities by first trying to call getauxval, if not +// available falls back to reading "/proc/self/auxv". +static unsigned long GetHardwareCapabilitiesFor(uint32_t type) { + unsigned long hwcaps = GetElfHwcapFromGetauxval(type); + if (!hwcaps) { + D("Parsing /proc/self/auxv to extract ELF hwcaps!\n"); + hwcaps = GetElfHwcapFromProcSelfAuxv(type); + } + return hwcaps; +} + +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) { + HardwareCapabilities capabilities; + capabilities.hwcaps = GetHardwareCapabilitiesFor(AT_HWCAP); + capabilities.hwcaps2 = GetHardwareCapabilitiesFor(AT_HWCAP2); + return capabilities; +} + +PlatformType kEmptyPlatformType; + +PlatformType CpuFeatures_GetPlatformType(void) { + PlatformType type = kEmptyPlatformType; + char *platform = (char *)GetHardwareCapabilitiesFor(AT_PLATFORM); + char *base_platform = (char *)GetHardwareCapabilitiesFor(AT_BASE_PLATFORM); + + if (platform != NULL) + CpuFeatures_StringView_CopyString(str(platform), type.platform, + sizeof(type.platform)); + if (base_platform != NULL) + CpuFeatures_StringView_CopyString(str(base_platform), type.base_platform, + sizeof(type.base_platform)); + return type; +} +#else // (defined(HWCAPS_SUPPORTED) + +//////////////////////////////////////////////////////////////////////////////// +// Implementation of GetHardwareCapabilities for unsupported platforms. +//////////////////////////////////////////////////////////////////////////////// + +const HardwareCapabilities kEmptyHardwareCapabilities; +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) { + return kEmptyHardwareCapabilities; +} +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/linux_features_aggregator.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/linux_features_aggregator.c new file mode 100644 index 0000000..b7f8f3d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/linux_features_aggregator.c @@ -0,0 +1,51 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/linux_features_aggregator.h" +#include "internal/string_view.h" + +void CpuFeatures_SetFromFlags(const size_t configs_size, + const CapabilityConfig* configs, + const StringView flags_line, + void* const features) { + size_t i = 0; + for (; i < configs_size; ++i) { + const CapabilityConfig config = configs[i]; + config.set_bit(features, CpuFeatures_StringView_HasWord( + flags_line, config.proc_cpuinfo_flag)); + } +} + +static bool IsSet(const uint32_t mask, const uint32_t value) { + return (value & mask) == mask; +} + +static bool IsHwCapsSet(const HardwareCapabilities hwcaps_mask, + const HardwareCapabilities hwcaps) { + return IsSet(hwcaps_mask.hwcaps, hwcaps.hwcaps) && + IsSet(hwcaps_mask.hwcaps2, hwcaps.hwcaps2); +} + +void CpuFeatures_OverrideFromHwCaps(const size_t configs_size, + const CapabilityConfig* configs, + const HardwareCapabilities hwcaps, + void* const features) { + size_t i = 0; + for (; i < configs_size; ++i) { + const CapabilityConfig* config = &configs[i]; + if (IsHwCapsSet(config->hwcaps_mask, hwcaps)) { + config->set_bit(features, true); + } + } +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/stack_line_reader.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/stack_line_reader.c new file mode 100644 index 0000000..b2c48ba --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/stack_line_reader.c @@ -0,0 +1,131 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/stack_line_reader.h" +#include "internal/filesystem.h" + +#include +#include +#include + +void StackLineReader_Initialize(StackLineReader* reader, int fd) { + reader->view.ptr = reader->buffer; + reader->view.size = 0; + reader->skip_mode = false; + reader->fd = fd; +} + +// Replaces the content of buffer with bytes from the file. +static int LoadFullBuffer(StackLineReader* reader) { + const int read = CpuFeatures_ReadFile(reader->fd, reader->buffer, + STACK_LINE_READER_BUFFER_SIZE); + assert(read >= 0); + reader->view.ptr = reader->buffer; + reader->view.size = read; + return read; +} + +// Appends with bytes from the file to buffer, filling the remaining space. +static int LoadMore(StackLineReader* reader) { + char* const ptr = reader->buffer + reader->view.size; + const size_t size_to_read = STACK_LINE_READER_BUFFER_SIZE - reader->view.size; + const int read = CpuFeatures_ReadFile(reader->fd, ptr, size_to_read); + assert(read >= 0); + assert(read <= (int)size_to_read); + reader->view.size += read; + return read; +} + +static int IndexOfEol(StackLineReader* reader) { + return CpuFeatures_StringView_IndexOfChar(reader->view, '\n'); +} + +// Relocate buffer's pending bytes at the beginning of the array and fills the +// remaining space with bytes from the file. +static int BringToFrontAndLoadMore(StackLineReader* reader) { + if (reader->view.size && reader->view.ptr != reader->buffer) { + memmove(reader->buffer, reader->view.ptr, reader->view.size); + } + reader->view.ptr = reader->buffer; + return LoadMore(reader); +} + +// Loads chunks of buffer size from disks until it contains a newline character +// or end of file. +static void SkipToNextLine(StackLineReader* reader) { + for (;;) { + const int read = LoadFullBuffer(reader); + if (read == 0) { + break; + } else { + const int eol_index = IndexOfEol(reader); + if (eol_index >= 0) { + reader->view = + CpuFeatures_StringView_PopFront(reader->view, eol_index + 1); + break; + } + } + } +} + +static LineResult CreateLineResult(bool eof, bool full_line, StringView view) { + LineResult result; + result.eof = eof; + result.full_line = full_line; + result.line = view; + return result; +} + +// Helper methods to provide clearer semantic in StackLineReader_NextLine. +static LineResult CreateEOFLineResult(StringView view) { + return CreateLineResult(true, true, view); +} + +static LineResult CreateTruncatedLineResult(StringView view) { + return CreateLineResult(false, false, view); +} + +static LineResult CreateValidLineResult(StringView view) { + return CreateLineResult(false, true, view); +} + +LineResult StackLineReader_NextLine(StackLineReader* reader) { + if (reader->skip_mode) { + SkipToNextLine(reader); + reader->skip_mode = false; + } + { + const bool can_load_more = + reader->view.size < STACK_LINE_READER_BUFFER_SIZE; + int eol_index = IndexOfEol(reader); + if (eol_index < 0 && can_load_more) { + const int read = BringToFrontAndLoadMore(reader); + if (read == 0) { + return CreateEOFLineResult(reader->view); + } + eol_index = IndexOfEol(reader); + } + if (eol_index < 0) { + reader->skip_mode = true; + return CreateTruncatedLineResult(reader->view); + } + { + StringView line = + CpuFeatures_StringView_KeepFront(reader->view, eol_index); + reader->view = + CpuFeatures_StringView_PopFront(reader->view, eol_index + 1); + return CreateValidLineResult(line); + } + } +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/string_view.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/string_view.c new file mode 100644 index 0000000..4f27cbd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/string_view.c @@ -0,0 +1,182 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/string_view.h" + +#include +#include +#include + +int CpuFeatures_StringView_IndexOfChar(const StringView view, char c) { + if (view.ptr && view.size) { + const char* const found = (const char*)memchr(view.ptr, c, view.size); + if (found) { + return found - view.ptr; + } + } + return -1; +} + +int CpuFeatures_StringView_IndexOf(const StringView view, + const StringView sub_view) { + if (sub_view.size) { + StringView remainder = view; + while (remainder.size >= sub_view.size) { + const int found_index = + CpuFeatures_StringView_IndexOfChar(remainder, sub_view.ptr[0]); + if (found_index < 0) break; + remainder = CpuFeatures_StringView_PopFront(remainder, found_index); + if (CpuFeatures_StringView_StartsWith(remainder, sub_view)) { + return remainder.ptr - view.ptr; + } + remainder = CpuFeatures_StringView_PopFront(remainder, 1); + } + } + return -1; +} + +bool CpuFeatures_StringView_IsEquals(const StringView a, const StringView b) { + if (a.size == b.size) { + return a.ptr == b.ptr || memcmp(a.ptr, b.ptr, b.size) == 0; + } + return false; +} + +bool CpuFeatures_StringView_StartsWith(const StringView a, const StringView b) { + return a.ptr && b.ptr && b.size && a.size >= b.size + ? memcmp(a.ptr, b.ptr, b.size) == 0 + : false; +} + +StringView CpuFeatures_StringView_PopFront(const StringView str_view, + size_t count) { + if (count > str_view.size) { + return kEmptyStringView; + } + return view(str_view.ptr + count, str_view.size - count); +} + +StringView CpuFeatures_StringView_PopBack(const StringView str_view, + size_t count) { + if (count > str_view.size) { + return kEmptyStringView; + } + return view(str_view.ptr, str_view.size - count); +} + +StringView CpuFeatures_StringView_KeepFront(const StringView str_view, + size_t count) { + return count <= str_view.size ? view(str_view.ptr, count) : str_view; +} + +char CpuFeatures_StringView_Front(const StringView view) { + assert(view.size); + assert(view.ptr); + return view.ptr[0]; +} + +char CpuFeatures_StringView_Back(const StringView view) { + assert(view.size); + return view.ptr[view.size - 1]; +} + +StringView CpuFeatures_StringView_TrimWhitespace(StringView view) { + while (view.size && isspace(CpuFeatures_StringView_Front(view))) + view = CpuFeatures_StringView_PopFront(view, 1); + while (view.size && isspace(CpuFeatures_StringView_Back(view))) + view = CpuFeatures_StringView_PopBack(view, 1); + return view; +} + +static int HexValue(const char c) { + if (c >= '0' && c <= '9') return c - '0'; + if (c >= 'a' && c <= 'f') return c - 'a' + 10; + if (c >= 'A' && c <= 'F') return c - 'A' + 10; + return -1; +} + +// Returns -1 if view contains non digits. +static int ParsePositiveNumberWithBase(const StringView view, int base) { + int result = 0; + StringView remainder = view; + for (; remainder.size; + remainder = CpuFeatures_StringView_PopFront(remainder, 1)) { + const int value = HexValue(CpuFeatures_StringView_Front(remainder)); + if (value < 0 || value >= base) return -1; + result = (result * base) + value; + } + return result; +} + +int CpuFeatures_StringView_ParsePositiveNumber(const StringView view) { + if (view.size) { + const StringView hex_prefix = str("0x"); + if (CpuFeatures_StringView_StartsWith(view, hex_prefix)) { + const StringView span_no_prefix = + CpuFeatures_StringView_PopFront(view, hex_prefix.size); + return ParsePositiveNumberWithBase(span_no_prefix, 16); + } + return ParsePositiveNumberWithBase(view, 10); + } + return -1; +} + +void CpuFeatures_StringView_CopyString(const StringView src, char* dst, + size_t dst_size) { + if (dst_size > 0) { + const size_t max_copy_size = dst_size - 1; + const size_t copy_size = + src.size > max_copy_size ? max_copy_size : src.size; + memcpy(dst, src.ptr, copy_size); + dst[copy_size] = '\0'; + } +} + +bool CpuFeatures_StringView_HasWord(const StringView line, + const char* const word_str) { + const StringView word = str(word_str); + StringView remainder = line; + for (;;) { + const int index_of_word = CpuFeatures_StringView_IndexOf(remainder, word); + if (index_of_word < 0) { + return false; + } else { + const StringView before = + CpuFeatures_StringView_KeepFront(line, index_of_word); + const StringView after = + CpuFeatures_StringView_PopFront(line, index_of_word + word.size); + const bool valid_before = + before.size == 0 || CpuFeatures_StringView_Back(before) == ' '; + const bool valid_after = + after.size == 0 || CpuFeatures_StringView_Front(after) == ' '; + if (valid_before && valid_after) return true; + remainder = + CpuFeatures_StringView_PopFront(remainder, index_of_word + word.size); + } + } + return false; +} + +bool CpuFeatures_StringView_GetAttributeKeyValue(const StringView line, + StringView* key, + StringView* value) { + const StringView sep = str(": "); + const int index_of_separator = CpuFeatures_StringView_IndexOf(line, sep); + if (index_of_separator < 0) return false; + *value = CpuFeatures_StringView_TrimWhitespace( + CpuFeatures_StringView_PopFront(line, index_of_separator + sep.size)); + *key = CpuFeatures_StringView_TrimWhitespace( + CpuFeatures_StringView_KeepFront(line, index_of_separator)); + return true; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/utils/list_cpu_features.c b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/utils/list_cpu_features.c new file mode 100644 index 0000000..a5f7f8c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/src/utils/list_cpu_features.c @@ -0,0 +1,237 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "cpu_features_macros.h" +#include "cpuinfo_aarch64.h" +#include "cpuinfo_arm.h" +#include "cpuinfo_mips.h" +#include "cpuinfo_ppc.h" +#include "cpuinfo_x86.h" + +static void PrintEscapedAscii(const char* str) { + putchar('"'); + for (; str && *str; ++str) { + switch (*str) { + case '\"': + case '\\': + case '/': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + putchar('\\'); + } + putchar(*str); + } + putchar('"'); +} + +static void PrintVoid(void) {} +static void PrintComma(void) { putchar(','); } +static void PrintLineFeed(void) { putchar('\n'); } +static void PrintOpenBrace(void) { putchar('{'); } +static void PrintCloseBrace(void) { putchar('}'); } +static void PrintOpenBracket(void) { putchar('['); } +static void PrintCloseBracket(void) { putchar(']'); } +static void PrintString(const char* field) { printf("%s", field); } +static void PrintAlignedHeader(const char* field) { printf("%-15s : ", field); } +static void PrintIntValue(int value) { printf("%d", value); } +static void PrintDecHexValue(int value) { + printf("%3d (0x%02X)", value, value); +} +static void PrintJsonHeader(const char* field) { + PrintEscapedAscii(field); + putchar(':'); +} + +typedef struct { + void (*Start)(void); + void (*ArrayStart)(void); + void (*ArraySeparator)(void); + void (*ArrayEnd)(void); + void (*PrintString)(const char* value); + void (*PrintValue)(int value); + void (*EndField)(void); + void (*StartField)(const char* field); + void (*End)(void); +} Printer; + +static Printer getJsonPrinter(void) { + return (Printer){ + .Start = &PrintOpenBrace, + .ArrayStart = &PrintOpenBracket, + .ArraySeparator = &PrintComma, + .ArrayEnd = &PrintCloseBracket, + .PrintString = &PrintEscapedAscii, + .PrintValue = &PrintIntValue, + .EndField = &PrintComma, + .StartField = &PrintJsonHeader, + .End = &PrintCloseBrace, + }; +} + +static Printer getTextPrinter(void) { + return (Printer){ + .Start = &PrintVoid, + .ArrayStart = &PrintVoid, + .ArraySeparator = &PrintComma, + .ArrayEnd = &PrintVoid, + .PrintString = &PrintString, + .PrintValue = &PrintDecHexValue, + .EndField = &PrintLineFeed, + .StartField = &PrintAlignedHeader, + .End = &PrintVoid, + }; +} + +// Prints a named numeric value in both decimal and hexadecimal. +static void PrintN(const Printer p, const char* field, int value) { + p.StartField(field); + p.PrintValue(value); + p.EndField(); +} + +// Prints a named string. +static void PrintS(const Printer p, const char* field, const char* value) { + p.StartField(field); + p.PrintString(value); + p.EndField(); +} + +static int cmp(const void* p1, const void* p2) { + return strcmp(*(const char* const*)p1, *(const char* const*)p2); +} + +#define DEFINE_PRINT_FLAGS(HasFeature, FeatureName, FeatureType, LastEnum) \ + static void PrintFlags(const Printer p, const FeatureType* features) { \ + size_t i; \ + const char* ptrs[LastEnum] = {0}; \ + size_t count = 0; \ + for (i = 0; i < LastEnum; ++i) { \ + if (HasFeature(features, i)) { \ + ptrs[count] = FeatureName(i); \ + ++count; \ + } \ + } \ + qsort(ptrs, count, sizeof(char*), cmp); \ + p.StartField("flags"); \ + p.ArrayStart(); \ + for (i = 0; i < count; ++i) { \ + if (i > 0) p.ArraySeparator(); \ + p.PrintString(ptrs[i]); \ + } \ + p.ArrayEnd(); \ + } + +#if defined(CPU_FEATURES_ARCH_X86) +DEFINE_PRINT_FLAGS(GetX86FeaturesEnumValue, GetX86FeaturesEnumName, X86Features, + X86_LAST_) +#elif defined(CPU_FEATURES_ARCH_ARM) +DEFINE_PRINT_FLAGS(GetArmFeaturesEnumValue, GetArmFeaturesEnumName, ArmFeatures, + ARM_LAST_) +#elif defined(CPU_FEATURES_ARCH_AARCH64) +DEFINE_PRINT_FLAGS(GetAarch64FeaturesEnumValue, GetAarch64FeaturesEnumName, + Aarch64Features, AARCH64_LAST_) +#elif defined(CPU_FEATURES_ARCH_MIPS) +DEFINE_PRINT_FLAGS(GetMipsFeaturesEnumValue, GetMipsFeaturesEnumName, + MipsFeatures, MIPS_LAST_) +#elif defined(CPU_FEATURES_ARCH_PPC) +DEFINE_PRINT_FLAGS(GetPPCFeaturesEnumValue, GetPPCFeaturesEnumName, PPCFeatures, + PPC_LAST_) +#endif + +static void PrintFeatures(const Printer printer) { +#if defined(CPU_FEATURES_ARCH_X86) + char brand_string[49]; + const X86Info info = GetX86Info(); + FillX86BrandString(brand_string); + PrintS(printer, "arch", "x86"); + PrintS(printer, "brand", brand_string); + PrintN(printer, "family", info.family); + PrintN(printer, "model", info.model); + PrintN(printer, "stepping", info.stepping); + PrintS(printer, "uarch", + GetX86MicroarchitectureName(GetX86Microarchitecture(&info))); + PrintFlags(printer, &info.features); +#elif defined(CPU_FEATURES_ARCH_ARM) + const ArmInfo info = GetArmInfo(); + PrintS(printer, "arch", "ARM"); + PrintN(printer, "implementer", info.implementer); + PrintN(printer, "architecture", info.architecture); + PrintN(printer, "variant", info.variant); + PrintN(printer, "part", info.part); + PrintN(printer, "revision", info.revision); + PrintFlags(printer, &info.features); +#elif defined(CPU_FEATURES_ARCH_AARCH64) + const Aarch64Info info = GetAarch64Info(); + PrintS(printer, "arch", "aarch64"); + PrintN(printer, "implementer", info.implementer); + PrintN(printer, "variant", info.variant); + PrintN(printer, "part", info.part); + PrintN(printer, "revision", info.revision); + PrintFlags(printer, &info.features); +#elif defined(CPU_FEATURES_ARCH_MIPS) + const MipsInfo info = GetMipsInfo(); + PrintS(printer, "arch", "mips"); + PrintFlags(printer, &info.features); +#elif defined(CPU_FEATURES_ARCH_PPC) + const PPCInfo info = GetPPCInfo(); + const PPCPlatformStrings strings = GetPPCPlatformStrings(); + PrintS(printer, "arch", "ppc"); + PrintS(printer, "platform", strings.platform); + PrintS(printer, "model", strings.model); + PrintS(printer, "machine", strings.machine); + PrintS(printer, "cpu", strings.cpu); + PrintS(printer, "instruction set", strings.type.platform); + PrintS(printer, "microarchitecture", strings.type.base_platform); + PrintFlags(printer, &info.features); +#endif +} + +static void showUsage(const char* name) { + printf( + "\n" + "Usage: %s [options]\n" + " Options:\n" + " -h | --help Show help message.\n" + " -j | --json Format output as json instead of plain text.\n" + "\n", + name); +} + +int main(int argc, char** argv) { + Printer printer = getTextPrinter(); + int i = 1; + for (; i < argc; ++i) { + const char* arg = argv[i]; + if (strcmp(arg, "-j") == 0 || strcmp(arg, "--json") == 0) { + printer = getJsonPrinter(); + } else { + showUsage(argv[0]); + if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) + return EXIT_SUCCESS; + return EXIT_FAILURE; + } + } + printer.Start(); + PrintFeatures(printer); + printer.End(); + PrintLineFeed(); + return EXIT_SUCCESS; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/CMakeLists.txt new file mode 100644 index 0000000..794ef04 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/CMakeLists.txt @@ -0,0 +1,79 @@ +# +# libraries for tests +# + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std11 instead of -gnustd11 + +include_directories(../include) +add_definitions(-DCPU_FEATURES_TEST) + +##------------------------------------------------------------------------------ +add_library(string_view ../src/string_view.c) +##------------------------------------------------------------------------------ +add_library(filesystem_for_testing filesystem_for_testing.cc) +##------------------------------------------------------------------------------ +add_library(hwcaps_for_testing hwcaps_for_testing.cc) +target_link_libraries(hwcaps_for_testing filesystem_for_testing) +##------------------------------------------------------------------------------ +add_library(stack_line_reader ../src/stack_line_reader.c) +target_compile_definitions(stack_line_reader PUBLIC STACK_LINE_READER_BUFFER_SIZE=1024) +target_link_libraries(stack_line_reader string_view) +##------------------------------------------------------------------------------ +add_library(stack_line_reader_for_test ../src/stack_line_reader.c) +target_compile_definitions(stack_line_reader_for_test PUBLIC STACK_LINE_READER_BUFFER_SIZE=16) +target_link_libraries(stack_line_reader_for_test string_view filesystem_for_testing) +##------------------------------------------------------------------------------ +add_library(all_libraries ../src/stack_line_reader.c ../src/linux_features_aggregator.c) +target_link_libraries(all_libraries hwcaps_for_testing stack_line_reader string_view) + +# +# tests +# +link_libraries(gtest gmock_main) + +## bit_utils_test +add_executable(bit_utils_test bit_utils_test.cc) +target_link_libraries(bit_utils_test) +add_test(NAME bit_utils_test COMMAND bit_utils_test) +##------------------------------------------------------------------------------ +## string_view_test +add_executable(string_view_test string_view_test.cc ../src/string_view.c) +target_link_libraries(string_view_test string_view) +add_test(NAME string_view_test COMMAND string_view_test) +##------------------------------------------------------------------------------ +## stack_line_reader_test +add_executable(stack_line_reader_test stack_line_reader_test.cc) +target_link_libraries(stack_line_reader_test stack_line_reader_for_test) +add_test(NAME stack_line_reader_test COMMAND stack_line_reader_test) +##------------------------------------------------------------------------------ +## linux_features_aggregator_test +add_executable(linux_features_aggregator_test linux_features_aggregator_test.cc) +target_link_libraries(linux_features_aggregator_test all_libraries) +add_test(NAME linux_features_aggregator_test COMMAND linux_features_aggregator_test) +##------------------------------------------------------------------------------ +## cpuinfo_x86_test +add_executable(cpuinfo_x86_test cpuinfo_x86_test.cc ../src/cpuinfo_x86.c) +target_link_libraries(cpuinfo_x86_test all_libraries) +add_test(NAME cpuinfo_x86_test COMMAND cpuinfo_x86_test) +##------------------------------------------------------------------------------ +## cpuinfo_arm_test +add_executable(cpuinfo_arm_test cpuinfo_arm_test.cc ../src/cpuinfo_arm.c) +target_link_libraries(cpuinfo_arm_test all_libraries) +add_test(NAME cpuinfo_arm_test COMMAND cpuinfo_arm_test) +##------------------------------------------------------------------------------ +## cpuinfo_aarch64_test +add_executable(cpuinfo_aarch64_test cpuinfo_aarch64_test.cc ../src/cpuinfo_aarch64.c) +target_link_libraries(cpuinfo_aarch64_test all_libraries) +add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test) +##------------------------------------------------------------------------------ +## cpuinfo_mips_test +add_executable(cpuinfo_mips_test cpuinfo_mips_test.cc ../src/cpuinfo_mips.c) +target_link_libraries(cpuinfo_mips_test all_libraries) +add_test(NAME cpuinfo_mips_test COMMAND cpuinfo_mips_test) +##------------------------------------------------------------------------------ +## cpuinfo_ppc_test +add_executable(cpuinfo_ppc_test cpuinfo_ppc_test.cc ../src/cpuinfo_ppc.c) +target_link_libraries(cpuinfo_ppc_test all_libraries) +add_test(NAME cpuinfo_ppc_test COMMAND cpuinfo_ppc_test) diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/bit_utils_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/bit_utils_test.cc new file mode 100644 index 0000000..8937cbc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/bit_utils_test.cc @@ -0,0 +1,53 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/bit_utils.h" + +#include "gtest/gtest.h" + +namespace cpu_features { +namespace { + +TEST(UtilsTest, IsBitSet) { + for (size_t bit_set = 0; bit_set < 32; ++bit_set) { + const uint32_t value = 1UL << bit_set; + for (size_t i = 0; i < 32; ++i) { + EXPECT_EQ(IsBitSet(value, i), i == bit_set); + } + } + + // testing 0, all bits should be 0. + for (size_t i = 0; i < 32; ++i) { + EXPECT_FALSE(IsBitSet(0, i)); + } + + // testing ~0, all bits should be 1. + for (size_t i = 0; i < 32; ++i) { + EXPECT_TRUE(IsBitSet(-1, i)); + } +} + +TEST(UtilsTest, ExtractBitRange) { + // Extracting all bits gives the same number. + EXPECT_EQ(ExtractBitRange(123, 31, 0), 123); + // Extracting 1 bit gives parity. + EXPECT_EQ(ExtractBitRange(123, 0, 0), 1); + EXPECT_EQ(ExtractBitRange(122, 0, 0), 0); + + EXPECT_EQ(ExtractBitRange(0xF0, 7, 4), 0xF); + EXPECT_EQ(ExtractBitRange(0x42 << 2, 10, 2), 0x42); +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_aarch64_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_aarch64_test.cc new file mode 100644 index 0000000..bdb4d17 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_aarch64_test.cc @@ -0,0 +1,74 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_aarch64.h" +#include "filesystem_for_testing.h" +#include "hwcaps_for_testing.h" + +#include "gtest/gtest.h" + +namespace cpu_features { +namespace { + +void DisableHardwareCapabilities() { SetHardwareCapabilities(0, 0); } + +TEST(CpuinfoAarch64Test, FromHardwareCap) { + SetHardwareCapabilities(AARCH64_HWCAP_FP | AARCH64_HWCAP_AES, 0); + GetEmptyFilesystem(); // disabling /proc/cpuinfo + const auto info = GetAarch64Info(); + EXPECT_TRUE(info.features.fp); + EXPECT_FALSE(info.features.asimd); + EXPECT_TRUE(info.features.aes); + EXPECT_FALSE(info.features.pmull); + EXPECT_FALSE(info.features.sha1); + EXPECT_FALSE(info.features.sha2); + EXPECT_FALSE(info.features.crc32); +} + +TEST(CpuinfoAarch64Test, ARMCortexA53) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(Processor : AArch64 Processor rev 3 (aarch64) +processor : 0 +processor : 1 +processor : 2 +processor : 3 +processor : 4 +processor : 5 +processor : 6 +processor : 7 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 +CPU implementer : 0x41 +CPU architecture: AArch64 +CPU variant : 0x0 +CPU part : 0xd03 +CPU revision : 3)"); + const auto info = GetAarch64Info(); + EXPECT_EQ(info.implementer, 0x41); + EXPECT_EQ(info.variant, 0x0); + EXPECT_EQ(info.part, 0xd03); + EXPECT_EQ(info.revision, 3); + + EXPECT_TRUE(info.features.fp); + EXPECT_TRUE(info.features.asimd); + EXPECT_TRUE(info.features.aes); + EXPECT_TRUE(info.features.pmull); + EXPECT_TRUE(info.features.sha1); + EXPECT_TRUE(info.features.sha2); + EXPECT_TRUE(info.features.crc32); +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_arm_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_arm_test.cc new file mode 100644 index 0000000..a72c566 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_arm_test.cc @@ -0,0 +1,182 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_arm.h" +#include "filesystem_for_testing.h" +#include "hwcaps_for_testing.h" + +#include "gtest/gtest.h" + +namespace cpu_features { +namespace { + +void DisableHardwareCapabilities() { SetHardwareCapabilities(0, 0); } + +TEST(CpuinfoArmTest, FromHardwareCap) { + SetHardwareCapabilities(ARM_HWCAP_NEON, ARM_HWCAP2_AES | ARM_HWCAP2_CRC32); + GetEmptyFilesystem(); // disabling /proc/cpuinfo + const auto info = GetArmInfo(); + EXPECT_TRUE(info.features.vfp); // triggered by vfpv3 + EXPECT_TRUE(info.features.vfpv3); // triggered by neon + EXPECT_TRUE(info.features.neon); + EXPECT_TRUE(info.features.aes); + EXPECT_TRUE(info.features.crc32); + + EXPECT_FALSE(info.features.vfpv4); + EXPECT_FALSE(info.features.iwmmxt); + EXPECT_FALSE(info.features.vfpv3d16); + EXPECT_FALSE(info.features.idiva); + EXPECT_FALSE(info.features.idivt); + EXPECT_FALSE(info.features.pmull); + EXPECT_FALSE(info.features.sha1); + EXPECT_FALSE(info.features.sha2); +} + +TEST(CpuinfoArmTest, ODroidFromCpuInfo) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", R"(processor : 0 +model name : ARMv7 Processor rev 3 (v71) +BogoMIPS : 120.00 +Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x2 +CPU part : 0xc0f +CPU revision : 3)"); + const auto info = GetArmInfo(); + EXPECT_EQ(info.implementer, 0x41); + EXPECT_EQ(info.variant, 0x2); + EXPECT_EQ(info.part, 0xc0f); + EXPECT_EQ(info.revision, 3); + EXPECT_EQ(info.architecture, 7); + + EXPECT_TRUE(info.features.vfp); + EXPECT_FALSE(info.features.iwmmxt); + EXPECT_TRUE(info.features.neon); + EXPECT_TRUE(info.features.vfpv3); + EXPECT_FALSE(info.features.vfpv3d16); + EXPECT_TRUE(info.features.vfpv4); + EXPECT_TRUE(info.features.idiva); + EXPECT_TRUE(info.features.idivt); + EXPECT_FALSE(info.features.aes); + EXPECT_FALSE(info.features.pmull); + EXPECT_FALSE(info.features.sha1); + EXPECT_FALSE(info.features.sha2); + EXPECT_FALSE(info.features.crc32); +} + +// http://code.google.com/p/android/issues/detail?id=10812 +TEST(CpuinfoArmTest, InvalidArmv7) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(Processor : ARMv6-compatible processor rev 6 (v6l) +BogoMIPS : 199.47 +Features : swp half thumb fastmult vfp edsp java +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xb76 +CPU revision : 6 + +Hardware : SPICA +Revision : 0020 +Serial : 33323613546d00ec )"); + const auto info = GetArmInfo(); + EXPECT_EQ(info.architecture, 6); +} + +// https://crbug.com/341598. +TEST(CpuinfoArmTest, InvalidNeon) { + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(Processor: ARMv7 Processory rev 0 (v71) +processor: 0 +BogoMIPS: 13.50 + +Processor: 1 +BogoMIPS: 13.50 + +Features: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt +CPU implementer : 0x51 +CPU architecture: 7 +CPU variant: 0x1 +CPU part: 0x04d +CPU revision: 0 + +Hardware: SAMSUNG M2 +Revision: 0010 +Serial: 00001e030000354e)"); + const auto info = GetArmInfo(); + EXPECT_FALSE(info.features.neon); +} + +// The Nexus 4 (Qualcomm Krait) kernel configuration forgets to report IDIV +// support. +TEST(CpuinfoArmTest, Nexus4_0x510006f2) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(CPU implementer : 0x51 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0x6f +CPU revision : 2)"); + const auto info = GetArmInfo(); + EXPECT_TRUE(info.features.idiva); + EXPECT_TRUE(info.features.idivt); +} + +// The Nexus 4 (Qualcomm Krait) kernel configuration forgets to report IDIV +// support. +TEST(CpuinfoArmTest, Nexus4_0x510006f3) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(CPU implementer : 0x51 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0x6f +CPU revision : 3)"); + const auto info = GetArmInfo(); + EXPECT_TRUE(info.features.idiva); + EXPECT_TRUE(info.features.idivt); +} + +// The emulator-specific Android 4.2 kernel fails to report support for the +// 32-bit ARM IDIV instruction. Technically, this is a feature of the virtual +// CPU implemented by the emulator. +TEST(CpuinfoArmTest, EmulatorSpecificIdiv) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(Processor : ARMv7 Processor rev 0 (v7l) +BogoMIPS : 629.14 +Features : swp half thumb fastmult vfp edsp neon vfpv3 +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xc08 +CPU revision : 0 + +Hardware : Goldfish +Revision : 0000 +Serial : 0000000000000000)"); + const auto info = GetArmInfo(); + EXPECT_TRUE(info.features.idiva); +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_mips_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_mips_test.cc new file mode 100644 index 0000000..7c5a675 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_mips_test.cc @@ -0,0 +1,125 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_mips.h" +#include "filesystem_for_testing.h" +#include "hwcaps_for_testing.h" +#include "internal/stack_line_reader.h" +#include "internal/string_view.h" + +#include "gtest/gtest.h" + +namespace cpu_features { + +namespace { + +void DisableHardwareCapabilities() { SetHardwareCapabilities(0, 0); } + +TEST(CpuinfoMipsTest, FromHardwareCapBoth) { + SetHardwareCapabilities(MIPS_HWCAP_EVA | MIPS_HWCAP_MSA, 0); + GetEmptyFilesystem(); // disabling /proc/cpuinfo + const auto info = GetMipsInfo(); + EXPECT_TRUE(info.features.msa); + EXPECT_TRUE(info.features.eva); +} + +TEST(CpuinfoMipsTest, FromHardwareCapOnlyOne) { + SetHardwareCapabilities(MIPS_HWCAP_MSA, 0); + GetEmptyFilesystem(); // disabling /proc/cpuinfo + const auto info = GetMipsInfo(); + EXPECT_TRUE(info.features.msa); + EXPECT_FALSE(info.features.eva); +} + +TEST(CpuinfoMipsTest, Ci40) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", R"(system type : IMG Pistachio SoC (B0) +machine : IMG Marduk – Ci40 with cc2520 +processor : 0 +cpu model : MIPS interAptiv (multi) V2.0 FPU V0.0 +BogoMIPS : 363.72 +wait instruction : yes +microsecond timers : yes +tlb_entries : 64 +extra interrupt vector : yes +hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb] +isa : mips1 mips2 mips32r1 mips32r2 +ASEs implemented : mips16 dsp mt eva +shadow register sets : 1 +kscratch registers : 0 +package : 0 +core : 0 +VCED exceptions : not available +VCEI exceptions : not available +VPE : 0 +)"); + const auto info = GetMipsInfo(); + EXPECT_FALSE(info.features.msa); + EXPECT_TRUE(info.features.eva); +} + +TEST(CpuinfoMipsTest, AR7161) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(system type : Atheros AR7161 rev 2 +machine : NETGEAR WNDR3700/WNDR3800/WNDRMAC +processor : 0 +cpu model : MIPS 24Kc V7.4 +BogoMIPS : 452.19 +wait instruction : yes +microsecond timers : yes +tlb_entries : 16 +extra interrupt vector : yes +hardware watchpoint : yes, count: 4, address/irw mask: [0x0000, 0x0f98, 0x0f78, 0x0df8] +ASEs implemented : mips16 +shadow register sets : 1 +kscratch registers : 0 +core : 0 +VCED exceptions : not available +VCEI exceptions : not available +)"); + const auto info = GetMipsInfo(); + EXPECT_FALSE(info.features.msa); + EXPECT_FALSE(info.features.eva); +} + +TEST(CpuinfoMipsTest, Goldfish) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", R"(system type : MIPS-Goldfish +Hardware : goldfish +Revison : 1 +processor : 0 +cpu model : MIPS 24Kc V0.0 FPU V0.0 +BogoMIPS : 1042.02 +wait instruction : yes +microsecond timers : yes +tlb_entries : 16 +extra interrupt vector : yes +hardware watchpoint : yes, count: 1, address/irw mask: [0x0ff8] +ASEs implemented : +shadow register sets : 1 +core : 0 +VCED exceptions : not available +VCEI exceptions : not available +)"); + const auto info = GetMipsInfo(); + EXPECT_FALSE(info.features.msa); + EXPECT_FALSE(info.features.eva); +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_ppc_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_ppc_test.cc new file mode 100644 index 0000000..5d5e798 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_ppc_test.cc @@ -0,0 +1,119 @@ +// Copyright 2018 IBM. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cpuinfo_ppc.h" +#include "filesystem_for_testing.h" +#include "hwcaps_for_testing.h" +#include "internal/string_view.h" + +#include "gtest/gtest.h" + +namespace cpu_features { +namespace { + +void DisableHardwareCapabilities() { SetHardwareCapabilities(0, 0); } + +TEST(CpustringsPPCTest, FromHardwareCap) { + SetHardwareCapabilities(PPC_FEATURE_HAS_FPU | PPC_FEATURE_HAS_VSX, + PPC_FEATURE2_ARCH_3_00); + GetEmptyFilesystem(); // disabling /proc/cpuinfo + const auto info = GetPPCInfo(); + EXPECT_TRUE(info.features.fpu); + EXPECT_FALSE(info.features.mmu); + EXPECT_TRUE(info.features.vsx); + EXPECT_TRUE(info.features.arch300); + EXPECT_FALSE(info.features.power4); + EXPECT_FALSE(info.features.altivec); + EXPECT_FALSE(info.features.vcrypto); + EXPECT_FALSE(info.features.htm); +} + +TEST(CpustringsPPCTest, Blade) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(processor : 14 +cpu : POWER7 (architected), altivec supported +clock : 3000.000000MHz +revision : 2.1 (pvr 003f 0201) + +processor : 15 +cpu : POWER7 (architected), altivec supported +clock : 3000.000000MHz +revision : 2.1 (pvr 003f 0201) + +timebase : 512000000 +platform : pSeries +model : IBM,8406-70Y +machine : CHRP IBM,8406-70Y)"); + SetPlatformTypes("power7", "power8"); + const auto strings = GetPPCPlatformStrings(); + ASSERT_STREQ(strings.platform, "pSeries"); + ASSERT_STREQ(strings.model, "IBM,8406-70Y"); + ASSERT_STREQ(strings.machine, "CHRP IBM,8406-70Y"); + ASSERT_STREQ(strings.cpu, "POWER7 (architected), altivec supported"); + ASSERT_STREQ(strings.type.platform, "power7"); + ASSERT_STREQ(strings.type.base_platform, "power8"); +} + +TEST(CpustringsPPCTest, Firestone) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(processor : 126 +cpu : POWER8 (raw), altivec supported +clock : 2061.000000MHz +revision : 2.0 (pvr 004d 0200) + +processor : 127 +cpu : POWER8 (raw), altivec supported +clock : 2061.000000MHz +revision : 2.0 (pvr 004d 0200) + +timebase : 512000000 +platform : PowerNV +model : 8335-GTA +machine : PowerNV 8335-GTA +firmware : OPAL v3)"); + const auto strings = GetPPCPlatformStrings(); + ASSERT_STREQ(strings.platform, "PowerNV"); + ASSERT_STREQ(strings.model, "8335-GTA"); + ASSERT_STREQ(strings.machine, "PowerNV 8335-GTA"); + ASSERT_STREQ(strings.cpu, "POWER8 (raw), altivec supported"); +} + +TEST(CpustringsPPCTest, w8) { + DisableHardwareCapabilities(); + auto& fs = GetEmptyFilesystem(); + fs.CreateFile("/proc/cpuinfo", + R"(processor : 143 +cpu : POWER9, altivec supported +clock : 2300.000000MHz +revision : 2.2 (pvr 004e 1202) + +timebase : 512000000 +platform : PowerNV +model : 0000000000000000 +machine : PowerNV 0000000000000000 +firmware : OPAL +MMU : Radix)"); + const auto strings = GetPPCPlatformStrings(); + ASSERT_STREQ(strings.platform, "PowerNV"); + ASSERT_STREQ(strings.model, "0000000000000000"); + ASSERT_STREQ(strings.machine, "PowerNV 0000000000000000"); + ASSERT_STREQ(strings.cpu, "POWER9, altivec supported"); +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_x86_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_x86_test.cc new file mode 100644 index 0000000..f7fc081 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/cpuinfo_x86_test.cc @@ -0,0 +1,172 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "gtest/gtest.h" + +#include "cpuinfo_x86.h" +#include "internal/cpuid_x86.h" + +namespace cpu_features { + +class FakeCpu { + public: + Leaf CpuId(uint32_t leaf_id) const { + const auto itr = cpuid_leaves_.find(leaf_id); + EXPECT_TRUE(itr != cpuid_leaves_.end()) << "Missing leaf " << leaf_id; + return itr->second; + } + + uint32_t GetXCR0Eax() const { return xcr0_eax_; } + + void SetLeaves(std::map configuration) { + cpuid_leaves_ = std::move(configuration); + } + + void SetOsBackupsExtendedRegisters(bool os_backups_extended_registers) { + xcr0_eax_ = os_backups_extended_registers ? -1 : 0; + } + + private: + std::map cpuid_leaves_; + uint32_t xcr0_eax_; +}; + +auto* g_fake_cpu = new FakeCpu(); + +extern "C" Leaf CpuId(uint32_t leaf_id) { return g_fake_cpu->CpuId(leaf_id); } +extern "C" uint32_t GetXCR0Eax(void) { return g_fake_cpu->GetXCR0Eax(); } + +namespace { + +TEST(CpuidX86Test, SandyBridge) { + g_fake_cpu->SetOsBackupsExtendedRegisters(true); + g_fake_cpu->SetLeaves({ + {0x00000000, Leaf{0x0000000D, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {0x00000001, Leaf{0x000206A6, 0x00100800, 0x1F9AE3BF, 0xBFEBFBFF}}, + {0x00000007, Leaf{0x00000000, 0x00000000, 0x00000000, 0x00000000}}, + }); + const auto info = GetX86Info(); + EXPECT_STREQ(info.vendor, "GenuineIntel"); + EXPECT_EQ(info.family, 0x06); + EXPECT_EQ(info.model, 0x02A); + EXPECT_EQ(info.stepping, 0x06); + // Leaf 7 is zeroed out so none of the Leaf 7 flags are set. + const auto features = info.features; + EXPECT_FALSE(features.erms); + EXPECT_FALSE(features.avx2); + EXPECT_FALSE(features.avx512f); + EXPECT_FALSE(features.avx512cd); + EXPECT_FALSE(features.avx512er); + EXPECT_FALSE(features.avx512pf); + EXPECT_FALSE(features.avx512bw); + EXPECT_FALSE(features.avx512dq); + EXPECT_FALSE(features.avx512vl); + EXPECT_FALSE(features.avx512ifma); + EXPECT_FALSE(features.avx512vbmi); + EXPECT_FALSE(features.avx512vbmi2); + EXPECT_FALSE(features.avx512vnni); + EXPECT_FALSE(features.avx512bitalg); + EXPECT_FALSE(features.avx512vpopcntdq); + EXPECT_FALSE(features.avx512_4vnniw); + EXPECT_FALSE(features.avx512_4vbmi2); + // All old cpu features should be set. + EXPECT_TRUE(features.aes); + EXPECT_TRUE(features.ssse3); + EXPECT_TRUE(features.sse4_1); + EXPECT_TRUE(features.sse4_2); + EXPECT_TRUE(features.avx); +} + +TEST(CpuidX86Test, SandyBridgeTestOsSupport) { + g_fake_cpu->SetLeaves({ + {0x00000000, Leaf{0x0000000D, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {0x00000001, Leaf{0x000206A6, 0x00100800, 0x1F9AE3BF, 0xBFEBFBFF}}, + {0x00000007, Leaf{0x00000000, 0x00000000, 0x00000000, 0x00000000}}, + }); + // avx is disabled if os does not support backing up ymm registers. + g_fake_cpu->SetOsBackupsExtendedRegisters(false); + EXPECT_FALSE(GetX86Info().features.avx); + // avx is disabled if os does not support backing up ymm registers. + g_fake_cpu->SetOsBackupsExtendedRegisters(true); + EXPECT_TRUE(GetX86Info().features.avx); +} + +TEST(CpuidX86Test, SkyLake) { + g_fake_cpu->SetOsBackupsExtendedRegisters(true); + g_fake_cpu->SetLeaves({ + {0x00000000, Leaf{0x00000016, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {0x00000001, Leaf{0x000406E3, 0x00100800, 0x7FFAFBBF, 0xBFEBFBFF}}, + {0x00000007, Leaf{0x00000000, 0x029C67AF, 0x00000000, 0x00000000}}, + }); + const auto info = GetX86Info(); + EXPECT_STREQ(info.vendor, "GenuineIntel"); + EXPECT_EQ(info.family, 0x06); + EXPECT_EQ(info.model, 0x04E); + EXPECT_EQ(info.stepping, 0x03); + EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_SKL); +} + +TEST(CpuidX86Test, Branding) { + g_fake_cpu->SetLeaves({ + {0x00000000, Leaf{0x00000016, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {0x00000001, Leaf{0x000406E3, 0x00100800, 0x7FFAFBBF, 0xBFEBFBFF}}, + {0x00000007, Leaf{0x00000000, 0x029C67AF, 0x00000000, 0x00000000}}, + {0x80000000, Leaf{0x80000008, 0x00000000, 0x00000000, 0x00000000}}, + {0x80000001, Leaf{0x00000000, 0x00000000, 0x00000121, 0x2C100000}}, + {0x80000002, Leaf{0x65746E49, 0x2952286C, 0x726F4320, 0x4D542865}}, + {0x80000003, Leaf{0x37692029, 0x3035362D, 0x43205530, 0x40205550}}, + {0x80000004, Leaf{0x352E3220, 0x7A484730, 0x00000000, 0x00000000}}, + }); + char brand_string[49]; + FillX86BrandString(brand_string); + EXPECT_STREQ(brand_string, "Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz"); +} + +// http://users.atw.hu/instlatx64/AuthenticAMD0630F81_K15_Godavari_CPUID.txt +TEST(CpuidX86Test, AMD_K15) { + g_fake_cpu->SetLeaves({ + {0x00000000, Leaf{0x0000000D, 0x68747541, 0x444D4163, 0x69746E65}}, + {0x00000001, Leaf{0x00630F81, 0x00040800, 0x3E98320B, 0x178BFBFF}}, + {0x00000007, Leaf{0x00000000, 0x00000000, 0x00000000, 0x00000000}}, + {0x80000000, Leaf{0x8000001E, 0x68747541, 0x444D4163, 0x69746E65}}, + {0x80000001, Leaf{0x00630F81, 0x10000000, 0x0FEBBFFF, 0x2FD3FBFF}}, + {0x80000002, Leaf{0x20444D41, 0x372D3841, 0x4B303736, 0x64615220}}, + {0x80000003, Leaf{0x206E6F65, 0x202C3752, 0x43203031, 0x75706D6F}}, + {0x80000004, Leaf{0x43206574, 0x7365726F, 0x2B433420, 0x00204736}}, + {0x80000005, Leaf{0xFF40FF18, 0xFF40FF30, 0x10040140, 0x60030140}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, "AuthenticAMD"); + EXPECT_EQ(info.family, 0x15); + EXPECT_EQ(info.model, 0x38); + EXPECT_EQ(info.stepping, 0x01); + EXPECT_EQ(GetX86Microarchitecture(&info), + X86Microarchitecture::AMD_BULLDOZER); + + char brand_string[49]; + FillX86BrandString(brand_string); + EXPECT_STREQ(brand_string, "AMD A8-7670K Radeon R7, 10 Compute Cores 4C+6G "); +} + +// TODO(user): test what happens when xsave/osxsave are not present. +// TODO(user): test what happens when xmm/ymm/zmm os support are not +// present. + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.cc new file mode 100644 index 0000000..4554c1f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.cc @@ -0,0 +1,103 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "filesystem_for_testing.h" + +#include +#include +#include +#include +#include + +namespace cpu_features { + +FakeFile::FakeFile(int file_descriptor, const char* content) + : file_descriptor_(file_descriptor), content_(content) {} + +FakeFile::~FakeFile() { assert(!opened_); } + +void FakeFile::Open() { + assert(!opened_); + opened_ = true; +} + +void FakeFile::Close() { + assert(opened_); + opened_ = false; +} + +int FakeFile::Read(int fd, void* buf, size_t count) { + assert(count < INT_MAX); + assert(fd == file_descriptor_); + const size_t remainder = content_.size() - head_index_; + const size_t read = count > remainder ? remainder : count; + memcpy(buf, content_.data() + head_index_, read); + head_index_ += read; + assert(read < INT_MAX); + return read; +} + +void FakeFilesystem::Reset() { files_.clear(); } + +FakeFile* FakeFilesystem::CreateFile(const std::string& filename, + const char* content) { + auto& file = files_[filename]; + file = + std::unique_ptr(new FakeFile(next_file_descriptor_++, content)); + return file.get(); +} + +FakeFile* FakeFilesystem::FindFileOrNull(const std::string& filename) const { + const auto itr = files_.find(filename); + return itr == files_.end() ? nullptr : itr->second.get(); +} + +FakeFile* FakeFilesystem::FindFileOrDie(const int file_descriptor) const { + for (const auto& filename_file_pair : files_) { + FakeFile* const file_ptr = filename_file_pair.second.get(); + if (file_ptr->GetFileDescriptor() == file_descriptor) { + return file_ptr; + } + } + assert(false); + return nullptr; +} + +static FakeFilesystem* kFilesystem = new FakeFilesystem(); + +FakeFilesystem& GetEmptyFilesystem() { + kFilesystem->Reset(); + return *kFilesystem; +} + +extern "C" int CpuFeatures_OpenFile(const char* filename) { + auto* const file = kFilesystem->FindFileOrNull(filename); + if (file) { + file->Open(); + return file->GetFileDescriptor(); + } + return -1; +} + +extern "C" void CpuFeatures_CloseFile(int file_descriptor) { + kFilesystem->FindFileOrDie(file_descriptor)->Close(); +} + +extern "C" int CpuFeatures_ReadFile(int file_descriptor, void* buffer, + size_t buffer_size) { + return kFilesystem->FindFileOrDie(file_descriptor) + ->Read(file_descriptor, buffer, buffer_size); +} + +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.h new file mode 100644 index 0000000..ca269e5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/filesystem_for_testing.h @@ -0,0 +1,61 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Implements a fake filesystem, useful for tests. +#ifndef CPU_FEATURES_TEST_FILESYSTEM_FOR_TESTING_H_ +#define CPU_FEATURES_TEST_FILESYSTEM_FOR_TESTING_H_ + +#include +#include +#include + +#include "internal/filesystem.h" + +namespace cpu_features { + +class FakeFile { + public: + explicit FakeFile(int file_descriptor, const char* content); + ~FakeFile(); + + void Open(); + void Close(); + int Read(int fd, void* buf, size_t count); + + int GetFileDescriptor() const { return file_descriptor_; } + + private: + const int file_descriptor_; + const std::string content_; + bool opened_ = false; + size_t head_index_ = 0; +}; + +class FakeFilesystem { + public: + void Reset(); + FakeFile* CreateFile(const std::string& filename, const char* content); + FakeFile* FindFileOrDie(const int file_descriptor) const; + FakeFile* FindFileOrNull(const std::string& filename) const; + + private: + size_t next_file_descriptor_ = 0; + std::unordered_map> files_; +}; + +FakeFilesystem& GetEmptyFilesystem(); + +} // namespace cpu_features + +#endif // CPU_FEATURES_TEST_FILESYSTEM_FOR_TESTING_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.cc new file mode 100644 index 0000000..07f68e8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.cc @@ -0,0 +1,45 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "hwcaps_for_testing.h" +#include "internal/string_view.h" + +namespace cpu_features { + +namespace { +static auto* const g_hardware_capabilities = new HardwareCapabilities(); +static auto* const g_platform_types = new PlatformType(); +} // namespace + +void SetHardwareCapabilities(uint32_t hwcaps, uint32_t hwcaps2) { + g_hardware_capabilities->hwcaps = hwcaps; + g_hardware_capabilities->hwcaps2 = hwcaps2; +} + +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) { + return *g_hardware_capabilities; +} + +void SetPlatformTypes(const char* platform, const char* base_platform) { + CpuFeatures_StringView_CopyString(str(platform), g_platform_types->platform, + sizeof(g_platform_types->platform)); + CpuFeatures_StringView_CopyString(str(base_platform), + g_platform_types->base_platform, + sizeof(g_platform_types->base_platform)); +} + +PlatformType CpuFeatures_GetPlatformType(void) { return *g_platform_types; } +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.h b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.h new file mode 100644 index 0000000..0d03777 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/hwcaps_for_testing.h @@ -0,0 +1,27 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CPU_FEATURES_TEST_HWCAPS_FOR_TESTING_H_ +#define CPU_FEATURES_TEST_HWCAPS_FOR_TESTING_H_ + +#include "internal/hwcaps.h" + +namespace cpu_features { + +void SetHardwareCapabilities(uint32_t hwcaps, uint32_t hwcaps2); +void SetPlatformTypes(const char *platform, const char *base_platform); + +} // namespace cpu_features + +#endif // CPU_FEATURES_TEST_HWCAPS_FOR_TESTING_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/linux_features_aggregator_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/linux_features_aggregator_test.cc new file mode 100644 index 0000000..99367dc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/linux_features_aggregator_test.cc @@ -0,0 +1,95 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "internal/linux_features_aggregator.h" + +#include "gtest/gtest.h" + +namespace cpu_features { + +namespace { + +struct Features { + bool a = false; + bool b = false; + bool c = false; +}; + +DECLARE_SETTER(Features, a) +DECLARE_SETTER(Features, b) +DECLARE_SETTER(Features, c) + +class LinuxFeatureAggregatorTest : public testing::Test { + public: + const std::array kConfigs = { + {{{0b0001, 0b0000}, "a", &set_a}, + {{0b0010, 0b0000}, "b", &set_b}, + {{0b0000, 0b1100}, "c", &set_c}}}; +}; + +TEST_F(LinuxFeatureAggregatorTest, FromFlagsEmpty) { + Features features; + CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str(""), + &features); + EXPECT_FALSE(features.a); + EXPECT_FALSE(features.b); + EXPECT_FALSE(features.c); +} + +TEST_F(LinuxFeatureAggregatorTest, FromFlagsAllSet) { + Features features; + CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a c b"), + &features); + EXPECT_TRUE(features.a); + EXPECT_TRUE(features.b); + EXPECT_TRUE(features.c); +} + +TEST_F(LinuxFeatureAggregatorTest, FromFlagsOnlyA) { + Features features; + CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a"), + &features); + EXPECT_TRUE(features.a); + EXPECT_FALSE(features.b); + EXPECT_FALSE(features.c); +} + +TEST_F(LinuxFeatureAggregatorTest, FromHwcapsNone) { + HardwareCapabilities capability; + capability.hwcaps = 0; // matches none + capability.hwcaps2 = 0; // matches none + Features features; + CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, + &features); + EXPECT_FALSE(features.a); + EXPECT_FALSE(features.b); + EXPECT_FALSE(features.c); +} + +TEST_F(LinuxFeatureAggregatorTest, FromHwcapsSet) { + HardwareCapabilities capability; + capability.hwcaps = 0b0010; // matches b but not a + capability.hwcaps2 = 0b1111; // matches c + Features features; + CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, + &features); + EXPECT_FALSE(features.a); + EXPECT_TRUE(features.b); + EXPECT_TRUE(features.c); +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/stack_line_reader_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/stack_line_reader_test.cc new file mode 100644 index 0000000..c8f9691 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/stack_line_reader_test.cc @@ -0,0 +1,132 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/stack_line_reader.h" +#include "filesystem_for_testing.h" + +#include "gtest/gtest.h" + +namespace cpu_features { + +bool operator==(const StringView& a, const StringView& b) { + return CpuFeatures_StringView_IsEquals(a, b); +} + +namespace { + +std::string ToString(StringView view) { return {view.ptr, view.size}; } + +TEST(StackLineReaderTest, Empty) { + auto& fs = GetEmptyFilesystem(); + auto* file = fs.CreateFile("/proc/cpuinfo", ""); + StackLineReader reader; + StackLineReader_Initialize(&reader, file->GetFileDescriptor()); + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_TRUE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("")); + } +} + +TEST(StackLineReaderTest, ManySmallLines) { + auto& fs = GetEmptyFilesystem(); + auto* file = fs.CreateFile("/proc/cpuinfo", "a\nb\nc"); + + StackLineReader reader; + StackLineReader_Initialize(&reader, file->GetFileDescriptor()); + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_FALSE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("a")); + } + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_FALSE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("b")); + } + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_TRUE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("c")); + } +} + +TEST(StackLineReaderTest, TruncatedLine) { + auto& fs = GetEmptyFilesystem(); + auto* file = fs.CreateFile("/proc/cpuinfo", R"(First +Second +More than 16 characters, this will be truncated. +last)"); + + StackLineReader reader; + StackLineReader_Initialize(&reader, file->GetFileDescriptor()); + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_FALSE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("First")); + } + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_FALSE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("Second")); + } + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_FALSE(result.eof); + EXPECT_FALSE(result.full_line); + EXPECT_EQ(result.line, str("More than 16 cha")); + } + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_TRUE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("last")); + } +} + +TEST(StackLineReaderTest, TruncatedLines) { + auto& fs = GetEmptyFilesystem(); + auto* file = fs.CreateFile("/proc/cpuinfo", R"(More than 16 characters +Another line that is too long)"); + + StackLineReader reader; + StackLineReader_Initialize(&reader, file->GetFileDescriptor()); + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_FALSE(result.eof); + EXPECT_FALSE(result.full_line); + EXPECT_EQ(result.line, str("More than 16 cha")); + } + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_FALSE(result.eof); + EXPECT_FALSE(result.full_line); + EXPECT_EQ(result.line, str("Another line tha")); + } + { + const auto result = StackLineReader_NextLine(&reader); + EXPECT_TRUE(result.eof); + EXPECT_TRUE(result.full_line); + EXPECT_EQ(result.line, str("")); + } +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/string_view_test.cc b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/string_view_test.cc new file mode 100644 index 0000000..abfcc2c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/cpu_features/test/string_view_test.cc @@ -0,0 +1,144 @@ +// Copyright 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal/string_view.h" + +#include "gtest/gtest.h" + +namespace cpu_features { + +bool operator==(const StringView& a, const StringView& b) { + return CpuFeatures_StringView_IsEquals(a, b); +} + +namespace { + +TEST(StringViewTest, Empty) { + EXPECT_EQ(kEmptyStringView.ptr, nullptr); + EXPECT_EQ(kEmptyStringView.size, 0); +} + +TEST(StringViewTest, Build) { + const auto view = str("test"); + EXPECT_EQ(view.ptr[0], 't'); + EXPECT_EQ(view.size, 4); +} + +TEST(StringViewTest, CpuFeatures_StringView_IndexOfChar) { + // Found. + EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("test"), 'e'), 1); + // Not found. + EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("test"), 'z'), -1); + // Empty. + EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(kEmptyStringView, 'z'), -1); +} + +TEST(StringViewTest, CpuFeatures_StringView_IndexOf) { + // Found. + EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("test"), str("es")), 1); + // Not found. + EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("test"), str("aa")), -1); + // Empty. + EXPECT_EQ(CpuFeatures_StringView_IndexOf(kEmptyStringView, str("aa")), -1); + EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("aa"), kEmptyStringView), -1); +} + +TEST(StringViewTest, CpuFeatures_StringView_StartsWith) { + EXPECT_TRUE(CpuFeatures_StringView_StartsWith(str("test"), str("te"))); + EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), str(""))); + EXPECT_FALSE( + CpuFeatures_StringView_StartsWith(str("test"), kEmptyStringView)); + EXPECT_FALSE( + CpuFeatures_StringView_StartsWith(kEmptyStringView, str("test"))); +} + +TEST(StringViewTest, CpuFeatures_StringView_IsEquals) { + EXPECT_TRUE( + CpuFeatures_StringView_IsEquals(kEmptyStringView, kEmptyStringView)); + EXPECT_TRUE(CpuFeatures_StringView_IsEquals(kEmptyStringView, str(""))); + EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str(""), kEmptyStringView)); + EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str("a"), str("a"))); + EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("a"), str("b"))); + EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("a"), kEmptyStringView)); + EXPECT_FALSE(CpuFeatures_StringView_IsEquals(kEmptyStringView, str("a"))); +} + +TEST(StringViewTest, CpuFeatures_StringView_PopFront) { + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 2), str("st")); + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 0), str("test")); + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 4), str("")); + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 100), str("")); +} + +TEST(StringViewTest, CpuFeatures_StringView_ParsePositiveNumber) { + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("42")), 42); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2a")), 42); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2A")), 42); + + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("-0x2A")), -1); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("abc")), -1); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("")), -1); +} + +TEST(StringViewTest, CpuFeatures_StringView_CopyString) { + char buf[4]; + buf[0] = 'X'; + + // Empty + CpuFeatures_StringView_CopyString(str(""), buf, sizeof(buf)); + EXPECT_STREQ(buf, ""); + + // Less + CpuFeatures_StringView_CopyString(str("a"), buf, sizeof(buf)); + EXPECT_STREQ(buf, "a"); + + // exact + CpuFeatures_StringView_CopyString(str("abc"), buf, sizeof(buf)); + EXPECT_STREQ(buf, "abc"); + + // More + CpuFeatures_StringView_CopyString(str("abcd"), buf, sizeof(buf)); + EXPECT_STREQ(buf, "abc"); +} + +TEST(StringViewTest, CpuFeatures_StringView_HasWord) { + // Find flags at beginning, middle and end. + EXPECT_TRUE( + CpuFeatures_StringView_HasWord(str("first middle last"), "first")); + EXPECT_TRUE( + CpuFeatures_StringView_HasWord(str("first middle last"), "middle")); + EXPECT_TRUE(CpuFeatures_StringView_HasWord(str("first middle last"), "last")); + // Do not match partial flags + EXPECT_FALSE( + CpuFeatures_StringView_HasWord(str("first middle last"), "irst")); + EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "mid")); + EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "las")); +} + +TEST(StringViewTest, CpuFeatures_StringView_GetAttributeKeyValue) { + const StringView line = str(" key : first middle last "); + StringView key, value; + EXPECT_TRUE(CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)); + EXPECT_EQ(key, str("key")); + EXPECT_EQ(value, str("first middle last")); +} + +TEST(StringViewTest, FailingGetAttributeKeyValue) { + const StringView line = str("key first middle last"); + StringView key, value; + EXPECT_FALSE(CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)); +} + +} // namespace +} // namespace cpu_features diff --git a/src/type3_AndroidCloud/anbox-master/external/nsexec/uidmapshift.c b/src/type3_AndroidCloud/anbox-master/external/nsexec/uidmapshift.c new file mode 100644 index 0000000..089b7b5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/nsexec/uidmapshift.c @@ -0,0 +1,160 @@ +/* + * Copyright © 2012-2016 Canonical, Inc + * + * Author: Serge Hallyn + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2 of the + * License. + * + */ +#define _XOPEN_SOURCE 500 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define min(a,b) (a) < (b) ? (a) : (b) +#define max(a,b) (a) > (b) ? (a) : (b) + +static int verbose = 0; +static int convert_uids = 0; +static int convert_gids = 0; +static uid_t srcid; +static uid_t dstid; +static uid_t range; +static uid_t range_uid_max = 0; +static uid_t range_uid_min = ~0; +static gid_t range_gid_max = 0; +static gid_t range_gid_min = ~0; + +void usage(void) +{ + extern const char *__progname; + printf("Usage: %s [OPTIONS] directory [src dst range]\n\n", __progname); + printf(" -u, --uid convert uids in directory\n"); + printf(" -g, --gid convert gids in directory\n"); + printf(" -b, --both convert uids and gids in directory\n"); + printf(" -r, --range find min,max uid/gid used in directory\n"); + printf(" -v, --verbose increate verbosity\n\n"); + printf("Note this program always recursively walks all of directory.\n"); + printf("If -u,-g, or -b is given, then [src dst range] are required to convert the \n"); + printf("ids within the range [src..src+range] to [dst..dst+range].\n\n"); + printf("Examples:\n"); + printf(" %s -r /path/to/directory # show min/max uid/gid\n", __progname); + printf(" %s -b /path/to/directory 0 100000 500 # map uids and gids up\n", __progname); + printf(" %s -u /path/to/directory 100000 0 500 # map the uids back down\n", __progname); +} + +int ftw_callback(const char *fpath, const struct stat *st, + int typeflag, struct FTW *ftw) +{ + uid_t new_uid = -1; + uid_t new_gid = -1; + int ret; + + range_uid_max = max(range_uid_max, st->st_uid); + range_uid_min = min(range_uid_min, st->st_uid); + range_gid_max = max(range_gid_max, st->st_gid); + range_gid_min = min(range_gid_min, st->st_gid); + + if (convert_uids && st->st_uid >= srcid && st->st_uid < srcid+range) + new_uid = (st->st_uid-srcid) + dstid; + if (convert_gids && st->st_gid >= srcid && st->st_gid < srcid+range) + new_gid = (st->st_gid-srcid) + dstid; + if (new_uid != -1 || new_gid != -1) { + ret = lchown(&fpath[ftw->base], new_uid, new_gid); + if (ret) { + fprintf(stderr, "failed to chown %d:%d %s\n", + new_uid, new_gid, fpath); + /* well, let's keep going */ + } else { + if (!S_ISLNK(st->st_mode)) { + if (verbose > 1) + fprintf(stderr, "resetting mode to %o on %s\n", + st->st_mode, fpath); + ret = chmod(&fpath[ftw->base], st->st_mode); + if (ret) { + fprintf(stderr, "failed to reset mode %o on %s\n", + st->st_mode, fpath); + /* well, let's keep going */ + } + } + if (verbose) + printf("u:%07d=%07d g:%07d=%07d m:%#07o %s %s\n", + st->st_uid, new_uid, + st->st_gid, new_gid, + st->st_mode, fpath, &fpath[ftw->base]); + } + } + return 0; +} + +int main(int argc, char *argv[]) +{ + const char *base; + int show_range = 0; + int opt,ret; + + static const struct option long_opts[] = { + { "help", no_argument, NULL, 'h' }, + { "uids", no_argument, NULL, 'u' }, + { "gids", no_argument, NULL, 'g' }, + { "both", no_argument, NULL, 'b' }, + { "range", no_argument, NULL, 'r' }, + { "verbose", no_argument, NULL, 'v' }, + { NULL, 0, NULL, 0 } + }; + + while ((opt = getopt_long(argc, argv, "hugbrv", long_opts, NULL)) >= 0) { + switch (opt) { + case 'h': usage(); exit(EXIT_SUCCESS); + case 'u': convert_uids = 1; break; + case 'g': convert_gids = 1; break; + case 'b': convert_uids = convert_gids = 1; break; + case 'r': show_range = 1; break; + case 'v': verbose++; break; + } + } + + argc -= optind; + argv += optind; + + if (argc < 1) { + usage(); + exit(EXIT_FAILURE); + } + + base = argv[0]; + if (convert_uids || convert_gids) { + if (argc < 4) { + usage(); + exit(EXIT_FAILURE); + } + srcid = atoi(argv[1]); + dstid = atoi(argv[2]); + range = atoi(argv[3]); + } + + ret = nftw(base, ftw_callback, 1000, FTW_PHYS|FTW_CHDIR); + if (ret < 0) { + fprintf(stderr, "Failed to walk path %s %s\n", base, strerror(errno)); + usage(); + return EXIT_FAILURE; + } + + if (show_range) { + printf("UIDs %d - %d\n" + "GIDs %d - %d\n", + range_uid_min, range_uid_max, + range_gid_min, range_gid_max); + } + + return EXIT_SUCCESS; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/CMakeLists.txt new file mode 100644 index 0000000..da19732 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/CMakeLists.txt @@ -0,0 +1,39 @@ +# Copyright © 2013 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Authored by: Thomas Voss + +cmake_minimum_required(VERSION 2.8) + +project(process-cpp) + +find_package(Boost COMPONENTS iostreams system REQUIRED) +find_package(Threads REQUIRED) + +include(GNUInstallDirs) + +set(PROCESS_CPP_VERSION_MAJOR 2) +set(PROCESS_CPP_VERSION_MINOR 0) +set(PROCESS_CPP_VERSION_PATCH 0) + +include(CTest) + +include_directories( + include/ + src/ + external/process-cpp-minimal + ${Boost_INCLUDE_DIRS} +) + +add_subdirectory(src) diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/COPYING b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/COPYING new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/COPYING @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/README.md b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/README.md new file mode 100644 index 0000000..41e6e90 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/README.md @@ -0,0 +1,86 @@ +process-cpp {#mainpage} +=========== + +process-cpp is a simple and straightforward wrapper around process creation and +control targeted towards linux. It helps both with handling child processes and with +interacting with the current process. Some of its features include: + + - Thread-safe get/set/unset operation on the current process's environment. + - Throwing and non-throwing overloads of functions when system calls are involved. + - Seamless redirection of input, output and error streams of child processes. + - Type-safe interaction with the virtual proc filesystem, both for reading & writing. + +The library's main purpose is to assist in testing and when a software component +needs to carry out process creation/control tasks, e.g., a graphical shell. To this end, +the library is extensively tested and tries to ensure fail-safe operation as much as possible. + +A simple echo +------------- + +~~~~~~~~~~~~~{.cpp} +// Fork and run a simple echo: +posix::ChildProcess child = posix::fork( + []() + { + std::string line; + while(true) + { + std::cin >> line; + std::cout << line << std::endl; + } + return EXIT_FAILURE; + }, + posix::StandardStreamFlags() + .set(posix::StandardStream::stdin) + .set(posix::StandardStream::stdout)); + +// Check that the resulting process has a valid pid. +EXPECT_TRUE(child.pid() > 0); + +// Check on echo functionality. +const std::string echo_value{"42"}; +child.cin() << echo_value << std::endl; +std::string line; child.cout() >> line; +EXPECT_EQ(echo_value, line); + +// Stop the process and synchronize with the process changing state. +EXPECT_NO_THROW(child.send_signal(posix::Signal::sig_stop)); +auto result = child.wait_for(posix::wait::Flag::untraced); +EXPECT_EQ(posix::wait::Result::Status::stopped, + result.status); +EXPECT_EQ(posix::Signal::sig_stop, + result.detail.if_stopped.signal); + +// Kill the stopped process and synchronize to its state change. +EXPECT_NO_THROW(child.send_signal(posix::Signal::sig_kill)); +result = child.wait_for(posix::wait::Flag::untraced); +EXPECT_EQ(posix::wait::Result::Status::signaled, + result.status); +EXPECT_EQ(posix::Signal::sig_kill, + result.detail.if_signaled.signal); +~~~~~~~~~~~~~ + +Adjusting OOM Score Values +-------------------------- + +~~~~~~~~~~~~~{.cpp} +// Setup the manipulator with a well-known value. +posix::linux::proc::process::OomScoreAdj oom_score_adj +{ + posix::linux::proc::process::OomScoreAdj::max_value() +}; +// Apply the manipulator to the current process +EXPECT_NO_THROW(posix::this_process::instance() << oom_score_adj); +// Read back the manipulators value for the current process +EXPECT_NO_THROW(posix::this_process::instance() >> oom_score_adj); +// And check that applying the manipulator was successful. +EXPECT_EQ(posix::linux::proc::process::OomScoreAdj::max_value(), + oom_score_adj.value); +// Instantiate the observer... +posix::linux::proc::process::OomScore oom_score; +// ... and fill in its value for the current process. +EXPECT_NO_THROW(posix::this_process::instance() >> oom_score); +// Check that applying the manipulator before results in adjustments to the +// OOM score. +EXPECT_TRUE(is_approximately_equal(oom_score.value, posix::linux::proc::process::OomScoreAdj::max_value())); +~~~~~~~~~~~~~ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/connection.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/connection.h new file mode 100644 index 0000000..03dbaf8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/connection.h @@ -0,0 +1,190 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef COM_UBUNTU_CONNECTION_H_ +#define COM_UBUNTU_CONNECTION_H_ + +#include +#include +#include + +namespace core +{ +class ScopedConnection; +/** + * @brief The Connection class models a signal-slot connection. + */ +class Connection +{ +public: + typedef std::function&)> Dispatcher; + + /** + * @brief Checks if this instance corresponds to an active signal-slot connection. + * @return true iff the instance corresponds to an active signal-slot connection. + */ + inline bool is_connected() const + { + if (!d) + return false; + + return (d->disconnector ? true : false); + } + + /** + * @brief End a signal-slot connection. + */ + inline void disconnect() + { + if (d) + d->disconnect(); + } + + /** + * @brief Installs a dispatcher for this signal-slot connection. + * @param dispatcher The dispatcher to be used for signal emissions. + */ + inline void dispatch_via(const Dispatcher& dispatcher) + { + if (d && d->dispatcher_installer) + d->dispatcher_installer(dispatcher); + } + +private: + friend class ScopedConnection; + + typedef std::function Disconnector; + typedef std::function DispatcherInstaller; + + template friend class Signal; + + inline Connection(const Disconnector& disconnector, + const DispatcherInstaller& installer) + : d(std::make_shared(disconnector, installer)) + { + } + + inline bool operator<(const Connection& rhs) const + { + return d < rhs.d; + } + + inline void reset() + { + if (d) + d->reset(); + } + + struct Private + { + Private(const Connection::Disconnector& disconnector, + const Connection::DispatcherInstaller& dispatcher_installer) + : disconnector(disconnector), + dispatcher_installer(dispatcher_installer) + { + } + + inline void reset() + { + std::lock_guard lg(guard); + reset_locked(); + } + + inline void reset_locked() + { + static const Connection::Disconnector empty_disconnector{}; + static const Connection::DispatcherInstaller empty_dispatcher_installer{}; + + disconnector = empty_disconnector; + dispatcher_installer = empty_dispatcher_installer; + } + + inline void disconnect() + { + static const Connection::Disconnector empty_disconnector{}; + + std::lock_guard lg(guard); + + if (disconnector) + disconnector(); + + reset_locked(); + } + + std::mutex guard; + Connection::Disconnector disconnector; + Connection::DispatcherInstaller dispatcher_installer; + }; + + // The whole class is implicitly shared and we thus forward our complete + // shared state to a private structure that is lifetime-managed by a shared_ptr. + std::shared_ptr d; +}; + +/** + * @brief Scoped helper class to map signal-slot connection mgmt. to RAII. + */ +class ScopedConnection +{ +public: + /** + * @brief Constructs an instance for an existing signal-slot connection. + * @param c The existing signal-slot connection. + */ + inline ScopedConnection(const Connection& c) : connection(c) + { + } + + inline ScopedConnection(ScopedConnection&& rhs) : connection(std::move(rhs.connection)) + { + } + + ScopedConnection(const ScopedConnection&) = delete; + + /** + * @brief Disconnects the signal-slot connection. + */ + inline ~ScopedConnection() noexcept(true) + { + try + { + connection.disconnect(); + } catch(...) + { + } + } + + inline ScopedConnection& operator=(ScopedConnection&& rhs) + { + connection = std::move(rhs.connection); + return *this; + } + + ScopedConnection& operator=(const ScopedConnection&) = delete; + bool operator==(const ScopedConnection&) = delete; + + inline bool operator<(const ScopedConnection& rhs) const + { + return connection < rhs.connection; + } + +private: + Connection connection; +}; +} + +#endif // COM_UBUNTU_CONNECTION_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/child_process.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/child_process.h new file mode 100644 index 0000000..fde7977 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/child_process.h @@ -0,0 +1,177 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_CHILD_PROCESS_H_ +#define CORE_POSIX_CHILD_PROCESS_H_ + +#include +#include +#include + +#include + +#include +#include + +namespace core +{ +namespace posix +{ +/** + * @brief The Process class models a child process of this process. + * + * In addition to the functionality offered by the Process class, an instance + * of ChildProcess offers functionality to wait for status changes of the child + * process and to access the child process's standard streams if they have been + * redirected when forking or exec'ing. + */ +class CORE_POSIX_DLL_PUBLIC ChildProcess : public Process +{ +public: + /** + * @brief The DeathObserver class observes child process' states and emits a signal when a monitored child has died. + * + * Please note that the name of this class is morbid for a reason: Listening + * for SIGCHLD is not enough to catch all dying children. Whenever a SIGCHLD is + * received, we have to wait for all the children of this process and reap all + * monitored ones. We are thus changing state and potentially race with other + * wait operations on children. + * + */ + class DeathObserver + { + public: + /** + * @brief Creates the unique instance of class DeathObserver. + * @throw std::logic_error if the given SignalTrap instance does not trap Signal::sig_chld. + * @throw std::runtime_error if there already is an instance of the death observer. + */ + static std::unique_ptr create_once_with_signal_trap( + std::shared_ptr trap); + + DeathObserver(const DeathObserver&) = delete; + virtual ~DeathObserver() = default; + + DeathObserver& operator=(const DeathObserver&) = delete; + bool operator==(const DeathObserver&) const = delete; + + /** + * @brief add adds the specified child to the list of observed child processes. + * @param child The child to be observed. + * @return true iff the child has been added to the list of observed child processes. + */ + virtual bool add(const ChildProcess& child) = 0; + + /** + * @brief has checks whether the specified child is observed. + * @param child The child to check for. + * @return true iff the specified child is observed for state changes. + */ + virtual bool has(const ChildProcess& child) const = 0; + + /** + * @brief child_died is emitted whenever an observed child ceases to exist. + */ + virtual const core::Signal& child_died() const = 0; + + /** + * @brief Checks and reaps all child processes registered with the observer instance. + */ + virtual void on_sig_child() = 0; + + protected: + DeathObserver() = default; + }; + + /** + * @brief Creates an invalid ChildProcess. + * @return An invalid ChildProcess instance. + */ + static ChildProcess invalid(); + + ~ChildProcess(); + + /** + * @brief Wait for the child process to change state. + * @param [in] flags Alters the behavior of the wait operation. + * @return Result of the wait operation, as well as information about the + * reasons for a child process's state change. + */ + wait::Result wait_for(const wait::Flags& flags); + + /** + * @brief Mark the child process to not to be killed when the ChildProcess + * instance goes away. + */ + void dont_kill_on_cleanup(); + +#ifndef ANDROID + /** + * @brief Access this process's stderr. + */ + std::istream& cerr(); + + /** + * @brief Access this process's stdin. + */ + std::ostream& cin(); + + /** + * @brief Access this process's stdout. + */ + std::istream& cout(); +#endif + +private: + friend ChildProcess fork(const std::function&, const StandardStream&); + friend ChildProcess vfork(const std::function&, const StandardStream&); + + class CORE_POSIX_DLL_LOCAL Pipe + { + public: + static Pipe invalid(); + + Pipe(); + Pipe(const Pipe& rhs); + ~Pipe(); + + Pipe& operator=(const Pipe& rhs); + + int read_fd() const; + void close_read_fd(); + + int write_fd() const; + void close_write_fd(); + + private: + Pipe(int fds[2]); + int fds[2]; + }; + + CORE_POSIX_DLL_LOCAL ChildProcess(pid_t pid, + const Pipe& stdin, + const Pipe& stdout, + const Pipe& stderr); + + struct CORE_POSIX_DLL_LOCAL Private; + std::shared_ptr d; +}; +} +} + +#endif // CORE_POSIX_CHILD_PROCESS_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exec.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exec.h new file mode 100644 index 0000000..147e69f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exec.h @@ -0,0 +1,68 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_EXEC_H_ +#define CORE_POSIX_EXEC_H_ + +#include +#include + +#include +#include +#include +#include + +namespace core +{ +namespace posix +{ +enum class RedirectFlags; + +/** + * @brief exec execve's the executable with the provided arguments and environment. + * @throws std::system_error in case of errors. + * @param fn The executable to run. + * @param argv Vector of command line arguments + * @param env Environment that the new process should run under + * @param flags Specifies which standard streams should be redirected. + * @return An instance of ChildProcess corresponding to the newly exec'd process. + */ +CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string& fn, + const std::vector& argv, + const std::map& env, + const StandardStream& flags); + +/** + * @brief exec execve's the executable with the provided arguments and environment. + * @throws std::system_error in case of errors. + * @param fn The executable to run. + * @param argv Vector of command line arguments + * @param env Environment that the new process should run under + * @param flags Specifies which standard streams should be redirected. + * @param child_setup Function to run in the child just before exec(). + * @return An instance of ChildProcess corresponding to the newly exec'd process. + */ +CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string& fn, + const std::vector& argv, + const std::map& env, + const StandardStream& flags, + const std::function& child_setup); +} +} + +#endif // CORE_POSIX_EXEC_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exit.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exit.h new file mode 100644 index 0000000..183f5c7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/exit.h @@ -0,0 +1,42 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_EXIT_H_ +#define CORE_POSIX_EXIT_H_ + +#include + +namespace core +{ +namespace posix +{ +namespace exit +{ + /** + * @brief The Status enum wrap's the posix exit status. + */ + enum class Status + { + success = EXIT_SUCCESS, + failure = EXIT_FAILURE + }; +} +} +} + +#endif // CORE_POSIX_EXIT_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/fork.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/fork.h new file mode 100644 index 0000000..d41f967 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/fork.h @@ -0,0 +1,54 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_FORK_H_ +#define CORE_POSIX_FORK_H_ + +#include +#include +#include + +#include + +namespace core +{ +namespace posix +{ +/** + * @brief fork forks a new process and executes the provided main function in the newly forked process. + * @throws std::system_error in case of errors. + * @param [in] main The main function of the newly forked process. + * @param [in] flags Specify which standard streams should be redirected to the parent process. + * @return An instance of ChildProcess in case of success. + */ +CORE_POSIX_DLL_PUBLIC ChildProcess fork(const std::function& main, + const StandardStream& flags); + +/** + * @brief fork vforks a new process and executes the provided main function in the newly forked process. + * @throws std::system_error in case of errors. + * @param [in] main The main function of the newly forked process. + * @param [in] flags Specify which standard streams should be redirected to the parent process. + * @return An instance of ChildProcess in case of success. + */ +CORE_POSIX_DLL_PUBLIC ChildProcess vfork(const std::function& main, + const StandardStream& flags); +} +} + +#endif // CORE_POSIX_FORK_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_adj.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_adj.h new file mode 100644 index 0000000..3cab652 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_adj.h @@ -0,0 +1,106 @@ +/* + * Copyright © 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_ADJ_H_ +#define CORE_POSIX_LINUX_PROC_PROCESS_OOM_ADJ_H_ + +#include + +namespace core +{ +namespace posix +{ +class Process; +namespace linux +{ +namespace proc +{ +namespace process +{ +/** + * This file can be used to adjust the score used to select which process + * should be killed in an out-of-memory (OOM) situation. The kernel uses this + * value for a bit-shift operation of the process's oom_score value: valid + * values are in the range -16 to +15, plus the special value -17, which disables + * OOM-killing altogether for this process. A positive score increases the + * likelihood of this process being killed by the OOM-killer; a negative score + * decreases the likelihood. + * + * The default value for this file is 0; a new process inherits its parent's + * oom_adj setting. A process must be privileged (CAP_SYS_RESOURCE) to update + * this file. + * + * Since Linux 2.6.36, use of this file is deprecated in favor of + * /proc/[pid]/oom_score_adj. + */ +struct CORE_POSIX_DLL_PUBLIC OomAdj +{ + /** + * @brief Returns the value that makes a process "invisible" to the oom killer. + * @return Returns the value that makes a process "invisible" to the oom killer. + */ + static int disable_value(); + + /** + * @brief Returns the minimum valid value. + * @return The minimum valid value that the OomAdj can be set to. + */ + static int min_value(); + + /** + * @brief Returns the maximum valid value. + * @return The maximum valid value that the OomAdj can be set to. + */ + static int max_value(); + + /** + * @brief is_valid checks whether the contained value is within the predefined bounds. + * @return true iff min_value() <= value <= max_value(). + */ + inline bool is_valid() const + { + return (disable_value() <= value) && (value <= max_value()); + } + + /** + * @brief Current value. + */ + int value; +}; + +/** + * \brief Read the OomAdj value for a process instance. + * \throws std::runtime_error in case of errors. + * \param [in] process The process to read the score for. + * \param [out] adj The destination to store the value in. + */ +CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomAdj& adj); + +/** + * \brief Write the OomAdj value for a process instance. + * \throw std::runtime_error in case of errors and std::logic_error if score_adj.is_valid() returns false. + * \param [in] process The process to write the score for. + * \param [in] adj The new value to store. + */ +CORE_POSIX_DLL_PUBLIC const posix::Process& operator<<(const posix::Process& process, + const OomAdj& adj); +} +} +} +} +} +#endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_ADJ_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score.h new file mode 100644 index 0000000..8e7b9a4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score.h @@ -0,0 +1,67 @@ +/* + * Copyright © 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_ +#define CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_ + +#include + +namespace core +{ +namespace posix +{ +class Process; +namespace linux +{ +namespace proc +{ +namespace process +{ +/** + * This file displays the current score that the kernel gives to this process + * for the purpose of selecting a process for the OOM-killer. A higher score + * means that the process is more likely to be selected by the OOM-killer. The + * basis for this score is the amount of memory used by the process, with + * increases (+) or decreases (-) for factors including: + * + * - whether the process creates a lot of children using fork(2) (+); + * - whether the process has been running a long time, or has used a lot of CPU time (-); + * - whether the process has a low nice value (i.e., > 0) (+); + * - whether the process is privileged (-); and + * - whether the process is making direct hardware access (-). + * + * The oom_score also reflects the adjustment specified by the oom_score_adj or + * oom_adj setting for the process. + */ +struct CORE_POSIX_DLL_PUBLIC OomScore +{ + int value = 0; ///< Current OomScore as calculated by the kernel. +}; + +/** + * \brief Read the OomScore for a process instance. + * \throws std::runtime_error in case of errors. + * \param [in] process The process to read the score for. + * \param [out] score The destination to store the value in. + */ +CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomScore& score); +} +} +} +} +} +#endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score_adj.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score_adj.h new file mode 100644 index 0000000..eb52b9a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/oom_score_adj.h @@ -0,0 +1,131 @@ +/* + * Copyright © 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_ADJ_H_ +#define CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_ADJ_H_ + +#include + +namespace core +{ +namespace posix +{ +class Process; +namespace linux +{ +namespace proc +{ +namespace process +{ +/** + * This file can be used to adjust the badness heuristic used to select which + * process gets killed in out-of-memory conditions. + * + * The badness heuristic assigns a value to each candidate task ranging from 0 + * (never kill) to 1000 (always kill) to determine which process is targeted. + * The units are roughly a proportion along that range of allowed memory the + * process may allocate from, based on an estimation of its current memory and + * swap use. For example, if a task is using all allowed memory, its badness + * score will be 1000. If it is using half of its allowed memory, its score + * will be 500. + * + * There is an additional factor included in the badness score: root processes are + * given 3% extra memory over other tasks. + * + * The amount of "allowed" memory depends on the context in which the + * OOM-killer was called. If it is due to the memory assigned to the allocating + * task's cpuset being exhausted, the allowed memory represents the set of mems + * assigned to that cpuset (see cpuset(7)). If it is due to a mempolicy's node(s) + * being exhausted, the allowed memory represents the set of mempolicy nodes. If + * it is due to a memory limit (or swap limit) being reached, the allowed memory + * is that configured limit. Finally, if it is due to the entire system being out + * of memory, the allowed memory represents all allocatable resources. + * + * The value of oom_score_adj is added to the badness score before it is used + * to determine which task to kill. Acceptable values range from -1000 + * (OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX). This allows user space to + * control the preference for OOM-killing, ranging from always preferring a + * certain task or completely disabling it from OOM- killing. The lowest possible + * value, -1000, is equivalent to disabling OOM-killing entirely for that task, + * since it will always report a badness score of 0. + * + * Consequently, it is very simple for user space to define the amount of + * memory to consider for each task. Setting a oom_score_adj value of +500, for + * example, is roughly equivalent to allowing the remainder of tasks sharing + * the same system, cpuset, mempolicy, or memory controller resources to use at + * least 50% more memory. A value of -500, on the other hand, would be roughly + * equivalent to discounting 50% of the task's allowed memory from being + * considered as scoring against the task. + * + * For backward compatibility with previous kernels, /proc/[pid]/oom_adj can + * still be used to tune the badness score. Its value is scaled linearly with + * oom_score_adj. + * + * Writing to /proc/[pid]/oom_score_adj or /proc/[pid]/oom_adj will change the + * other with its scaled value. + */ +struct CORE_POSIX_DLL_PUBLIC OomScoreAdj +{ + /** + * @brief Returns the minimum valid value. + * @return The minimum valid value that the Oom Score Adj can be set to. + */ + static int min_value(); + + /** + * @brief Returns the maximum valid value. + * @return The maximum valid value that the Oom Score Adj can be set to. + */ + static int max_value(); + + /** + * @brief is_valid checks whether the contained value is within the predefined bounds. + * @return true iff min_value() <= value <= max_value(). + */ + inline bool is_valid() const + { + return (min_value() <= value) && (value <= max_value()); + } + + /** + * @brief Current value. + */ + int value; +}; + +/** + * @brief Read the OomScoreAdj value for a process instance. + * @throw std::runtime_error in case of errors. + * @param [in] process The process to read the score for. + * @param [out] score_adj The destination to store the value in. + */ +CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomScoreAdj& score_adj); + +/** + * @brief Write the OomScoreAdj value for a process instance. + * @throw std::runtime_error in case of errors and std::logic_error if score_adj.is_valid() returns false. + * @param [in] process The process to write the score for. + * @param [in] score_adj The new value to store. + */ +CORE_POSIX_DLL_PUBLIC const posix::Process& operator<<(const posix::Process& process, + const OomScoreAdj& score_adj); +} +} +} +} +} +#endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_ADJ_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/stat.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/stat.h new file mode 100644 index 0000000..bfbe440 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/stat.h @@ -0,0 +1,120 @@ +/* + * Copyright © 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_ +#define CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_ + +#include + +#include + +#include + +namespace core +{ +namespace posix +{ +class Process; +namespace linux +{ +namespace proc +{ +namespace process +{ +/** + * @brief The Stat struct encapsulates status information about a process. + */ +struct CORE_POSIX_DLL_PUBLIC Stat +{ + pid_t pid = 1; ///< The process ID + std::string executable; ///< The filename of the executable, in parentheses. + State state = State::undefined; ///< State of the process. + pid_t parent = -1; ///< The PID of the parent. + pid_t process_group = -1; ///< The process group ID of the process. + int session_id = -1; ///< The session ID of the process. + int tty_nr = -1; ///< The controlling terminal of the process. + int controlling_process_group = -1; ///< The ID of the foreground process group of the controlling terminal of the process. + unsigned int kernel_flags = 0; ///< The kernel flags word of the process. + long unsigned int minor_faults_count = 0; ///< The number of minor faults the process has made which have not required loading a memory page from disk. + long unsigned int minor_faults_count_by_children = 0; ///< The number of minor faults that the process's waited-for children have made. + long unsigned int major_faults_count = 0; ///< The number of major faults the process has made which have required loading a memory page from disk. + long unsigned int major_faults_count_by_children = 0; ///< The number of major faults that the process's waited-for children have made. + struct + { + long unsigned int user = 0; ///< Amount of time that this process has been scheduled in user mode, [clock ticks]. + long unsigned int system = 0; ///< Amount of time that this process has been scheduled in kernel mode, [clock ticks]. + long unsigned int user_for_children = 0; ///< Amount of time that this process's waited-for children have been scheduled in user mode, [clock ticks]. + long unsigned int system_for_children = 0; ///< Amount of time that this process's waited-for children have been scheduled in kernel mode, [clock ticks]. + } time; + /** + * (Explanation for Linux 2.6) For processes running a real-time scheduling + * policy (policy below; see sched_setscheduler(2)), this is the negated + * scheduling priority, minus one; that is, a number in the range -2 to + * -100, corresponding to real-time priorities 1 to 99. For processes running + * under a non-real-time scheduling policy, this is the raw nice value + * (setpriority(2)) as represented in the kernel. The kernel stores nice + * values as numbers in the range 0 (high) to 39 (low), corresponding to + * the user-visible nice range of -20 to 19. + * + *Before Linux 2.6, this was a scaled value based on the scheduler + *weighting given to this process. + */ + long int priority = 0; + long int nice = 0; ///< The nice value (see setpriority(2)), a value in the range 19 (low priority) to -20 (high priority). + long int thread_count = 0; ///< Number of threads in this process (since Linux 2.6). + long int time_before_next_sig_alarm = 0; ///< The time in jiffies before the next SIGALRM is sent to the process due to an interval timer. Since kernel 2.6.17, this field is no longer maintained, and is hard coded as 0. + long int start_time = 0; ///< The time the process started after system boot. In kernels before Linux 2.6, this value was expressed in jiffies. Since Linux 2.6, the value is expressed in clock ticks (divide by sysconf(_SC_CLK_TCK)). + struct + { + long unsigned int virt = 0; ///< Virtual memory size in bytes. + long unsigned int resident_set = 0; ///< Resident Set Size: number of pages the process has in real memory. This is just the pages which count toward text, data, or stack space. This does not include pages which have not been demand-loaded in, or which are swapped out. + long unsigned int resident_set_limit = 0; ///< Current soft limit in bytes on the rss of the process; see the description of RLIMIT_RSS in getrlimit(2). + } size; + struct + { + long unsigned int start_code = 0; ///< The address above which program text can run. + long unsigned int end_code = 0; ///< The address below which program text can run. + long unsigned int start_stack = 0; ///< The address of the start (i.e., bottom) of the stack. + long unsigned int stack_pointer = 0; ///< The current value of ESP (stack pointer), as found in the kernel stack page for the process. + long unsigned int instruction_pointer = 0; ///< The current EIP (instruction pointer). + } addresses; + struct + { + long unsigned int pending = 0; ///< The bitmap of pending signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. + long unsigned int blocked = 0; ///< The bitmap of blocked signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. + long unsigned int ignored = 0; ///< The bitmap of ignored signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. + long unsigned int caught = 0; ///< The bitmap of caught signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead. + } signals; + long unsigned int channel = 0; ///< This is the "channel" in which the process is waiting. It is the address of a system call, and can be looked up in a namelist if you need a textual name. (If you have an up-to-date /etc/psdatabase, then try ps -l to see the WCHAN field in action.) + long unsigned int swap_count = 0; ///< Number of pages swapped (not maintained). + long unsigned int swap_count_children = 0; ///< Cumulative nswap for child processes (not maintained). + int exit_signal = -1; ///< Signal to be sent to parent when we die. + int cpu_count = -1; ///< CPU number last executed on. + unsigned int realtime_priority = 0; ///< Real-time scheduling priority, a number in the range 1 to 99 for processes scheduled under a real-time policy, or 0, for non-real-time processes (see sched_setscheduler(2)). + unsigned int scheduling_policy = 0; ///< Scheduling policy (see sched_setscheduler(2)). Decode using the SCHED_* constants in linux/sched.h. + long long unsigned int aggregated_block_io_delays = 0; ///< Aggregated block I/O delays, measured in clock ticks (centiseconds). + long unsigned int guest_time = 0; ///< Guest time of the process (time spent running a virtual CPU for a guest operating system), measured in clock ticks. + long unsigned int guest_time_children = 0; ///< Guest time of the process's children, measured in clock ticks. +}; + +CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, Stat& stat); +} +} +} +} +} +#endif // CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/state.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/state.h new file mode 100644 index 0000000..df9d74b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/linux/proc/process/state.h @@ -0,0 +1,51 @@ +/* + * Copyright © 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef CORE_POSIX_LINUX_PROC_PROCESS_STATE_H_ +#define CORE_POSIX_LINUX_PROC_PROCESS_STATE_H_ + +#include + +#include + +namespace core +{ +namespace posix +{ +namespace linux +{ +namespace proc +{ +namespace process +{ +enum class State +{ + undefined = -1, + running = 'R', + sleeping = 'S', + disk_sleep = 'D', + zombie = 'Z', + traced_or_stopped = 'T', + paging = 'W' +}; +} +} +} +} +} + +#endif // CORE_POSIX_LINUX_PROC_PROCESS_STATE_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process.h new file mode 100644 index 0000000..48f7be2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process.h @@ -0,0 +1,93 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_PROCESS_H_ +#define CORE_POSIX_PROCESS_H_ + +#include +#include +#include +#include +#include + +#include +#include + +namespace core +{ +namespace posix +{ +enum class Signal; +class Self; +class WaitFlags; + +/** + * @brief The Process class models a process and possible operations on it. + * + * The process class is implicitly shared. + */ +class CORE_POSIX_DLL_PUBLIC Process : public Signalable +{ +public: + /** + * @brief Creates a process instance wrapping an existing process. + * @throw Throw std::system_error if pid is invalid, i.e., pid < 0. + * @param pid The process identifier of the existing process. + */ + explicit Process(pid_t pid); + + /** + * @brief Returns an invalid instance for testing purposes. + * @return An invalid instance. + */ + static Process invalid(); + + /** + * @brief Frees resources associated with the process. + */ + virtual ~Process() noexcept; + + /** + * @brief Query the pid of the process. + * @return The pid of the process. + */ + virtual pid_t pid() const; + + /** + * @brief Queries the id of the process group this process belongs to. + * @throw std::system_error in case of errors. + * @return The id of the process group this process belongs to. + */ + virtual ProcessGroup process_group_or_throw() const; + + /** + * @brief Queries the id of the process group this process belongs to. + * + * @return A tuple with the first element being the id of the process group + * this process belongs to and the second element a boolean flag indicating + * an error if true. + */ + virtual ProcessGroup process_group(std::error_code& se) const noexcept(true); + +private: + struct CORE_POSIX_DLL_LOCAL Private; + std::shared_ptr d; +}; +} +} +#endif // CORE_POSIX_PROCESS_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process_group.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process_group.h new file mode 100644 index 0000000..0c972b4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/process_group.h @@ -0,0 +1,65 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_PROCESS_GROUP_H_ +#define CORE_POSIX_PROCESS_GROUP_H_ + +#include +#include + +#include + +namespace core +{ +namespace posix +{ +class Process; + +/** + * @brief The ProcessGroup class models a signalable group of process. + * + * Summary from http://en.wikipedia.org/wiki/Process_group: + * + * In POSIX-conformant operating systems, a process group denotes a collection + * of one or more processes. Process groups are used to control the distribution + * of signals. A signal directed to a process group is delivered individually to + * all of the processes that are members of the group. + */ +class CORE_POSIX_DLL_PUBLIC ProcessGroup : public Signalable +{ +public: + /** + * @brief Accesses the id of this process group. + * @return The id of this process group. + */ + virtual pid_t id() const; + + static ProcessGroup invalid(); + +protected: + friend class Process; + CORE_POSIX_DLL_LOCAL ProcessGroup(pid_t id); + +private: + struct CORE_POSIX_DLL_LOCAL Private; + std::shared_ptr d; +}; +} +} + +#endif // CORE_POSIX_PROCESS_GROUP_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signal.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signal.h new file mode 100644 index 0000000..d11724a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signal.h @@ -0,0 +1,117 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_SIGNAL_H_ +#define CORE_POSIX_SIGNAL_H_ + +#include + +#include + +#include + +#include +#include + +namespace core +{ +namespace posix +{ +/** + * @brief The Signal enum collects the most common POSIX signals. + */ +enum class Signal +{ + unknown = 0, + sig_hup = SIGHUP, + sig_int = SIGINT, + sig_quit = SIGQUIT, + sig_ill = SIGILL, + sig_abrt = SIGABRT, + sig_fpe = SIGFPE, + sig_kill = SIGKILL, + sig_segv = SIGSEGV, + sig_pipe = SIGPIPE, + sig_alrm = SIGALRM, + sig_term = SIGTERM, + sig_usr1 = SIGUSR1, + sig_usr2 = SIGUSR2, + sig_chld = SIGCHLD, + sig_cont = SIGCONT, + sig_stop = SIGSTOP, + sig_tstp = SIGTSTP, + sig_ttin = SIGTTIN, + sig_ttou = SIGTTOU +}; + +/** + * @brief The SignalTrap class encapsulates functionality to trap and handle signals. + */ +class CORE_POSIX_DLL_PUBLIC SignalTrap +{ +public: + SignalTrap(const SignalTrap&) = delete; + virtual ~SignalTrap() = default; + + SignalTrap& operator=(const SignalTrap&) = delete; + bool operator==(const SignalTrap&) const = delete; + + /** + * @brief Returns true if the given signal is trapped by this instance. + */ + virtual bool has(Signal signal) = 0; + + /** + * @brief Starts observation of incoming signals, relaying them via + * signal_raised(). The call blocks until stop is called. + */ + virtual void run() = 0; + + /** + * @brief Stops execution of the signal trap. + */ + virtual void stop() = 0; + + /** + * @brief Emitted whenever a trapped signal is raised by the operating system. + */ + virtual core::Signal& signal_raised() = 0; + +protected: + SignalTrap() = default; +}; + +/** + * @brief Traps the specified signals for the entire process. + */ +CORE_POSIX_DLL_PUBLIC +std::shared_ptr trap_signals_for_process( + std::initializer_list blocked_signals); + +/** + * @brief Traps the specified signals for the current thread, and inherits + * the respective signal mask to all child-threads. + */ +CORE_POSIX_DLL_PUBLIC +std::shared_ptr trap_signals_for_all_subsequent_threads( + std::initializer_list blocked_signals); + +} +} + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signalable.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signalable.h new file mode 100644 index 0000000..be28f61 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/signalable.h @@ -0,0 +1,64 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_SIGNALABLE_H_ +#define CORE_POSIX_SIGNALABLE_H_ + +#include +#include + +#include +#include + +namespace core +{ +namespace posix +{ +/** + * @brief The Signalable class abstracts the ability of an entity to be delivered a posix signal. + */ +class CORE_POSIX_DLL_PUBLIC Signalable +{ +public: + virtual ~Signalable() { } + + /** + * @brief Sends a signal to this signalable object. + * @throws std::system_error in case of problems. + * @param [in] signal The signal to be sent to the process. + */ + virtual void send_signal_or_throw(Signal signal); + + /** + * @brief Sends a signal to this signalable object. + * @param [in] signal The signal to be sent to the process. + * @param [out] e Set to contain an error if an issue arises. + */ + virtual void send_signal(Signal signal, std::error_code& e) noexcept(true); + +protected: + CORE_POSIX_DLL_LOCAL explicit Signalable(pid_t pid); + +private: + struct CORE_POSIX_DLL_LOCAL Private; + std::shared_ptr d; +}; +} +} + +#endif // CORE_POSIX_SIGNALABLE_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/standard_stream.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/standard_stream.h new file mode 100644 index 0000000..f50a9b7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/standard_stream.h @@ -0,0 +1,46 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_STANDARD_STREAM_H_ +#define CORE_POSIX_STANDARD_STREAM_H_ + +#include + +#include + +namespace core +{ +namespace posix +{ +/** + * @brief The StandardStream enum wraps the POSIX standard streams. + */ +enum class StandardStream : std::uint8_t +{ + empty = 0, + stdin = 1 << 0, + stdout = 1 << 1, + stderr = 1 << 2 +}; + +CORE_POSIX_DLL_PUBLIC StandardStream operator|(StandardStream l, StandardStream r); +CORE_POSIX_DLL_PUBLIC StandardStream operator&(StandardStream l, StandardStream r); +} +} + +#endif // CORE_POSIX_STANDARD_STREAM_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/this_process.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/this_process.h new file mode 100644 index 0000000..584a94e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/this_process.h @@ -0,0 +1,128 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_THIS_PROCESS_H_ +#define CORE_POSIX_THIS_PROCESS_H_ + +#include + +#include +#include +#include +#include + +namespace core +{ +namespace posix +{ +class Process; +namespace this_process +{ +namespace env +{ +/** + * @brief for_each invokes a functor for every key-value pair in the environment. + * @param [in] functor Invoked for every key-value pair. + */ +CORE_POSIX_DLL_PUBLIC void for_each( + const std::function& functor) noexcept(true); + +/** + * @brief get queries the value of an environment variable. + * @throw std::runtime_error if there is no variable with the given key defined in the env. + * @param [in] key Name of the variable to query the value for. + * @return Contents of the variable. + */ +CORE_POSIX_DLL_PUBLIC std::string get_or_throw(const std::string& key); + +/** + * @brief get queries the value of an environment variable. + * @param [in] key Name of the variable to query the value for. + * @param [in] default_value Default value to return when key is not present in the environment. + * @return Contents of the variable or an empty string if the variable is not defined. + */ +CORE_POSIX_DLL_PUBLIC std::string get( + const std::string& key, + const std::string& default_value = std::string()) noexcept(true); + +/** + * @brief unset_or_throw removes the variable with name key from the environment. + * @throw std::system_error in case of errors. + * @param [in] key Name of the variable to unset. + */ +CORE_POSIX_DLL_PUBLIC void unset_or_throw(const std::string& key); + +/** + * @brief unset removes the variable with name key from the environment. + * @return false in case of errors, true otherwise. + * @param [in] key Name of the variable to unset. + * @param [out] se Receives error details if unset returns false. + */ +CORE_POSIX_DLL_PUBLIC bool unset(const std::string& key, + std::error_code& se) noexcept(true); + +/** + * @brief set_or_throw will adjust the contents of the variable identified by key to the provided value. + * @throw std::system_error in case of errors. + * @param [in] key Name of the variable to set the value for. + * @param [in] value New contents of the variable. + */ +CORE_POSIX_DLL_PUBLIC void set_or_throw(const std::string& key, + const std::string& value); +/** + * @brief set will adjust the contents of the variable identified by key to the provided value. + * @return false in case of errors, true otherwise. + * @param [in] key Name of the variable to set the value for. + * @param [in] value New contents of the variable. + * @param [out] se Receives the details in case of errors. + */ +CORE_POSIX_DLL_PUBLIC bool set(const std::string &key, + const std::string &value, + std::error_code& se) noexcept(true); +} + +/** + * @brief Returns a Process instance corresponding to this process. + */ +CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true); + +/** + * @brief Query the parent of the process. + * @return The parent of the process. + */ +CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true); + +/** + * @brief Access this process's stdin. + */ +CORE_POSIX_DLL_PUBLIC std::istream& cin() noexcept(true); + +/** + * @brief Access this process's stdout. + */ +CORE_POSIX_DLL_PUBLIC std::ostream& cout() noexcept(true); + +/** + * @brief Access this process's stderr. + */ +CORE_POSIX_DLL_PUBLIC std::ostream& cerr() noexcept(true); +} +} +} + +#endif // CORE_POSIX_THIS_PROCESS_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/visibility.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/visibility.h new file mode 100644 index 0000000..e99d849 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/visibility.h @@ -0,0 +1,30 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_VISIBILITY_H_ +#define CORE_POSIX_VISIBILITY_H_ + +#if __GNUC__ >= 4 +#define CORE_POSIX_DLL_PUBLIC __attribute__ ((visibility ("default"))) +#define CORE_POSIX_DLL_LOCAL __attribute__ ((visibility ("hidden"))) +#else +#define CORE_POSIX_DLL_PUBLIC +#define CORE_POSIX_DLL_LOCAL +#endif + +#endif // CORE_POSIX_VISIBILITY_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/wait.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/wait.h new file mode 100644 index 0000000..2b47cd6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/posix/wait.h @@ -0,0 +1,104 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_WAIT_H_ +#define CORE_POSIX_WAIT_H_ + +#include +#include +#include + +#include + +#include + +#include + +namespace core +{ +namespace posix +{ +namespace wait +{ + +/** + * @brief Flags enumerates different behavior when waiting for a child process to change state. + */ +enum class Flags : std::uint8_t +{ + continued = WCONTINUED, ///< Also wait for a child to continue after having been stopped. + untraced = WUNTRACED, ///< Also wait for state changes in untraced children. + no_hang = WNOHANG ///< Do not block if a child process hasn't changed state. +}; + +CORE_POSIX_DLL_PUBLIC Flags operator|(Flags l, Flags r); + +/** + * @brief The Result struct encapsulates the result of waiting for a process state change. + */ +struct CORE_POSIX_DLL_PUBLIC Result +{ + /** + * @brief The status of the process/wait operation. + */ + enum class Status + { + undefined, ///< Marks an undefined state. + no_state_change, ///< No state change occured. + exited, ///< The process exited normally. + signaled, ///< The process was signalled and terminated. + stopped, ///< The process was signalled and stopped. + continued ///< The process resumed operation. + } status = Status::undefined; + + /** + * @brief Union of result-specific details. + */ + union + { + /** + * Contains the exit status of the process if status == Status::exited. + */ + struct + { + exit::Status status; ///< Exit status of the process. + } if_exited; + + /** + * Contains the signal that caused the process to terminate if status == Status::signaled. + */ + struct + { + Signal signal; ///< Signal that caused the process to terminate. + bool core_dumped; ///< true if the process termination resulted in a core dump. + } if_signaled; + + /** + * Contains the signal that caused the process to terminate if status == Status::stopped. + */ + struct + { + Signal signal; ///< Signal that caused the process to terminate. + } if_stopped; + } detail; +}; +} +} +} + +#endif // CORE_POSIX_WAIT_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/signal.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/signal.h new file mode 100644 index 0000000..690d236 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/signal.h @@ -0,0 +1,297 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef COM_UBUNTU_SIGNAL_H_ +#define COM_UBUNTU_SIGNAL_H_ + +#include + +#include +#include +#include +#include +#include + +namespace core +{ +/** + * @brief A signal class that observers can subscribe to. + * @tparam Arguments List of argument types passed on to observers when the signal is emitted. + */ +template +class Signal +{ +public: + /** + * @brief Slot is the function type that observers have to provide to connect to this signal. + */ + typedef std::function Slot; + +private: + struct SlotWrapper + { + void operator()(Arguments... args) + { + dispatcher(std::bind(slot, args...)); + } + + Slot slot; + Connection::Dispatcher dispatcher; + Connection connection; + }; + +public: + /** + * @brief Signal constructs a new instance. Never throws. + */ + inline Signal() noexcept(true) : d(new Private()) + { + } + + inline ~Signal() + { + std::lock_guard lg(d->guard); + for (auto slot : d->slot_list) + slot.connection.reset(); + } + + // Copy construction, assignment and equality comparison are disabled. + Signal(const Signal&) = delete; + Signal& operator=(const Signal&) = delete; + bool operator==(const Signal&) const = delete; + + /** + * @brief Connects the provided slot to this signal instance. + * + * Calling this method is thread-safe and synchronized with any + * other connect, signal emission or disconnect calls. + * + * @param slot The function to be called when the signal is emitted. + * @return A connection object corresponding to the signal-slot connection. + */ + inline Connection connect(const Slot& slot) const + { + // Helpers to initialize an invalid connection. + static const Connection::Disconnector empty_disconnector{}; + static const Connection::DispatcherInstaller empty_dispatcher_installer{}; + + // The default dispatcher immediately executes the function object + // provided as argument on whatever thread is currently running. + static const Connection::Dispatcher default_dispatcher + = [](const std::function& handler) { handler(); }; + + Connection conn{empty_disconnector, empty_dispatcher_installer}; + + std::lock_guard lg(d->guard); + + auto result = d->slot_list.insert( + d->slot_list.end(), + SlotWrapper{slot, default_dispatcher, conn}); + + // We implicitly share our internal state with the connection here + // by passing in our private bits contained in 'd' to the std::bind call. + // This admittedly uncommon approach allows us to cleanly manage connection + // and signal lifetimes without the need to mark everything as mutable. + conn.d->disconnector = std::bind( + &Private::disconnect_slot_for_iterator, + d, + result); + conn.d->dispatcher_installer = std::bind( + &Private::install_dispatcher_for_iterator, + d, + std::placeholders::_1, + result); + + return conn; + } + + /** + * @brief operator () emits the signal with the provided parameters. + * + * Please note that signal emissions might not be delivered immediately to + * registered slots, depending on whether the respective connection is dispatched + * via a queueing dispatcher. For that reason, the lifetime of the arguments has to + * exceed the scope of the call to this operator and its surrounding scope. + * + * @param args The arguments to be passed on to registered slots. + */ + inline void operator()(Arguments... args) + { + std::lock_guard lg(d->guard); + for(auto slot : d->slot_list) + { + slot(args...); + } + } + +private: + struct Private + { + typedef std::list SlotList; + + inline void disconnect_slot_for_iterator(typename SlotList::iterator it) + { + std::lock_guard lg(guard); + slot_list.erase(it); + } + + inline void install_dispatcher_for_iterator(const Connection::Dispatcher& dispatcher, + typename SlotList::iterator it) + { + std::lock_guard lg(guard); + it->dispatcher = dispatcher; + } + + std::mutex guard; + SlotList slot_list; + }; + std::shared_ptr d; +}; + +/** + * @brief A signal class that observers can subscribe to, + * template specialization for signals without arguments. + */ +template<> +class Signal +{ +public: + /** + * @brief Slot is the function type that observers have to provide to connect to this signal. + */ + typedef std::function Slot; + +private: + struct SlotWrapper + { + void operator()() + { + dispatcher(slot); + } + + Slot slot; + Connection::Dispatcher dispatcher; + Connection connection; + }; + +public: + /** + * @brief Signal constructs a new instance. Never throws. + */ + inline Signal() noexcept(true) : d(new Private()) + { + } + + inline ~Signal() + { + std::lock_guard lg(d->guard); + for (auto slot : d->slot_list) + slot.connection.reset(); + } + + // Copy construction, assignment and equality comparison are disabled. + Signal(const Signal&) = delete; + Signal& operator=(const Signal&) = delete; + bool operator==(const Signal&) const = delete; + + /** + * @brief Connects the provided slot to this signal instance. + * + * Calling this method is thread-safe and synchronized with any + * other connect, signal emission or disconnect calls. + * + * @param slot The function to be called when the signal is emitted. + * @return A connection object corresponding to the signal-slot connection. + */ + inline Connection connect(const Slot& slot) const + { + // Helpers to initialize an invalid connection. + static const Connection::Disconnector empty_disconnector{}; + static const Connection::DispatcherInstaller empty_dispatcher_installer{}; + + // The default dispatcher immediately executes the function object + // provided as argument on whatever thread is currently running. + static const Connection::Dispatcher default_dispatcher + = [](const std::function& handler) { handler(); }; + + Connection conn{empty_disconnector, empty_dispatcher_installer}; + + std::lock_guard lg(d->guard); + + auto result = d->slot_list.insert( + d->slot_list.end(), + SlotWrapper{slot, default_dispatcher, conn}); + + // We implicitly share our internal state with the connection here + // by passing in our private bits contained in 'd' to the std::bind call. + // This admittedly uncommon approach allows us to cleanly manage connection + // and signal lifetimes without the need to mark everything as mutable. + conn.d->disconnector = std::bind( + &Private::disconnect_slot_for_iterator, + d, + result); + conn.d->dispatcher_installer = std::bind( + &Private::install_dispatcher_for_iterator, + d, + std::placeholders::_1, + result); + + return conn; + } + + /** + * @brief operator () emits the signal. + * + * Please note that signal emissions might not be delivered immediately to + * registered slots, depending on whether the respective connection is dispatched + * via a queueing dispatcher. + */ + inline void operator()() + { + std::lock_guard lg(d->guard); + for(auto slot : d->slot_list) + { + slot(); + } + } + +private: + struct Private + { + typedef std::list SlotList; + + inline void disconnect_slot_for_iterator(typename SlotList::iterator it) + { + std::lock_guard lg(guard); + slot_list.erase(it); + } + + inline void install_dispatcher_for_iterator(const Connection::Dispatcher& dispatcher, + typename SlotList::iterator it) + { + std::lock_guard lg(guard); + it->dispatcher = dispatcher; + } + + std::mutex guard; + SlotList slot_list; + }; + std::shared_ptr d; +}; +} + +#endif // COM_UBUNTU_SIGNAL_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/cross_process_sync.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/cross_process_sync.h new file mode 100644 index 0000000..18d7132 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/cross_process_sync.h @@ -0,0 +1,99 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voss + */ + +#ifndef CORE_TESTING_CROSS_PROCESS_SYNC_H_ +#define CORE_TESTING_CROSS_PROCESS_SYNC_H_ + +#include + +#include + +#include +#include + +namespace core +{ +namespace testing +{ +/** + * @brief A cross-process synchronization primitive that supports simple wait-condition-like scenarios. + */ +class CORE_POSIX_DLL_PUBLIC CrossProcessSync +{ + public: + struct Error + { + Error() = delete; + ~Error() = delete; + + /** + * @brief Thrown if any of the *_for functions times out. + */ + struct Timeout : public std::runtime_error + { + Timeout() : std::runtime_error("Timeout while waiting for event to happen.") + { + } + }; + }; + + /** + * @brief Constructs a new sync element. + */ + CrossProcessSync(); + + /** + * @brief Copy c'tor, duping the underlying fds. + * @param rhs The instance to copy. + */ + CrossProcessSync(const CrossProcessSync& rhs); + + /** + * @brief Closes the underlying fds. + */ + ~CrossProcessSync() noexcept; + + /** + * @brief operator =, dup's the underlying fds. + * @param rhs The instance to assign from. + * @return A mutable reference to this instance. + */ + CrossProcessSync& operator=(const CrossProcessSync& rhs); + + /** + * @brief Try to signal the other side that we are ready for at most duration milliseconds. + * @throw Error::Timeout in case of a timeout. + * @throw std::system_error for problems with the underlying pipe. + */ + void try_signal_ready_for(const std::chrono::milliseconds& duration); + + /** + * @brief Wait for the other sides to signal readiness for at most duration milliseconds. + * @return The number of ready signals that have been collected since creation. + * @throw Error::Timeout in case of a timeout. + * @throw std::system_error for problems with the underlying pipe. + */ + std::uint32_t wait_for_signal_ready_for(const std::chrono::milliseconds& duration); + + private: + int fds[2]; ///< The cross-process pipe. + std::uint32_t counter; ///< Counts the number of times the sync has been signalled. +}; +} +} +#endif // CORE_TESTING_CROSS_PROCESS_SYNC_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/fork_and_run.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/fork_and_run.h new file mode 100644 index 0000000..7bd5dec --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/include/core/testing/fork_and_run.h @@ -0,0 +1,115 @@ +/* + * Copyright © 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ +#ifndef CORE_TESTING_FORK_AND_RUN_H_ +#define CORE_TESTING_FORK_AND_RUN_H_ + +#include +#include +#include + +#include + +namespace core +{ +namespace testing +{ +/** + * @brief The ForkAndRunResult enum models the different failure modes of fork_and_run. + */ +enum class ForkAndRunResult +{ + empty = 0, ///< Special value indicating no bit being set. + client_failed = 1 << 0, ///< The client failed. + service_failed = 1 << 1 ///< The service failed. +}; + +CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator|(ForkAndRunResult lhs, ForkAndRunResult rhs); +CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator&(ForkAndRunResult lhs, ForkAndRunResult rhs); + +/** + * @brief Forks two processes for both the service and the client. + * + * The function does the following: + * - Forks a process for the service and runs the respective closure. + * - Forks a process for the client and runs the respective closure. + * - After the client has finished, the service is signalled with sigterm. + * + * @throw std::system_error if an error occured during process interaction. + * @throw std::runtime_error for signalling all other error conditions. + * @param [in] service The service to be executed in a child process. + * @param [in] client The client to be executed in a child process. + * @return ForkAndRunResult indicating if either of service or client failed. + */ +CORE_POSIX_DLL_PUBLIC ForkAndRunResult fork_and_run( + const std::function& service, + const std::function& client); +} +} + +/** + * Test definition macro which runs a TEST in a forked process. + * Note that you can only use EXPECT_*, not + * ASSERT_*! + * + * Usage: + * TESTP(test_suite, test_name, { + * test code ... + * EXPECT_* ... + * }) + */ +#define TESTP(test_suite, test_name, CODE) \ + TEST(test_suite, test_name) { \ + auto test = [&]() { \ + CODE \ + return HasFailure() ? core::posix::exit::Status::failure \ + : core::posix::exit::Status::success; \ + }; \ + auto child = core::posix::fork( \ + test, \ + core::posix::StandardStream::empty); \ + auto result = child.wait_for(core::posix::wait::Flags::untraced); \ + EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status); \ + EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status); \ + } \ + +/** + * Test definition macro which runs a TEST_F in a forked process. + * Note that you can only use EXPECT_*, not ASSERT_*! + * + * Usage: + * TESTP_F(FixtureName, TestName, { + * ... test code ... + * EXPECT_* ... + * }) + */ +#define TESTP_F(test_fixture, test_name, CODE) \ + TEST_F(test_fixture, test_name) { \ + auto test = [&]() { \ + CODE \ + return HasFailure() ? core::posix::exit::Status::failure \ + : core::posix::exit::Status::success; \ + }; \ + auto child = core::posix::fork( \ + test, \ + core::posix::StandardStream::empty); \ + auto result = child.wait_for(core::posix::wait::Flags::untraced); \ + EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status); \ + EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status); \ + } \ + +#endif // CORE_TESTING_FORK_AND_RUN_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/CMakeLists.txt new file mode 100644 index 0000000..dec4659 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/CMakeLists.txt @@ -0,0 +1,49 @@ +# Copyright © 2013 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Authored by: Thomas Voss +add_library( + process-cpp + + STATIC + + core/posix/backtrace.h + core/posix/backtrace.cpp + + core/posix/child_process.cpp + core/posix/exec.cpp + core/posix/fork.cpp + core/posix/process.cpp + core/posix/process_group.cpp + core/posix/signal.cpp + core/posix/signalable.cpp + core/posix/standard_stream.cpp + core/posix/wait.cpp + core/posix/this_process.cpp + + core/posix/linux/proc/process/oom_adj.cpp + core/posix/linux/proc/process/oom_score.cpp + core/posix/linux/proc/process/oom_score_adj.cpp + core/posix/linux/proc/process/stat.cpp + + core/testing/cross_process_sync.cpp + core/testing/fork_and_run.cpp +) + +target_link_libraries( + process-cpp + + ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} +) diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/CMakeLists.txt new file mode 100644 index 0000000..fbbaa81 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright © 2013 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Authored by: Thomas Voss + +add_library( + posix-process + + process.cpp +) + +add_subdirectory(linux) + \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.cpp new file mode 100644 index 0000000..7a02bbd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.cpp @@ -0,0 +1,153 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include "backtrace.h" + +#include + +#include + +namespace bt = core::posix::backtrace; + +namespace impl +{ +std::tuple demangle(const std::string& symbol) +{ + int status = 1; + auto result = abi::__cxa_demangle(symbol.c_str(), + nullptr, + nullptr, + &status); + + if (!result || status != 0) + { + return std::make_tuple(std::string(), false); + } + + std::string s{result}; + ::free(result); + + return std::make_tuple(s, true); +} + +struct Frame : public bt::Frame +{ + struct Symbol : public bt::Frame::Symbol + { + Symbol(const char* symbol) : raw_(symbol) + { + auto first = raw_.find_first_of("("); + auto last = raw_.find_last_of(")"); + + if (first != std::string::npos && last != std::string::npos) + { + auto mangled_symbol = raw_.substr(first+1, + (last-1) - (first+1)); + + auto plus = mangled_symbol.find_first_of("+"); + if (plus != std::string::npos) + mangled_symbol.erase(plus); + + std::tie(demangled_, is_cxx_) = demangle(mangled_symbol); + if (!is_cxx_) + demangled_ = raw_; + } + } + + bool is_cxx() const + { + return is_cxx_; + } + + std::string demangled() const + { + return demangled_; + } + + std::string raw() const + { + return raw_; + } + + std::string raw_; + std::string demangled_; + bool is_cxx_ = false; + }; + + std::size_t depth_; + void* frame_pointer_; + Symbol symbol_; + + Frame(std::size_t depth, void* frame_pointer, const char* symbol) + : depth_(depth), + frame_pointer_(frame_pointer), + symbol_(symbol) + { + } + + std::size_t depth() const + { + return depth_; + } + + virtual void* frame_pointer() const + { + return frame_pointer_; + } + + const Symbol& symbol() const + { + return symbol_; + } +}; +} + +std::shared_ptr bt::Frame::Symbol::for_testing_from_raw_symbol(const char* symbol) +{ + return std::shared_ptr(new impl::Frame::Symbol(symbol)); +} + +void bt::visit_with_handler(const bt::FrameHandler& handler) +{ + static const unsigned int max_frames=64; + void *frames[max_frames]; + + auto frame_count = ::backtrace(frames, max_frames); + auto symbols = ::backtrace_symbols(frames, frame_count); + + struct Scope + { + Scope(char** symbols) : symbols(symbols) + { + } + + ~Scope() + { + ::free(symbols); + } + + char** symbols = nullptr; + } scope{symbols}; + + for (int i = 0; i < frame_count; i++) + { + impl::Frame frame(i, frames[i], symbols[i]); + if (!handler(frame)) + return; + } +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.h b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.h new file mode 100644 index 0000000..7a77ddd --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/backtrace.h @@ -0,0 +1,122 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef CORE_POSIX_BACKTRACE_H_ +#define CORE_POSIX_BACKTRACE_H_ + +#include + +#include +#include +#include + +namespace core +{ +namespace posix +{ +namespace backtrace +{ +/** + * @brief The Frame class models an individual frame of a backtrace. + */ +class Frame +{ +public: + /** + * @brief The Symbol class models the symbolic representation of a frame pointer. + */ + class Symbol + { + public: + + static std::shared_ptr for_testing_from_raw_symbol(const char* symbol); + + Symbol(const Symbol&) = delete; + virtual ~Symbol() = default; + + Symbol& operator=(const Symbol&) = delete; + + /** + * @brief is_cxx checks whether the symbol refers to a mangled C++ symbol. + * @return true iff the symbol refers to a mangled C++ symbol. + */ + virtual bool is_cxx() const = 0; + + /** + * @brief demangled returns the demangled C++ symbol name or raw. + */ + virtual std::string demangled() const = 0; + + /** + * @brief raw The raw symbolic representation of a frame pointer. + * @return + */ + virtual std::string raw() const = 0; + + protected: + Symbol() = default; + }; + + Frame(const Frame&) = delete; + virtual ~Frame() = default; + + Frame& operator=(const Frame&) = delete; + + /** + * @brief depth returns the depth of this frame in the overall backtrace. + */ + virtual std::size_t depth() const = 0; + + /** + * @brief frame_pointer returns the the raw frame pointer of this frame. + * @return + */ + virtual void* frame_pointer() const = 0; + + /** + * @brief symbol returns the symbolic representation of this frame. + */ + virtual const Symbol& symbol() const = 0; + +protected: + Frame() = default; +}; + +/** + * @brief FrameHandler is the functor invoked for every frame of a backtrace. + * + * A FrameHandler should return true if it wants to continue walking the stack + * or false otherwise. + */ +typedef std::function FrameHandler; + +/** + *@brief visit_with_handler iterates the backtrace of the calling program, + *invoking the handler for every frame. + * + * A FrameHandler should return true if it wants to continue walking the stack + * or false otherwise + * + * @param handler The handler invoked for every frame. + */ +void CORE_POSIX_DLL_PUBLIC visit_with_handler(const FrameHandler& handler); +} +} +} + +#endif // CORE_POSIX_BACKTRACE_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/child_process.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/child_process.cpp new file mode 100644 index 0000000..ad16571 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/child_process.cpp @@ -0,0 +1,422 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#ifndef ANDROID +#include +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +#ifndef ANDROID +namespace io = boost::iostreams; +#endif + +namespace +{ + +struct DeathObserverImpl : public core::posix::ChildProcess::DeathObserver +{ + DeathObserverImpl(const std::shared_ptr& trap) + : on_sig_child_connection + { + trap->signal_raised().connect([this](core::posix::Signal signal) + { + switch (signal) + { + case core::posix::Signal::sig_chld: + on_sig_child(); + break; + default: + break; + } + }) + } + { + if (!trap->has(core::posix::Signal::sig_chld)) + throw std::logic_error( + "DeathObserver::DeathObserverImpl: Given SignalTrap" + " instance does not trap Signal::sig_chld."); + } + + bool add(const core::posix::ChildProcess& process) override + { + if (process.pid() == -1) + return false; + + std::lock_guard lg(guard); + + bool added = false; + auto new_process = std::make_pair(process.pid(), process); + std::tie(std::ignore, added) = children.insert(new_process); + + if (added) + { + // The process may have died between it's instantiation and it + // being added to the children map. Check that it's still alive. + int status{-1}; + if (::waitpid(process.pid(), &status, WNOHANG) != 0) // child no longer alive + { + // we missed the SIGCHLD signal so we must now manually + // inform our subscribers. + signals.child_died(new_process.second); + children.erase(new_process.first); + return false; + } + } + + return added; + } + + bool has(const core::posix::ChildProcess& process) const override + { + std::lock_guard lg(guard); + return children.count(process.pid()) > 0; + } + + const core::Signal& child_died() const override + { + return signals.child_died; + } + + void on_sig_child() override + { + pid_t pid{-1}; int status{-1}; + while (true) + { + pid = ::waitpid(0, &status, WNOHANG); + + if (pid == -1) + { + if (errno == ECHILD) + { + break; // No more children + } + continue; // Ignore stray SIGCHLD signals + } + else if (pid == 0) + { + break; // No more children + } + else + { + std::lock_guard lg(guard); + auto it = children.find(pid); + + if (it != children.end()) + { + if (WIFSIGNALED(status) || WIFEXITED(status)) + { + signals.child_died(it->second); + children.erase(it); + } + } + } + } + } + + mutable std::mutex guard; + std::unordered_map children; + core::ScopedConnection on_sig_child_connection; + struct + { + core::Signal child_died; + } signals; +}; +} + +std::unique_ptr +core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap( + std::shared_ptr trap) +{ + static std::atomic has_been_created_once{false}; + + if (has_been_created_once.exchange(true)) + throw std::runtime_error + { + "DeathObserver::create_once_with_signal_trap: " + "Cannot create more than one instance." + }; + + try + { + std::unique_ptr result + { + new DeathObserverImpl{trap} + }; + + return result; + } catch(...) + { + // We make sure that a throwing c'tor does not impact our ability to + // retry creation of a DeathObserver instance. + has_been_created_once.store(false); + + std::rethrow_exception(std::current_exception()); + } + + assert(false && "We should never reach here."); + + // Silence the compiler. + return std::unique_ptr{}; +} + +namespace core +{ +namespace posix +{ +ChildProcess::Pipe ChildProcess::Pipe::invalid() +{ + static Pipe p; + static std::once_flag flag; + + std::call_once(flag, [&]() { p.close_read_fd(); p.close_write_fd(); }); + + return p; +} + +ChildProcess::Pipe::Pipe() +{ + int rc = ::pipe(fds); + + if (rc == -1) + throw std::system_error(errno, std::system_category()); +} + +ChildProcess::Pipe::Pipe(const ChildProcess::Pipe& rhs) : fds{-1, -1} +{ + if (rhs.fds[0] != -1) + fds[0] = ::dup(rhs.fds[0]); + + if (rhs.fds[1] != -1) + fds[1] = ::dup(rhs.fds[1]); +} + +ChildProcess::Pipe::~Pipe() +{ + if (fds[0] != -1) + ::close(fds[0]); + if (fds[1] != -1) + ::close(fds[1]); +} + +int ChildProcess::Pipe::read_fd() const +{ + return fds[0]; +} + +void ChildProcess::Pipe::close_read_fd() +{ + if (fds[0] != -1) + { + ::close(fds[0]); + fds[0] = -1; + } +} + +int ChildProcess::Pipe::write_fd() const +{ + return fds[1]; +} + +void ChildProcess::Pipe::close_write_fd() +{ + if (fds[1] != -1) + { + ::close(fds[1]); + fds[1] = -1; + } +} + +ChildProcess::Pipe& ChildProcess::Pipe::operator=(const ChildProcess::Pipe& rhs) +{ + if (fds[0] != -1) + ::close(fds[0]); + if (fds[1] != -1) + ::close(fds[1]); + + if (rhs.fds[0] != -1) + fds[0] = ::dup(rhs.fds[0]); + else + fds[0] = -1; + if (rhs.fds[1] != -1) + fds[1] = ::dup(rhs.fds[1]); + else + fds[1] = -1; + + return *this; +} + +struct ChildProcess::Private +{ + // stdin and stdout are always "relative" to the childprocess, i.e., we + // write to stdin of the child process and read from its stdout. + Private(pid_t pid, + const ChildProcess::Pipe& stderr, + const ChildProcess::Pipe& stdin, + const ChildProcess::Pipe& stdout) + : pipes{stderr, stdin, stdout}, +#ifndef ANDROID + serr(pipes.stderr.read_fd(), io::never_close_handle), + sin(pipes.stdin.write_fd(), io::never_close_handle), + sout(pipes.stdout.read_fd(), io::never_close_handle), + cerr(&serr), + cin(&sin), + cout(&sout), +#endif + original_parent_pid(::getpid()), + original_child_pid(pid) + { + } + + ~Private() + { + // Check if we are in the original parent process. + if (original_parent_pid == getpid() && !dont_kill_on_cleanup) + { + // If so, check if we are considering a valid pid here. + // If so, we kill the original child. + if (original_child_pid != -1) + ::kill(original_child_pid, SIGKILL); + } + } + + struct + { + ChildProcess::Pipe stdin; + ChildProcess::Pipe stdout; + ChildProcess::Pipe stderr; + } pipes; + +#ifndef ANDROID + io::stream_buffer serr; + io::stream_buffer sin; + io::stream_buffer sout; + std::istream cerr; + std::ostream cin; + std::istream cout; +#endif + + // We need to store the original parent pid as we might have been forked + // and with our automatic cleanup in place, it might happen that the d'tor + // is called from the child process. + pid_t original_parent_pid; + pid_t original_child_pid; + + bool dont_kill_on_cleanup = false; +}; + +ChildProcess ChildProcess::invalid() +{ + // We take the init process as child. + static const pid_t invalid_pid = 1; + return ChildProcess(invalid_pid, Pipe::invalid(), Pipe::invalid(), Pipe::invalid()); +} + +ChildProcess::ChildProcess(pid_t pid, + const ChildProcess::Pipe& stdin_pipe, + const ChildProcess::Pipe& stdout_pipe, + const ChildProcess::Pipe& stderr_pipe) + : Process(pid), + d(new Private{pid, stdin_pipe, stdout_pipe, stderr_pipe}) +{ +} + +ChildProcess::~ChildProcess() +{ +} + +wait::Result ChildProcess::wait_for(const wait::Flags& flags) +{ + int status = -1; + pid_t result_pid = ::waitpid(pid(), std::addressof(status), static_cast(flags)); + + if (result_pid == -1) + throw std::system_error(errno, std::system_category()); + + wait::Result result; + + if (result_pid == 0) + { + result.status = wait::Result::Status::no_state_change; + return result; + } + + if (WIFEXITED(status)) + { + result.status = wait::Result::Status::exited; + result.detail.if_exited.status = static_cast(WEXITSTATUS(status)); + } else if (WIFSIGNALED(status)) + { + result.status = wait::Result::Status::signaled; + result.detail.if_signaled.signal = static_cast(WTERMSIG(status)); + result.detail.if_signaled.core_dumped = WCOREDUMP(status); + } else if (WIFSTOPPED(status)) + { + result.status = wait::Result::Status::stopped; + result.detail.if_stopped.signal = static_cast(WSTOPSIG(status)); + } +#ifndef ANDROID + else if (WIFCONTINUED(status)) + { + result.status = wait::Result::Status::continued; + } +#endif + + return result; +} + +void ChildProcess::dont_kill_on_cleanup() +{ + d->dont_kill_on_cleanup = true; +} + +#ifndef ANDROID +std::istream& ChildProcess::cerr() +{ + return d->cerr; +} + +std::ostream& ChildProcess::cin() +{ + return d->cin; +} + +std::istream& ChildProcess::cout() +{ + return d->cout; +} +#endif +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/exec.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/exec.cpp new file mode 100644 index 0000000..0b48479 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/exec.cpp @@ -0,0 +1,75 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include +#include +#include + +#include + +#include + +#include + +namespace core +{ +namespace posix +{ +ChildProcess exec(const std::string& fn, + const std::vector& argv, + const std::map& env, + const StandardStream& flags) +{ + std::function null_function = [](){}; + return exec(fn, argv, env, flags, null_function); +} + +ChildProcess exec(const std::string& fn, + const std::vector& argv, + const std::map& env, + const StandardStream& flags, + const std::function& child_setup) +{ + return posix::fork([fn, argv, env, child_setup]() + { + char** it; char** pargv; char** penv; + it = pargv = new char*[argv.size()+2]; + *it = ::strdup(fn.c_str()); + it++; + for (auto element : argv) + { + *it = ::strdup(element.c_str()); + it++; + } + *it = nullptr; + + it = penv = new char*[env.size()+1]; + for (auto pair : env) + { + *it = ::strdup((pair.first + "=" + pair.second).c_str()); + it++; + } + *it = nullptr; + + child_setup(); + return static_cast(execve(fn.c_str(), pargv, penv)); + }, flags); +} + +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/fork.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/fork.cpp new file mode 100644 index 0000000..82a225c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/fork.cpp @@ -0,0 +1,184 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include +#include + +#ifndef ANDROID +#include "backtrace.h" +#endif + +#include +#include +#include + +#include + +namespace +{ +void redirect_stream_to_fd(int fd, int stream) +{ + auto rc = ::dup2(fd, stream); + if (rc == -1) + throw std::system_error(errno, std::system_category()); +} + +void print_backtrace(std::ostream& out, const std::string& line_prefix) +{ +#ifndef ANDROID + core::posix::backtrace::visit_with_handler([&out, line_prefix](const core::posix::backtrace::Frame& frame) + { + out << line_prefix << std::dec << std::setw(2) << frame.depth() << "@" << std::hex << std::setw(14) << frame.frame_pointer() << ": " + << (frame.symbol().is_cxx() ? frame.symbol().demangled() : frame.symbol().raw()) << std::endl; + return true; + }); +#endif +} +} + +namespace core +{ +namespace posix +{ + +bool is_child(pid_t pid) { return pid == 0; } + +ChildProcess fork(const std::function& main, + const StandardStream& flags) +{ + ChildProcess::Pipe stdin_pipe{ChildProcess::Pipe::invalid()}; + ChildProcess::Pipe stdout_pipe{ChildProcess::Pipe::invalid()}; + ChildProcess::Pipe stderr_pipe{ChildProcess::Pipe::invalid()}; + + if ((flags & StandardStream::stdin) != StandardStream::empty) + stdin_pipe = ChildProcess::Pipe(); + if ((flags & StandardStream::stdout) != StandardStream::empty) + stdout_pipe = ChildProcess::Pipe(); + if ((flags & StandardStream::stderr) != StandardStream::empty) + stderr_pipe = ChildProcess::Pipe(); + + pid_t pid = ::fork(); + + if (pid == -1) + throw std::system_error(errno, std::system_category()); + + if (is_child(pid)) + { + posix::exit::Status result = posix::exit::Status::failure; + + try + { + stdin_pipe.close_write_fd(); + stdout_pipe.close_read_fd(); + stderr_pipe.close_read_fd(); + // We replace stdin and stdout of the child process first: + if ((flags & StandardStream::stdin) != StandardStream::empty) + redirect_stream_to_fd(stdin_pipe.read_fd(), STDIN_FILENO); + if ((flags & StandardStream::stdout) != StandardStream::empty) + redirect_stream_to_fd(stdout_pipe.write_fd(), STDOUT_FILENO); + if ((flags & StandardStream::stderr) != StandardStream::empty) + redirect_stream_to_fd(stderr_pipe.write_fd(), STDERR_FILENO); + + result = main(); + } catch(const std::exception& e) + { + std::cerr << "core::posix::fork(): An unhandled std::exception occured in the child process:" << std::endl + << " what(): " << e.what() << std::endl; + print_backtrace(std::cerr, " "); + } catch(...) + { + std::cerr << "core::posix::fork(): An unhandled exception occured in the child process." << std::endl; + print_backtrace(std::cerr, " "); + } + + // We have to ensure that we exit here. Otherwise, we run into + // all sorts of weird issues. + ::exit(static_cast(result)); + } + + // We are in the parent process, and create a process object + // corresponding to the newly forked process. + stdin_pipe.close_read_fd(); + stdout_pipe.close_write_fd(); + stderr_pipe.close_write_fd(); + + return ChildProcess(pid, + stdin_pipe, + stdout_pipe, + stderr_pipe); +} + +ChildProcess vfork(const std::function& main, + const StandardStream& flags) +{ + ChildProcess::Pipe stdin_pipe, stdout_pipe, stderr_pipe; + + pid_t pid = ::vfork(); + + if (pid == -1) + throw std::system_error(errno, std::system_category()); + + if (is_child(pid)) + { + posix::exit::Status result = posix::exit::Status::failure; + + try + { + // We replace stdin and stdout of the child process first: + stdin_pipe.close_write_fd(); + stdout_pipe.close_read_fd(); + stderr_pipe.close_read_fd(); + // We replace stdin and stdout of the child process first: + if ((flags & StandardStream::stdin) != StandardStream::empty) + redirect_stream_to_fd(stdin_pipe.read_fd(), STDIN_FILENO); + if ((flags & StandardStream::stdout) != StandardStream::empty) + redirect_stream_to_fd(stdout_pipe.write_fd(), STDOUT_FILENO); + if ((flags & StandardStream::stderr) != StandardStream::empty) + redirect_stream_to_fd(stderr_pipe.write_fd(), STDERR_FILENO); + + result = main(); + } catch(const std::exception& e) + { + std::cerr << "core::posix::fork(): An unhandled std::exception occured in the child process:" << std::endl + << " what(): " << e.what() << std::endl; + print_backtrace(std::cerr, " "); + } catch(...) + { + std::cerr << "core::posix::fork(): An unhandled exception occured in the child process." << std::endl; + print_backtrace(std::cerr, " "); + } + + // We have to ensure that we exit here. Otherwise, we run into + // all sorts of weird issues. + ::exit(static_cast(result)); + } + + // We are in the parent process, and create a process object + // corresponding to the newly forked process. + // Close the parent's pipe end + stdin_pipe.close_read_fd(); + stdout_pipe.close_write_fd(); + stderr_pipe.close_write_fd(); + + return ChildProcess(pid, + stdin_pipe, + stdout_pipe, + stderr_pipe); +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/CMakeLists.txt new file mode 100644 index 0000000..19f87b4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright © 2013 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Authored by: Thomas Voss + +add_library( + linux-process + + process.cpp +) + +target_link_libraries( + linux-process + + posix-process +) + \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_adj.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_adj.cpp new file mode 100644 index 0000000..3b1b67e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_adj.cpp @@ -0,0 +1,81 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include + +#include +#include +#include + +#include + +namespace core +{ +namespace posix +{ +namespace linux +{ +namespace proc +{ +namespace process +{ + +int OomAdj::disable_value() +{ + return OOM_DISABLE; +} + +int OomAdj::min_value() +{ + return OOM_ADJUST_MIN; +} + +int OomAdj::max_value() +{ + return OOM_ADJUST_MAX; +} + +const posix::Process& operator>>(const posix::Process& process, OomAdj& adj) +{ + std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_adj"; + std::ifstream in(ss.str()); + + in >> adj.value; + + return process; +} + +const posix::Process& operator<<(const posix::Process& process, const OomAdj& adj) +{ + if (!adj.is_valid()) + throw std::logic_error("Value for adjusting the oom score is invalid."); + + std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_adj"; + std::ofstream out(ss.str()); + + out << adj.value; + + return process; +} +} +} +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score.cpp new file mode 100644 index 0000000..d52420f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score.cpp @@ -0,0 +1,49 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include + +#include +#include + +namespace core +{ +namespace posix +{ +namespace linux +{ +namespace proc +{ +namespace process +{ +const posix::Process& operator>>(const posix::Process& process, OomScore& score) +{ + std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_score"; + std::ifstream in(ss.str()); + + in >> score.value; + + return process; +} +} +} +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score_adj.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score_adj.cpp new file mode 100644 index 0000000..6a068d1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/oom_score_adj.cpp @@ -0,0 +1,76 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include + +#include +#include +#include + +#include + +namespace core +{ +namespace posix +{ +namespace linux +{ +namespace proc +{ +namespace process +{ + +int OomScoreAdj::min_value() +{ + return OOM_SCORE_ADJ_MIN; +} + +int OomScoreAdj::max_value() +{ + return OOM_SCORE_ADJ_MAX; +} + +const posix::Process& operator>>(const posix::Process& process, OomScoreAdj& score_adj) +{ + std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_score_adj"; + std::ifstream in(ss.str()); + + in >> score_adj.value; + + return process; +} + +const posix::Process& operator<<(const posix::Process& process, const OomScoreAdj& score_adj) +{ + if (!score_adj.is_valid()) + throw std::logic_error("Value for adjusting the oom score is invalid."); + + std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_score_adj"; + std::ofstream out(ss.str()); + + out << score_adj.value; + + return process; +} +} +} +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/stat.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/stat.cpp new file mode 100644 index 0000000..6cb4484 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/stat.cpp @@ -0,0 +1,106 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include + +#include +#include +#include + +namespace core +{ +namespace posix +{ +namespace linux +{ +namespace proc +{ +namespace process +{ +std::istream& operator>>(std::istream& in, State& state) +{ + char c; in >> c; state = static_cast(c); + return in; +} + +std::istream& operator>>(std::istream& in, Stat& stat) +{ + in >> stat.pid + >> stat.executable + >> stat.state + >> stat.parent + >> stat.process_group + >> stat.session_id + >> stat.tty_nr + >> stat.controlling_process_group + >> stat.kernel_flags + >> stat.minor_faults_count + >> stat.minor_faults_count_by_children + >> stat.major_faults_count + >> stat.major_faults_count_by_children + >> stat.time.user + >> stat.time.system + >> stat.time.user_for_children + >> stat.time.system_for_children + >> stat.priority + >> stat.nice + >> stat.thread_count + >> stat.time_before_next_sig_alarm + >> stat.start_time + >> stat.size.virt + >> stat.size.resident_set + >> stat.size.resident_set_limit + >> stat.addresses.start_code + >> stat.addresses.end_code + >> stat.addresses.start_stack + >> stat.addresses.stack_pointer + >> stat.addresses.instruction_pointer + >> stat.signals.pending + >> stat.signals.blocked + >> stat.signals.ignored + >> stat.signals.caught + >> stat.channel + >> stat.swap_count + >> stat.swap_count_children + >> stat.exit_signal + >> stat.cpu_count + >> stat.realtime_priority + >> stat.scheduling_policy + >> stat.aggregated_block_io_delays + >> stat.guest_time + >> stat.guest_time_children; + + return in; +} + +const posix::Process& operator>>(const posix::Process& process, Stat& stat) +{ + std::stringstream ss; ss << "/proc/" << process.pid() << "/stat"; + std::ifstream in(ss.str()); + + in >> stat; + + return process; +} +} +} +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/state.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/state.cpp new file mode 100644 index 0000000..ddc5537 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/linux/proc/process/state.cpp @@ -0,0 +1,40 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include + +#include + +namespace core +{ +namespace posix +{ +namespace linux +{ +namespace proc +{ +namespace process +{ + +} +} +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process.cpp new file mode 100644 index 0000000..049e7b1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process.cpp @@ -0,0 +1,86 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include + +#include +#include + +#include + +namespace core +{ +namespace posix +{ + +struct Process::Private +{ + pid_t pid; +}; + +Process Process::invalid() +{ + static const pid_t invalid_pid = 0; + Process p(invalid_pid); + p.d->pid = -1; + + return p; +} + +Process::Process(pid_t pid) + : Signalable(pid), + d(new Private{pid}) +{ + if (pid < 0) + throw std::runtime_error("Cannot construct instance for invalid pid."); +} + +Process::~Process() noexcept +{ +} + +pid_t Process::pid() const +{ + return d->pid; +} + +ProcessGroup Process::process_group_or_throw() const +{ + pid_t pgid = ::getpgid(pid()); + + if (pgid == -1) + throw std::system_error(errno, std::system_category()); + + return ProcessGroup(pgid); +} + +ProcessGroup Process::process_group(std::error_code& se) const noexcept(true) +{ + pid_t pgid = ::getpgid(pid()); + + if (pgid == -1) + { + se = std::error_code(errno, std::system_category()); + } + + return ProcessGroup(pgid); +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process_group.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process_group.cpp new file mode 100644 index 0000000..4098883 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/process_group.cpp @@ -0,0 +1,47 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +namespace core +{ +namespace posix +{ +struct ProcessGroup::Private +{ + pid_t id; +}; + +pid_t ProcessGroup::id() const +{ + return d->id; +} + +ProcessGroup::ProcessGroup(pid_t id) + : Signalable(-id), // We rely on ::kill to deliver signals, thus negate the id (see man 2 kill). + d(new Private{id}) +{ +} + +ProcessGroup ProcessGroup::invalid() +{ + static const pid_t invalid_pid = 1; + return ProcessGroup(invalid_pid); +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signal.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signal.cpp new file mode 100644 index 0000000..bcbbac8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signal.cpp @@ -0,0 +1,221 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include +#include +#include +#include + +#include + +#include + +namespace impl +{ +void set_thread_signal_mask(::sigset_t* new_mask, ::sigset_t* old_mask) +{ + ::pthread_sigmask(SIG_BLOCK, new_mask, old_mask); +} + +void set_process_signal_mask(::sigset_t* new_mask, ::sigset_t* old_mask) +{ + ::sigprocmask(SIG_BLOCK, new_mask, old_mask); +} + +class SignalTrap : public core::posix::SignalTrap +{ +public: + enum class Scope + { + process, + thread + }; + + enum class State + { + not_running, + running + }; + + SignalTrap(Scope scope, std::initializer_list blocked_signals) + : scope(scope), + state(State::not_running), + event_fd(::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)) + { + if (event_fd == -1) + throw std::system_error(errno, std::system_category()); + + ::sigemptyset(&blocked_signals_mask); + + for(auto signal : blocked_signals) + ::sigaddset(&blocked_signals_mask, static_cast(signal)); + + switch (scope) + { + case Scope::process: + set_process_signal_mask(&blocked_signals_mask, &old_signals_mask); + break; + case Scope::thread: + set_thread_signal_mask(&blocked_signals_mask, &old_signals_mask); + break; + default: + break; + } + } + + ~SignalTrap() + { + switch (scope) + { + case Scope::process: + set_process_signal_mask(&old_signals_mask, nullptr); + break; + case Scope::thread: + set_thread_signal_mask(&old_signals_mask, nullptr); + break; + default: + break; + } + + ::close(event_fd); + } + + bool has(core::posix::Signal signal) override + { + return ::sigismember(&blocked_signals_mask, static_cast(signal)); + } + + void run() override + { + static constexpr int signal_fd_idx = 0; + static constexpr int event_fd_idx = 1; + + static constexpr int signal_info_buffer_size = 5; + + if (state.load() == State::running) + throw std::runtime_error("SignalTrap::run can only be run once."); + + state.store(State::running); + + // Make sure we clean up the signal fd whenever + // we leave the scope of run. + struct Scope + { + ~Scope() + { + if (signal_fd != -1) + ::close(signal_fd); + } + + int signal_fd; + } scope{::signalfd(-1, &blocked_signals_mask, SFD_CLOEXEC | SFD_NONBLOCK)}; + + if (scope.signal_fd == -1) + throw std::system_error(errno, std::system_category()); + + pollfd fds[2]; + signalfd_siginfo signal_info[signal_info_buffer_size]; + + for (;;) + { + fds[signal_fd_idx] = {scope.signal_fd, POLLIN, 0}; + fds[event_fd_idx] = {event_fd, POLLIN, 0}; + + auto rc = ::poll(fds, 2, -1); + + if (rc == -1) + { + if (errno == EINTR) + continue; + + break; + } + + if (rc == 0) + continue; + + if (fds[signal_fd_idx].revents & POLLIN) + { + auto result = ::read(scope.signal_fd, signal_info, sizeof(signal_info)); + + for (unsigned int i = 0; i < result / sizeof(signalfd_siginfo); i++) + { + if (has(static_cast(signal_info[i].ssi_signo))) + { + on_signal_raised( + static_cast( + signal_info[i].ssi_signo)); + } + } + } + + if (fds[event_fd_idx].revents & POLLIN) + { + std::int64_t value{1}; + // Consciously void-ing the return value here. + // Not much we can do about an error. + auto result = ::read(event_fd, &value, sizeof(value)); + (void) result; + + break; + } + } + + state.store(State::not_running); + } + + void stop() override + { + static const std::int64_t value = {1}; + if (sizeof(value) != ::write(event_fd, &value, sizeof(value))) + throw std::system_error(errno, std::system_category()); + } + + core::Signal& signal_raised() override + { + return on_signal_raised; + } + +private: + Scope scope; + std::atomic state; + int event_fd; + core::Signal on_signal_raised; + ::sigset_t old_signals_mask; + ::sigset_t blocked_signals_mask; +}; +} + +std::shared_ptr core::posix::trap_signals_for_process( + std::initializer_list blocked_signals) +{ + return std::make_shared( + impl::SignalTrap::Scope::process, + blocked_signals); +} + +std::shared_ptr core::posix::trap_signals_for_all_subsequent_threads( + std::initializer_list blocked_signals) +{ + return std::make_shared( + impl::SignalTrap::Scope::thread, + blocked_signals); +} + diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signalable.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signalable.cpp new file mode 100644 index 0000000..5542fa8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/signalable.cpp @@ -0,0 +1,52 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +namespace core +{ +namespace posix +{ +struct Signalable::Private +{ + pid_t pid; +}; + +Signalable::Signalable(pid_t pid) : d(new Private{pid}) +{ +} + +void Signalable::send_signal_or_throw(Signal signal) +{ + auto result = ::kill(d->pid, static_cast(signal)); + + if (result == -1) + throw std::system_error(errno, std::system_category()); +} + +void Signalable::send_signal(Signal signal, std::error_code& e) noexcept +{ + auto result = ::kill(d->pid, static_cast(signal)); + + if (result == -1) + { + e = std::error_code(errno, std::system_category()); + } +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/standard_stream.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/standard_stream.cpp new file mode 100644 index 0000000..66c796c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/standard_stream.cpp @@ -0,0 +1,35 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +namespace core +{ +namespace posix +{ +StandardStream operator|(StandardStream l, StandardStream r) +{ + return static_cast(static_cast(l) | static_cast(r)); +} + +StandardStream operator&(StandardStream l, StandardStream r) +{ + return static_cast(static_cast(l) & static_cast(r)); +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/this_process.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/this_process.cpp new file mode 100644 index 0000000..53f5241 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/this_process.cpp @@ -0,0 +1,177 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#if defined(_GNU_SOURCE) +#include +#else +extern char** environ; +#endif + +namespace core +{ +namespace posix +{ +namespace this_process +{ +namespace env +{ +namespace +{ +std::mutex& env_guard() +{ + static std::mutex m; + return m; +} +} + +void for_each(const std::function& functor) noexcept(true) +{ + std::lock_guard lg(env_guard()); + auto it = ::environ; + while (it != nullptr && *it != nullptr) + { + std::string line(*it); + functor(line.substr(0,line.find_first_of('=')), + line.substr(line.find_first_of('=')+1)); + ++it; + } +} + +std::string get_or_throw(const std::string& key) +{ + std::lock_guard lg(env_guard()); + + auto result = ::getenv(key.c_str()); + + if (result == nullptr) + { + std::stringstream ss; + ss << "Variable with name " << key << " is not defined in the environment"; + throw std::runtime_error(ss.str()); + } + + return std::string{result}; +} + +std::string get(const std::string& key, + const std::string& default_value) noexcept(true) +{ + std::lock_guard lg(env_guard()); + + auto result = ::getenv(key.c_str()); + return std::string{result ? result : default_value}; +} + +void unset_or_throw(const std::string& key) +{ + std::lock_guard lg(env_guard()); + + auto rc = ::unsetenv(key.c_str()); + + if (rc == -1) + throw std::system_error(errno, std::system_category()); +} + +bool unset(const std::string& key, + std::error_code& se) noexcept(true) +{ + std::lock_guard lg(env_guard()); + + auto rc = ::unsetenv(key.c_str()); + + if (rc == -1) + { + se = std::error_code(errno, std::system_category()); + return false; + } + + return true; +} + +void set_or_throw(const std::string& key, + const std::string& value) +{ + std::lock_guard lg(env_guard()); + + static const int overwrite = 0; + auto rc = ::setenv(key.c_str(), value.c_str(), overwrite); + + if (rc == -1) + throw std::system_error(errno, std::system_category()); +} + +bool set(const std::string &key, + const std::string &value, + std::error_code& se) noexcept(true) +{ + std::lock_guard lg(env_guard()); + + static const int overwrite = 0; + auto rc = ::setenv(key.c_str(), value.c_str(), overwrite); + + if (rc == -1) + { + se = std::error_code(errno, std::system_category()); + return false; + } + + return true; +} +} + +Process instance() noexcept(true) +{ + static const Process self{getpid()}; + return self; +} + +Process parent() noexcept(true) +{ + return Process(getppid()); +} + +std::istream& cin() noexcept(true) +{ + return std::cin; +} + +std::ostream& cout() noexcept(true) +{ + return std::cout; +} + +std::ostream& cerr() noexcept(true) +{ + return std::cerr; +} +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/wait.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/wait.cpp new file mode 100644 index 0000000..0d9eec4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/posix/wait.cpp @@ -0,0 +1,33 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +namespace core +{ +namespace posix +{ +namespace wait +{ +Flags operator|(Flags l, Flags r) +{ + return static_cast(static_cast(l) | static_cast(r)); +} +} +} +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/cross_process_sync.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/cross_process_sync.cpp new file mode 100644 index 0000000..cc03389 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/cross_process_sync.cpp @@ -0,0 +1,99 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voss + */ + +#include + +#include + +#include +#include + +namespace +{ +const int read_fd = 0; +const int write_fd = 1; +} + +core::testing::CrossProcessSync::CrossProcessSync() : counter(0) +{ + if (::pipe(fds) < 0) + throw std::system_error(errno, std::system_category()); +} + +core::testing::CrossProcessSync::CrossProcessSync(const CrossProcessSync& rhs) : counter(rhs.counter) +{ + fds[0] = ::dup(rhs.fds[0]); + fds[1] = ::dup(rhs.fds[1]); +} + +core::testing::CrossProcessSync::~CrossProcessSync() noexcept +{ + ::close(fds[0]); + ::close(fds[1]); +} + +core::testing::CrossProcessSync& core::testing::CrossProcessSync::operator=(const core::testing::CrossProcessSync& rhs) +{ + ::close(fds[0]); + ::close(fds[1]); + fds[0] = ::dup(rhs.fds[0]); + fds[1] = ::dup(rhs.fds[1]); + + counter = rhs.counter; + + return *this; +} + +void core::testing::CrossProcessSync::try_signal_ready_for(const std::chrono::milliseconds& duration) +{ + static const short empty_revents = 0; + pollfd poll_fd[1] = { { fds[write_fd], POLLOUT, empty_revents } }; + int rc = -1; + + if ((rc = ::poll(poll_fd, 1, duration.count())) < 0) + throw std::system_error(errno, std::system_category()); + else if (rc == 0) + throw Error::Timeout{}; + + static const std::uint32_t value = 1; + if (sizeof(value) != write(fds[write_fd], std::addressof(value), sizeof(value))) + throw std::system_error(errno, std::system_category()); +} + +std::uint32_t core::testing::CrossProcessSync::wait_for_signal_ready_for(const std::chrono::milliseconds& duration) +{ + static const short empty_revents = 0; + pollfd poll_fd[1] = { { fds[read_fd], POLLIN, empty_revents } }; + int rc = -1; + + if ((rc = ::poll(poll_fd, 1, duration.count())) < 0) + throw std::system_error(errno, std::system_category()); + else if (rc == 0) + throw Error::Timeout{}; + + std::uint32_t value = 0; + if (sizeof(value) != read(fds[read_fd], std::addressof(value), sizeof(value))) + throw std::system_error(errno, std::system_category()); + + if (value != 1) + throw std::system_error(errno, std::system_category()); + + counter += value; + + return counter; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/fork_and_run.cpp b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/fork_and_run.cpp new file mode 100644 index 0000000..ba2efd6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/src/core/testing/fork_and_run.cpp @@ -0,0 +1,78 @@ +/* + * Copyright © 2012-2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include + +#include +#include +#include + +core::testing::ForkAndRunResult core::testing::operator|( + core::testing::ForkAndRunResult lhs, + core::testing::ForkAndRunResult rhs) +{ + return static_cast( + static_cast (lhs) | static_cast(rhs)); +} + +core::testing::ForkAndRunResult core::testing::operator&( + core::testing::ForkAndRunResult lhs, + core::testing::ForkAndRunResult rhs) +{ + return static_cast( + static_cast (lhs) & static_cast(rhs)); +} + +core::testing::ForkAndRunResult core::testing::fork_and_run( + const std::function& service, + const std::function& client) +{ + core::testing::ForkAndRunResult result = core::testing::ForkAndRunResult::empty; + + auto service_process = core::posix::fork(service, core::posix::StandardStream::empty); + auto client_process = core::posix::fork(client, core::posix::StandardStream::empty); + + auto client_result = client_process.wait_for(core::posix::wait::Flags::untraced); + + switch (client_result.status) + { + case core::posix::wait::Result::Status::exited: + if (client_result.detail.if_exited.status == core::posix::exit::Status::failure) + result = result | core::testing::ForkAndRunResult::client_failed; + break; + default: + result = result | core::testing::ForkAndRunResult::client_failed; + break; + } + + service_process.send_signal_or_throw(core::posix::Signal::sig_term); + auto service_result = service_process.wait_for(core::posix::wait::Flags::untraced); + + switch (service_result.status) + { + case core::posix::wait::Result::Status::exited: + if (service_result.detail.if_exited.status == core::posix::exit::Status::failure) + result = result | core::testing::ForkAndRunResult::service_failed; + break; + default: + result = result | core::testing::ForkAndRunResult::service_failed; + break; + } + + return result; +} diff --git a/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/symbols.map b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/symbols.map new file mode 100644 index 0000000..6d3c2a9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/process-cpp-minimal/symbols.map @@ -0,0 +1,16 @@ +{ +global: + extern "C++" { + core::*; + typeinfo?for?core::*; + typeinfo?name?for?core::*; + VTT?for?core::*; + virtual?thunk?to?core::*; + vtable?for?core::*; + std::hash*; + }; +local: + extern "C++" { + *; + }; +}; \ No newline at end of file diff --git a/src/type3_AndroidCloud/anbox-master/external/xdg/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/external/xdg/CMakeLists.txt new file mode 100644 index 0000000..249da48 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/xdg/CMakeLists.txt @@ -0,0 +1,24 @@ +# We have to manually alter the cxx flags to have a working +# travis-ci build. Its container-based infrastructure only features +# a very old cmake that does not support the more current: +# set_property(TARGET xdg_test PROPERTY CXX_STANDARD 11) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + +find_package(Boost COMPONENTS filesystem system unit_test_framework) + +include_directories( + . + ${Boost_INCLUDE_DIRS} +) + +add_library(xdg STATIC xdg.cpp) +set_property(TARGET xdg PROPERTY CXX_STANDARD 11) +target_link_libraries(xdg ${Boost_LIBRARIES}) + +enable_testing() +add_definitions(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN -DBOOST_TEST_MODULE=xdg) +add_executable(xdg_test xdg_test.cpp) +set_property(TARGET xdg_test PROPERTY CXX_STANDARD 11) +target_link_libraries(xdg_test xdg ${Boost_LIBRARIES}) + +add_test(xdg_test xdg_test) diff --git a/src/type3_AndroidCloud/anbox-master/external/xdg/LICENSE b/src/type3_AndroidCloud/anbox-master/external/xdg/LICENSE new file mode 100644 index 0000000..341c30b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/xdg/LICENSE @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + diff --git a/src/type3_AndroidCloud/anbox-master/external/xdg/xdg.cpp b/src/type3_AndroidCloud/anbox-master/external/xdg/xdg.cpp new file mode 100644 index 0000000..d54fdfe --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/xdg/xdg.cpp @@ -0,0 +1,202 @@ +// Copyright (C) 2015 Thomas Voß +// +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + +#include + +#include + +#include +#include + +namespace fs = boost::filesystem; + +namespace +{ + +fs::path throw_if_not_absolute(const fs::path& p) +{ + if (p.has_root_directory()) + return p; + + throw std::runtime_error{"Directores MUST be absolute."}; +} + +namespace env +{ +std::string get(const std::string& key, const std::string& default_value) +{ + if (auto value = std::getenv(key.c_str())) + return value; + return default_value; +} + +std::string get_or_throw(const std::string& key) +{ + if (auto value = std::getenv(key.c_str())) + { + return value; + } + + throw std::runtime_error{key + " not set in environment"}; +} + +constexpr const char* xdg_data_home{"XDG_DATA_HOME"}; +constexpr const char* xdg_data_dirs{"XDG_DATA_DIRS"}; +constexpr const char* xdg_config_home{"XDG_CONFIG_HOME"}; +constexpr const char* xdg_config_dirs{"XDG_CONFIG_DIRS"}; +constexpr const char* xdg_cache_home{"XDG_CACHE_HOME"}; +} + +namespace impl +{ +class BaseDirSpecification : public xdg::BaseDirSpecification +{ +public: + static const BaseDirSpecification& instance() + { + static const BaseDirSpecification spec; + return spec; + } + + BaseDirSpecification() + { + } + + const xdg::Data& data() const override + { + return data_; + } + + const xdg::Config& config() const override + { + return config_; + } + + const xdg::Cache& cache() const override + { + return cache_; + } + + const xdg::Runtime& runtime() const override + { + return runtime_; + } + +private: + xdg::Data data_; + xdg::Config config_; + xdg::Cache cache_; + xdg::Runtime runtime_; +}; +} +} + +fs::path xdg::Data::home() const +{ + auto v = env::get(env::xdg_data_home, ""); + if (v.empty()) + return throw_if_not_absolute(fs::path{env::get_or_throw("HOME")} / ".local" / "share"); + + return throw_if_not_absolute(fs::path(v)); +} + +std::vector xdg::Data::dirs() const +{ + auto v = env::get(env::xdg_data_dirs, ""); + if (v.empty()) + return {fs::path{"/usr/local/share"}, fs::path{"/usr/share"}}; + + std::vector tokens; + tokens = boost::split(tokens, v, boost::is_any_of(":")); + std::vector result; + for (const auto& token : tokens) + { + result.push_back(throw_if_not_absolute(fs::path(token))); + } + return result; +} + +fs::path xdg::Config::home() const +{ + auto v = env::get(env::xdg_config_home, ""); + if (v.empty()) + return throw_if_not_absolute(fs::path{env::get_or_throw("HOME")} / ".config"); + + return throw_if_not_absolute(fs::path(v)); +} + +std::vector xdg::Config::dirs() const +{ + auto v = env::get(env::xdg_config_dirs, ""); + if (v.empty()) + return {fs::path{"/etc/xdg"}}; + + std::vector tokens; + tokens = boost::split(tokens, v, boost::is_any_of(":")); + std::vector result; + for (const auto& token : tokens) + { + fs::path p(token); + result.push_back(throw_if_not_absolute(p)); + } + return result; +} + +fs::path xdg::Cache::home() const +{ + auto v = env::get(env::xdg_cache_home, ""); + if (v.empty()) + return throw_if_not_absolute(fs::path{env::get_or_throw("HOME")} / ".cache"); + + return throw_if_not_absolute(fs::path(v)); +} + +fs::path xdg::Runtime::dir() const +{ + auto v = env::get(env::xdg_config_home, ""); + if (v.empty()) + { + // We do not fall back gracefully and instead throw, dispatching to calling + // code for handling the case of a safe user-specfic runtime directory missing. + throw std::runtime_error{"Runtime directory not set"}; + } + + return throw_if_not_absolute(fs::path(v)); +} + +std::shared_ptr xdg::BaseDirSpecification::create() +{ + return std::make_shared(); +} + +const xdg::Data& xdg::data() +{ + return impl::BaseDirSpecification::instance().data(); +} + +const xdg::Config& xdg::config() +{ + return impl::BaseDirSpecification::instance().config(); +} + +const xdg::Cache& xdg::cache() +{ + return impl::BaseDirSpecification::instance().cache(); +} + +const xdg::Runtime& xdg::runtime() +{ + return impl::BaseDirSpecification::instance().runtime(); +} diff --git a/src/type3_AndroidCloud/anbox-master/external/xdg/xdg.h b/src/type3_AndroidCloud/anbox-master/external/xdg/xdg.h new file mode 100644 index 0000000..379f0ff --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/xdg/xdg.h @@ -0,0 +1,118 @@ +// Copyright (C) 2015 Thomas Voß +// +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +#ifndef XDG_H_ +#define XDG_H_ + +#include + +#include +#include + +namespace xdg +{ +// NotCopyable deletes the copy c'tor and the assignment operator. +struct NotCopyable +{ + NotCopyable() = default; + NotCopyable(const NotCopyable&) = delete; + virtual ~NotCopyable() = default; + NotCopyable& operator=(const NotCopyable&) = delete; +}; + +// NotMoveable deletes the move c'tor and the move assignment operator. +struct NotMoveable +{ + NotMoveable() = default; + NotMoveable(NotMoveable&&) = delete; + virtual ~NotMoveable() = default; + NotMoveable& operator=(NotMoveable&&) = delete; +}; + +// Data provides functions to query the XDG_DATA_* entries. +class Data : NotCopyable, NotMoveable +{ +public: + // home returns the base directory relative to which user specific + // data files should be stored. + virtual boost::filesystem::path home() const; + // dirs returns the preference-ordered set of base directories to + // search for data files in addition to the $XDG_DATA_HOME base + // directory. + virtual std::vector dirs() const; +}; + +// Config provides functions to query the XDG_CONFIG_* entries. +class Config : NotCopyable, NotMoveable +{ +public: + // home returns the base directory relative to which user specific + // configuration files should be stored. + virtual boost::filesystem::path home() const; + // dirs returns the preference-ordered set of base directories to + // search for configuration files in addition to the + // $XDG_CONFIG_HOME base directory. + virtual std::vector dirs() const; +}; + +// Cache provides functions to query the XDG_CACHE_HOME entry. +class Cache : NotCopyable, NotMoveable +{ +public: + // home returns the base directory relative to which user specific + // non-essential data files should be stored. + virtual boost::filesystem::path home() const; +}; + +// Runtime provides functions to query the XDG_RUNTIME_DIR entry. +class Runtime : NotCopyable, NotMoveable +{ +public: + // home returns the base directory relative to which user-specific + // non-essential runtime files and other file objects (such as + // sockets, named pipes, ...) should be stored. + virtual boost::filesystem::path dir() const; +}; + +// A BaseDirSpecification implements the XDG base dir specification: +// http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +class BaseDirSpecification : NotCopyable, NotMoveable +{ +public: + // create returns an Implementation of BaseDirSpecification. + static std::shared_ptr create(); + + // data returns an immutable Data instance. + virtual const Data& data() const = 0; + // config returns an immutable Config instance. + virtual const Config& config() const = 0; + // cache returns an immutable Cache instance. + virtual const Cache& cache() const = 0; + // runtime returns an immutable Runtime instance. + virtual const Runtime& runtime() const = 0; +protected: + BaseDirSpecification() = default; +}; + +// data returns an immutable reference to a Data instance. +const Data& data(); +// config returns an immutable reference to a Config instance. +const Config& config(); +// cache returns an immutable reference to a Cache instance. +const Cache& cache(); +// runtime returns an immutable reference to a Runtime instance. +const Runtime& runtime(); +} + +#endif // XDG_H_ diff --git a/src/type3_AndroidCloud/anbox-master/external/xdg/xdg_test.cpp b/src/type3_AndroidCloud/anbox-master/external/xdg/xdg_test.cpp new file mode 100644 index 0000000..d5b3632 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/external/xdg/xdg_test.cpp @@ -0,0 +1,130 @@ +// Copyright (C) 2015 Thomas Voß +// +// This library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + +#include + +#include + +#include +#include + +BOOST_AUTO_TEST_CASE(XdgDataHomeThrowsForRelativeDirectoryFromEnv) +{ + ::setenv("XDG_DATA_HOME", "tmp", 1); + BOOST_CHECK_THROW(xdg::BaseDirSpecification::create()->data().home(), std::runtime_error); + BOOST_CHECK_THROW(xdg::data().home(), std::runtime_error); +} + +BOOST_AUTO_TEST_CASE(XdgDataHomeReturnsDefaultValueForEmptyEnv) +{ + ::setenv("HOME", "/tmp", 1); + ::setenv("XDG_DATA_HOME", "", 1); + BOOST_CHECK_EQUAL("/tmp/.local/share", xdg::BaseDirSpecification::create()->data().home()); + BOOST_CHECK_EQUAL("/tmp/.local/share", xdg::data().home()); +} + +BOOST_AUTO_TEST_CASE(XdgDataDirsCorrectlyTokenizesEnv) +{ + ::setenv("XDG_DATA_DIRS", "/tmp:/tmp", 1); + BOOST_CHECK(2 == xdg::BaseDirSpecification::create()->data().dirs().size()); + BOOST_CHECK(2 == xdg::data().dirs().size()); +} + +BOOST_AUTO_TEST_CASE(XdgDataDirsThrowsForRelativeDirectoryFromEnv) +{ + ::setenv("XDG_DATA_DIRS", "/tmp:tmp", 1); + BOOST_CHECK_THROW(xdg::BaseDirSpecification::create()->data().dirs(), std::runtime_error); + BOOST_CHECK_THROW(xdg::data().dirs(), std::runtime_error); +} + +BOOST_AUTO_TEST_CASE(XdgDataDirsReturnsDefaultValueForEmptyEnv) +{ + ::setenv("XDG_DATA_DIRS", "", 1); + auto dirs = xdg::data().dirs(); + BOOST_CHECK_EQUAL("/usr/local/share", dirs[0]); + BOOST_CHECK_EQUAL("/usr/share", dirs[1]); + + dirs = xdg::BaseDirSpecification::create()->data().dirs(); + BOOST_CHECK_EQUAL("/usr/local/share", dirs[0]); + BOOST_CHECK_EQUAL("/usr/share", dirs[1]); +} + +BOOST_AUTO_TEST_CASE(XdgConfigHomeThrowsForRelativeDirectoryFromEnv) +{ + ::setenv("XDG_CONFIG_HOME", "tmp", 1); + BOOST_CHECK_THROW(xdg::BaseDirSpecification::create()->config().home(), std::runtime_error); + BOOST_CHECK_THROW(xdg::config().home(), std::runtime_error); +} + +BOOST_AUTO_TEST_CASE(XdgConfigHomeReturnsDefaultValueForEmptyEnv) +{ + ::setenv("HOME", "/tmp", 1); + ::setenv("XDG_CONFIG_HOME", "", 1); + BOOST_CHECK_EQUAL("/tmp/.config", xdg::BaseDirSpecification::create()->config().home()); + BOOST_CHECK_EQUAL("/tmp/.config", xdg::config().home()); +} + +BOOST_AUTO_TEST_CASE(XdgConfigDirsCorrectlyTokenizesEnv) +{ + ::setenv("XDG_CONFIG_DIRS", "/tmp:/tmp", 1); + BOOST_CHECK(2 == xdg::BaseDirSpecification::create()->config().dirs().size()); + BOOST_CHECK(2 == xdg::config().dirs().size()); +} + +BOOST_AUTO_TEST_CASE(XdgConfigDirsThrowsForRelativeDirectoryFromEnv) +{ + ::setenv("XDG_CONFIG_DIRS", "/tmp:tmp", 1); + BOOST_CHECK_THROW(xdg::BaseDirSpecification::create()->config().dirs(), std::runtime_error); + BOOST_CHECK_THROW(xdg::config().dirs(), std::runtime_error); +} + +BOOST_AUTO_TEST_CASE(XdgConfigDirsReturnsDefaultValueForEmptyEnv) +{ + ::setenv("XDG_CONFIG_DIRS", "", 1); + auto dirs = xdg::config().dirs(); + BOOST_CHECK_EQUAL("/etc/xdg", dirs[0]); + dirs = xdg::BaseDirSpecification::create()->config().dirs(); + BOOST_CHECK_EQUAL("/etc/xdg", dirs[0]); +} + +BOOST_AUTO_TEST_CASE(XdgCacheHomeThrowsForRelativeDirectoryFromEnv) +{ + ::setenv("XDG_CACHE_HOME", "tmp", 1); + BOOST_CHECK_THROW(xdg::BaseDirSpecification::create()->cache().home(), std::runtime_error); + BOOST_CHECK_THROW(xdg::cache().home(), std::runtime_error); +} + +BOOST_AUTO_TEST_CASE(XdgCacheHomeReturnsDefaultValueForEmptyEnv) +{ + ::setenv("HOME", "/tmp", 1); + ::setenv("XDG_CACHE_HOME", "", 1); + BOOST_CHECK_EQUAL("/tmp/.cache", xdg::BaseDirSpecification::create()->cache().home()); + BOOST_CHECK_EQUAL("/tmp/.cache", xdg::cache().home()); +} + +BOOST_AUTO_TEST_CASE(XdgRuntimeDirThrowsForRelativeDirectoryFromEnv) +{ + ::setenv("XDG_RUNTIME_DIR", "tmp", 1); + BOOST_CHECK_THROW(xdg::BaseDirSpecification::create()->runtime().dir(), std::runtime_error); + BOOST_CHECK_THROW(xdg::runtime().dir(), std::runtime_error); +} + +BOOST_AUTO_TEST_CASE(XdgRuntimeDirThrowsForEmptyEnv) +{ + ::setenv("XDG_RUNTIME_DIR", "", 1); + BOOST_CHECK_THROW(xdg::BaseDirSpecification::create()->runtime().dir(), std::runtime_error); + BOOST_CHECK_THROW(xdg::runtime().dir(), std::runtime_error); +} + diff --git a/src/type3_AndroidCloud/anbox-master/products/AndroidProducts.mk b/src/type3_AndroidCloud/anbox-master/products/AndroidProducts.mk new file mode 100644 index 0000000..3297750 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/AndroidProducts.mk @@ -0,0 +1,4 @@ +PRODUCT_MAKEFILES := \ + $(LOCAL_DIR)/anbox_x86_64.mk \ + $(LOCAL_DIR)/anbox_armv7a_neon.mk \ + $(LOCAL_DIR)/anbox_arm64.mk diff --git a/src/type3_AndroidCloud/anbox-master/products/anbox.mk b/src/type3_AndroidCloud/anbox-master/products/anbox.mk new file mode 100644 index 0000000..6ab2330 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/anbox.mk @@ -0,0 +1,100 @@ +# +# Copyright (C) 2013 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +PRODUCT_PACKAGES += \ + egl.cfg \ + gralloc.goldfish \ + libGLESv1_CM_emulation \ + lib_renderControl_enc \ + libEGL_emulation \ + libGLES_android \ + libGLESv2_enc \ + libOpenglSystemCommon \ + libGLESv2_emulation \ + libGLESv1_enc \ + qemu-props \ + qemud \ + camera.goldfish \ + camera.goldfish.jpeg \ + lights.goldfish \ + gps.goldfish \ + fingerprint.goldfish \ + sensors.goldfish \ + audio.primary.goldfish \ + vibrator.goldfish \ + power.goldfish \ + fingerprintd + +PRODUCT_COPY_FILES += \ + vendor/anbox/android/fstab.goldfish:root/fstab.goldfish \ + vendor/anbox/android/init.goldfish.rc:root/init.goldfish.rc \ + vendor/anbox/android/init.goldfish.sh:system/etc/init.goldfish.sh \ + vendor/anbox/android/ueventd.goldfish.rc:root/ueventd.goldfish.rc \ + vendor/anbox/android/media/media_profiles.xml:system/etc/media_profiles.xml \ + vendor/anbox/android/media/media_codecs.xml:system/etc/media_codecs.xml \ + vendor/anbox/android/media/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \ + vendor/anbox/android/media/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \ + vendor/anbox/android/media/media_codecs_google_tv.xml:system/etc/media_codecs_google_tv.xml \ + vendor/anbox/android/media/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \ + hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf + +PRODUCT_CHARACTERISTICS := emulator + +# Include drawables for all densities +PRODUCT_AAPT_CONFIG := normal + +PRODUCT_COPY_FILES += \ + vendor/anbox/scripts/anbox-init.sh:root/anbox-init.sh \ + vendor/anbox/products/anbox.xml:system/etc/permissions/anbox.xml + +PRODUCT_PACKAGES += \ + anboxd \ + hwcomposer.anbox \ + AnboxAppMgr + +PRODUCT_PROPERTY_OVERRIDES += \ + ro.hardware=goldfish \ + ro.hardware.hwcomposer=anbox \ + ro.kernel.qemu.gles=1 \ + ro.kernel.qemu=1 + ro.adb.qemud=1 + +# Disable any software key elements in the UI +PRODUCT_PROPERTY_OVERRIDES += \ + qemu.hw.mainkeys=1 + +# Let everything know we're running inside a container +PRODUCT_PROPERTY_OVERRIDES += \ + ro.anbox=1 \ + ro.boot.container=1 + +# We don't want telephony support for now +PRODUCT_PROPERTY_OVERRIDES += \ + ro.radio.noril=yes + +# Disable boot-animation permanently +PRODUCT_PROPERTY_OVERRIDES += \ + debug.sf.nobootanimation=1 + +DEVICE_PACKAGE_OVERLAYS += \ + vendor/anbox/products/overlay + +$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk) +# Extend heap size we use for dalvik/art runtime +$(call inherit-product, frameworks/native/build/tablet-10in-xhdpi-2048-dalvik-heap.mk) + +PRODUCT_COPY_FILES += \ + vendor/anbox/products/anbox.xml:system/etc/permissions/anbox.xml diff --git a/src/type3_AndroidCloud/anbox-master/products/anbox.xml b/src/type3_AndroidCloud/anbox-master/products/anbox.xml new file mode 100644 index 0000000..c3ad9bb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/anbox.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/type3_AndroidCloud/anbox-master/products/anbox_arm64.mk b/src/type3_AndroidCloud/anbox-master/products/anbox_arm64.mk new file mode 100644 index 0000000..e535271 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/anbox_arm64.mk @@ -0,0 +1,24 @@ +# +# Copyright (C) 2013 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +$(call inherit-product, $(LOCAL_PATH)/arm64/device.mk) +$(call inherit-product, $(LOCAL_PATH)/anbox.mk) + +PRODUCT_NAME := anbox_arm64 +# We're using device/generic/arm64/BoardConfig.mk here +PRODUCT_DEVICE := arm64 +PRODUCT_BRAND := Android +PRODUCT_MODEL := Anbox diff --git a/src/type3_AndroidCloud/anbox-master/products/anbox_armv7a_neon.mk b/src/type3_AndroidCloud/anbox-master/products/anbox_armv7a_neon.mk new file mode 100644 index 0000000..7f83a5e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/anbox_armv7a_neon.mk @@ -0,0 +1,27 @@ +# +# Copyright (C) 2013 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +$(call inherit-product, $(LOCAL_PATH)/armv7-a-neon/device.mk) +$(call inherit-product, $(LOCAL_PATH)/anbox.mk) + +# Enable low-mem related options (see https://source.android.com/devices/tech/config/low-ram) +PRODUCT_PROPERTY_OVERRIDES += ro.config.low_ram=true +PRODUCT_PROPERTY_OVERRIDES += dalvik.vm.jit.codecachesize=0 + +PRODUCT_NAME := anbox_armv7a_neon +PRODUCT_DEVICE := armv7-a-neon +PRODUCT_BRAND := Android +PRODUCT_MODEL := Anbox diff --git a/src/type3_AndroidCloud/anbox-master/products/anbox_x86_64.mk b/src/type3_AndroidCloud/anbox-master/products/anbox_x86_64.mk new file mode 100644 index 0000000..b0f0789 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/anbox_x86_64.mk @@ -0,0 +1,25 @@ +# +# Copyright (C) 2013 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) +$(call inherit-product, $(LOCAL_PATH)/x86_64/device.mk) + +$(call inherit-product, $(LOCAL_PATH)/anbox.mk) + +PRODUCT_NAME := anbox_x86_64 +PRODUCT_DEVICE := x86_64 +PRODUCT_BRAND := Android +PRODUCT_MODEL := Anbox diff --git a/src/type3_AndroidCloud/anbox-master/products/arm64/BoardConfig.mk b/src/type3_AndroidCloud/anbox-master/products/arm64/BoardConfig.mk new file mode 100644 index 0000000..df9f8b4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/arm64/BoardConfig.mk @@ -0,0 +1,53 @@ +# config.mk +# +# Product-specific compile-time definitions. +# + +# The generic product target doesn't have any hardware-specific pieces. +TARGET_NO_BOOTLOADER := true +TARGET_NO_KERNEL := true + +TARGET_ARCH := arm64 +TARGET_ARCH_VARIANT := armv8-a +TARGET_CPU_VARIANT := generic +TARGET_CPU_ABI := arm64-v8a + +# TARGET_2ND_ARCH := arm +# TARGET_2ND_ARCH_VARIANT := armv7-a-neon +# TARGET_2ND_CPU_VARIANT := cortex-a15 +# TARGET_2ND_CPU_ABI := armeabi-v7a +# TARGET_2ND_CPU_ABI2 := armeabi + +AUDIOSERVER_MULTILIB := 64 + +TARGET_USES_64_BIT_BINDER := true + +SMALLER_FONT_FOOTPRINT := true +MINIMAL_FONT_FOOTPRINT := true +# Some framework code requires this to enable BT +BOARD_HAVE_BLUETOOTH := true +BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/generic/common/bluetooth + +BOARD_USES_GENERIC_AUDIO := true + +USE_CAMERA_STUB := true + +BUILD_EMULATOR_OPENGL := true +USE_OPENGL_RENDERER := true + +BOARD_USE_LEGACY_UI := true + +# Enable dex-preoptimization to speed up the first boot sequence +# of an SDK AVD. Note that this operation only works on Linux for now +ifeq ($(HOST_OS),linux) +WITH_DEXPREOPT ?= true +endif + +# PDK does not use ext4 image, but it is added here to prevent build break. +TARGET_USERIMAGES_USE_EXT4 := true +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 # 2 GB +BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 +BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016 +BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 +BOARD_FLASH_BLOCK_SIZE := 512 +TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true diff --git a/src/type3_AndroidCloud/anbox-master/products/arm64/device.mk b/src/type3_AndroidCloud/anbox-master/products/arm64/device.mk new file mode 100644 index 0000000..69f26ac --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/arm64/device.mk @@ -0,0 +1,25 @@ +# +# Copyright (C) 2013 The Android Open-Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Copy the 64-bit primary, 32-bit secondary zygote startup script +PRODUCT_COPY_FILES += system/core/rootdir/init.zygote64.rc:root/init.zygote64.rc + +# Set the zygote property to select the 64-bit primary, 32-bit secondary script +# This line must be parsed before the one in core_minimal.mk +PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.zygote=zygote64 + +TARGET_SUPPORTS_32_BIT_APPS := false +TARGET_SUPPORTS_64_BIT_APPS := true diff --git a/src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/BoardConfig.mk b/src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/BoardConfig.mk new file mode 100644 index 0000000..2f096fb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/BoardConfig.mk @@ -0,0 +1,47 @@ +# config.mk +# +# Product-specific compile-time definitions. +# + +# The generic product target doesn't have any hardware-specific pieces. +TARGET_NO_BOOTLOADER := true +TARGET_NO_KERNEL := true +TARGET_ARCH := arm + +TARGET_ARCH_VARIANT := armv7-a-neon +TARGET_CPU_VARIANT := generic +TARGET_CPU_ABI := armeabi-v7a +TARGET_CPU_ABI2 := armeabi + +TARGET_USES_64_BIT_BINDER := true + +SMALLER_FONT_FOOTPRINT := true +MINIMAL_FONT_FOOTPRINT := true +# Some framework code requires this to enable BT +BOARD_HAVE_BLUETOOTH := true +BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/generic/common/bluetooth + +BOARD_USES_GENERIC_AUDIO := true + +USE_CAMERA_STUB := true + +BUILD_EMULATOR_OPENGL := true +USE_OPENGL_RENDERER := true + +BOARD_USE_LEGACY_UI := true + +# Enable dex-preoptimization to speed up the first boot sequence +# of an SDK AVD. Note that this operation only works on Linux for now +ifeq ($(HOST_OS),linux) +WITH_DEXPREOPT ?= true +endif + +TARGET_USERIMAGES_USE_EXT4 := true +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 # 2 GB +BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 +BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016 +BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 +BOARD_FLASH_BLOCK_SIZE := 512 +TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true + +BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy diff --git a/src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/device.mk b/src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/device.mk new file mode 100644 index 0000000..101f432 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/armv7-a-neon/device.mk @@ -0,0 +1 @@ +# Nothing yet diff --git a/src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml new file mode 100644 index 0000000..ada952c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SettingsProvider/res/values/defaults.xml @@ -0,0 +1,24 @@ + + + + + false + + true + + true + true + diff --git a/src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SystemUI/res/values/config.xml b/src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SystemUI/res/values/config.xml new file mode 100644 index 0000000..2197015 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/overlay/frameworks/base/packages/SystemUI/res/values/config.xml @@ -0,0 +1,22 @@ + + + + + + com.android.systemui.statusbar.tv.TvStatusBar + + false + diff --git a/src/type3_AndroidCloud/anbox-master/products/vendorsetup.sh b/src/type3_AndroidCloud/anbox-master/products/vendorsetup.sh new file mode 100644 index 0000000..8be12b5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/vendorsetup.sh @@ -0,0 +1,6 @@ +add_lunch_combo anbox_x86_64-userdebug +add_lunch_combo anbox_x86_64-user +add_lunch_combo anbox_armv7a_neon-userdebug +add_lunch_combo anbox_armv7a_neon-user +add_lunch_combo anbox_arm64-userdebug +add_lunch_combo anbox_arm64-user diff --git a/src/type3_AndroidCloud/anbox-master/products/x86_64/BoardConfig.mk b/src/type3_AndroidCloud/anbox-master/products/x86_64/BoardConfig.mk new file mode 100644 index 0000000..824a8bc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/x86_64/BoardConfig.mk @@ -0,0 +1,36 @@ +TARGET_NO_BOOTLOADER := true +TARGET_NO_KERNEL := true +TARGET_CPU_ABI := x86_64 +TARGET_ARCH := x86_64 +TARGET_ARCH_VARIANT := x86_64 +TARGET_PRELINK_MODULE := false + +TARGET_2ND_CPU_ABI := x86 +TARGET_2ND_ARCH := x86 +TARGET_2ND_ARCH_VARIANT := x86 + +TARGET_USES_64_BIT_BINDER := true + +# no hardware camera +USE_CAMERA_STUB := true + +# Enable dex-preoptimization to speed up the first boot sequence +# of an SDK AVD. Note that this operation only works on Linux for now +ifeq ($(HOST_OS),linux) +WITH_DEXPREOPT ?= true +endif + +# Build OpenGLES emulation host and guest libraries +BUILD_EMULATOR_OPENGL := true + +# Build and enable the OpenGL ES View renderer. When running on the emulator, +# the GLES renderer disables itself if host GL acceleration isn't available. +USE_OPENGL_RENDERER := true + +TARGET_USERIMAGES_USE_EXT4 := true +BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 # 2 GB +BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 +BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016 +BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 +BOARD_FLASH_BLOCK_SIZE := 512 +TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true diff --git a/src/type3_AndroidCloud/anbox-master/products/x86_64/device.mk b/src/type3_AndroidCloud/anbox-master/products/x86_64/device.mk new file mode 100644 index 0000000..101f432 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/products/x86_64/device.mk @@ -0,0 +1 @@ +# Nothing yet diff --git a/src/type3_AndroidCloud/anbox-master/scripts/anbox-bridge.sh b/src/type3_AndroidCloud/anbox-master/scripts/anbox-bridge.sh new file mode 100644 index 0000000..1546990 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/anbox-bridge.sh @@ -0,0 +1,182 @@ +#!/bin/sh +# Copyright (C) 2016 The Linux Containers Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Taken from https://github.com/lxc/lxd-pkg-ubuntu/blob/dpm-xenial/lxd-bridge/lxd-bridge +# but modified for the use within anbox. + +varrun="/run/anbox" + +if [ -n "$SNAP_DATA" ]; then + varrun="$SNAP_DATA"/network +fi + +BRIDGE="anbox0" + +# IPv4 +IPV4_ADDR="192.168.250.1" +IPV4_NETMASK="255.255.255.0" +IPV4_NETWORK="192.168.250.1/24" +IPV4_BROADCAST="0.0.0.0" +IPV4_NAT="true" + +if [ -n "$SNAP" ]; then + snap_ipv4_address=$(snapctl get bridge.address) + snap_ipv4_netmask=$(snapctl get bridge.netmask) + snap_ipv4_network=$(snapctl get bridge.network) + snap_ipv4_broadcast=$(snapctl get bridge.broadcast) + snap_enable_nat=$(snapctl get bridge.nat.enable) + if [ -n "$snap_ipv4_address" ]; then + IPV4_ADDR="$snap_ipv4_address" + fi + if [ -n "$snap_ipv4_netmask" ]; then + IPV4_NETMASK="$snap_ipv4_netmask" + fi + if [ -n "$snap_ipv4_network" ]; then + IPV4_NETWORK="$snap_ipv4_network" + fi + if [ -n "$snap_ipv4_broadcast" ]; then + IPV4_BROADCAST="$snap_ipv4_broadcast" + fi + if [ "$snap_enable_nat" = false ]; then + IPV4_NAT="false" + fi +fi + +use_iptables_lock="-w" +iptables -w -L -n > /dev/null 2>&1 || use_iptables_lock="" + +_netmask2cidr () { + # Assumes there's no "255." after a non-255 byte in the mask + local x=${1##*255.} + set -- "0^^^128^192^224^240^248^252^254^" "$(( (${#1} - ${#x})*2 ))" "${x%%.*}" + x=${1%%${3}*} + echo $(( ${2} + (${#x}/4) )) +} + +ifdown() { + ip addr flush dev "${1}" + ip link set dev "${1}" down +} + +ifup() { + [ "${HAS_IPV6}" = "true" ] && [ "${IPV6_PROXY}" = "true" ] && ip addr add fe80::1/64 dev "${1}" + if [ -n "${IPV4_NETMASK}" ] && [ -n "${IPV4_ADDR}" ]; then + MASK=$(_netmask2cidr ${IPV4_NETMASK}) + CIDR_ADDR="${IPV4_ADDR}/${MASK}" + ip addr add "${CIDR_ADDR}" broadcast "${IPV4_BROADCAST}" dev "${1}" + fi + ip link set dev "${1}" up +} + +start() { + [ ! -f "${varrun}/network_up" ] || { echo "anbox-bridge is already running"; exit 1; } + + if [ -d /sys/class/net/${BRIDGE} ]; then + stop force 2>/dev/null || true + fi + + FAILED=1 + + cleanup() { + set +e + if [ "${FAILED}" = "1" ]; then + echo "Failed to setup anbox-bridge." >&2 + stop force + fi + } + + trap cleanup EXIT HUP INT TERM + set -e + + # set up the anbox network + [ ! -d "/sys/class/net/${BRIDGE}" ] && ip link add dev "${BRIDGE}" type bridge + + # if we are run from systemd on a system with selinux enabled, + # the mkdir will create /run/anbox as init_var_run_t which dnsmasq + # can't write its pid into, so we restorecon it (to var_run_t) + if [ ! -d "${varrun}" ]; then + mkdir -p "${varrun}" + if which restorecon >/dev/null 2>&1; then + restorecon "${varrun}" + fi + fi + + ifup "${BRIDGE}" "${IPV4_ADDR}" "${IPV4_NETMASK}" + + IPV4_ARG="" + if [ -n "${IPV4_ADDR}" ] && [ -n "${IPV4_NETMASK}" ] && [ -n "${IPV4_NETWORK}" ]; then + echo 1 > /proc/sys/net/ipv4/ip_forward + if [ "${IPV4_NAT}" = "true" ]; then + iptables "${use_iptables_lock}" -t nat -A POSTROUTING -s "${IPV4_NETWORK}" ! -d "${IPV4_NETWORK}" -j MASQUERADE -m comment --comment "managed by anbox-bridge" + fi + fi + + iptables "${use_iptables_lock}" -I INPUT -i "${BRIDGE}" -p udp --dport 67 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables "${use_iptables_lock}" -I INPUT -i "${BRIDGE}" -p tcp --dport 67 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables "${use_iptables_lock}" -I INPUT -i "${BRIDGE}" -p udp --dport 53 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables "${use_iptables_lock}" -I INPUT -i "${BRIDGE}" -p tcp --dport 53 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables "${use_iptables_lock}" -I FORWARD -i "${BRIDGE}" -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables "${use_iptables_lock}" -I FORWARD -o "${BRIDGE}" -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables "${use_iptables_lock}" -t mangle -A POSTROUTING -o "${BRIDGE}" -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill -m comment --comment "managed by anbox-bridge" + + touch "${varrun}/network_up" + FAILED=0 +} + +stop() { + [ -f "${varrun}/network_up" ] || [ "${1}" = "force" ] || { echo "anbox-bridge isn't running"; exit 1; } + + if [ -d /sys/class/net/${BRIDGE} ]; then + ifdown ${BRIDGE} + iptables ${use_iptables_lock} -D INPUT -i ${BRIDGE} -p udp --dport 67 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables ${use_iptables_lock} -D INPUT -i ${BRIDGE} -p tcp --dport 67 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables ${use_iptables_lock} -D INPUT -i ${BRIDGE} -p udp --dport 53 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables ${use_iptables_lock} -D INPUT -i ${BRIDGE} -p tcp --dport 53 -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables ${use_iptables_lock} -D FORWARD -i ${BRIDGE} -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables ${use_iptables_lock} -D FORWARD -o ${BRIDGE} -j ACCEPT -m comment --comment "managed by anbox-bridge" + iptables ${use_iptables_lock} -t mangle -D POSTROUTING -o ${BRIDGE} -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill -m comment --comment "managed by anbox-bridge" + + if [ -n "${IPV4_NETWORK}" ] && [ "${IPV4_NAT}" = "true" ]; then + iptables ${use_iptables_lock} -t nat -D POSTROUTING -s ${IPV4_NETWORK} ! -d ${IPV4_NETWORK} -j MASQUERADE -m comment --comment "managed by anbox-bridge" + fi + + # if ${BRIDGE} has attached interfaces, don't destroy the bridge + ls /sys/class/net/${BRIDGE}/brif/* > /dev/null 2>&1 || ip link delete "${BRIDGE}" + fi + + rm -f "${varrun}/network_up" +} + +# See how we were called. +case "${1}" in + start) + start + ;; + + stop) + stop + ;; + + restart|reload|force-reload) + ${0} stop + ${0} start + ;; + + *) + echo "Usage: ${0} {start|stop|restart|reload|force-reload}" + exit 2 +esac + +exit $? diff --git a/src/type3_AndroidCloud/anbox-master/scripts/anbox-init.sh b/src/type3_AndroidCloud/anbox-master/scripts/anbox-init.sh new file mode 100644 index 0000000..e6fc1af --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/anbox-init.sh @@ -0,0 +1,40 @@ +#!/system/bin/sh +# Copyright (C) 2016 Simon Fels +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranties of +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +set -x + +function prepare_filesystem() { + # These dev files need to be adjusted everytime as they are + # bind mounted into the temporary rootfs + for f in qemu_pipe qemu_trace goldfish_pipe input/* ; do + if [ ! -e "/dev/$f" ] ; then + continue + fi + chown system:system /dev/$f + chmod 0666 /dev/$f + done + + if [ -e "/dev/tun" ] ; then + chown system:vpn /dev/tun + chmod 0660 /dev/tun + fi +} + +prepare_filesystem & +echo "Waiting for filesystem being prepared ..." +wait $! + +echo "Starting real init now ..." +exec /init diff --git a/src/type3_AndroidCloud/anbox-master/scripts/anbox-shell.sh b/src/type3_AndroidCloud/anbox-master/scripts/anbox-shell.sh new file mode 100644 index 0000000..10016f0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/anbox-shell.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +if [ "$(id -u)" -ne 0 ]; then + echo "ERROR: You need to run this script as root!" + exit 1 +fi + +CONTAINER_PATH="$SNAP_COMMON/containers" +CONTAINER_NAME=default + +if [ -z "$SNAP" ] ; then + CONTAINER_PATH=/var/lib/anbox/containers +fi + +state=$(lxc-info -P "$CONTAINER_PATH" -n "$CONTAINER_NAME" -s | cut -d':' -f 2 | tr -d '[:space:]') +if [ "$state" != "RUNNING" ] ; then + echo "ERROR: Cannot attach to container as it is not running" + exit 1 +fi + +echo "NOTE: This shell will give you full root access inside the Android" +echo " container. Be careful with what you're doing!" +echo + +exec lxc-attach \ + -q \ + --clear-env \ + -P "$CONTAINER_PATH" \ + -n "$CONTAINER_NAME" \ + -v PATH=/sbin:/system/bin:/system/sbin:/system/xbin \ + -v ANDROID_ASSETS=/assets \ + -v ANDROID_DATA=/data \ + -v ANDROID_ROOT=/system \ + -v ANDROID_STORAGE=/storage \ + -v ASEC_MOUNTPOINT=/mnt/asec \ + -v EXTERNAL_STORAGE=/sdcard -- /system/bin/sh diff --git a/src/type3_AndroidCloud/anbox-master/scripts/android-sync.sh b/src/type3_AndroidCloud/anbox-master/scripts/android-sync.sh new file mode 100644 index 0000000..a3b23de --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/android-sync.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -ex + +if [ -z "$ANDROID_PRODUCT_OUT" ]; then + echo "ANDROID_PRODUCT_OUT is not set!" + exit 1 +fi + +target=$1 +if [ -z "$target" ]; then + echo "No target path provided!" + exit 1 +fi + +sudo cp -rv $ANDROID_PRODUCT_OUT/system $target +sudo rm /var/lib/anbox/rootfs/.anbox_setup_done diff --git a/src/type3_AndroidCloud/anbox-master/scripts/app-android-settings.sh b/src/type3_AndroidCloud/anbox-master/scripts/app-android-settings.sh new file mode 100644 index 0000000..78a5fa4 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/app-android-settings.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +PACKAGE=com.android.settings + +exec $SNAP/bin/anbox-wrapper.sh launch \ + --package="$PACKAGE" diff --git a/src/type3_AndroidCloud/anbox-master/scripts/app-appmgr.sh b/src/type3_AndroidCloud/anbox-master/scripts/app-appmgr.sh new file mode 100644 index 0000000..ef18be0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/app-appmgr.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +PACKAGE=org.anbox.appmgr +COMPONENT=org.anbox.appmgr.AppViewActivity + +exec $SNAP/bin/anbox-wrapper.sh launch \ + --package="$PACKAGE" \ + --component="$COMPONENT" diff --git a/src/type3_AndroidCloud/anbox-master/scripts/build-debs.sh b/src/type3_AndroidCloud/anbox-master/scripts/build-debs.sh new file mode 100644 index 0000000..b750ca0 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/build-debs.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -ex + +debuild_args="$@" + +if [ -z "$BUILD_ID" ]; then + BUILD_ID=1 +fi + +build_and_publish_package() { + dir="$1" + distro="$2" + ppa="$3" + + cd $dir + + git checkout -- debian/changelog + + # Bump the current version by a minor number. Having the distro parse + # at the end with current date, git rev and build id will do the rest. + new_base_version=$(dpkg-parsechangelog --show-field Version).1 + dch --newversion "$new_base_version~$(date +%Y%m%d).$BUILD_ID.$distro.$(git rev-parse --short HEAD)" \ + -D "$distro" "Nightly release" + + debuild -S -sa -I "$debuild_args" + cd .. + dput "$ppa" *.changes +} + +top_dir="$PWD" + +build_and_publish_package "$top_dir" xenial "ppa:morphis/anbox-support" +build_and_publish_package "$top_dir" bionic "ppa:morphis/anbox-support" diff --git a/src/type3_AndroidCloud/anbox-master/scripts/build-with-docker.sh b/src/type3_AndroidCloud/anbox-master/scripts/build-with-docker.sh new file mode 100644 index 0000000..51d0359 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/build-with-docker.sh @@ -0,0 +1,3 @@ +#!/bin/sh +docker build -t anbox/anbox-builder . +docker run --rm -v $PWD:/anbox anbox/anbox-builder /anbox/scripts/clean-build.sh diff --git a/src/type3_AndroidCloud/anbox-master/scripts/clean-build.sh b/src/type3_AndroidCloud/anbox-master/scripts/clean-build.sh new file mode 100644 index 0000000..d31589b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/clean-build.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -ex + +cleanup() { + # In cases where anbox comes directly from a checked out Android + # build environment we miss some symlinks which are present on + # the host and don't have a valid git repository in that case. + if [ -d .git ] ; then + git clean -fdx . + git reset --hard + fi +} + +cleanup + +mkdir build || rm -rf build/* +cd build +cmake .. +VERBOSE=1 make -j10 +VERBOSE=1 make test +cd .. diff --git a/src/type3_AndroidCloud/anbox-master/scripts/clean-format.sh b/src/type3_AndroidCloud/anbox-master/scripts/clean-format.sh new file mode 100644 index 0000000..0f8c4ce --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/clean-format.sh @@ -0,0 +1,3 @@ +#!/bin/sh +find src -name "*.h" | xargs clang-format -style=file -i +find src -name "*.cpp" | xargs clang-format -style=file -i diff --git a/src/type3_AndroidCloud/anbox-master/scripts/collect-bug-info.sh b/src/type3_AndroidCloud/anbox-master/scripts/collect-bug-info.sh new file mode 100644 index 0000000..afc04e9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/collect-bug-info.sh @@ -0,0 +1,57 @@ +#!/bin/sh -e + +TMPDIR=$(mktemp -d) + +if [ $(id -u) -ne 0 ] ; then + echo "WARNING: You're not running as root. This will prevent the script from" + echo " adding a few important file for bug diagnostics to the report." + echo " If you want to have a look at the script before giving it root" + echo " access, please have a look at $0." + exit 0 +fi + +echo "This script will collect a few interesting things which developers will" +echo "need to have a better insight into the Anbox system when something goes" +echo "wrong." +echo +echo "PLEASE NOTE: The collected log files may collect information about your" +echo "system. Please have a look before you're sending them to anyone!" +echo +echo "Collecting anbox log files ... " + +set -x +# Collect several things which are of interest for bug reports +cp /var/snap/anbox/common/data/system.log $TMPDIR || true +cp /var/snap/anbox/common/containers/lxc-monitord.log $TMPDIR || true +cp /var/snap/anbox/common/logs/container.log $TMPDIR || true +cp /var/snap/anbox/common/logs/console.log* $TMPDIR || true +$SNAP/command-anbox.wrapper system-info > $TMPDIR/system-info.log 2>&1 || true + +if [ -e /etc/systemd/system/snap.anbox.container-manager.service ]; then + sudo journalctl --no-pager -u snap.anbox.container-manager.service > $TMPDIR/container-manager.log 2>&1 || true +fi +set +x + +echo +echo "DONE!" + +echo +echo "Do you want to include the kernel log of your system? [y/N]" +read -r action +if [ "$action" = "y" ]; then + set -x + dmesg > $TMPDIR/kernel.log 2>&1 + set +x +fi + +echo "Generating archive with all log files in $PWD ..." +CURDIR=$PWD +(cd $TMPDIR; zip -r $CURDIR/anbox-system-diagnostics-$(date --rfc-3339=date --utc).zip *) +rm -rf $TMPDIR +echo "DONE!" + +echo +echo "Now please take the ZIP archive generated in your current directory" +echo "and attach it to your bug report. Please don't hesitate to have a" +echo "look into the archive before you do so to verify you don't leak any" +echo "information you don't want!" diff --git a/src/type3_AndroidCloud/anbox-master/scripts/container-manager.sh b/src/type3_AndroidCloud/anbox-master/scripts/container-manager.sh new file mode 100644 index 0000000..4361121 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/container-manager.sh @@ -0,0 +1,124 @@ +#!/bin/bash +set -x + +# We need to put the rootfs somewhere where we can modify some +# parts of the content on first boot (namely file permissions). +# Other than that nothing should ever modify the content of the +# rootfs. + +DATA_PATH=$SNAP_COMMON/ +ANDROID_IMG=$SNAP/android.img + +if [ "$(id -u)" != 0 ]; then + echo "ERROR: You need to run the container manager as root" + exit 1 +fi + +if [ ! -e "$ANDROID_IMG" ]; then + echo "ERROR: android image does not exist" + exit 1 +fi + +if [ "$SNAP_ARCH" = "amd64" ]; then + ARCH="x86_64-linux-gnu" +elif [ "$SNAP_ARCH" = "armhf" ]; then + ARCH="arm-linux-gnueabihf" +else + ARCH="$SNAP_ARCH-linux-gnu" +fi + +# Re-exec outside of apparmor confinement +if [ -d /sys/kernel/security/apparmor ] && [ "$(cat /proc/self/attr/current)" != "unconfined" ]; then + exec /usr/sbin/aa-exec -p unconfined -- "$0" "$@" +fi + +start() { + # Make sure our setup path for the container rootfs + # is present as lxc is statically configured for + # this path. + mkdir -p "$SNAP_COMMON/lxc" + + # We start the bridge here as long as a oneshot service unit is not + # possible. See snapcraft.yaml for further details. + "$SNAP"/bin/anbox-bridge.sh start + + # Ensure FUSE support for user namespaces is enabled + echo Y | tee /sys/module/fuse/parameters/userns_mounts || echo "WARNING: kernel doesn't support fuse in user namespaces" + + # liblxc.so.1 is in $SNAP/lib + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/liblxc" + + # For unknown reason we got bug reports that the container manager failed to start + # because it cannot find libboost_log.so.1.58.0 To mitigate this we're adding the + # lib directory as explicit search target here. + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/usr/lib/$ARCH" + + enable_debug="$(snapctl get debug.enable)" + if [ "$enable_debug" = true ]; then + export ANBOX_LOG_LEVEL=debug + export LD_DEBUG=libs + fi + + EXTRA_ARGS= + enable_rootfs_overlay="$(snapctl get rootfs-overlay.enable)" + if [ "$enable_rootfs_overlay" = true ]; then + EXTRA_ARGS="$EXTRA_ARGS --use-rootfs-overlay" + fi + + enable_privileged_container="$(snapctl get container.privileged)" + if [ "$enable_privileged_container" = true ]; then + EXTRA_ARGS="$EXTRA_ARGS --privileged" + fi + + container_network_address=$(snapctl get container.network.address) + if [ -n "$container_network_address" ]; then + EXTRA_ARGS="$EXTRA_ARGS --container-network-address=$container_network_address" + fi + + container_network_gateway=$(snapctl get container.network.gateway) + if [ -n "$container_network_gateway" ]; then + EXTRA_ARGS="$EXTRA_ARGS --container-network-gateway=$container_network_gateway" + fi + + container_network_dns=$(snapctl get container.network.dns) + if [ -n "$container_network_dns" ]; then + EXTRA_ARGS="$EXTRA_ARGS --container-network-dns-servers=$container_network_dns" + fi + + # Load all relevant kernel modules + modprobe binder_linux + modprobe ashmem_linux + + # Ensure we have binderfs mounted when our kernel supports it + if cat /proc/filesystems | grep -q binder ; then + mkdir -p "$SNAP_COMMON"/binderfs + # Remove old mounts so that we start fresh without any devices allocated + if cat /proc/mounts | grep -q "binder $SNAP_COMMON/binderfs" ; then + umount "$SNAP_COMMON"/binderfs + fi + mount -t binder none "$SNAP_COMMON"/binderfs + fi + + exec "$SNAP"/bin/anbox-wrapper.sh container-manager \ + --data-path="$DATA_PATH" \ + --android-image="$ANDROID_IMG" \ + --daemon \ + $EXTRA_ARGS +} + +stop() { + "$SNAP"/bin/anbox-bridge.sh stop +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + *) + echo "ERROR: Unknown command '$1'" + exit 1 + ;; +esac diff --git a/src/type3_AndroidCloud/anbox-master/scripts/create-package.sh b/src/type3_AndroidCloud/anbox-master/scripts/create-package.sh new file mode 100644 index 0000000..231b477 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/create-package.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -ex + +ramdisk=$1 +system=$2 +image=${3:-android.img} + +if [ -z "$ramdisk" ] || [ -z "$system" ]; then + echo "Usage: $0 []" + exit 1 +fi + +workdir=`mktemp -d` +rootfs=$workdir/rootfs + +mkdir -p $rootfs + +# Extract ramdisk and preserve ownership of files +(cd $rootfs ; cat $ramdisk | gzip -d | sudo cpio -i) + +mkdir $workdir/system +sudo mount -o loop,ro $system $workdir/system +sudo cp -ar $workdir/system/* $rootfs/system +sudo umount $workdir/system + +gcc -o $workdir/uidmapshift external/nsexec/uidmapshift.c +sudo $workdir/uidmapshift -b $rootfs 0 100000 65536 + +# FIXME +sudo chmod +x $rootfs/anbox-init.sh + +sudo mksquashfs $rootfs $image -comp xz -no-xattrs +sudo chown $USER:$USER $image + +sudo rm -rf $workdir diff --git a/src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-entries.py b/src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-entries.py new file mode 100644 index 0000000..b88137e --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-entries.py @@ -0,0 +1,482 @@ +#!/usr/bin/env python2 + +# Copyright 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Utility functions used to parse a list of DLL entry points. +# Expected format: +# +# -> ignored +# # -> ignored +# % -> verbatim output for header files. +# ! -> prefix name for header files. +# ; -> entry point declaration. +# +# Anything else is an error. + +from __future__ import print_function +import re +import sys +import argparse + +re_func = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)\((.*)\);$""") +re_param = re.compile(r"""^(.*[\* ])([A-Za-z_][A-Za-z0-9_]*)$""") + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + +class Entry: + """Small class used to model a single DLL entry point.""" + def __init__(self, func_name, return_type, parameters): + """Initialize Entry instance. |func_name| is the function name, + |return_type| its return type, and |parameters| is a list of + (type,name) tuples from the entry's signature. + """ + self.func_name = func_name + self.return_type = return_type + self.parameters = "" + self.vartypes = [] + self.varnames = [] + self.call = "" + comma = "" + for param in parameters: + self.vartypes.append(param[0]) + self.varnames.append(param[1]) + self.parameters += "%s%s %s" % (comma, param[0], param[1]) + self.call += "%s%s" % (comma, param[1]) + comma = ", " + +def banner_command(argv): + """Return sanitized command-line description. + |argv| must be a list of command-line parameters, e.g. sys.argv. + Return a string corresponding to the command, with platform-specific + paths removed.""" + + # Remove path from first parameter + argv = argv[:] + argv[0] = "android/scripts/gen-entries.py" + return ' '.join(argv) + +def parse_entries_file(lines): + """Parse an .entries file and return a tuple of: + entries: list of Entry instances from the file. + prefix_name: prefix name from the file, or None. + verbatim: list of verbatim lines from the file. + errors: list of errors in the file, prefixed by line number. + """ + entries = [] + verbatim = [] + errors = [] + lineno = 0 + prefix_name = None + for line in lines: + lineno += 1 + line = line.strip() + if len(line) == 0: # Ignore empty lines + continue + if line[0] == '#': # Ignore comments + continue + if line[0] == '!': # Prefix name + prefix_name = line[1:] + continue + if line[0] == '%': # Verbatim line copy + verbatim.append(line[1:]) + continue + # Must be a function signature. + m = re_func.match(line) + if not m: + errors.append("%d: '%s'" % (lineno, line)) + continue + + return_type, func_name, parameters = m.groups() + return_type = return_type.strip() + parameters = parameters.strip() + params = [] + failure = False + if parameters != "void": + for parameter in parameters.split(','): + parameter = parameter.strip() + m = re_param.match(parameter) + if not m: + errors.append("%d: parameter '%s'" % (lineno, parameter)) + failure = True + break + else: + param_type, param_name = m.groups() + params.append((param_type.strip(), param_name.strip())) + + if not failure: + entries.append(Entry(func_name, return_type, params)) + + return (entries, prefix_name, verbatim, errors) + + +def gen_functions_header(entries, prefix_name, verbatim, filename, with_args): + """Generate a C header containing a macro listing all entry points. + |entries| is a list of Entry instances. + |prefix_name| is a prefix-name, it will be converted to upper-case. + |verbatim| is a list of verbatim lines that must appear before the + macro declaration. Useful to insert #include <> statements. + |filename| is the name of the original file. + """ + prefix_name = prefix_name.upper() + + print("// Auto-generated with: %s" % banner_command(sys.argv)) + print("// DO NOT EDIT THIS FILE") + print("") + print("#ifndef %s_FUNCTIONS_H" % prefix_name) + print("#define %s_FUNCTIONS_H" % prefix_name) + print("") + for line in verbatim: + print(line) + + print("#define LIST_%s_FUNCTIONS(X) \\" % prefix_name) + for entry in entries: + if with_args: + print(" X(%s, %s, (%s), (%s)) \\" % \ + (entry.return_type, entry.func_name, entry.parameters, + entry.call)) + else: + print(" X(%s, %s, (%s)) \\" % \ + (entry.return_type, entry.func_name, entry.parameters)) + + print("") + print("") + print("#endif // %s_FUNCTIONS_H" % prefix_name) + + + +# The purpose of gen_translator() +# is to quickly generate implementations on the host Translator, +# which processes commands that just got onto the renderthread off goldfish pipe +# and are fed to system OpenGL. + +def gen_translator(entries): + # Definitions for custom implementation bodies go in + # android/scripts/gles3translatorgen/gles30_custom.py + # android/scripts/gles3translatorgen/gles31_custom.py + from gles3translatorgen import gles30_custom + from gles3translatorgen import gles31_custom + + translator_custom_share_processing = { } + for (k, v) in gles30_custom.custom_share_processing.items(): + translator_custom_share_processing[k] = v + for (k, v) in gles31_custom.custom_share_processing.items(): + translator_custom_share_processing[k] = v + + translator_custom_pre = { } + for (k, v) in gles30_custom.custom_preprocesses.items(): + translator_custom_pre[k] = v + for (k, v) in gles31_custom.custom_preprocesses.items(): + translator_custom_pre[k] = v + + translator_custom_post = { } + for (k, v) in gles30_custom.custom_postprocesses.items(): + translator_custom_post[k] = v + for (k, v) in gles31_custom.custom_postprocesses.items(): + translator_custom_post[k] = v + + translator_no_passthrough = {} + for (k, v) in gles30_custom.no_passthrough.items(): + translator_no_passthrough[k] = v + for (k, v) in gles31_custom.no_passthrough.items(): + translator_no_passthrough[k] = v + + translator_needexternc = { + "glGetStringi": 1, + "glUniform4ui": 1, + "glGetUniformIndices": 1, + "glTransformFeedbackVaryings": 1, + "glCreateShaderProgramv": 1, + "glProgramUniform2ui": 1, + "glProgramUniform3ui": 1, + "glProgramUniform4ui": 1, + "glBindVertexBuffer": 1, + } + translator_nocontext_fail_codes = { + "glClientWaitSync" : "GL_WAIT_FAILED", + } + def needExternC(entry): + if translator_needexternc.has_key(entry.func_name): + return "extern \"C\" " + else: + return "" + def get_fail_code(entry): + if translator_nocontext_fail_codes.has_key(entry.func_name): + return translator_nocontext_fail_codes[entry.func_name] + else: + return "0" + def gen_cxt_getter(entry): + if (entry.return_type == "void"): + print(" GET_CTX_V2();") + else: + print(" GET_CTX_V2_RET(%s);" % get_fail_code(entry)) + + def gen_validations_custom_impl(entry): + isGen = entry.func_name.startswith("glGen") + isDelete = entry.func_name.startswith("glDelete") + isBufferOp = "Buffer" in entry.func_name + + hasTargetArg = "target" in entry.varnames + hasProgramArg = "program" in entry.varnames + + def mySetError(condition, glerr): + if entry.return_type == "void": + return "SET_ERROR_IF(%s,%s)" % (condition, glerr); + else: + return "RET_AND_SET_ERROR_IF(%s,%s,%s)" % (condition, glerr, get_fail_code(entry)) + + if (isGen or isDelete) and ("n" in entry.varnames): + print(" %s;" % mySetError("n < 0", "GL_INVALID_VALUE")) + if (isBufferOp and hasTargetArg): + print(" %s;" % mySetError("!GLESv2Validate::bufferTarget(ctx, target)", "GL_INVALID_ENUM")) + if translator_custom_pre.has_key(entry.func_name): + print(translator_custom_pre[entry.func_name],) + + def gen_call_ret(entry): + globalNameTypes = { + ("GLuint", "program") : "NamedObjectType::SHADER_OR_PROGRAM", + ("GLuint", "texture") : "NamedObjectType::TEXTURE", + ("GLuint", "buffer") : "NamedObjectType::VERTEXBUFFER", + ("GLuint", "sampler") : "NamedObjectType::SAMPLER", + ("GLuint", "query") : "NamedObjectType::QUERY", + } + globalNames = { + ("GLuint", "program") : "globalProgramName", + ("GLuint", "texture") : "globalTextureName", + ("GLuint", "buffer") : "globalBufferName", + ("GLuint", "sampler") : "globalSampler", + ("GLuint", "query") : "globalQuery", + } + + needsShareGroup = False + for v in zip(entry.vartypes, entry.varnames): + if v in globalNameTypes.keys(): + needsShareGroup = True + + if needsShareGroup: + print(" if (ctx->shareGroup().get()) {") + for key in zip(entry.vartypes, entry.varnames): + vartype, varname = key + if globalNames.has_key(key): + print(" const GLuint %s = ctx->shareGroup()->getGlobalName(%s, %s);" % (globalNames[key], globalNameTypes[key], varname)) + + globalCall = ", ".join(map(lambda k: globalNames.get(k, k[1]), zip(entry.vartypes, entry.varnames))) + + if needsShareGroup and translator_custom_share_processing.has_key(entry.func_name): + print(translator_custom_share_processing[entry.func_name]) + + if (entry.return_type == "void"): + if (needsShareGroup): + print(" "), + + if not translator_no_passthrough.has_key(entry.func_name): + print(" ctx->dispatcher().%s(%s);" % (entry.func_name, globalCall)) + + if needsShareGroup: + print(" }") + if translator_custom_post.has_key(entry.func_name): + print(translator_custom_post[entry.func_name]) + else: + if (needsShareGroup): + print(" "), + if not translator_no_passthrough.has_key(entry.func_name): + print(" %s %s = ctx->dispatcher().%s(%s);" % (entry.return_type, entry.func_name + "RET", entry.func_name, globalCall)) + else: + print(") %s %s = %s" % (entry.return_type, entry_func_name + "RET", get_fail_code(entry))) + + if translator_custom_post.has_key(entry.func_name): + print(translator_custom_post[entry.func_name]) + + print(" return %s;" % (entry.func_name + "RET")) + if needsShareGroup: + print(" } else return %s;" % (get_fail_code(entry))) + + print("// Auto-generated with: %s" % banner_command(sys.argv)) + print("// This file is best left unedited.") + print("// Try to make changes through gen_translator in gen-entries.py,") + print("// and/or parcel out custom functionality in separate code.") + for entry in entries: + print("%sGL_APICALL %s GL_APIENTRY %s(%s) {" % (needExternC(entry), entry.return_type, entry.func_name, entry.parameters)) + gen_cxt_getter(entry) + gen_validations_custom_impl(entry) + gen_call_ret(entry) + print("}\n") + +def gen_dll_wrapper(entries, prefix_name, verbatim, filename): + """Generate a C source file that contains functions that act as wrappers + for entry points located in another shared library. This allows the + code that calls these functions to perform lazy-linking to system + libraries. + |entries|, |prefix_name|, |verbatim| and |filename| are the same as + for gen_functions_header() above. + """ + upper_name = prefix_name.upper() + + ENTRY_PREFIX = "__dll_" + + print("// Auto-generated with: %s" % banner_command(sys.argv)) + print("// DO NOT EDIT THIS FILE") + print("") + print("#include ") + for line in verbatim: + print(line) + + print("") + print("///") + print("/// W R A P P E R P O I N T E R S") + print("///") + print("") + for entry in entries: + ptr_name = ENTRY_PREFIX + entry.func_name + print("static %s (*%s)(%s) = 0;" % \ + (entry.return_type, ptr_name, entry.parameters)) + + print("") + print("///") + print("/// W R A P P E R F U N C T I O N S") + print("///") + print("") + + for entry in entries: + print ("%s %s(%s) {" % \ + (entry.return_type, entry.func_name, entry.parameters)) + ptr_name = ENTRY_PREFIX + entry.func_name + if entry.return_type != "void": + print(" return %s(%s);" % (ptr_name, entry.call)) + else: + print(" %s(%s);" % (ptr_name, entry.call)) + print("}\n") + + print("") + print("///") + print("/// I N I T I A L I Z A T I O N F U N C T I O N") + print("///") + print("") + + print("int %s_dynlink_init(void* lib) {" % prefix_name) + for entry in entries: + ptr_name = ENTRY_PREFIX + entry.func_name + print(" %s = (%s(*)(%s))dlsym(lib, \"%s\");" % \ + (ptr_name, + entry.return_type, + entry.parameters, + entry.func_name)) + print(" if (!%s) return -1;" % ptr_name) + print(" return 0;") + print("}") + + +def gen_windows_def_file(entries): + """Generate a windows DLL .def file. |entries| is a list of Entry instances. + """ + print("EXPORTS") + for entry in entries: + print(" %s" % entry.func_name) + + +def gen_unix_sym_file(entries): + """Generate an ELF linker version file. |entries| is a list of Entry + instances. + """ + print("VERSION {") + print("\tglobal:") + for entry in entries: + print("\t\t%s;" % entry.func_name) + print("\tlocal:") + print("\t\t*;") + print("};") + +def gen_symbols(entries, underscore): + """Generate a list of symbols from |entries|, a list of Entry instances. + |underscore| is a boolean. If True, then prepend an underscore to each + symbol name. + """ + prefix = "" + if underscore: + prefix = "_" + for entry in entries: + print("%s%s" % (prefix, entry.func_name)) + +def parse_file(filename, lines, mode): + """Generate one of possible outputs from |filename|. |lines| must be a list + of text lines from the file, and |mode| is one of the --mode option + values. + """ + entries, prefix_name, verbatim, errors = parse_entries_file(lines) + if errors: + for error in errors: + eprint("ERROR: %s:%s" % (filename, error), file=sys.stderr) + sys.exit(1) + + if not prefix_name: + prefix_name = "unknown" + + if mode == 'def': + gen_windows_def_file(entries) + elif mode == 'sym': + gen_unix_sym_file(entries) + elif mode == 'translator_passthrough': + gen_translator(entries) + elif mode == 'wrapper': + gen_dll_wrapper(entries, prefix_name, verbatim, filename) + elif mode == 'symbols': + gen_symbols(entries, False) + elif mode == '_symbols': + gen_symbols(entries, True) + elif mode == 'functions': + gen_functions_header(entries, prefix_name, verbatim, filename, False) + elif mode == 'funcargs': + gen_functions_header(entries, prefix_name, verbatim, filename, True) + + +# List of valid --mode option values. +mode_list = [ + 'def', 'sym', 'translator_passthrough', 'wrapper', 'symbols', '_symbols', 'functions', 'funcargs' +] + +# Argument parsing. +parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description="""\ +A script used to parse an .entries input file containing a list of function +declarations, and generate various output files depending on the value of +the --mode option, which can be: + + def Generate a windows DLL .def file. + sym Generate a Unix .so linker script. + wrapper Generate a C source file containing wrapper functions. + symbols Generate a simple list of symbols, one per line. + _symbols Generate a simple list of symbols, prefixed with _. + functions Generate a C header containing a macro listing all functions. + funcargs Like 'functions', but adds function call arguments to listing. + +""") +parser.add_argument("--mode", help="Output mode", choices=mode_list) +parser.add_argument("--output", help="output file") +parser.add_argument("file", help=".entries file path") + +args = parser.parse_args() + +if not args.mode: + eprint("ERROR: Please use --mode=, see --help.", file=sys.stderr) + sys.exit(1) + +if args.output: + sys.stdout = open(args.output, "w+") + +if args.file == '--': + parse_file("", sys.stdin, args.mode) +else: + parse_file(args.file, open(args.file), args.mode) diff --git a/src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-headers.sh b/src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-headers.sh new file mode 100644 index 0000000..20aa9d1 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/gen-emugl-headers.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Run this script to re-generate headers with the gen-entries.py script. + +set -e +export LANG=C +export LC_ALL=C + +PROGDIR=$(dirname "$0") +OUTDIR=$1 + +panic () { + echo "ERROR: $@" + exit 1 +} + +if [ -z "$OUTDIR" ]; then + panic "No output dir defined!" +fi + +QEMU_TOP_DIR=$(cd $PROGDIR/../ && pwd -P) +SCRIPT_DIR=scripts +if [ ! -d "$QEMU_TOP_DIR/$SCRIPT_DIR" ]; then + panic "Missing scripts directory: $QEMU_TOP_DIR/$SCRIPT_DIR" +fi + +cd $QEMU_TOP_DIR +GEN_ENTRIES=$SCRIPT_DIR/gen-emugl-entries.py +if [ ! -f "$GEN_ENTRIES" ]; then + panic "Missing script: $GEN_ENTRIES" +fi + +FAILURES= + +# $1: Source file +# $2: Target file +# $3: gen-entries script. +gen_functions_header () { + local SRC_FILE="$1" + local DST_FILE="$2" + local GEN_ENTRIES="$3" + if [ ! -f "$SRC_FILE" ]; then + echo "ERROR: Missing source file: $SRC_FILE" + FAILURES=true + else + echo "Generating $DST_FILE" + $GEN_ENTRIES --mode=functions $SRC_FILE --output=$DST_FILE + fi +} + +# $1: Source file +# $2: Target file +# $3: gen-entries script. +gen_funcargs_header () { + local SRC_FILE="$1" + local DST_FILE="$2" + local GEN_ENTRIES="$3" + if [ ! -f "$SRC_FILE" ]; then + echo "ERROR: Missing source file: $SRC_FILE" + FAILURES=true + else + echo "Generating $DST_FILE" + $GEN_ENTRIES --mode=funcargs $SRC_FILE --output=$DST_FILE + fi +} + + +## +## libOpenGLESDispatch headers. +## +OPENGLES_DISPATCH_SRCDIR=external/android-emugl/host/libs/libOpenGLESDispatch +OPENGLES_DISPATCH_INCLUDE=$OUTDIR/external/android-emugl/host/include/OpenGLESDispatch +mkdir -p $OPENGLES_DISPATCH_INCLUDE + +gen_functions_header \ + "$OPENGLES_DISPATCH_SRCDIR"/render_egl.entries \ + "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_functions.h \ + "$GEN_ENTRIES" + +gen_functions_header \ + "$OPENGLES_DISPATCH_SRCDIR"/render_egl_extensions.entries \ + "$OPENGLES_DISPATCH_INCLUDE"/RenderEGL_extensions_functions.h \ + "$GEN_ENTRIES" + +GLES_ENTRIES="gles_common gles_extensions gles1_only gles1_extensions gles2_only \ +gles2_extensions gles3_only" + +for ENTRY in $GLES_ENTRIES; do + SRC_FILE=$OPENGLES_DISPATCH_SRCDIR/${ENTRY}.entries + DST_FILE=$OPENGLES_DISPATCH_INCLUDE/${ENTRY}_functions.h + gen_funcargs_header "$SRC_FILE" "$DST_FILE" "$GEN_ENTRIES" +done + +if [ "$FAILURES" ]; then + exit 1 +fi diff --git a/src/type3_AndroidCloud/anbox-master/scripts/load-kmods.sh b/src/type3_AndroidCloud/anbox-master/scripts/load-kmods.sh new file mode 100644 index 0000000..12a98a9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/load-kmods.sh @@ -0,0 +1,5 @@ +#!/bin/sh -ex +sudo rmmod binder_linux || true +sudo rmmod ashmem_linux || true +(cd kernel/binder ; make clean && make -j4 ; sudo insmod binder_linux.ko; sudo chmod 666 /dev/binder) +(cd kernel/ashmem ; make clean && make -j4 ; sudo insmod ashmem_linux.ko; sudo chmod 666 /dev/ashmem) diff --git a/src/type3_AndroidCloud/anbox-master/scripts/mount-android.sh b/src/type3_AndroidCloud/anbox-master/scripts/mount-android.sh new file mode 100644 index 0000000..75d2f20 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/mount-android.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +DATA_PATH=/var/lib/anbox +ROOTFS_PATH=$DATA_PATH/rootfs +ANDROID_IMG=$1 +CONTAINER_BASE_UID=100000 +DIR="$(dirname $0)" + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 +fi + +if [ -z "$1" ]; then + echo "Usage:" + echo "./mount-android.sh [Android image]" + exit 1 +fi + +if [ ! -f $ANDROID_IMG ]; then + echo "Android image not found" + exit 1 +fi + +# Setup the read-only rootfs +mkdir -p $ROOTFS_PATH +mount -o loop,ro $ANDROID_IMG $ROOTFS_PATH + +# but certain top-level directories need to be in a writable space +for dir in cache data; do + mkdir -p $DATA_PATH/android-$dir + chown $CONTAINER_BASE_UID:$CONTAINER_BASE_UID $DATA_PATH/android-$dir + mount -o bind $DATA_PATH/android-$dir $ROOTFS_PATH/$dir +done + +$DIR/anbox-bridge.sh start +$DIR/load-kmods.sh diff --git a/src/type3_AndroidCloud/anbox-master/scripts/setup-partial-chroot.sh b/src/type3_AndroidCloud/anbox-master/scripts/setup-partial-chroot.sh new file mode 100644 index 0000000..983a649 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/setup-partial-chroot.sh @@ -0,0 +1,181 @@ +#!/bin/bash +# +# Copyright © 2016 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 3, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# +# Taken from the Mir Project (https://launchpad.net/mir) + +set -e + +name=${0} + +usage() { + echo "Usage: ${name} [options] mychroot-dir" + echo "options:" + echo " -a arch Select architecture, i.e. armhf, arm64, ppc... Default is armhf" + echo " -d dist Select distribution, i.e. vivid, wily. Default is vivid" + echo " -r rep Select an additional repository for bootstrap. Default is none" + echo + echo "please supply at least a directory to create partial chroot in. (eg, ./setup-partial-armhf-chroot.sh mychroot-dir)" +} + +# Default to vivid as we don't seem to have any working wily devices right now. +# Also Jenkins expects this script to default to vivid (TODO: update CI?) +arch=armhf +dist=vivid +sourceid=0 +repositories= +sources= + +while getopts a:d:r:h opt; do + case $opt in + a) + arch=$OPTARG + ;; + d) + dist=$OPTARG + ;; + r) + repositories="$repositories $OPTARG" + ((++sourceid)) + sources="$sources source$sourceid" + ;; + :) + echo "Option -$OPTARG requires an argument" + usage + exit 1 + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 1 + ;; + esac +done + +shift $((OPTIND-1)) + +if [ -z ${1} ]; then + usage + exit 1 +fi + +directory=${1} +echo "creating phablet-compatible $arch partial chroot for anbox compilation in directory ${directory}" + +if [ ! -d ${directory} ]; then + mkdir -p ${directory} +fi + +DEBCONTROL=$(pwd)/../debian/control + +pushd ${directory} > /dev/null + +# Empty dpkg status file, so that ALL dependencies are listed with dpkg-checkbuilddeps +echo "" > status + +# Manual error code checking is needed for dpkg-checkbuilddeps +set +e + +# Parse dependencies from debian/control +# dpkg-checkbuilddeps returns non-zero when dependencies are not met and the list is sent to stderr +builddeps=$(dpkg-checkbuilddeps -a ${arch} --admindir=. ${DEBCONTROL} 2>&1 ) +if [ $? -eq 0 ] ; then + exit 0 +fi +echo "${builddeps}" + +# now turn exit on error option +set -e + +# Sanitize dependencies list for submission to multistrap +# build-essential is not needed as we are cross-compiling +builddeps=$(echo ${builddeps} | sed -e 's/dpkg-checkbuilddeps://g' \ + -e 's/error://g' \ + -e 's/Unmet build dependencies://g' \ + -e 's/build-essential:native//g') +builddeps=$(echo ${builddeps} | sed 's/([^)]*)//g') +builddeps=$(echo ${builddeps} | sed -e 's/abi-compliance-checker//g') +builddeps=$(echo ${builddeps} | sed -e 's/multistrap//g') + +case ${arch} in + amd64 | i386 ) + source_url=http://archive.ubuntu.com/ubuntu + ;; + * ) + source_url=http://ports.ubuntu.com/ubuntu-ports + ;; +esac + +echo "[General] +arch=${arch} +directory=${directory} +unpack=false +noauth=true +bootstrap=Ubuntu UbuntuUpdates UbuntuSecurity ${sources} + +[Ubuntu] +packages=${builddeps} +source=${source_url} +suite=${dist} +components=main universe + +[UbuntuUpdates] +packages=${builddeps} +source=${source_url} +suite=${dist}-updates +components=main universe + +[UbuntuSecurity] +packages=${builddeps} +source=${source_url} +suite=${dist}-security +components=main universe +" > mstrap.conf + +sourceid=0 +for x in ${repositories}; +do + ((++sourceid)) + echo "[source${sourceid}] +source=${x} +suite=${dist} +" >> mstrap.conf +done + +multistrap -f mstrap.conf + +rm -f var/cache/apt/archives/lock + +# Remove libc libraries that confuse the cross-compiler +rm -f var/cache/apt/archives/libc-dev*.deb +rm -f var/cache/apt/archives/libc6*.deb + +for deb in var/cache/apt/archives/* ; do + if [ ! -d ${deb} ] ; then + echo "unpacking: ${deb}" + dpkg -x ${deb} . + fi +done + +# Fix up symlinks which asssumed the usual root path +for broken_symlink in $(find . -name \*.so -type l -xtype l) ; do + ln -sf $(pwd)$(readlink ${broken_symlink}) ${broken_symlink} +done + +popd > /dev/null diff --git a/src/type3_AndroidCloud/anbox-master/scripts/snap-wrapper.sh b/src/type3_AndroidCloud/anbox-master/scripts/snap-wrapper.sh new file mode 100644 index 0000000..4337c61 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/snap-wrapper.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +if [ "$SNAP_ARCH" = "amd64" ]; then + ARCH="x86_64-linux-gnu" +elif [ "$SNAP_ARCH" = "armhf" ]; then + ARCH="arm-linux-gnueabihf" +else + ARCH="$SNAP_ARCH-linux-gnu" +fi + +# With recent builds on Ubuntu 16.04 the snap does not find the path to +# libpulsecommon-8.0.so anymore so we have to teach the linker manually +# where it can be found +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/usr/lib/$ARCH/pulseaudio" + +# liblxc.so.1 is in $SNAP/lib +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/lib" + +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/usr/lib/$ARCH" + +# We set XDG_DATA_HOME to SNAP_USER_COMMON here as this will be the location we will +# create all our application launchers in. The system application launcher will +# be configured by our installer to look into this directory for available +# launchers. +export XDG_DATA_HOME="$SNAP_USER_COMMON/app-data" + +# In order to support GLVND based systems we need to work around a bug in snapd +# as it does not yet expose the EGL vendor configurations from the host to snaps. +# As long as this isn't fixed we have to carry a set of configs on our own which +# may map to the host. GLVND will handle situation properly where a vendor is +# configured but the actual EGL implementation is missing. +export __EGL_VENDOR_LIBRARY_DIRS="$SNAP/glvnd" + +# Suppress "libEGL warning: FIXME: egl/x11 doesn't support front buffer rendering." spam +export EGL_LOG_LEVEL="fatal" + +enable_debug="$(snapctl get debug.enable)" +if [ "$enable_debug" = true ]; then + export ANBOX_LOG_LEVEL=debug +fi + +if [ "$(snapctl get software-rendering.enable)" = true ]; then + export ANBOX_FORCE_SOFTWARE_RENDERING=true +fi + +if [ "$(snapctl get touch-emulation.enable)" = false ]; then + export ANBOX_ENABLE_TOUCH_EMULATION=false +fi + +if [ "$(snapctl get server-side-decoration.enable)" = true ]; then + export ANBOX_FORCE_SERVER_SIDE_DECORATION=true +fi + +# Use custom Anbox binary for debugging purposes if available +ANBOX="$SNAP"/usr/bin/anbox +if [ -e "$SNAP_COMMON"/anbox.debug ]; then + ANBOX="$SNAP_COMMON"/anbox.debug +fi + +exec "$ANBOX" "$@" diff --git a/src/type3_AndroidCloud/anbox-master/scripts/start-container.sh b/src/type3_AndroidCloud/anbox-master/scripts/start-container.sh new file mode 100644 index 0000000..15cf4b8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/start-container.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +exec $SNAP/bin/lxc-start -P $SNAP_COMMON/var/lib/anbox/containers -n default -F diff --git a/src/type3_AndroidCloud/anbox-master/scripts/update-emugl-sources.sh b/src/type3_AndroidCloud/anbox-master/scripts/update-emugl-sources.sh new file mode 100644 index 0000000..97b7dd7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/scripts/update-emugl-sources.sh @@ -0,0 +1,136 @@ +#!/bin/sh + +# Copyright 2014 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set -e + +export LANG=C +export LC_ALL=C + +PROGDIR=$(dirname "$0") +PROGNAME=$(basename "$0") + +fatal () { + echo "ERROR: $@" + exit 1 +} + +ANBOX_DIR="$PWD" + +OPT_ANBOX_DIR= +OPT_EMUGEN= +OPT_HELP= + +for OPT; do + OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true) + case $OPT in + --help|-h|-\?) + OPT_HELP=true + ;; + --anbox-dir=*) + OPT_ANBOX_DIR=$OPTARG + ;; + --emugen=*) + OPT_EMUGEN=$OPTARG + ;; + -*) + fatal "Invalid option '$OPT', see --help." + ;; + *) + fatal "This script doesn't take arguments, see --help." + ;; + esac +done + +if [ "$OPT_HELP" ]; then + cat < Specify top-level Anbox directory [$ANBOX_DIR]. + --emugen= Emugen program path, if not in path. +EOF + exit 0 +fi + +EMUGEN= +if [ "$OPT_EMUGEN" ]; then + EMUGEN=$OPT_EMUGEN + if [ ! -f "$EMUGEN" ]; then + fatal "Missing emugen binary: $EMUGEN" + fi +else + EMUGEN=$PROGDIR/../../../objs/build/intermediates64/emugen/emugen + if [ ! -f "$EMUGEN" ]; then + fatal "Missing emugen binary: $EMUGEN, please build it or use --emugen=" + fi + echo "Auto-config: --emugen=$EMUGEN" +fi + +if [ "$OPT_ANBOX_DIR" ]; then + ANBOX_DIR=$OPT_ANBOX_DIR +else + echo "Auto-config: --anbox-dir=$ANBOX_DIR" +fi +if [ ! -d "$ANBOX_DIR/src/anbox" ]; then + fatal "Not an Anbox directory: $ANBOX_DIR" +fi + +ANBOX_DIR=$(cd "$ANBOX_DIR" && pwd -P) + +# Find the sources for the encoder: +ENCODER_TOP_DIR=$ANBOX_DIR/android/opengl/system +DECODER_TOP_DIR=$ANBOX_DIR/external/android-emugl/host/libs + +if [ ! -d "$ENCODER_TOP_DIR" ]; then + fatal "Missing encoder source directory: $ENCODER_TOP_DIR" +fi +if [ ! -d "$DECODER_TOP_DIR" ]; then + fatal "Missing decoder source directory: $DECODER_TOP_DIR" +fi + +# GLESv1 encoder +GLESv1_INPUT_DIR=$DECODER_TOP_DIR/GLESv1_dec +GLESv2_INPUT_DIR=$DECODER_TOP_DIR/GLESv2_dec +RENDERCONTROL_INPUT_DIR=$DECODER_TOP_DIR/renderControl_dec + +# The encoder has prefix GL while decoder has GLES +cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.attrib $DECODER_TOP_DIR/GLESv1_dec/gl.attrib +cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.in $DECODER_TOP_DIR/GLESv1_dec/gl.in +cp -f $DECODER_TOP_DIR/GLESv1_dec/gles1.types $DECODER_TOP_DIR/GLESv1_dec/gl.types + +cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.attrib $DECODER_TOP_DIR/GLESv2_dec/gl2.attrib +cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.in $DECODER_TOP_DIR/GLESv2_dec/gl2.in +cp -f $DECODER_TOP_DIR/GLESv2_dec/gles2.types $DECODER_TOP_DIR/GLESv2_dec/gl2.types + +$EMUGEN -i $DECODER_TOP_DIR/GLESv1_dec -E $ENCODER_TOP_DIR/GLESv1_enc gl +$EMUGEN -i $DECODER_TOP_DIR/GLESv2_dec -E $ENCODER_TOP_DIR/GLESv2_enc gl2 +$EMUGEN -i $DECODER_TOP_DIR/renderControl_dec -E $ENCODER_TOP_DIR/renderControl_enc renderControl + +rm $DECODER_TOP_DIR/GLESv1_dec/gl.attrib +rm $DECODER_TOP_DIR/GLESv1_dec/gl.in +rm $DECODER_TOP_DIR/GLESv1_dec/gl.types + +rm $DECODER_TOP_DIR/GLESv2_dec/gl2.attrib +rm $DECODER_TOP_DIR/GLESv2_dec/gl2.in +rm $DECODER_TOP_DIR/GLESv2_dec/gl2.types + +echo "Done, see $ENCODER_TOP_DIR" +exit 0 diff --git a/src/type3_AndroidCloud/anbox-master/snap/.snapcraft/state b/src/type3_AndroidCloud/anbox-master/snap/.snapcraft/state new file mode 100644 index 0000000..0278549 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/snap/.snapcraft/state @@ -0,0 +1,4 @@ +!GlobalState +assets: + build-packages: [] + build-snaps: [] diff --git a/src/type3_AndroidCloud/anbox-master/snap/gui/icon.png b/src/type3_AndroidCloud/anbox-master/snap/gui/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..240a38c0a0d4695949fd0a8616bcc05485746a1e GIT binary patch literal 60960 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 aUBNG2{x$saE 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 IHRss>0cR6F=l}o! literal 0 HcmV?d00001 diff --git a/src/type3_AndroidCloud/anbox-master/snap/hooks/configure b/src/type3_AndroidCloud/anbox-master/snap/hooks/configure new file mode 100644 index 0000000..0677cf6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/snap/hooks/configure @@ -0,0 +1,7 @@ +#!/bin/sh + +# We need to have something for snapd in place in order to +# allow configuration options for our snap even if the items +# are read via snapctl elsewhere in the code. + +exit 0 diff --git a/src/type3_AndroidCloud/anbox-master/snap/hooks/install b/src/type3_AndroidCloud/anbox-master/snap/hooks/install new file mode 100644 index 0000000..e395790 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/snap/hooks/install @@ -0,0 +1,4 @@ +#!/bin/sh + +# If not all feature checks pass we fail the Anbox installation +exec $SNAP/bin/desktop-launch $SNAP/bin/anbox-wrapper.sh check-features diff --git a/src/type3_AndroidCloud/anbox-master/snap/snapcraft.yaml b/src/type3_AndroidCloud/anbox-master/snap/snapcraft.yaml new file mode 100644 index 0000000..3da323d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/snap/snapcraft.yaml @@ -0,0 +1,308 @@ +name: anbox +version: 4 +version-script: | + if [ "$SNAPCRAFT_GRADE" = "stable" ]; then + echo $SNAPCRAFT_PROJECT_VERSION + else + echo $SNAPCRAFT_PROJECT_VERSION-$(git rev-parse --short HEAD) + fi +summary: Android in a Box +description: | + Runtime for Android applications which runs a full Android system + in a container using Linux namespaces (user, ipc, net, mount) to + separate the Android system fully from the host. +confinement: devmode +grade: devel +architectures: [amd64] + +slots: + dbus-session-slot: + interface: dbus + bus: session + name: org.anbox + +plugs: + dbus-session-plug: + interface: dbus + bus: session + name: org.anbox + +apps: + anbox: + command: desktop-launch $SNAP/bin/anbox-wrapper.sh + slots: + - dbus-session-slot + plugs: + - x11 + - unity7 + - network + - opengl + - wayland + - pulseaudio + - home + - process-control + - desktop + + container-manager: + command: bin/container-manager.sh start + stop-command: bin/container-manager.sh stop + daemon: simple + plugs: + - firewall-control + - mount-observe + - network-control + - network-bind + + collect-bug-info: + command: bin/collect-bug-info.sh + shell: + command: bin/anbox-shell.sh + android-settings: + command: desktop-launch $SNAP/bin/app-android-settings.sh + desktop: desktop/android-settings.desktop + slots: + - dbus-session-slot + plugs: + - dbus-session-plug + - x11 + - unity7 + - network + - opengl + - wayland + - pulseaudio + - home + - process-control + - desktop + + appmgr: + command: desktop-launch $SNAP/bin/app-appmgr.sh + desktop: desktop/appmgr.desktop + slots: + - dbus-session-slot + plugs: + - dbus-session-plug + - x11 + - unity7 + - network + - opengl + - wayland + - pulseaudio + - home + - process-control + - desktop + +parts: + android: + plugin: dump + # This needs to be any directory but not the root one as if we use + # it we get superious permissions errors with the copied .git tree + source: data + build-packages: + - wget + override-build: | + LOCAL_IMAGE=$SNAPCRAFT_PART_INSTALL/../../../android-images/android.img + + if [ -f $LOCAL_IMAGE ]; then + + echo "Using local image $LOCAL_IMAGE" + cp $LOCAL_IMAGE $SNAPCRAFT_PART_INSTALL/android.img + + else + + IMAGE_PATH= + IMAGE_NAME= + ARCH=$(uname -m) + + case "$ARCH" in + x86_64) + IMAGE_PATH="2018/07/19" + IMAGE_NAME="android_amd64.img" + IMAGE_HASH="6b04cd33d157814deaf92dccf8a23da4dc00b05ca6ce982a03830381896a8cca" + ;; + *) + echo "ERROR: Unknown architecture $ARCH" + exit 1 + ;; + esac + + # FIXME: downloading with a source: field doesn't work as snapcraft + # expects the downloaded file to be an archive it can extract. + echo "Downloading image..." + wget http://build.anbox.io/android-images/$IMAGE_PATH/$IMAGE_NAME + + echo "$IMAGE_HASH $IMAGE_NAME" > image-hash + sha256sum -c image-hash || exit 1 + + mv $IMAGE_NAME $SNAPCRAFT_PART_INSTALL/android.img + + fi + prime: + - android.img + + apparmor: + plugin: nil + stage-packages: + - apparmor + + zip: + plugin: nil + stage-packages: + - zip + prime: + - usr/bin/zip + + lxc: + source: https://github.com/lxc/lxc + source-type: git + source-tag: lxc-3.0.1 + build-packages: + - libapparmor-dev + - libcap-dev + - libgnutls28-dev + - libseccomp-dev + - pkg-config + plugin: autotools + configflags: + - --disable-selinux + - --disable-python + - --disable-lua + - --disable-tests + - --disable-examples + - --disable-doc + - --disable-api-docs + - --disable-bash + - --disable-cgmanager + - --enable-apparmor + - --enable-seccomp + - --enable-capabilities + - --with-rootfs-path=/var/snap/anbox/common/lxc/ + - --libexecdir=/snap/anbox/current/libexec/ + override-build: | + set -ex + git config user.email "buildbot@anbox.io" + git config user.name "Anbox Buildbot" + git remote add anbox https://github.com/anbox/lxc + git fetch anbox + # apparmor: don't require a transition for Anbox child profiles + git cherry-pick 2f81fb7c91560b32e506bb874f8cd63e37985906 + set +ex + snapcraftctl build + organize: + snap/anbox/current/libexec: libexec + prime: + - lib/liblxc.so.1 + - lib/liblxc.so.1.4.0 + - libexec/lxc/lxc-monitord + - bin/lxc-start + - bin/lxc-stop + - bin/lxc-info + - bin/lxc-attach + - bin/lxc-ls + - bin/lxc-top + + swiftshader: + plugin: cmake + source: https://swiftshader.googlesource.com/SwiftShader + source-type: git + source-commit: b6e8c3f0f4830887d69ba765a922ac3c40e81dd9 + override-build: | + git submodule update --init + snapcraftctl build + artifacts: + - libEGL.so + - libGLES_CM.so + - libGLESv2.so + organize: + libEGL.so: lib/anbox/swiftshader/libEGL.so + libGLES_CM.so: lib/anbox/swiftshader/libGLES_CM.so + libGLESv2.so: lib/anbox/swiftshader/libGLESv2.so + + anbox-scripts: + plugin: dump + source: scripts + organize: + snap-wrapper.sh: bin/anbox-wrapper.sh + container-manager.sh: bin/container-manager.sh + anbox-bridge.sh: bin/anbox-bridge.sh + collect-bug-info.sh: bin/collect-bug-info.sh + app-android-settings.sh: bin/app-android-settings.sh + app-appmgr.sh: bin/app-appmgr.sh + anbox-shell.sh: bin/anbox-shell.sh + prime: + - bin/anbox-bridge.sh + - bin/anbox-shell.sh + - bin/anbox-wrapper.sh + - bin/container-manager.sh + - bin/collect-bug-info.sh + - bin/app-*.sh + + anbox-data: + plugin: dump + source: data + prime: + - glvnd + - desktop + - apparmor + - seccomp + + anbox: + plugin: cmake + after: + - lxc + - desktop-glib-only + source: . + configflags: + # FIXME: Anbox currently has some paths with hard coded prefixes. Once + # that is fixed we can avoid using a prefix here. + - -DCMAKE_INSTALL_PREFIX:PATH=/usr + - -DANBOX_VERSION=$SNAPCRAFT_PROJECT_VERSION + - -DBINDERFS_PATH=/var/snap/anbox/common/binderfs + # FIXME: Once we have everything in place for full snap confinement we + # can securely enable this. + # - -DSNAP_CONFINEMENT=ON + build-packages: + - build-essential + - cmake + - cmake-data + - cmake-extras + - debhelper + - dbus + - google-mock + - libboost-dev + - libboost-filesystem-dev + - libboost-log-dev + - libboost-iostreams-dev + - libboost-program-options-dev + - libboost-system-dev + - libboost-test-dev + - libboost-thread-dev + - libcap-dev + - libdbus-1-dev + - libegl1-mesa-dev + - libgles2-mesa-dev + - libglm-dev + - libgtest-dev + - libprotobuf-dev + - libproperties-cpp-dev + - libsdl2-dev + - libsdl2-image-dev + - libsystemd-dev + - pkg-config + - protobuf-compiler + stage-packages: + - libboost-log1.58.0 + - libboost-iostreams1.58.0 + - libboost-program-options1.58.0 + - libboost-thread1.58.0 + - libdb5.3 + - libegl1-mesa + - libgles2-mesa + - libgl1-mesa-glx + - libsdl2-2.0-0 + - libsdl2-gfx-1.0-0 + - libsdl2-image-2.0-0 + - libsystemd0 + prime: + - usr/bin/anbox + - usr/share/anbox + - usr/lib/*-linux-*/ diff --git a/src/type3_AndroidCloud/anbox-master/src/CMakeLists.txt b/src/type3_AndroidCloud/anbox-master/src/CMakeLists.txt new file mode 100644 index 0000000..e751cbc --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/CMakeLists.txt @@ -0,0 +1,389 @@ +include_directories( + ${Boost_INCLUDE_DIRS} + ${MIRCLIENT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} + ${SDL2_INCLUDE_DIRS} + ${SDL2_IMAGE_INCLUDE_DIRS} + ${PROPERTIES_CPP_INCLUDE_DIRS} + ${LXC_INCLUDE_DIRS} + ${MIRCLIENT_INCLUDE_DIRS} + ${LIBSYSTEMD_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/external + ${CMAKE_SOURCE_DIR}/external/process-cpp-minimal/include + ${CMAKE_SOURCE_DIR}/external/android-emugl/shared + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/include + ${CMAKE_BINARY_DIR}/external/android-emugl/host/include + ${CMAKE_SOURCE_DIR}/external/android-emugl/shared/OpenglCodecCommon + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/include/libOpenglRender + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/GLESv1_dec + ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/GLESv1_dec + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/GLESv2_dec + ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/GLESv2_dec + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/renderControl_dec + ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/renderControl_dec + ${CMAKE_SOURCE_DIR}/external/cpu_features/include +) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBINDERFS_PATH=\"\\\"${BINDERFS_PATH}\\\"\"") + +protobuf_generate_cpp( + GENERATED_PROTOBUF_RPC_SRCS GENERATED_PROTOBUF_RPC_HDRS + anbox/protobuf/anbox_rpc.proto) + +protobuf_generate_cpp( + GENERATED_PROTOBUF_BRIDGE_SRCS GENERATED_PROTOBUF_BRIDGE_HDRS + anbox/protobuf/anbox_bridge.proto) + +protobuf_generate_cpp( + GENERATED_PROTOBUF_CONTAINER_SRCS GENERATED_PROTOBUF_CONTAINER_HDRS + anbox/protobuf/anbox_container.proto) + + +add_library(anbox-protobuf + STATIC + ${GENERATED_PROTOBUF_BRIDGE_SRCS} + ${GENERATED_PROTOBUF_BRIDGE_HDRS} + ${GENERATED_PROTOBUF_RPC_SRCS} + ${GENERATED_PROTOBUF_RPC_HDRS} + ${GENERATED_PROTOBUF_CONTAINER_SRCS} + ${GENERATED_PROTOBUF_CONTAINER_HDRS} + anbox/protobuf/anbox_rpc.proto + anbox/protobuf/anbox_bridge.proto + anbox/protobuf/anbox_container.proto + anbox/protobuf/google_protobuf_guard.cpp) +target_link_libraries(anbox-protobuf + ${PROTOBUF_LITE_LIBRARIES}) + +set(SOURCES + anbox/android/intent.cpp + anbox/android/intent.h + anbox/android/ip_config_builder.cpp + anbox/android/ip_config_builder.h + + anbox/application/database.cpp + anbox/application/database.h + anbox/application/launcher_storage.cpp + anbox/application/launcher_storage.h + anbox/application/manager.h + + anbox/audio/client_info.h + anbox/audio/server.cpp + anbox/audio/server.h + anbox/audio/sink.h + anbox/audio/source.h + + anbox/bridge/android_api_stub.cpp + anbox/bridge/android_api_stub.h + anbox/bridge/platform_api_skeleton.cpp + anbox/bridge/platform_api_skeleton.h + anbox/bridge/platform_message_processor.cpp + anbox/bridge/platform_message_processor.h + + anbox/build/config.h + anbox/build/config.h.in + + anbox/cmds/container_manager.cpp + anbox/cmds/container_manager.h + anbox/cmds/launch.cpp + anbox/cmds/launch.h + anbox/cmds/session_manager.cpp + anbox/cmds/session_manager.h + anbox/cmds/system_info.cpp + anbox/cmds/system_info.h + anbox/cmds/version.cpp + anbox/cmds/version.h + anbox/cmds/wait_ready.cpp + anbox/cmds/wait_ready.h + anbox/cmds/check_features.cpp + anbox/cmds/check_features.h + + anbox/common/binary_writer.cpp + anbox/common/binary_writer.h + anbox/common/dispatcher.cpp + anbox/common/dispatcher.h + anbox/common/fd.cpp + anbox/common/fd.h + anbox/common/fd_sets.h + anbox/common/loop_device_allocator.cpp + anbox/common/loop_device_allocator.h + anbox/common/loop_device.cpp + anbox/common/loop_device.h + anbox/common/message_channel.cpp + anbox/common/message_channel.h + anbox/common/mount_entry.cpp + anbox/common/mount_entry.h + anbox/common/scope_ptr.h + anbox/common/small_vector.h + anbox/common/type_traits.h + anbox/common/variable_length_array.h + anbox/common/wait_handle.cpp + anbox/common/wait_handle.h + anbox/common/binderfs.h + anbox/common/binder_device.cpp + anbox/common/binder_device.h + anbox/common/binder_device_allocator.cpp + anbox/common/binder_device_allocator.h + + anbox/container/client.cpp + anbox/container/client.h + anbox/container/configuration.h + anbox/container/container.cpp + anbox/container/container.h + anbox/container/lxc_container.cpp + anbox/container/lxc_container.h + anbox/container/management_api_message_processor.cpp + anbox/container/management_api_message_processor.h + anbox/container/management_api_skeleton.cpp + anbox/container/management_api_skeleton.h + anbox/container/management_api_stub.cpp + anbox/container/management_api_stub.h + anbox/container/service.cpp + anbox/container/service.h + + anbox/dbus/bus.cpp + anbox/dbus/bus.h + anbox/dbus/codecs.h + anbox/dbus/interface.h + anbox/dbus/sd_bus_helpers.c + anbox/dbus/sd_bus_helpers.h + anbox/dbus/sd_bus_helpers.hpp + anbox/dbus/skeleton/application_manager.cpp + anbox/dbus/skeleton/application_manager.h + anbox/dbus/skeleton/service.cpp + anbox/dbus/skeleton/service.h + anbox/dbus/stub/application_manager.cpp + anbox/dbus/stub/application_manager.h + + anbox/graphics/buffered_io_stream.cpp + anbox/graphics/buffered_io_stream.h + anbox/graphics/buffer_queue.cpp + anbox/graphics/buffer_queue.h + anbox/graphics/density.cpp + anbox/graphics/density.h + anbox/graphics/gl_extensions.h + anbox/graphics/gl_renderer_server.cpp + anbox/graphics/gl_renderer_server.h + anbox/graphics/layer_composer.cpp + anbox/graphics/layer_composer.h + anbox/graphics/multi_window_composer_strategy.cpp + anbox/graphics/multi_window_composer_strategy.h + anbox/graphics/opengles_message_processor.cpp + anbox/graphics/opengles_message_processor.h + anbox/graphics/primitives.h + anbox/graphics/program_family.cpp + anbox/graphics/program_family.h + anbox/graphics/rect.cpp + anbox/graphics/rect.h + anbox/graphics/renderer.h + anbox/graphics/single_window_composer_strategy.cpp + anbox/graphics/single_window_composer_strategy.h + + anbox/graphics/emugl/ColorBuffer.cpp + anbox/graphics/emugl/ColorBuffer.h + anbox/graphics/emugl/DispatchTables.h + anbox/graphics/emugl/DisplayManager.cpp + anbox/graphics/emugl/DisplayManager.h + anbox/graphics/emugl/ReadBuffer.cpp + anbox/graphics/emugl/ReadBuffer.h + anbox/graphics/emugl/Renderable.cpp + anbox/graphics/emugl/Renderable.h + anbox/graphics/emugl/RenderApi.cpp + anbox/graphics/emugl/RenderApi.h + anbox/graphics/emugl/RenderContext.cpp + anbox/graphics/emugl/RenderContext.h + anbox/graphics/emugl/RenderControl.cpp + anbox/graphics/emugl/RenderControl.h + anbox/graphics/emugl/RendererConfig.cpp + anbox/graphics/emugl/RendererConfig.h + anbox/graphics/emugl/Renderer.cpp + anbox/graphics/emugl/Renderer.h + anbox/graphics/emugl/RenderThread.cpp + anbox/graphics/emugl/RenderThread.h + anbox/graphics/emugl/RenderThreadInfo.cpp + anbox/graphics/emugl/RenderThreadInfo.h + anbox/graphics/emugl/TextureDraw.cpp + anbox/graphics/emugl/TextureDraw.h + anbox/graphics/emugl/TextureResize.cpp + anbox/graphics/emugl/TextureResize.h + anbox/graphics/emugl/TimeUtils.cpp + anbox/graphics/emugl/TimeUtils.h + anbox/graphics/emugl/WindowSurface.cpp + anbox/graphics/emugl/WindowSurface.h + + anbox/input/device.cpp + anbox/input/device.h + anbox/input/manager.cpp + anbox/input/manager.h + + anbox/network/base_socket_messenger.cpp + anbox/network/base_socket_messenger.h + anbox/network/connection_context.cpp + anbox/network/connection_context.h + anbox/network/connection_creator.cpp + anbox/network/connection_creator.h + anbox/network/connections.h + anbox/network/connector.h + anbox/network/credentials.cpp + anbox/network/credentials.h + anbox/network/delegate_connection_creator.h + anbox/network/delegate_message_processor.cpp + anbox/network/delegate_message_processor.h + anbox/network/fd_socket_transmission.cpp + anbox/network/fd_socket_transmission.h + anbox/network/local_socket_messenger.cpp + anbox/network/local_socket_messenger.h + anbox/network/message_processor.h + anbox/network/message_receiver.h + anbox/network/message_sender.h + anbox/network/published_socket_connector.cpp + anbox/network/published_socket_connector.h + anbox/network/socket_connection.cpp + anbox/network/socket_connection.h + anbox/network/socket_helper.cpp + anbox/network/socket_helper.h + anbox/network/socket_messenger.cpp + anbox/network/socket_messenger.h + anbox/network/tcp_socket_connector.cpp + anbox/network/tcp_socket_connector.h + anbox/network/tcp_socket_messenger.cpp + anbox/network/tcp_socket_messenger.h + + anbox/platform/base_platform.cpp + anbox/platform/base_platform.h + anbox/platform/null/platform.cpp + anbox/platform/null/platform.h + anbox/platform/sdl/audio_sink.cpp + anbox/platform/sdl/audio_sink.h + anbox/platform/sdl/keycode_converter.cpp + anbox/platform/sdl/keycode_converter.h + anbox/platform/sdl/platform.cpp + anbox/platform/sdl/platform.h + anbox/platform/sdl/sdl_wrapper.h + anbox/platform/sdl/window.cpp + anbox/platform/sdl/window.h + + anbox/protobuf/anbox_bridge.proto + anbox/protobuf/anbox_container.proto + anbox/protobuf/anbox_rpc.proto + anbox/protobuf/google_protobuf_guard.cpp + + anbox/qemu/adb_message_processor.cpp + anbox/qemu/adb_message_processor.h + anbox/qemu/at_parser.cpp + anbox/qemu/at_parser.h + anbox/qemu/bootanimation_message_processor.cpp + anbox/qemu/bootanimation_message_processor.h + anbox/qemu/boot_properties_message_processor.cpp + anbox/qemu/boot_properties_message_processor.h + anbox/qemu/camera_message_processor.cpp + anbox/qemu/camera_message_processor.h + anbox/qemu/fingerprint_message_processor.cpp + anbox/qemu/fingerprint_message_processor.h + anbox/qemu/gsm_message_processor.cpp + anbox/qemu/gsm_message_processor.h + anbox/qemu/hwcontrol_message_processor.cpp + anbox/qemu/hwcontrol_message_processor.h + anbox/qemu/null_message_processor.cpp + anbox/qemu/null_message_processor.h + anbox/qemu/pipe_connection_creator.cpp + anbox/qemu/pipe_connection_creator.h + anbox/qemu/qemud_message_processor.cpp + anbox/qemu/qemud_message_processor.h + anbox/qemu/sensors_message_processor.cpp + anbox/qemu/sensors_message_processor.h + + anbox/rpc/channel.cpp + anbox/rpc/channel.h + anbox/rpc/connection_creator.cpp + anbox/rpc/connection_creator.h + anbox/rpc/constants.h + anbox/rpc/make_protobuf_object.h + anbox/rpc/message_processor.cpp + anbox/rpc/message_processor.h + anbox/rpc/pending_call_cache.cpp + anbox/rpc/pending_call_cache.h + anbox/rpc/template_message_processor.h + + anbox/testing/gtest_utils.h + + anbox/ui/splash_screen.cpp + anbox/ui/splash_screen.h + + anbox/utils/environment_file.cpp + anbox/utils/environment_file.h + + anbox/wm/display.cpp + anbox/wm/display.h + anbox/wm/manager.cpp + anbox/wm/manager.h + anbox/wm/multi_window_manager.cpp + anbox/wm/multi_window_manager.h + anbox/wm/single_window_manager.cpp + anbox/wm/single_window_manager.h + anbox/wm/stack.cpp + anbox/wm/stack.h + anbox/wm/task.cpp + anbox/wm/task.h + anbox/wm/window.cpp + anbox/wm/window.h + anbox/wm/window_state.cpp + anbox/wm/window_state.h + + anbox/cli.cpp + anbox/cli.h + anbox/daemon.cpp + anbox/daemon.h + anbox/defer_action.h + anbox/do_not_copy_or_move.h + anbox/logger.cpp + anbox/logger.h + anbox/not_reachable.cpp + anbox/not_reachable.h + anbox/optional.h + anbox/utils.cpp + anbox/utils.h + anbox/runtime.cpp + anbox/runtime.h + anbox/system_configuration.cpp + anbox/system_configuration.h) + +add_library(anbox-core STATIC ${SOURCES}) +target_link_libraries(anbox-core + ${Boost_LDFLAGS} + ${Boost_LIBRARIES} + ${SDL2_LDFLAGS} + ${SDL2_LIBRARIES} + ${SDL2_IMAGE_LDFLAGS} + ${SDL2_IMAGE_LIBRARIES} + ${LXC_LDFLAGS} + ${LXC_LIBRARIES} + ${MIRCLIENT_LDFLAGS} + ${MIRCLIENT_LIBRARIES} + ${LIBSYSTEMD_LDFLAGS} + ${LIBSYSTEMD_LIBRARIES} + cpu_features + pthread + process-cpp + emugl_common + GLESv1_dec + GLESv2_dec + renderControl_dec + OpenGLESDispatch + OpenglCodecCommon + anbox-protobuf + xdg) + +add_executable(anbox main.cpp ${BACKWARD_ENABLE}) +target_link_libraries(anbox + anbox-core) +add_backward(anbox) + +install( + TARGETS anbox + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static) diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.cpp new file mode 100644 index 0000000..1b7b0e3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/android/intent.h" + +#include + +namespace anbox { +namespace android { +bool Intent::valid() const { + // At the moment we only support component+package for intents + // (see android/service/android_api_skeleton.cpp for more details) + return !(component.empty() && package.empty()); +} + +std::ostream &operator<<(std::ostream &out, const Intent &intent) { + out << "["; + if (!intent.action.empty()) + out << " " << "action=" << intent.action << " "; + if (!intent.uri.empty()) + out << " " << "uri=" << intent.uri << " "; + if (!intent.type.empty()) + out << " " << "type=" << intent.type << " "; + if (intent.flags > 0) + out << " " << "flags=" << intent.flags << " "; + if (!intent.package.empty()) + out << " " << "package=" << intent.package << " "; + if (!intent.component.empty()) + out << "component=" << intent.component << " "; + if (intent.categories.size() > 0) { + out << "categories=[ "; + for (const auto &category : intent.categories) out << category << " "; + out << "] "; + } + out << "]"; + return out; +} +} // namespace android +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.h b/src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.h new file mode 100644 index 0000000..57f2add --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/android/intent.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_ANDROID_INTENT_H_ +#define ANBOX_ANDROID_INTENT_H_ + +#include +#include + +namespace anbox { +namespace android { +struct Intent { + std::string action; + std::string uri; + std::string type; + int flags = 0; + std::string package; + std::string component; + std::vector categories; + + bool valid() const; +}; + +std::ostream &operator<<(std::ostream &out, const Intent &intent); +} // namespace android +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.cpp new file mode 100644 index 0000000..8ba13ce --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/android/ip_config_builder.h" + +#include + +#include +#include + +namespace { +constexpr const char *assignment_key{"ipAssignment"}; +constexpr const char *link_address_key{"linkAddress"}; +constexpr const char *gateway_key{"gateway"}; +constexpr const char *dns_key{"dns"}; +constexpr const char *id_key{"id"}; +constexpr const char *eos_key{"eos"}; +constexpr const char *assignment_static{"STATIC"}; +constexpr const char *assignment_dhcp{"DHCP"}; +constexpr const char *assignment_unknown{"UNKNOWN"}; + +constexpr const std::uint32_t is_default_gateway{0}; +constexpr const std::uint32_t gateway_is_present{1}; + +namespace aa = anbox::android; +std::string assignment_to_string(const aa::IpConfigBuilder::Assignment &value) { + switch (value) { + case anbox::android::IpConfigBuilder::Assignment::Static: + return assignment_static; + break; + case anbox::android::IpConfigBuilder::Assignment::DHCP: + return assignment_dhcp; + break; + default: + break; + } + return assignment_unknown; +} +} + +namespace anbox { +namespace android { +std::size_t IpConfigBuilder::write(common::BinaryWriter &writer) { + writer.set_byte_order(common::BinaryWriter::Order::Big); + + // See http://androidxref.com/7.1.1_r6/xref/frameworks/base/services/core/java/com/android/server/net/IpConfigStore.java + // for more details on the binary file format used here. + + writer.write_uint32(static_cast(version_)); + + writer.write_string_with_size(assignment_key); + writer.write_string_with_size(assignment_to_string(assignment_)); + + writer.write_string_with_size(link_address_key); + writer.write_string_with_size(link_.address); + writer.write_uint32(link_.prefix_length); + + writer.write_string_with_size(gateway_key); + writer.write_uint32(is_default_gateway); + writer.write_uint32(gateway_is_present); + writer.write_string_with_size(gateway_); + + writer.write_string_with_size(dns_key); + for (const auto &server : dns_servers_) + writer.write_string_with_size(server); + + writer.write_string_with_size(id_key); + writer.write_uint32(id_); + + writer.write_string_with_size(eos_key); + + return writer.bytes_written(); +} + +void IpConfigBuilder::set_version(const Version &version) { + version_ = version; +} + +void IpConfigBuilder::set_assignment(const Assignment &assignment) { + assignment_ = assignment; +} + +void IpConfigBuilder::set_link_address(const std::string &address, uint32_t prefix_length) { + link_.address = address; + link_.prefix_length = prefix_length; +} + +void IpConfigBuilder::set_gateway(const std::string &gateway) { + gateway_ = gateway; +} + +void IpConfigBuilder::set_dns_servers(const std::vector &dns_servers) { + dns_servers_ = dns_servers; +} + +void IpConfigBuilder::set_id(uint32_t id) { + id_ = id; +} +} // namespace android +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.h b/src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.h new file mode 100644 index 0000000..812da7c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/android/ip_config_builder.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_ANDROID_IPCONFIGBUILDER_H_ +#define ANBOX_ANDROID_IPCONFIGBUILDER_H_ + +#include "anbox/common/binary_writer.h" + +#include +#include +#include + +namespace anbox { +namespace android { +class IpConfigBuilder { + public: + enum class Version : std::uint32_t { + Version1 = 1, + Version2 = 2, + }; + + enum class Assignment { + Static, + DHCP, + }; + + IpConfigBuilder() = default; + + std::size_t write(common::BinaryWriter &writer); + + void set_version(const Version &version); + void set_assignment(const Assignment &assignment); + void set_link_address(const std::string &address, std::uint32_t prefix_length); + void set_gateway(const std::string &gateway); + void set_dns_servers(const std::vector &dns_servers); + void set_id(std::uint32_t id); + + private: + Version version_; + Assignment assignment_; + struct { + std::string address; + std::uint32_t prefix_length; + } link_; + std::string gateway_; + std::vector dns_servers_; + std::uint32_t id_; +}; +} // namespace android +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/application/database.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/application/database.cpp new file mode 100644 index 0000000..7fc3b44 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/application/database.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/application/database.h" +#include "anbox/application/launcher_storage.h" +#include "anbox/system_configuration.h" +#include "anbox/logger.h" + +namespace anbox { +namespace application { +const Database::Item Database::Unknown{}; + +Database::Database() : + storage_(std::make_shared(SystemConfiguration::instance().application_item_dir())) {} + +Database::~Database() {} + +void Database::store_or_update(const Item &item) { + if (!done_reset) { + storage_->reset(); + done_reset = true; + } + storage_->add_or_update(item); + items_[item.package] = item; + + // We don't need to store the icon data anymore at this point as the + // launcher is already stored it on the disk. + items_[item.package].icon.clear(); +} + +void Database::remove(const Item &item) { + auto iter = items_.find(item.package); + if (iter == items_.end()) + return; + storage_->remove(item); + items_.erase(iter); +} + +const Database::Item& Database::find_by_package(const std::string &package) const { + auto iter = items_.find(package); + if (iter == items_.end()) + return Unknown; + return iter->second; +} +} // namespace application +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/application/database.h b/src/type3_AndroidCloud/anbox-master/src/anbox/application/database.h new file mode 100644 index 0000000..ba04081 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/application/database.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_APPLICATION_DATABASE_H_ +#define ANBOX_APPLICATION_DATABASE_H_ + +#include "anbox/android/intent.h" + +#include +#include +#include + +namespace anbox { +namespace application { +class LauncherStorage; +class Database { + public: + struct Item { + std::string name; + std::string package; + android::Intent launch_intent; + std::vector icon; + + bool valid() const { return package.length() > 0; } + }; + + static const Item Unknown; + + Database(); + ~Database(); + + void store_or_update(const Item &item); + void remove(const Item &item); + + const Item& find_by_package(const std::string &package) const; + + private: + std::shared_ptr storage_; + std::map items_; + bool done_reset = false; +}; +} // namespace application +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.cpp new file mode 100644 index 0000000..5bdf931 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/application/launcher_storage.h" +#include "anbox/utils.h" +#include "anbox/logger.h" + +#include +#include +#include + +namespace fs = boost::filesystem; + +namespace { +// This will always point us to the right executable when we're running within +// a snap environment. +constexpr const char *snap_exe_path{"/snap/bin/anbox"}; +} + +namespace anbox { +namespace application { +LauncherStorage::LauncherStorage(const fs::path &path) : + path_(path) {} + +LauncherStorage::~LauncherStorage() {} + +void LauncherStorage::reset() { + if (fs::exists(path_)) { + for(auto & p : boost::filesystem::directory_iterator(path_)) { + if (fs::is_regular_file(p)){ + auto str = p.path().filename().string(); + if (boost::starts_with(str, "anbox-")) + fs::remove(p); + } + } + } +} + +std::string LauncherStorage::clean_package_name(const std::string &package_name) { + auto cleaned_package_name = package_name; + std::replace(cleaned_package_name.begin(), cleaned_package_name.end(), '.', '-'); + return cleaned_package_name; +} + +fs::path LauncherStorage::path_for_item(const std::string &package_name) { + return path_ / utils::string_format("anbox-%s.desktop", package_name); +} + +fs::path LauncherStorage::path_for_item_icon(const std::string &package_name) { + return path_ / utils::string_format("anbox-%s.png", package_name); +} + +void LauncherStorage::add_or_update(const Database::Item &item) { + if (!fs::exists(path_)) fs::create_directories(path_); + + auto package_name = item.package; + std::replace(package_name.begin(), package_name.end(), '.', '-'); + + auto exe_path = utils::process_get_exe_path(getpid()); + if (utils::get_env_value("SNAP").length() > 0) + exe_path = snap_exe_path; + + std::string exec = utils::string_format("%s launch ", exe_path); + + if (!item.launch_intent.action.empty()) + exec += utils::string_format("--action=%s ", item.launch_intent.action); + + if (!item.launch_intent.type.empty()) + exec += utils::string_format("--type=%s ", item.launch_intent.type); + + if (!item.launch_intent.uri.empty()) + exec += utils::string_format("--uri=%s ", item.launch_intent.uri); + + if (!item.launch_intent.package.empty()) + exec += utils::string_format("--package=%s ", item.launch_intent.package); + + if (!item.launch_intent.component.empty()) + exec += utils::string_format("--component=%s ", item.launch_intent.component); + + const auto item_icon_path = path_for_item_icon(package_name); + if (auto desktop_item = std::ofstream(path_for_item(package_name).string())) { + desktop_item << "[Desktop Entry]" << std::endl + << "Name=" << item.name << std::endl + << "Exec=" << exec << std::endl + << "Terminal=false" << std::endl + << "Type=Application" << std::endl + << "Icon=" << item_icon_path.string() << std::endl; + } else { + BOOST_THROW_EXCEPTION(std::runtime_error("Failed to create desktop item")); + } + + if (auto icon = std::ofstream(item_icon_path.string())) + icon.write(item.icon.data(), item.icon.size()); + else + BOOST_THROW_EXCEPTION(std::runtime_error("Failed to write icon")); +} + +void LauncherStorage::remove(const Database::Item &item) { + auto package_name = clean_package_name(item.package); + + const auto item_path = path_for_item(package_name); + if (fs::exists(item_path)) + fs::remove(item_path); + + const auto item_icon_path = path_for_item_icon(package_name); + if (fs::exists(item_icon_path)) + fs::remove(item_icon_path); +} + +} // namespace application +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.h b/src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.h new file mode 100644 index 0000000..55cfd8a --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/application/launcher_storage.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_APPLICATION_LAUNCHER_STORAGE_H_ +#define ANBOX_APPLICATION_LAUNCHER_STORAGE_H_ + +#include "anbox/application/database.h" +#include "anbox/android/intent.h" + +#include +#include + +#include +#include + +namespace anbox { +namespace application { +class LauncherStorage { + public: + LauncherStorage(const boost::filesystem::path &path); + ~LauncherStorage(); + + void reset(); + void add_or_update(const Database::Item &item); + void remove(const Database::Item &item); + + private: + std::string clean_package_name(const std::string &package_name); + boost::filesystem::path path_for_item(const std::string &package_name); + boost::filesystem::path path_for_item_icon(const std::string &package_name); + + boost::filesystem::path path_; +}; +} // namespace application +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/application/manager.h b/src/type3_AndroidCloud/anbox-master/src/anbox/application/manager.h new file mode 100644 index 0000000..b05593b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/application/manager.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_APPLICATION_MANAGER_H_ +#define ANBOX_APPLICATION_MANAGER_H_ + +#include "anbox/android/intent.h" +#include "anbox/do_not_copy_or_move.h" +#include "anbox/graphics/rect.h" +#include "anbox/wm/stack.h" + +#include + +#include + +namespace anbox { +namespace application { +class Manager : public DoNotCopyOrMove { + public: + virtual void launch(const android::Intent &intent, + const graphics::Rect &launch_bounds = graphics::Rect::Invalid, + const wm::Stack::Id &stack = wm::Stack::Id::Default) = 0; + + virtual core::Property& ready() = 0; +}; + +class RestrictedManager : public Manager { + public: + RestrictedManager( + const std::shared_ptr &other, + const wm::Stack::Id &launch_stack = wm::Stack::Id::Invalid) : + other_(other), + launch_stack_(launch_stack) {} + + virtual ~RestrictedManager() {} + + void launch(const android::Intent &intent, + const graphics::Rect &launch_bounds = graphics::Rect::Invalid, + const wm::Stack::Id &stack = wm::Stack::Id::Default) override { + auto selected_stack = stack; + // If we have a static launch stack set use that one instead of + // the one the caller gave us. + if (launch_stack_ != wm::Stack::Id::Invalid) + selected_stack = launch_stack_; + other_->launch(intent, launch_bounds, selected_stack); + } + + core::Property& ready() override { return other_->ready(); } + + private: + std::shared_ptr other_; + wm::Stack::Id launch_stack_; +}; +} // namespace application +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/audio/client_info.h b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/client_info.h new file mode 100644 index 0000000..29900f8 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/client_info.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_AUDIO_CLIENT_INFO_H_ +#define ANBOX_AUDIO_CLIENT_INFO_H_ + +#include + +namespace anbox { +namespace audio { +struct ClientInfo { + enum class Type : std::uint8_t { + Playback = 0, + Recording = 1, + Max = 2, + }; + Type type; +}; +} // namespace audio +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.cpp new file mode 100644 index 0000000..ad13968 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/audio/server.h" +#include "anbox/audio/sink.h" +#include "anbox/network/published_socket_connector.h" +#include "anbox/network/delegate_connection_creator.h" +#include "anbox/network/local_socket_messenger.h" +#include "anbox/network/message_processor.h" +#include "anbox/common/type_traits.h" +#include "anbox/system_configuration.h" +#include "anbox/utils.h" +#include "anbox/logger.h" + +using namespace std::placeholders; + +namespace { +class AudioForwarder : public anbox::network::MessageProcessor { + public: + AudioForwarder(const std::shared_ptr &sink) : + sink_(sink) { + } + + bool process_data(const std::vector &data) override { + sink_->write_data(data); + return true; + } + + private: + std::shared_ptr sink_; +}; +} + +namespace anbox { +namespace audio { +Server::Server(const std::shared_ptr& rt, const std::shared_ptr &platform) : + platform_(platform), + socket_file_(utils::string_format("%s/anbox_audio", SystemConfiguration::instance().socket_dir())), + connector_(std::make_shared( + socket_file_, rt, + std::make_shared>(std::bind(&Server::create_connection_for, this, _1)))), + connections_(std::make_shared>()), + next_id_(0) { + + // FIXME: currently creating the socket creates it with the rights of + // the user we're running as. As this one is mapped into the container + ::chmod(socket_file_.c_str(), 0777); +} + +Server::~Server() {} + +void Server::create_connection_for(std::shared_ptr> const& socket) { + auto const messenger = + std::make_shared(socket); + + // We have to read the client flags first before we can continue + // processing the actual commands + ClientInfo client_info; + auto err = messenger->receive_msg( + boost::asio::buffer(&client_info, sizeof(ClientInfo))); + if (err) { + ERROR("Failed to read client info: %s", err.message()); + return; + } + + std::shared_ptr processor; + + switch (client_info.type) { + case ClientInfo::Type::Playback: + processor = std::make_shared(platform_->create_audio_sink()); + break; + case ClientInfo::Type::Recording: + break; + default: + ERROR("Invalid client type %d", static_cast(client_info.type)); + return; + } + + // Everything ok, so approve the client by sending the requesting client + // info back. Once we have more things to negotiate we will send a modified + // client info struct back. + messenger->send(reinterpret_cast(&client_info), sizeof(client_info)); + + auto connection = std::make_shared( + messenger, messenger, next_id(), connections_, processor); + connections_->add(connection); + + connection->read_next_message(); +} + +int Server::next_id() { + return next_id_.fetch_add(1); +} +} // namespace audio +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.h b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.h new file mode 100644 index 0000000..34ce8f9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/server.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_AUDIO_SERVER_H_ +#define ANBOX_AUDIO_SERVER_H_ + +#include "anbox/runtime.h" +#include "anbox/audio/client_info.h" +#include "anbox/network/socket_messenger.h" +#include "anbox/network/socket_connection.h" +#include "anbox/platform/base_platform.h" + +#include + +namespace anbox { +namespace network { +class PublishedSocketConnector; +} // namespace network +namespace audio { +class Server { + public: + Server(const std::shared_ptr& rt, const std::shared_ptr &platform); + ~Server(); + + std::string socket_file() const { return socket_file_; } + + private: + void create_connection_for(std::shared_ptr> const& socket); + + int next_id(); + + std::shared_ptr platform_; + std::string socket_file_; + std::shared_ptr connector_; + std::shared_ptr> const connections_; + std::atomic next_id_; +}; +} // namespace audio +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/audio/sink.h b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/sink.h new file mode 100644 index 0000000..39e1b32 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/sink.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_AUDIO_SINK_H_ +#define ANBOX_AUDIO_SINK_H_ + +#include + +#include + +namespace anbox { +namespace audio { +class Sink { + public: + virtual ~Sink() {} + virtual void write_data(const std::vector &data) = 0; +}; +} // namespace audio +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/audio/source.h b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/source.h new file mode 100644 index 0000000..72dcc32 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/audio/source.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_AUDIO_SOURCE_H_ +#define ANBOX_AUDIO_SOURCE_H_ + +#include + +#include + +namespace anbox { +namespace audio { +class Source { + public: + virtual ~Source() {} + + virtual void read_data(std::vector &data) = 0; +}; +} // namespace audio +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.cpp new file mode 100644 index 0000000..b81ebe5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/bridge/android_api_stub.h" +#include "anbox/system_configuration.h" +#include "anbox/logger.h" +#include "anbox/rpc/channel.h" +#include "anbox/utils.h" +#include "anbox/wm/stack.h" + +#include "anbox_bridge.pb.h" +#include "anbox_rpc.pb.h" + +#include +#ifdef USE_PROTOBUF_CALLBACK_HEADER +#include +#endif + + +namespace fs = boost::filesystem; + +namespace { +constexpr const std::chrono::milliseconds default_rpc_call_timeout{30000}; +} // namespace + +namespace anbox { +namespace bridge { +AndroidApiStub::AndroidApiStub() {} + +AndroidApiStub::~AndroidApiStub() {} + +void AndroidApiStub::set_rpc_channel( + const std::shared_ptr &channel) { + channel_ = channel; +} + +void AndroidApiStub::reset_rpc_channel() { channel_.reset(); } + +void AndroidApiStub::ensure_rpc_channel() { + if (!channel_) throw std::runtime_error("No remote client connected"); +} + +void AndroidApiStub::launch(const android::Intent &intent, + const graphics::Rect &launch_bounds, + const wm::Stack::Id &stack) { + ensure_rpc_channel(); + + auto c = std::make_shared>(); + protobuf::bridge::LaunchApplication message; + + { + std::lock_guard lock(mutex_); + launch_wait_handle_.expect_result(); + } + + switch (stack) { + case wm::Stack::Id::Default: + message.set_stack(::anbox::protobuf::bridge::LaunchApplication_Stack_DEFAULT); + break; + case wm::Stack::Id::Fullscreen: + message.set_stack(::anbox::protobuf::bridge::LaunchApplication_Stack_FULLSCREEN); + break; + case wm::Stack::Id::Freeform: + message.set_stack(::anbox::protobuf::bridge::LaunchApplication_Stack_FREEFORM); + break; + default: + break; + } + + if (launch_bounds != graphics::Rect::Invalid) { + auto rect = message.mutable_launch_bounds(); + rect->set_left(launch_bounds_.left()); + rect->set_top(launch_bounds_.top()); + rect->set_right(launch_bounds_.right()); + rect->set_bottom(launch_bounds_.bottom()); + } + + auto launch_intent = message.mutable_intent(); + + if (!intent.action.empty()) launch_intent->set_action(intent.action); + + if (!intent.uri.empty()) launch_intent->set_uri(intent.uri); + + if (!intent.type.empty()) launch_intent->set_type(intent.type); + + if (!intent.package.empty()) launch_intent->set_package(intent.package); + + if (!intent.component.empty()) launch_intent->set_component(intent.component); + + for (const auto &category : intent.categories) { + auto c = launch_intent->add_categories(); + *c = category; + } + + channel_->call_method( + "launch_application", &message, c->response.get(), + google::protobuf::NewCallback(this, &AndroidApiStub::application_launched, + c.get())); + + launch_wait_handle_.wait_for_pending(default_rpc_call_timeout); + if (!launch_wait_handle_.has_result()) + throw std::runtime_error("RPC call timed out"); + + if (c->response->has_error()) throw std::runtime_error(c->response->error()); +} + +core::Property& AndroidApiStub::ready() { + return ready_; +} + +void AndroidApiStub::application_launched( + Request *request) { + (void)request; + launch_wait_handle_.result_received(); +} + +void AndroidApiStub::set_focused_task(const std::int32_t &id) { + ensure_rpc_channel(); + + auto c = std::make_shared>(); + + protobuf::bridge::SetFocusedTask message; + message.set_id(id); + + { + std::lock_guard lock(mutex_); + set_focused_task_handle_.expect_result(); + } + + channel_->call_method("set_focused_task", &message, c->response.get(), + google::protobuf::NewCallback( + this, &AndroidApiStub::focused_task_set, c.get())); + + set_focused_task_handle_.wait_for_pending(default_rpc_call_timeout); + if (!set_focused_task_handle_.has_result()) + throw std::runtime_error("RPC call timed out"); + + if (c->response->has_error()) throw std::runtime_error(c->response->error()); +} + +void AndroidApiStub::focused_task_set(Request *request) { + (void)request; + set_focused_task_handle_.result_received(); +} + +void AndroidApiStub::remove_task(const std::int32_t &id) { + ensure_rpc_channel(); + + auto c = std::make_shared>(); + + protobuf::bridge::RemoveTask message; + message.set_id(id); + + { + std::lock_guard lock(mutex_); + remove_task_handle_.expect_result(); + } + + channel_->call_method("remove_task", &message, c->response.get(), + google::protobuf::NewCallback( + this, &AndroidApiStub::task_removed, c.get())); + + remove_task_handle_.wait_for_pending(default_rpc_call_timeout); + if (!remove_task_handle_.has_result()) + throw std::runtime_error("RPC call timed out"); + + if (c->response->has_error()) throw std::runtime_error(c->response->error()); +} + +void AndroidApiStub::task_removed(Request *request) { + (void)request; + remove_task_handle_.result_received(); +} + +void AndroidApiStub::resize_task(const std::int32_t &id, + const anbox::graphics::Rect &rect, + const std::int32_t &resize_mode) { + ensure_rpc_channel(); + + auto c = std::make_shared>(); + + protobuf::bridge::ResizeTask message; + message.set_id(id); + message.set_resize_mode(resize_mode); + + auto r = message.mutable_rect(); + r->set_left(rect.left()); + r->set_top(rect.top()); + r->set_right(rect.right()); + r->set_bottom(rect.bottom()); + + { + std::lock_guard lock(mutex_); + resize_task_handle_.expect_result(); + } + + channel_->call_method("resize_task", &message, c->response.get(), + google::protobuf::NewCallback( + this, &AndroidApiStub::task_resized, c.get())); + + resize_task_handle_.wait_for_pending(default_rpc_call_timeout); + if (!resize_task_handle_.has_result()) + throw std::runtime_error("RPC call timed out"); + + if (c->response->has_error()) throw std::runtime_error(c->response->error()); +} + +void AndroidApiStub::task_resized(Request *request) { + (void)request; + resize_task_handle_.result_received(); +} +} // namespace bridge +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.h b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.h new file mode 100644 index 0000000..d95fd7b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/android_api_stub.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_BRIDGE_ANDROID_API_STUB_H_ +#define ANBOX_BRIDGE_ANDROID_API_STUB_H_ + +#include "anbox/application/manager.h" +#include "anbox/common/wait_handle.h" +#include "anbox/graphics/rect.h" + +#include +#include + +namespace anbox { +namespace protobuf { +namespace rpc { +class Void; +} // namespace bridge +} // namespace protobuf +namespace rpc { +class Channel; +} // namespace rpc +namespace bridge { +class AndroidApiStub : public anbox::application::Manager { + public: + AndroidApiStub(); + ~AndroidApiStub(); + + void set_rpc_channel(const std::shared_ptr &channel); + void reset_rpc_channel(); + + void set_focused_task(const std::int32_t &id); + void remove_task(const std::int32_t &id); + void resize_task(const std::int32_t &id, const anbox::graphics::Rect &rect, + const std::int32_t &resize_mode); + + void launch(const android::Intent &intent, + const graphics::Rect &launch_bounds = graphics::Rect::Invalid, + const wm::Stack::Id &stack = wm::Stack::Id::Default) override; + + core::Property& ready() override; + + private: + void ensure_rpc_channel(); + + template + struct Request { + Request() : response(std::make_shared()), success(true) {} + std::shared_ptr response; + bool success; + }; + + void application_launched(Request *request); + void focused_task_set(Request *request); + void task_removed(Request *request); + void task_resized(Request *request); + + mutable std::mutex mutex_; + std::shared_ptr channel_; + common::WaitHandle launch_wait_handle_; + common::WaitHandle set_focused_task_handle_; + common::WaitHandle remove_task_handle_; + common::WaitHandle resize_task_handle_; + graphics::Rect launch_bounds_ = graphics::Rect::Invalid; + core::Property ready_; +}; +} // namespace bridge +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.cpp new file mode 100644 index 0000000..1274754 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/bridge/platform_api_skeleton.h" +#include "anbox/application/database.h" +#include "anbox/platform/base_platform.h" +#include "anbox/wm/manager.h" +#include "anbox/wm/window_state.h" +#include "anbox/logger.h" + +#if defined(Status) +#undef Status +#endif // defined(Status) + +#include "anbox_bridge.pb.h" + +#ifdef USE_PROTOBUF_CALLBACK_HEADER +#include +#endif + +namespace anbox { +namespace bridge { +PlatformApiSkeleton::PlatformApiSkeleton( + const std::shared_ptr &pending_calls, + const std::shared_ptr &platform, + const std::shared_ptr &window_manager, + const std::shared_ptr &app_db) + : pending_calls_(pending_calls), + platform_(platform), + window_manager_(window_manager), + app_db_(app_db) {} + +PlatformApiSkeleton::~PlatformApiSkeleton() {} + + +void PlatformApiSkeleton::set_clipboard_data(anbox::protobuf::bridge::ClipboardData const *request, + anbox::protobuf::rpc::Void *response, + google::protobuf::Closure *done) { + (void)response; + + if (request->has_text()) + platform_->set_clipboard_data(platform::BasePlatform::ClipboardData{request->text()}); + + done->Run(); +} + +void PlatformApiSkeleton::get_clipboard_data(anbox::protobuf::rpc::Void const *request, + anbox::protobuf::bridge::ClipboardData *response, + google::protobuf::Closure *done) { + (void)request; + + auto data = platform_->get_clipboard_data(); + if (!data.text.empty()) + response->set_text(data.text); + + done->Run(); +} + +void PlatformApiSkeleton::handle_boot_finished_event(const anbox::protobuf::bridge::BootFinishedEvent&) { + if (boot_finished_handler_) + boot_finished_handler_(); +} + +void PlatformApiSkeleton::handle_window_state_update_event(const anbox::protobuf::bridge::WindowStateUpdateEvent &event) { + auto convert_window_state = []( + const ::anbox::protobuf::bridge::WindowStateUpdateEvent_WindowState + &window) { + return wm::WindowState( + wm::Display::Id(window.display_id()), window.has_surface(), + graphics::Rect(window.frame_left(), window.frame_top(), + window.frame_right(), window.frame_bottom()), + window.package_name(), wm::Task::Id(window.task_id()), + wm::Stack::Id(window.stack_id())); + }; + + wm::WindowState::List updated; + for (int n = 0; n < event.windows_size(); n++) { + const auto window = event.windows(n); + updated.push_back(convert_window_state(window)); + } + + wm::WindowState::List removed; + for (int n = 0; n < event.removed_windows_size(); n++) { + const auto window = event.removed_windows(n); + removed.push_back(convert_window_state(window)); + } + + window_manager_->apply_window_state_update(updated, removed); +} + +void PlatformApiSkeleton::handle_application_list_update_event(const anbox::protobuf::bridge::ApplicationListUpdateEvent &event) { + for (int n = 0; n < event.removed_applications_size(); n++) { + application::Database::Item item; + + const auto app = event.removed_applications(n); + item.package = app.package(); + + if (item.package.empty()) + continue; + + app_db_->remove(item); + } + + for (int n = 0; n < event.applications_size(); n++) { + application::Database::Item item; + + const auto app = event.applications(n); + item.name = app.name(); + item.package = app.package(); + + const auto li = app.launch_intent(); + item.launch_intent.action = li.action(); + item.launch_intent.uri = li.uri(); + item.launch_intent.type = li.uri(); + item.launch_intent.package = li.package(); + item.launch_intent.component = li.component(); + + for (int m = 0; m < li.categories_size(); m++) + item.launch_intent.categories.push_back(li.categories(m)); + + item.icon = std::vector(app.icon().begin(), app.icon().end()); + + if (item.package.empty()) + continue; + + app_db_->store_or_update(item); + } +} + +void PlatformApiSkeleton::register_boot_finished_handler(const std::function &action) { + boot_finished_handler_ = action; +} +} // namespace bridge +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.h b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.h new file mode 100644 index 0000000..02fe1d6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_api_skeleton.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_BRIDGE_PLATFORM_SERVER_H_ +#define ANBOX_BRIDGE_PLATFORM_SERVER_H_ + +#include +#include + +namespace google { +namespace protobuf { +class Closure; +} // namespace protobuf +} // namespace google + +namespace anbox { +namespace protobuf { +namespace rpc { +class Void; +} // namespace rpc +namespace bridge { +class ClipboardData; +class BootFinishedEvent; +class WindowStateUpdateEvent; +class ApplicationListUpdateEvent; +} // namespace bridge +} // namespace protobuf +namespace platform { +class BasePlatform; +} // namespace platform +namespace rpc { +class PendingCallCache; +} // namespace rpc +namespace wm { +class Manager; +} // namespace wm +namespace application { +class Database; +} // namespace application +namespace bridge { +class PlatformApiSkeleton { + public: + PlatformApiSkeleton( + const std::shared_ptr &pending_calls, + const std::shared_ptr &platform, + const std::shared_ptr &window_manager, + const std::shared_ptr &app_db); + virtual ~PlatformApiSkeleton(); + + void set_clipboard_data(anbox::protobuf::bridge::ClipboardData const *request, + anbox::protobuf::rpc::Void *response, + google::protobuf::Closure *done); + void get_clipboard_data(anbox::protobuf::rpc::Void const *request, + anbox::protobuf::bridge::ClipboardData *response, + google::protobuf::Closure *done); + + void handle_boot_finished_event( + const anbox::protobuf::bridge::BootFinishedEvent &event); + void handle_window_state_update_event( + const anbox::protobuf::bridge::WindowStateUpdateEvent &event); + void handle_application_list_update_event( + const anbox::protobuf::bridge::ApplicationListUpdateEvent &event); + + void register_boot_finished_handler(const std::function &action); + + private: + std::shared_ptr pending_calls_; + std::shared_ptr platform_; + std::shared_ptr window_manager_; + std::shared_ptr app_db_; + std::function boot_finished_handler_; +}; +} // namespace bridge +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.cpp new file mode 100644 index 0000000..7642ab5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/bridge/platform_message_processor.h" +#include "anbox/bridge/platform_api_skeleton.h" +#include "anbox/logger.h" +#include "anbox/rpc/template_message_processor.h" + +#include "anbox_bridge.pb.h" + +namespace anbox { +namespace bridge { +PlatformMessageProcessor::PlatformMessageProcessor( + const std::shared_ptr &sender, + const std::shared_ptr &server, + const std::shared_ptr &pending_calls) + : rpc::MessageProcessor(sender, pending_calls), server_(server) {} + +PlatformMessageProcessor::~PlatformMessageProcessor() {} + +void PlatformMessageProcessor::dispatch(rpc::Invocation const &invocation) { + if (invocation.method_name() == "set_clipboard_data") + invoke(this, server_.get(), &PlatformApiSkeleton::set_clipboard_data, invocation); + else if (invocation.method_name() == "get_clipboard_data") + invoke(this, server_.get(), &PlatformApiSkeleton::get_clipboard_data, invocation); +} + +void PlatformMessageProcessor::process_event_sequence( + const std::string &raw_events) { + anbox::protobuf::bridge::EventSequence seq; + if (!seq.ParseFromString(raw_events)) { + WARNING("Failed to parse events from raw string"); + return; + } + + if (seq.has_boot_finished()) + server_->handle_boot_finished_event(seq.boot_finished()); + + if (seq.has_window_state_update()) + server_->handle_window_state_update_event(seq.window_state_update()); + + if (seq.has_application_list_update()) + server_->handle_application_list_update_event( + seq.application_list_update()); +} +} // namespace anbox +} // namespace network diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.h b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.h new file mode 100644 index 0000000..307b051 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/bridge/platform_message_processor.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_BRIDGE_PLATFORM_MESSAGE_PROCESSOR_H_ +#define ANBOX_BRIDGE_PLATFORM_MESSAGE_PROCESSOR_H_ + +#include "anbox/rpc/message_processor.h" + +namespace anbox { +namespace bridge { +class PlatformApiSkeleton; +class PlatformMessageProcessor : public rpc::MessageProcessor { + public: + PlatformMessageProcessor( + const std::shared_ptr &sender, + const std::shared_ptr &server, + const std::shared_ptr &pending_calls); + ~PlatformMessageProcessor(); + + void dispatch(rpc::Invocation const &invocation) override; + void process_event_sequence(const std::string &event) override; + + private: + std::shared_ptr server_; +}; +} // namespace anbox +} // namespace network + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/build/config.h.in b/src/type3_AndroidCloud/anbox-master/src/anbox/build/config.h.in new file mode 100644 index 0000000..01b7e83 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/build/config.h.in @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ + +#ifndef ANBOX_CONFIG_H_ +#define ANBOX_CONFIG_H_ + +#include +#include + +namespace anbox { +namespace build { +/// @brief version marks the version +static constexpr const char *version{"@ANBOX_VERSION@"}; + +// path for system configuration +static constexpr const char *default_resource_path{"@ANBOX_RESOURCE_DIR_FULL@"}; +static constexpr const char *default_data_path{"@ANBOX_STATEDIR_FULL@"}; +} // namespace build +} // namespace anbox + +#endif // ANBOX_CONFIG_H_ diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cli.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cli.cpp new file mode 100644 index 0000000..959a43c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cli.cpp @@ -0,0 +1,249 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ + +#include +#include + +#include "anbox/cli.h" + +namespace cli = anbox::cli; +namespace po = boost::program_options; + +namespace { +namespace pattern { +static constexpr const char* help_for_command_with_subcommands = + "NAME:\n" + " %1% - %2%\n" + "\n" + "USAGE:\n" + " %3% [command options] [arguments...]"; + +static constexpr const char* commands = "COMMANDS:"; +static constexpr const char* command = " %1% %2%"; + +static constexpr const char* options = "OPTIONS:"; +static constexpr const char* option = " --%1% %2%"; +} + +void add_to_desc_for_flags(po::options_description& desc, + const std::set& flags) { + for (auto flag : flags) { + po::value_semantic *spec = nullptr; + flag->specify_option(spec); + if (!spec) continue; + desc.add_options()(flag->name().as_string().c_str(), spec, + flag->description().as_string().c_str()); + } +} +} + +std::vector cli::args(int argc, char** argv) { + std::vector result; + for (int i = 1; i < argc; i++) result.push_back(argv[i]); + return result; +} + +const cli::Name& cli::Flag::name() const { return name_; } + +const cli::Description& cli::Flag::description() const { return description_; } + +cli::Flag::Flag(const Name& name, const Description& description) + : name_{name}, description_{description} {} + +cli::Command::FlagsWithInvalidValue::FlagsWithInvalidValue() + : std::runtime_error{"Flags with invalid value"} {} + +cli::Command::FlagsMissing::FlagsMissing() + : std::runtime_error{"Flags are missing in command invocation"} {} + +cli::Name cli::Command::name() const { return name_; } + +cli::Usage cli::Command::usage() const { return usage_; } + +cli::Description cli::Command::description() const { return description_; } + +bool cli::Command::hidden() const { return hidden_; } + +cli::Command::Command(const cli::Name& name, const cli::Usage& usage, + const cli::Description& description, bool hidden) + : name_(name), usage_(usage), description_(description), hidden_(hidden) {} + +cli::CommandWithSubcommands::CommandWithSubcommands( + const Name& name, const Usage& usage, const Description& description) + : Command{name, usage, description} { + command(std::make_shared(*this)); +} + +cli::CommandWithSubcommands& cli::CommandWithSubcommands::command( + const Command::Ptr& command) { + commands_[command->name().as_string()] = command; + return *this; +} + +cli::CommandWithSubcommands& cli::CommandWithSubcommands::flag( + const Flag::Ptr& flag) { + flags_.insert(flag); + return *this; +} + +void cli::CommandWithSubcommands::help(std::ostream& out) { + out << boost::format(pattern::help_for_command_with_subcommands) % + name().as_string() % usage().as_string() % name().as_string() + << std::endl; + + if (flags_.size() > 0) { + out << std::endl + << pattern::options << std::endl; + for (const auto& flag : flags_) + out << boost::format(pattern::option) % flag->name() % flag->description() + << std::endl; + } + + if (commands_.size() > 0) { + out << std::endl + << pattern::commands << std::endl; + for (const auto& cmd : commands_) { + if (cmd.second && !cmd.second->hidden()) + out << boost::format(pattern::command) % cmd.second->name() % + cmd.second->description() + << std::endl; + } + } +} + +int cli::CommandWithSubcommands::run(const cli::Command::Context& ctxt) { + po::positional_options_description pdesc; + pdesc.add("command", 1); + + po::options_description desc("Options"); + desc.add_options()("command", po::value()->required(), + "the command to be executed"); + + add_to_desc_for_flags(desc, flags_); + + try { + po::variables_map vm; + auto parsed = po::command_line_parser(ctxt.args) + .options(desc) + .positional(pdesc) + .style(po::command_line_style::unix_style) + .allow_unregistered() + .run(); + + po::store(parsed, vm); + po::notify(vm); + + auto cmd = commands_[vm["command"].as()]; + if (!cmd) { + ctxt.cout << "Unknown command '" << vm["command"].as() << "'" + << std::endl; + help(ctxt.cout); + return EXIT_FAILURE; + } + + return cmd->run(cli::Command::Context{ + ctxt.cin, ctxt.cout, + po::collect_unrecognized(parsed.options, po::include_positional)}); + } catch (const po::error& e) { + ctxt.cout << e.what() << std::endl; + help(ctxt.cout); + return EXIT_FAILURE; + } + + return EXIT_FAILURE; +} + +cli::CommandWithFlagsAndAction::CommandWithFlagsAndAction( + const Name& name, const Usage& usage, const Description& description, bool hidden) + : Command{name, usage, description, hidden} {} + +cli::CommandWithFlagsAndAction& cli::CommandWithFlagsAndAction::flag( + const Flag::Ptr& flag) { + flags_.insert(flag); + return *this; +} + +cli::CommandWithFlagsAndAction& cli::CommandWithFlagsAndAction::action( + const Action& action) { + action_ = action; + return *this; +} + +int cli::CommandWithFlagsAndAction::run(const Context& ctxt) { + po::options_description cd(name().as_string()); + + bool help_requested{false}; + cd.add_options()("help", po::bool_switch(&help_requested), + "produces a help message"); + + add_to_desc_for_flags(cd, flags_); + + try { + po::variables_map vm; + auto parsed = po::command_line_parser(ctxt.args) + .options(cd) + .style(po::command_line_style::unix_style) + .allow_unregistered() + .run(); + po::store(parsed, vm); + po::notify(vm); + + if (help_requested) { + help(ctxt.cout); + return EXIT_SUCCESS; + } + + return action_(cli::Command::Context{ + ctxt.cin, ctxt.cout, + po::collect_unrecognized(parsed.options, po::include_positional)}); + } catch (const po::error& e) { + ctxt.cout << e.what() << std::endl; + help(ctxt.cout); + return EXIT_FAILURE; + } + + return EXIT_FAILURE; +} + +void cli::CommandWithFlagsAndAction::help(std::ostream& out) { + out << boost::format(pattern::help_for_command_with_subcommands) % + name().as_string() % description().as_string() % name().as_string() + << std::endl; + + if (flags_.size() > 0) { + out << std::endl + << boost::format(pattern::options) << std::endl; + for (const auto& flag : flags_) + out << boost::format(pattern::option) % flag->name() % flag->description() + << std::endl; + } +} + +cli::cmd::Help::Help(Command& cmd) + : Command{cli::Name{"help"}, cli::Usage{"Print a short help message"}, + cli::Description{"Print a short help message"}}, + command{cmd} {} + +// From Command +int cli::cmd::Help::run(const Context& context) { + command.help(context.cout); + return EXIT_FAILURE; +} + +void cli::cmd::Help::help(std::ostream& out) { command.help(out); } diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cli.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cli.h new file mode 100644 index 0000000..09a06e3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cli.h @@ -0,0 +1,386 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ +#ifndef BIOMETRY_UTIL_CLI_H_ +#define BIOMETRY_UTIL_CLI_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "anbox/do_not_copy_or_move.h" +#include "anbox/optional.h" + +#include + +namespace anbox { +namespace cli { + +template +class SizeConstrainedString { + public: + SizeConstrainedString(const std::string& s) : s{s} { + if (s.size() > max) + throw std::logic_error{"Max size exceeded " + std::to_string(max)}; + } + + const std::string& as_string() const { return s; } + + operator std::string() const { return s; } + + private: + std::string s; +}; + +template +bool operator<(const SizeConstrainedString& lhs, + const SizeConstrainedString& rhs) { + return lhs.as_string() < rhs.as_string(); +} + +template +bool operator==(const SizeConstrainedString& lhs, + const SizeConstrainedString& rhs) { + return lhs.as_string() == rhs.as_string(); +} + +template +std::ostream& operator<<(std::ostream& out, + const SizeConstrainedString& scs) { + return out << std::setw(max) << std::left << scs.as_string(); +} + +// We are imposing size constraints to ensure a consistent CLI layout. +typedef SizeConstrainedString<30> Name; +typedef SizeConstrainedString<60> Usage; +typedef SizeConstrainedString<100> Description; + +/// @brief Flag models an input parameter to a command. +class Flag : public DoNotCopyOrMove { + public: + typedef boost::program_options::value_semantic* Specification; + + // Safe us some typing. + typedef std::shared_ptr Ptr; + + /// @brief name returns the name of the Flag. + const Name& name() const; + /// @brief description returns a human-readable description of the flag. + const Description& description() const; + + /// @brief specify the program option of the flag. + virtual void specify_option(Specification& spec) = 0; + + protected: + /// @brief Flag creates a new instance, initializing name and description + /// from the given values. + Flag(const Name& name, const Description& description); + + private: + Name name_; + Description description_; +}; + +/// @brief TypedFlag implements Flag relying on operator<< and operator>> to +/// read/write values to/from strings. +template +class TypedFlag : public Flag { + public: + typedef std::shared_ptr> Ptr; + + TypedFlag(const Name& name, const Description& description) + : Flag{name, description} {} + + /// @brief value installs the given value in the flag. + TypedFlag& value(const T& value) { + value_ = value; + return *this; + } + + /// @brief value returns the optional value associated with the flag. + const Optional& value() const { return value_; } + + /// @brief Option generated by specify_option tries to unwrap a value + /// of type T from value. + void specify_option(Flag::Specification& spec) override { + spec = boost::program_options::value()->notifier([&](const std::string& s) { + std::stringstream ss{s}; + T value; + ss >> value; + value_ = value; + }); + } + + private: + Optional value_; +}; + +/// @brief TypedReferenceFlag implements Flag, relying on operator<> to +/// convert to/from string representations, +/// updating the given mutable reference to a value of type T. +template +class TypedReferenceFlag : public Flag { + public: + // Safe us some typing. + typedef std::shared_ptr> Ptr; + + /// @brief TypedReferenceFlag initializes a new instance with name, + /// description and value. + TypedReferenceFlag(const Name& name, const Description& description, T& value) + : Flag{name, description}, value_{value} {} + + /// @brief Option generated by specify_option tries to unwrap a value of type T + /// from value, relying on operator>> to read from given string s. + void specify_option(Flag::Specification& spec) override { + spec = boost::program_options::value()->notifier([&](const std::string& s) { + std::stringstream ss{s}; + ss >> value_.get(); + }); + } + + private: + std::reference_wrapper value_; +}; + +/// @brief OptionalTypedReferenceFlag handles Optional references, making +/// sure that a value is always read on notify, even if the Optional wasn't +/// initialized previously. +template +class OptionalTypedReferenceFlag : public Flag { + public: + typedef std::shared_ptr> Ptr; + + OptionalTypedReferenceFlag(const Name& name, const Description& description, + Optional& value) + : Flag{name, description}, value_{value} {} + + /// @brief Option generated by specify_option tries to unwrap a value of + /// type T from value. + void specify_option(Flag::Specification& spec) override { + spec = boost::program_options::value()->notifier([&](const std::string& s) { + std::stringstream ss{s}; + T value; + ss >> value; + value_.get() = value; + }); + } + + private: + std::reference_wrapper> value_; +}; + +/// @brief BoolSwitchFlag implements Flag, updating the given mutable reference +/// to a boolean value. +class BoolSwitchFlag : public Flag { + public: + typedef std::shared_ptr Ptr; + + BoolSwitchFlag(const Name& name, const Description& description, bool& value) + : Flag{name, description}, value_(value) {} + + /// @brief Option generated by specify_option tries to unwrap a boolean + /// value from value. + void specify_option(Flag::Specification& spec) override { + spec = boost::program_options::bool_switch(&value_.get()); + } + + private: + std::reference_wrapper value_; +}; + +/// @brief Command abstracts an individual command available from the daemon. +class Command : public DoNotCopyOrMove { + public: + // Safe us some typing + typedef std::shared_ptr Ptr; + + /// @brief FlagsMissing is thrown if at least one required flag is missing. + struct FlagsMissing : public std::runtime_error { + /// @brief FlagsMissing initializes a new instance. + FlagsMissing(); + }; + + /// @brief FlagsWithWrongValue is thrown if a value passed on the command line + /// is invalid. + struct FlagsWithInvalidValue : public std::runtime_error { + /// @brief FlagsWithInvalidValue initializes a new instance. + FlagsWithInvalidValue(); + }; + + /// @brief Context bundles information passed to Command::run invocations. + struct Context { + std::istream& cin; ///< The std::istream that should be used for reading. + std::ostream& cout; ///< The std::ostream that should be used for writing. + std::vector args; ///< The command line args. + }; + + /// @brief name returns the Name of the command. + virtual Name name() const; + + /// @brief usage returns a short usage string for the command. + virtual Usage usage() const; + + /// @brief description returns a longer string explaining the command. + virtual Description description() const; + + /// @brief hidden returns if the command is hidden from the user or not. + virtual bool hidden() const; + + /// @brief run puts the command to execution. + virtual int run(const Context& context) = 0; + + /// @brief help prints information about a command to out. + virtual void help(std::ostream& out) = 0; + + protected: + /// @brief Command initializes a new instance with the given name, usage and + /// description. + Command(const Name& name, const Usage& usage, const Description& description, bool hidden = false); + + /// @brief name adjusts the name of the command to n. + // virtual void name(const Name& n); + /// @brief usage adjusts the usage string of the comand to u. + // virtual void usage(const Usage& u); + /// @brief description adjusts the description string of the command to d. + // virtual void description(const Description& d); + + private: + Name name_; + Usage usage_; + Description description_; + bool hidden_; +}; + +/// @brief CommandWithSubcommands implements Command, selecting one of a set of +/// actions. +class CommandWithSubcommands : public Command { + public: + typedef std::shared_ptr Ptr; + typedef std::function Action; + + /// @brief CommandWithSubcommands initializes a new instance with the given + /// name, usage and description. + CommandWithSubcommands(const Name& name, const Usage& usage, + const Description& description); + + /// @brief command adds the given command to the set of known commands. + CommandWithSubcommands& command(const Command::Ptr& command); + + /// @brief flag adds the given flag to the set of known flags. + CommandWithSubcommands& flag(const Flag::Ptr& flag); + + // From Command + int run(const Context& context) override; + void help(std::ostream& out) override; + + private: + std::unordered_map commands_; + std::set flags_; +}; + +/// @brief CommandWithFlagsAction implements Command, executing an Action after +/// handling +class CommandWithFlagsAndAction : public Command { + public: + typedef std::shared_ptr Ptr; + typedef std::function Action; + + /// @brief CommandWithFlagsAndAction initializes a new instance with the given + /// name, usage and description. Optionally the command can be marked as hidden. + CommandWithFlagsAndAction(const Name& name, const Usage& usage, + const Description& description, bool hidden = false); + + /// @brief flag adds the given flag to the set of known flags. + CommandWithFlagsAndAction& flag(const Flag::Ptr& flag); + + /// @brief action installs the given action. + CommandWithFlagsAndAction& action(const Action& action); + + // From Command + int run(const Context& context) override; + void help(std::ostream& out) override; + + private: + std::set flags_; + Action action_; +}; + +namespace cmd { +/// @brief HelpFor prints a help message for the given command on execution. +class Help : public Command { + public: + /// @brief HelpFor initializes a new instance with the given reference to a + /// cmd. + explicit Help(Command& cmd); + + // From Command + int run(const Context& context) override; + void help(std::ostream& out) override; + + private: + /// @cond + Command& command; + /// @endcond +}; +} + +/// @brief args returns a vector of strings assembled from argc and argv. +std::vector args(int argc, char** argv); + +/// @brief make_flag returns a flag with the given name and description. +template +typename TypedFlag::Ptr make_flag(const Name& name, + const Description& description) { + return std::make_shared>(name, description); +} + +/// @brief make_flag returns a flag with the given name and description, +/// notifying updates to value. +template +typename TypedReferenceFlag::Ptr make_flag(const Name& name, + const Description& desc, + T& value) { + return std::make_shared>(name, desc, value); +} + +/// @brief make_flag returns a flag with the given name and description, +/// updating the given optional value. +template +typename OptionalTypedReferenceFlag::Ptr make_flag(const Name& name, + const Description& desc, + Optional& value) { + return std::make_shared>(name, desc, value); +} + +/// @brief make_flag returns a flag with the given name and description, +/// updating the given boolean value. +inline BoolSwitchFlag::Ptr make_flag(const Name& name, + const Description &desc, + bool &value) { + return std::make_shared(name, desc, value); +} + +} // namespace cli +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.cpp new file mode 100644 index 0000000..8a6f505 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.cpp @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2018 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/cmds/check_features.h" +#include "anbox/utils.h" + +#include "cpu_features_macros.h" +#if defined(CPU_FEATURES_ARCH_X86) +#include "cpuinfo_x86.h" +#endif + +namespace { +std::vector cpu_whitelist = { + // QEMU does not necessarily expose correctly that it supports SSE and friends even + // when started with `-cpu qemu64,+ssse3,+sse4.1,+sse4.2,+x2apic` + "QEMU", + + // The following CPUs do not support AVX and without it cpu_features can't detect + // if SSE & friends are supported. See https://github.com/google/cpu_features/issues/4 + + // Intel Core i7 M620 + "M 620", + // Intel Core i5 M460 + "M 460", + // Intel Celeron N2840 + "N2840", + // Intel Core i7 Q720 + "Q 720", + // Intel Pentium T4500 + "T4500", + // Intel Core i7 Q720 + "Q 720", + // Intel Xeon E5520 + "E5520" + // Intel Core2 Duo T6500 + "T6500" +}; +} // namespace + +anbox::cmds::CheckFeatures::CheckFeatures() + : CommandWithFlagsAndAction{ + cli::Name{"check-features"}, cli::Usage{"check-features"}, + cli::Description{"Check that the host system supports all necessary features"}} { + + action([this](const cli::Command::Context&) { +#if defined(CPU_FEATURES_ARCH_X86) + const auto info = cpu_features::GetX86Info(); + std::vector missing_features; + +#define CHECK_BOOL(x, name) \ + if (!x) \ + missing_features.push_back(name) + + CHECK_BOOL(info.features.sse4_1, "SSE 4.1"); + CHECK_BOOL(info.features.sse4_2, "SSE 4.2"); + CHECK_BOOL(info.features.ssse3, "SSSE 3"); + + char brand_string[49]; + cpu_features::FillX86BrandString(brand_string); + std::string brand(brand_string); + + // Check if we have a CPU which's features we can't detect correctly + auto is_whitelisted = false; + for (const auto &entry : cpu_whitelist) { + if (brand.find(entry) != std::string::npos) { + is_whitelisted = true; + break; + } + } + + if (missing_features.size() > 0 && !is_whitelisted && !sanity_check_for_features()) { + std::cerr << "The CPU of your computer (" << brand_string << ") does not support all" << std::endl + << "features Anbox requires." << std::endl + << "It is missing support for the following features: "; + + for (size_t n = 0; n < missing_features.size(); n++) { + const auto feature = missing_features[n]; + std::cerr << feature; + if (n < missing_features.size() - 1) + std::cerr << ", "; + } + std::cerr << std::endl; + std::cerr << "You can for example find more information about SSE" << std::endl + << "here https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions" << std::endl; + + return EXIT_FAILURE; + } + + std::cout << "Your computer does meet all requirements to run Anbox" << std::endl; + + return EXIT_SUCCESS; +#else + std::cerr << "You're running Anbox on a not yet supported architecture" << std::endl; + return EXIT_FAILURE; +#endif + }); +} + +// In case that the CPU supports AVX we take the decision as from our analysis +// of the output from the cpu_features library. If it does not we have to check +// further via the compiler builtins if we the CPU supports all mandatory features +// or not. In case that any is missing we will fail the test. +// +// This uses the compiler builtin function __builtin_cpu_supports which allows us +// to detect certain CPU features. +// See https://gcc.gnu.org/onlinedocs/gcc/x86-Built-in-Functions.html +bool anbox::cmds::CheckFeatures::sanity_check_for_features() { +#if defined(CPU_FEATURES_ARCH_X86) + if (__builtin_cpu_supports("avx")) + return true; + + std::vector missing_features; + +#define CHECK_FEATURE(name) \ + if (!__builtin_cpu_supports(name)) \ + missing_features.push_back(name); + + CHECK_FEATURE("sse4.1"); + CHECK_FEATURE("sse4.2"); + CHECK_FEATURE("ssse3"); + + return missing_features.empty(); +#else + return true; +#endif +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.h new file mode 100644 index 0000000..8402ca6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/check_features.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_CMDS_CHECK_FEATURES_H_ +#define ANBOX_CMDS_CHECK_FEATURES_H_ + +#include +#include +#include + +#include "anbox/cli.h" + +namespace anbox { +namespace cmds { +class CheckFeatures : public cli::CommandWithFlagsAndAction { + public: + CheckFeatures(); + + private: + bool sanity_check_for_features(); +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.cpp new file mode 100644 index 0000000..1c99881 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.cpp @@ -0,0 +1,276 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/cmds/container_manager.h" +#include "anbox/container/service.h" +#include "anbox/common/loop_device_allocator.h" +#include "anbox/logger.h" +#include "anbox/runtime.h" +#include "anbox/system_configuration.h" + +#include "core/posix/signal.h" +#include "core/posix/exec.h" + +#include +#include +#include + +namespace fs = boost::filesystem; + +namespace { +constexpr unsigned int unprivileged_user_id{100000}; +} + +anbox::cmds::ContainerManager::ContainerManager() + : CommandWithFlagsAndAction{ + cli::Name{"container-manager"}, cli::Usage{"container-manager"}, + cli::Description{"Start the container manager service"}, true} { + + flag(cli::make_flag(cli::Name{"android-image"}, + cli::Description{"Path to the Android rootfs image file if not stored in the data path"}, + android_img_path_)); + flag(cli::make_flag(cli::Name{"data-path"}, + cli::Description{"Path where the container and its data is stored"}, + data_path_)); + flag(cli::make_flag(cli::Name{"privileged"}, + cli::Description{"Run Android container in privileged mode"}, + privileged_)); + flag(cli::make_flag(cli::Name{"daemon"}, + cli::Description{"Mark service as being started as systemd daemon"}, + daemon_)); + flag(cli::make_flag(cli::Name{"use-rootfs-overlay"}, + cli::Description{"Use an overlay for the Android rootfs"}, + enable_rootfs_overlay_)); + flag(cli::make_flag(cli::Name{"force-squashfuse"}, + cli::Description{"Force using squashfuse for mounting the Android rootfs"}, + enable_squashfuse_)); + flag(cli::make_flag(cli::Name{"container-network-address"}, + cli::Description{"Assign the specified network address to the Android container"}, + container_network_address_)); + flag(cli::make_flag(cli::Name{"container-network-gateway"}, + cli::Description{"Assign the specified network gateway to the Android container"}, + container_network_gateway_)); + flag(cli::make_flag(cli::Name{"container-network-dns-servers"}, + cli::Description{"Assign the specified DNS servers to the Android container"}, + container_network_dns_servers_)); + + action([&](const cli::Command::Context&) { + try { + if (!daemon_) { + WARNING("You are running the container manager manually which is most likely not"); + WARNING("what you want. The container manager is normally started by systemd or"); + WARNING("another init system. If you still want to run the container-manager"); + WARNING("you can get rid of this warning by starting with the --daemon option."); + WARNING(""); + } + + if (geteuid() != 0) { + ERROR("You are not running the container-manager as root. Generally you don't"); + ERROR("want to run the container-manager manually unless you're a developer"); + ERROR("as it is started by the init system of your operating system."); + return EXIT_FAILURE; + } + + auto trap = core::posix::trap_signals_for_process( + {core::posix::Signal::sig_term, core::posix::Signal::sig_int}); + trap->signal_raised().connect([trap](const core::posix::Signal& signal) { + INFO("Signal %i received. Good night.", static_cast(signal)); + trap->stop(); + }); + + if (!data_path_.empty()) + SystemConfiguration::instance().set_data_path(data_path_); + + if (!fs::exists(data_path_)) + fs::create_directories(data_path_); + + if (!setup_mounts()) + return EXIT_FAILURE; + + auto rt = Runtime::create(); + container::Service::Configuration config; + config.privileged = privileged_; + config.rootfs_overlay = enable_rootfs_overlay_; + config.container_network_address = container_network_address_; + config.container_network_gateway = container_network_gateway_; + + if (container_network_dns_servers_.length() > 0) + config.container_network_dns_servers = utils::string_split(container_network_dns_servers_, ','); + + auto service = container::Service::create(rt, config); + + rt->start(); + trap->run(); + rt->stop(); + + return EXIT_SUCCESS; + } catch (std::exception &err) { + ERROR("%s", err.what()); + return EXIT_FAILURE; + } + }); +} + +anbox::cmds::ContainerManager::~ContainerManager() {} + +bool anbox::cmds::ContainerManager::setup_mounts() { + fs::path android_img_path = android_img_path_; + if (android_img_path.empty()) + android_img_path = SystemConfiguration::instance().data_dir() / "android.img"; + + if (!fs::exists(android_img_path)) { + ERROR("Android image does not exist at path %s", android_img_path); + return false; + } + + const auto android_rootfs_dir = SystemConfiguration::instance().rootfs_dir(); + if (utils::is_mounted(android_rootfs_dir)) { + ERROR("Androd rootfs is already mounted!?"); + return false; + } + + if (!fs::exists(android_rootfs_dir)) + fs::create_directory(android_rootfs_dir); + + // We prefer using the kernel for mounting the squashfs image but + // for some cases (unprivileged containers) where no loop support + // is available we do the mount instead via squashfuse which will + // work entirely in userspace. + if (!fs::exists("/dev/loop-control") && !enable_squashfuse_) { + WARNING("/dev/loop-control not found. Falling back to squashfuse."); + enable_squashfuse_ = true; + } + if (!enable_squashfuse_) { + std::shared_ptr loop_device; + + try { + loop_device = common::LoopDeviceAllocator::new_device(); + } catch (const std::exception& e) { + ERROR("Could not create loopback device: %s", e.what()); + return false; + } catch (...) { + ERROR("Could not create loopback device"); + return false; + } + + if (!loop_device->attach_file(android_img_path)) { + ERROR("Failed to attach Android rootfs image to loopback device"); + return false; + } + + auto m = common::MountEntry::create(loop_device, android_rootfs_dir, "squashfs", MS_MGC_VAL | MS_RDONLY | MS_PRIVATE); + if (!m) { + ERROR("Failed to mount Android rootfs"); + return false; + } + mounts_.push_back(m); + } else if (fs::exists("/dev/fuse") && !utils::find_program_on_path("squashfuse").empty()) { + std::vector args = { + "-t", "fuse.squashfuse", + // Allow other users than root to access the rootfs + "-o", "allow_other", + android_img_path.string(), + android_rootfs_dir, + }; + + // Easiest is here to go with the standard mount program as that + // will handle everything for us which is relevant to get the + // squashfs via squashfuse properly mount without having to + // reimplement all the details. Once the mount call comes back + // without an error we can expect the image to be mounted. + auto child = core::posix::exec("/bin/mount", args, {}, core::posix::StandardStream::empty, []() {}); + const auto result = child.wait_for(core::posix::wait::Flags::untraced); + if (result.status != core::posix::wait::Result::Status::exited || + result.detail.if_exited.status != core::posix::exit::Status::success) { + ERROR("Failed to mount squashfs Android image"); + return false; + } + + auto m = common::MountEntry::create(android_rootfs_dir); + if (!m) { + ERROR("Failed to create mount entry for Android rootfs"); + return false; + } + mounts_.push_back(m); + } else { + ERROR("No loop device or FUSE support found. Can't setup Android rootfs!"); + return false; + } + + auto final_android_rootfs_dir = android_rootfs_dir; + if (enable_rootfs_overlay_) { + if (!setup_rootfs_overlay()) + return false; + + final_android_rootfs_dir = SystemConfiguration::instance().combined_rootfs_dir(); + } + + + for (const auto &dir_name : std::vector{"cache", "data"}) { + auto target_dir_path = fs::path(final_android_rootfs_dir) / dir_name; + auto src_dir_path = SystemConfiguration::instance().data_dir() / dir_name; + + if (!fs::exists(src_dir_path)) { + if (!fs::create_directory(src_dir_path)) { + ERROR("Failed to create Android %s directory", dir_name); + mounts_.clear(); + return false; + } + if (::chown(src_dir_path.c_str(), unprivileged_user_id, unprivileged_user_id) != 0) { + ERROR("Failed to allow access for unprivileged user on %s directory of the rootfs", dir_name); + mounts_.clear(); + return false; + } + } + + auto m = common::MountEntry::create(src_dir_path, target_dir_path, "", MS_MGC_VAL | MS_BIND | MS_PRIVATE); + if (!m) { + ERROR("Failed to mount Android %s directory", dir_name); + mounts_.clear(); + return false; + } + mounts_.push_back(m); + } + + // Unmounting needs to happen in reverse order + std::reverse(mounts_.begin(), mounts_.end()); + + return true; +} + +bool anbox::cmds::ContainerManager::setup_rootfs_overlay() { + const auto combined_rootfs_path = SystemConfiguration::instance().combined_rootfs_dir(); + if (!fs::exists(combined_rootfs_path)) + fs::create_directories(combined_rootfs_path); + + const auto overlay_path = SystemConfiguration::instance().overlay_dir(); + if (!fs::exists(overlay_path)) + fs::create_directories(overlay_path); + + const auto rootfs_path = SystemConfiguration::instance().rootfs_dir(); + const auto overlay_config = utils::string_format("lowerdir=%s:%s", overlay_path, rootfs_path); + auto m = common::MountEntry::create("overlay", combined_rootfs_path, "overlay", MS_RDONLY, overlay_config.c_str()); + if (!m) { + ERROR("Failed to setup rootfs overlay"); + mounts_.clear(); + return false; + } + mounts_.push_back(m); + + DEBUG("Successfully setup rootfs overlay"); + return true; +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.h new file mode 100644 index 0000000..77ac47d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/container_manager.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_CMDS_CONTAINER_MANAGER_H_ +#define ANBOX_CMDS_CONTAINER_MANAGER_H_ + +#include +#include +#include + +#include "anbox/cli.h" + +#include "anbox/common/loop_device.h" +#include "anbox/common/mount_entry.h" + +namespace anbox { +namespace cmds { +class ContainerManager : public cli::CommandWithFlagsAndAction { + public: + ContainerManager(); + ~ContainerManager(); + + private: + bool setup_mounts(); + bool setup_rootfs_overlay(); + + std::string android_img_path_; + std::string data_path_; + std::shared_ptr android_img_loop_dev_; + std::vector> mounts_; + bool privileged_ = false; + bool daemon_ = false; + bool enable_rootfs_overlay_ = false; + bool enable_squashfuse_ = false; + std::string container_network_address_; + std::string container_network_gateway_; + std::string container_network_dns_servers_; +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.cpp new file mode 100644 index 0000000..ff3c4af --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/cmds/install.h" +#include "anbox/dbus/stub/application_manager.h" + +#include + +#include + +namespace fs = boost::filesystem; + +anbox::cmds::Install::Install() + : CommandWithFlagsAndAction{ + cli::Name{"install"}, cli::Usage{"install"}, + cli::Description{ + "Install specified application in the Android container"}} { + flag(cli::make_flag(cli::Name{"apk"}, + cli::Description{"Path to APK to install"}, apk_)); + action([this](const cli::Command::Context&) { + if (apk_.length() == 0) + BOOST_THROW_EXCEPTION(std::runtime_error("No APK to install specified")); + + if (!fs::is_regular_file(apk_)) + BOOST_THROW_EXCEPTION( + std::runtime_error("Specified APK file does not exist")); + + auto bus = + std::make_shared(core::dbus::WellKnownBus::session); + bus->install_executor(core::dbus::asio::make_executor(bus)); + auto stub = dbus::stub::ApplicationManager::create_for_bus(bus); + + stub->install(apk_); + + return EXIT_SUCCESS; + }); +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.h new file mode 100644 index 0000000..63f2102 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/install.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_CMDS_INSTALL_H_ +#define ANBOX_CMDS_INSTALL_H_ + +#include +#include +#include + +#include "anbox/cli.h" + +namespace anbox { +namespace cmds { +class Install : public cli::CommandWithFlagsAndAction { + public: + Install(); + + private: + std::string apk_; +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.cpp new file mode 100644 index 0000000..a8de408 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.cpp @@ -0,0 +1,225 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/cmds/launch.h" +#include "anbox/dbus/stub/application_manager.h" +#include "anbox/dbus/interface.h" +#include "anbox/ui/splash_screen.h" +#include "anbox/system_configuration.h" +#include "anbox/logger.h" + +#include "core/posix/exec.h" +#include "core/posix/fork.h" +#include "core/posix/signal.h" + +#include + +#include +#include + +namespace fs = boost::filesystem; + +namespace { +constexpr unsigned int max_session_mgr_wait_attempts{10}; +const std::chrono::seconds session_mgr_wait_interval{5}; +constexpr unsigned int max_dbus_service_wait_attempts{10}; +const std::chrono::seconds dbus_service_wait_interval{5}; + +static int redirect_to_null(int flags, int fd) { + int fd2; + if ((fd2 = open("/dev/null", flags)) < 0) + return -1; + + if (fd2 == fd) + return fd; + + if (dup2(fd2, fd) < 0) + return -1; + + close(fd2); + return fd; +} +} // namespace + +bool anbox::cmds::Launch::launch_session_manager() { + std::vector args = {"session-manager"}; + const auto should_force_software_rendering = utils::get_env_value("ANBOX_FORCE_SOFTWARE_RENDERING", "false"); + if (should_force_software_rendering == "true") + args.push_back("--software-rendering"); + + std::map env; + core::posix::this_process::env::for_each([&](const std::string &name, const std::string &value) { + env.insert({name, value}); + }); + + const auto exe_path = utils::process_get_exe_path(::getpid()); + if (!fs::exists(exe_path)) { + ERROR("Can't find correct anbox executable to run. Found %s but does not exist", exe_path); + return false; + } + + try { + auto flags = core::posix::StandardStream::empty; + auto child = core::posix::fork([&]() { + + // We redirect all in/out/err to /dev/null as they can't be seen + // anywhere. All logging output will directly go to syslog as we + // will become a session leader below which will get us rid of a + // controlling terminal. + if (redirect_to_null(O_RDONLY, 0) < 0 || + redirect_to_null(O_WRONLY, 1) < 0 || + redirect_to_null(O_WRONLY, 2) < 0) { + ERROR("Failed to redirect stdout/stderr/stdin: %s", strerror(errno)); + return core::posix::exit::Status::failure; + } + + // As we forked one time already we're sure that our process is + // not the session leader anymore so we can safely become the + // new one and lead the process group. + if (setsid() < 0) { + ERROR("Failed to become new session leader: %s", strerror(errno)); + return core::posix::exit::Status::failure; + } + + umask(0077); + + if (chdir("/") < 0) { + ERROR("Failed to change current directory: %s", strerror(errno)); + return core::posix::exit::Status::failure; + } + + auto grandchild = core::posix::exec(exe_path, args, env, flags); + grandchild.dont_kill_on_cleanup(); + return core::posix::exit::Status::success; + }, flags); + + // We don't wait for the grandchild but the child as we use double forking + // here to break through the process hierarchy and make the grandchild a + // direct child of the init process so it keeps running on its own and + // indepent of our short living process here. + child.wait_for(core::posix::wait::Flags::untraced); + + DEBUG("Started session manager, will now try to connect .."); + } + catch (...) { + ERROR("Failed to start session manager instance"); + } + + return true; +} + +bool anbox::cmds::Launch::try_launch_activity(const std::shared_ptr &stub) { + try { + DEBUG("Sending launch intent %s to Android ..", intent_); + stub->launch(intent_, graphics::Rect::Invalid, stack_); + } catch (const std::exception &err) { + ERROR("Failed to launch activity: %s", err.what()); + return false; + } catch (...) { + ERROR("Failed to launch activity"); + return false; + } + + return true; +} + +anbox::cmds::Launch::Launch() + : CommandWithFlagsAndAction{ + cli::Name{"launch"}, cli::Usage{"launch"}, + cli::Description{"Launch an Activity by sending an intent"}} { + flag(cli::make_flag(cli::Name{"action"}, + cli::Description{"Action of the intent"}, + intent_.action)); + flag(cli::make_flag(cli::Name{"type"}, + cli::Description{"MIME type for the intent"}, + intent_.type)); + flag(cli::make_flag(cli::Name{"uri"}, + cli::Description{"URI used as data within the intent"}, + intent_.uri)); + flag(cli::make_flag(cli::Name{"package"}, + cli::Description{"Package the intent should go to"}, + intent_.package)); + flag(cli::make_flag(cli::Name{"component"}, + cli::Description{"Component of a package the intent should go"}, + intent_.component)); + flag(cli::make_flag(cli::Name{"stack"}, + cli::Description{"Which window stack the activity should be started on. Possible: default, fullscreen, freeform"}, + stack_)); + flag(cli::make_flag(cli::Name{"use-system-dbus"}, + cli::Description{"Use system instead of session DBus"}, + use_system_dbus_)); + + + action([this](const cli::Command::Context&) { + if (!intent_.valid()) { + ERROR("The intent you provided is invalid. Please provide a correct launch intent."); + ERROR("For example to launch the application manager, run:"); + ERROR("$ anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity"); + return EXIT_FAILURE; + } + + auto bus_type = anbox::dbus::Bus::Type::Session; + if (use_system_dbus_) + bus_type = anbox::dbus::Bus::Type::System; + auto bus = std::make_shared(bus_type); + + std::shared_ptr ss; + if (!bus->has_service_with_name(dbus::interface::Service::name())) { + DEBUG("Session manager is not yet running, trying to start it"); + + if (!launch_session_manager()) + return EXIT_FAILURE; + + // Give us a splash screen as long as we're trying to connect + // with the session manager so the user knows something is + // happening after he started Anbox. + ss = std::make_shared(); + } + + unsigned int n = 0; + while (n < max_dbus_service_wait_attempts) { + if (bus->has_service_with_name(dbus::interface::Service::name())) + break; + + std::this_thread::sleep_for(dbus_service_wait_interval); + n++; + } + + auto app_mgr = dbus::stub::ApplicationManager::create_for_bus(bus); + n = 0; + while (n < max_session_mgr_wait_attempts) { + app_mgr->update_properties(); + if (app_mgr->ready().get()) + break; + + std::this_thread::sleep_for(session_mgr_wait_interval); + n++; + } + + if (!app_mgr->ready()) { + ERROR("Session manager failed to become ready"); + return EXIT_FAILURE; + } + + // If we have a splash screen now is the time to drop it as we're + // going to launch the real application now. + ss.reset(); + + const auto success = try_launch_activity(app_mgr); + return success ? EXIT_SUCCESS : EXIT_FAILURE; + }); +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.h new file mode 100644 index 0000000..2aa3d0f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/launch.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_CMDS_LAUNCH_H_ +#define ANBOX_CMDS_LAUNCH_H_ + +#include +#include +#include + +#include "anbox/android/intent.h" +#include "anbox/dbus/stub/application_manager.h" +#include "anbox/wm/stack.h" +#include "anbox/cli.h" + +namespace anbox { +namespace cmds { +class Launch : public cli::CommandWithFlagsAndAction { + public: + Launch(); + + private: + bool launch_session_manager(); + bool try_launch_activity(const std::shared_ptr &stub); + + android::Intent intent_; + wm::Stack::Id stack_ = wm::Stack::Id::Default; + bool use_system_dbus_ = false; +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.cpp new file mode 100644 index 0000000..81452a5 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.cpp @@ -0,0 +1,313 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#include + +#include "core/posix/signal.h" + +#include "anbox/application/launcher_storage.h" +#include "anbox/application/database.h" +#include "anbox/audio/server.h" +#include "anbox/bridge/android_api_stub.h" +#include "anbox/bridge/platform_api_skeleton.h" +#include "anbox/bridge/platform_message_processor.h" +#include "anbox/graphics/gl_renderer_server.h" + +#include "anbox/cmds/session_manager.h" +#include "anbox/common/dispatcher.h" +#include "anbox/system_configuration.h" +#include "anbox/container/client.h" +#include "anbox/dbus/bus.h" +#include "anbox/dbus/skeleton/service.h" +#include "anbox/input/manager.h" +#include "anbox/logger.h" +#include "anbox/network/published_socket_connector.h" +#include "anbox/qemu/pipe_connection_creator.h" +#include "anbox/rpc/channel.h" +#include "anbox/rpc/connection_creator.h" +#include "anbox/runtime.h" +#include "anbox/platform/base_platform.h" +#include "anbox/wm/multi_window_manager.h" +#include "anbox/wm/single_window_manager.h" + +#include "external/xdg/xdg.h" + +#include + +#pragma GCC diagnostic pop + +namespace fs = boost::filesystem; + +namespace { +constexpr const char *default_appmgr_package{"org.anbox.appmgr"}; +constexpr const char *default_appmgr_component{"org.anbox.appmgr.AppViewActivity"}; +const boost::posix_time::milliseconds default_appmgr_startup_delay{50}; +const anbox::graphics::Rect default_single_window_size{0, 0, 1024, 768}; + +class NullConnectionCreator : public anbox::network::ConnectionCreator< + boost::asio::local::stream_protocol> { + public: + void create_connection_for( + std::shared_ptr const + &socket) override { + WARNING("Not implemented"); + socket->close(); + } +}; +} + +void anbox::cmds::SessionManager::launch_appmgr_if_needed(const std::shared_ptr &android_api_stub) { + if (!single_window_) + return; + + android::Intent launch_intent; + launch_intent.package = default_appmgr_package; + launch_intent.component = default_appmgr_component; + // As this will only be executed in single window mode we don't have + // to specify and launch bounds. + android_api_stub->launch(launch_intent, graphics::Rect::Invalid, wm::Stack::Id::Default); +} + +anbox::cmds::SessionManager::SessionManager() + : CommandWithFlagsAndAction{cli::Name{"session-manager"}, cli::Usage{"session-manager"}, + cli::Description{"Run the the anbox session manager"}}, + window_size_(default_single_window_size) { + // Just for the purpose to allow QtMir (or unity8) to find this on our + // /proc/*/cmdline + // for proper confinement etc. + flag(cli::make_flag(cli::Name{"desktop_file_hint"}, + cli::Description{"Desktop file hint for QtMir/Unity8"}, + desktop_file_hint_)); + flag(cli::make_flag(cli::Name{"single-window"}, + cli::Description{"Start in single window mode."}, + single_window_)); + flag(cli::make_flag(cli::Name{"window-size"}, + cli::Description{"Size of the window in single window mode, e.g. --window-size=1024,768"}, + window_size_)); + flag(cli::make_flag(cli::Name{"standalone"}, + cli::Description{"Prevents the Container Manager from starting the default container (Experimental)"}, + standalone_)); + flag(cli::make_flag(cli::Name{"experimental"}, + cli::Description{"Allows users to use experimental features"}, + experimental_)); + flag(cli::make_flag(cli::Name{"use-system-dbus"}, + cli::Description{"Use system instead of session DBus"}, + use_system_dbus_)); + flag(cli::make_flag(cli::Name{"software-rendering"}, + cli::Description{"Use software rendering instead of hardware accelerated GL rendering"}, + use_software_rendering_)); + flag(cli::make_flag(cli::Name{"no-touch-emulation"}, + cli::Description{"Disable touch emulation applied on mouse inputs"}, + no_touch_emulation_)); + flag(cli::make_flag(cli::Name{"server-side-decoration"}, + cli::Description{"Prefer to use server-side decoration instead of client-side decoration"}, + server_side_decoration_)); + + action([this](const cli::Command::Context &) { + auto trap = core::posix::trap_signals_for_process( + {core::posix::Signal::sig_term, core::posix::Signal::sig_int}); + trap->signal_raised().connect([trap](const core::posix::Signal &signal) { + INFO("Signal %i received. Good night.", static_cast(signal)); + trap->stop(); + }); + + if (standalone_ && !experimental_) { + ERROR("Experimental features selected, but --experimental flag not set"); + return EXIT_FAILURE; + } + + if ((!fs::exists("/dev/binder") && !fs::exists(BINDERFS_PATH)) || !fs::exists("/dev/ashmem")) { + ERROR("Failed to start as either binder or ashmem kernel drivers are not loaded"); + return EXIT_FAILURE; + } + + utils::ensure_paths({ + SystemConfiguration::instance().socket_dir(), + SystemConfiguration::instance().input_device_dir(), + }); + + auto rt = Runtime::create(); + auto dispatcher = anbox::common::create_dispatcher_for_runtime(rt); + + if (!standalone_) { + container_ = std::make_shared(rt); + container_->register_terminate_handler([&]() { + WARNING("Lost connection to container manager, terminating."); + trap->stop(); + }); + } + + auto input_manager = std::make_shared(rt); + auto android_api_stub = std::make_shared(); + + auto display_frame = graphics::Rect::Invalid; + if (single_window_) + display_frame = window_size_; + + const auto should_enable_touch_emulation = utils::get_env_value("ANBOX_ENABLE_TOUCH_EMULATION", "true"); + if (should_enable_touch_emulation == "false" || no_touch_emulation_) + no_touch_emulation_ = true; + + const auto should_force_server_side_decoration = utils::get_env_value("ANBOX_FORCE_SERVER_SIDE_DECORATION", "false"); + if (should_force_server_side_decoration == "true") + server_side_decoration_ = true; + + platform::Configuration platform_config; + platform_config.single_window = single_window_; + platform_config.no_touch_emulation = no_touch_emulation_; + platform_config.display_frame = display_frame; + platform_config.server_side_decoration = server_side_decoration_; + + auto platform = platform::create(utils::get_env_value("ANBOX_PLATFORM", "sdl"), + input_manager, + platform_config); + if (!platform) + return EXIT_FAILURE; + + auto app_db = std::make_shared(); + + std::shared_ptr window_manager; + bool using_single_window = false; + if (platform->supports_multi_window() && !single_window_) + window_manager = std::make_shared(platform, android_api_stub, app_db); + else { + window_manager = std::make_shared(platform, display_frame, app_db); + using_single_window = true; + } + + const auto should_force_software_rendering = utils::get_env_value("ANBOX_FORCE_SOFTWARE_RENDERING", "false"); + auto gl_driver = graphics::GLRendererServer::Config::Driver::Host; + if (should_force_software_rendering == "true" || use_software_rendering_) + gl_driver = graphics::GLRendererServer::Config::Driver::Software; + + graphics::GLRendererServer::Config renderer_config { + gl_driver, + single_window_ + }; + auto gl_server = std::make_shared(renderer_config, window_manager); + + platform->set_window_manager(window_manager); + platform->set_renderer(gl_server->renderer()); + window_manager->setup(); + + auto app_manager = std::static_pointer_cast(android_api_stub); + if (!using_single_window) { + // When we're not running single window mode we need to restrict ourself to + // only launch applications in freeform mode as otherwise the window tracking + // doesn't work. + app_manager = std::make_shared( + android_api_stub, wm::Stack::Id::Freeform); + } + + auto audio_server = std::make_shared(rt, platform); + + const auto socket_path = SystemConfiguration::instance().socket_dir(); + + // The qemu pipe is used as a very fast communication channel between guest + // and host for things like the GLES emulation/translation, the RIL or ADB. + auto qemu_pipe_connector = + std::make_shared( + utils::string_format("%s/qemu_pipe", socket_path), rt, + std::make_shared(gl_server->renderer(), rt)); + + boost::asio::deadline_timer appmgr_start_timer(rt->service()); + + auto bridge_connector = std::make_shared( + utils::string_format("%s/anbox_bridge", socket_path), rt, + std::make_shared( + rt, [&](const std::shared_ptr &sender) { + auto pending_calls = std::make_shared(); + auto rpc_channel = + std::make_shared(pending_calls, sender); + // This is safe as long as we only support a single client. If we + // support + // more than one one day we need proper dispatching to the right + // one. + android_api_stub->set_rpc_channel(rpc_channel); + + auto server = std::make_shared( + pending_calls, platform, window_manager, app_db); + server->register_boot_finished_handler([&]() { + DEBUG("Android successfully booted"); + android_api_stub->ready().set(true); + appmgr_start_timer.expires_from_now(default_appmgr_startup_delay); + appmgr_start_timer.async_wait([&](const boost::system::error_code &err) { + if (err != boost::system::errc::success) + return; + launch_appmgr_if_needed(android_api_stub); + }); + }); + return std::make_shared( + sender, server, pending_calls); + })); + + container::Configuration container_configuration; + + // Instruct healthd to fake battery level as it may take it from other connected + // devices like mouse or keyboard and will incorrectly show a system popup to + // shutdown the Android system because of low battery. This prevents any kind of + // input as focus is bound to the system popup exclusively. + // + // See https://github.com/anbox/anbox/issues/780 for further details. + container_configuration.extra_properties.push_back("ro.boot.fake_battery=1"); + + if (server_side_decoration_) + container_configuration.extra_properties.push_back("ro.anbox.no_decorations=1"); + + if (!standalone_) { + container_configuration.bind_mounts = { + {qemu_pipe_connector->socket_file(), "/dev/qemu_pipe"}, + {bridge_connector->socket_file(), "/dev/anbox_bridge"}, + {audio_server->socket_file(), "/dev/anbox_audio"}, + {SystemConfiguration::instance().input_device_dir(), "/dev/input"}, + + }; + + container_configuration.devices = { + {"/dev/fuse", {0666}}, + }; + + dispatcher->dispatch([&]() { + container_->start(container_configuration); + }); + } + + auto bus_type = anbox::dbus::Bus::Type::Session; + if (use_system_dbus_) + bus_type = anbox::dbus::Bus::Type::System; + auto bus = std::make_shared(bus_type); + + auto skeleton = anbox::dbus::skeleton::Service::create_for_bus(bus, app_manager); + + bus->run_async(); + + rt->start(); + trap->run(); + + if (!standalone_) { + // Stop the container which should close all open connections we have on + // our side and should terminate all services. + container_->stop(); + } + + rt->stop(); + + return EXIT_SUCCESS; + }); +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.h new file mode 100644 index 0000000..b60c571 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/session_manager.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_CMDS_RUN_H_ +#define ANBOX_CMDS_RUN_H_ + +#include "anbox/cli.h" + +#include +#include +#include + +#include "anbox/graphics/gl_renderer_server.h" +#include "anbox/graphics/rect.h" + +namespace anbox { +namespace bridge { +class AndroidApiStub; +} // namespace bridge +namespace container { +class Client; +} // namespace container +namespace cmds { +class SessionManager : public cli::CommandWithFlagsAndAction { + public: + SessionManager(); + + private: + void launch_appmgr_if_needed(const std::shared_ptr &android_api_stub); + + std::shared_ptr container_; + std::string desktop_file_hint_; + bool single_window_ = false; + graphics::Rect window_size_; + bool standalone_ = false; + bool experimental_ = false; + bool use_system_dbus_ = false; + bool use_software_rendering_ = false; + bool no_touch_emulation_ = false; + bool server_side_decoration_ = false; +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.cpp new file mode 100644 index 0000000..b999417 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.cpp @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ + +#include "anbox/cmds/system_info.h" +#include "anbox/graphics/emugl/RenderApi.h" +#include "anbox/graphics/emugl/DispatchTables.h" +#include "anbox/utils/environment_file.h" +#include "anbox/logger.h" + +#include "anbox/build/config.h" + +#include +#include + +#include + +#include "OpenGLESDispatch/EGLDispatch.h" + +#include "cpu_features_macros.h" +#if defined(CPU_FEATURES_ARCH_X86) +#include "cpuinfo_x86.h" +#endif + +namespace fs = boost::filesystem; + +namespace { +constexpr const char *os_release_path{"/etc/os-release"}; +constexpr const char *host_os_release_path{"/var/lib/snapd/hostfs/etc/os-release"}; +constexpr const char *proc_version_path{"/proc/version"}; +constexpr const char *binder_path{"/dev/binder"}; +constexpr const char *ashmem_path{"/dev/ashmem"}; +constexpr const char *os_release_name{"NAME"}; +constexpr const char *os_release_version{"VERSION"}; + +class SystemInformation { + public: + SystemInformation() { + collect_cpu_info(); + collect_os_info(); + collect_kernel_info(); + collect_graphics_info(); + } + + std::string to_text() const { + std::stringstream s; + + s << "version: " + << anbox::build::version + << std::endl; + + if (anbox::utils::is_env_set("SNAP_REVISION")) { + s << "snap-revision: " + << anbox::utils::get_env_value("SNAP_REVISION") + << std::endl; + } + + s << "cpu:" << std::endl + << " arch: " << cpu_info_.arch << std::endl + << " brand: " << cpu_info_.brand << std::endl + << " features: " << std::endl; + for (const auto& feature : cpu_info_.features) + s << " - " << feature << std::endl; + + s << "os:" << std::endl + << " name: " << os_info_.name << std::endl + << " version: " << os_info_.version << std::endl + << " snap-based: " << std::boolalpha << os_info_.snap_based << std::endl; + + s << "kernel:" << std::endl + << " version: " << kernel_info_.version << std::endl + << " binder: " << std::boolalpha << kernel_info_.binder << std::endl + << " ashmem: " << std::boolalpha << kernel_info_.ashmem << std::endl; + + auto print_extensions = [](const std::vector &extensions) { + std::stringstream s; + if (extensions.size() > 0) { + s << std::endl; + for (const auto &ext : extensions) { + if (ext.length() == 0) + continue; + s << " - " << ext << std::endl; + } + } else { + s << " []" << std::endl; + } + return s.str(); + }; + + s << "graphics:" << std::endl + << " egl:" << std::endl + << " vendor: " << graphics_info_.egl_vendor << std::endl + << " version: " << graphics_info_.egl_version << std::endl + << " extensions:" << print_extensions(graphics_info_.egl_extensions) + << " gles2:" << std::endl + << " vendor: " << graphics_info_.gles2_vendor << std::endl + << " vendor: " << graphics_info_.gles2_version << std::endl + << " extensions:" << print_extensions(graphics_info_.gles2_extensions); + + return s.str(); + } + + private: + void collect_cpu_info() { +#if defined(CPU_FEATURES_ARCH_X86) + cpu_info_.arch = "x86"; + + const auto info = cpu_features::GetX86Info(); + if (info.features.aes) + cpu_info_.features.push_back("aes"); + if (info.features.sse4_1) + cpu_info_.features.push_back("sse4_1"); + if (info.features.sse4_2) + cpu_info_.features.push_back("sse4_2"); + if (info.features.avx) + cpu_info_.features.push_back("avx"); + if (info.features.avx2) + cpu_info_.features.push_back("avx2"); + + char brand_string[49]; + cpu_features::FillX86BrandString(brand_string); + cpu_info_.brand = brand_string; +#endif + } + + void collect_os_info() { + os_info_.snap_based = !anbox::utils::get_env_value("SNAP").empty(); + fs::path path = os_release_path; + // If we're running from within a snap the best we can do is to + // access the hostfs and read the os-release file from there. + if (os_info_.snap_based && fs::exists(host_os_release_path)) + path = host_os_release_path; + + // Double check that there aren't any permission errors when trying + // to access the file (e.g. because of snap confinement) + if (fs::exists(path)) { + anbox::utils::EnvironmentFile os_release(path); + os_info_.name = os_release.value(os_release_name); + os_info_.version = os_release.value(os_release_version); + } + } + + void collect_kernel_info() { + if (fs::exists(proc_version_path)) { + std::ifstream in(proc_version_path); + std::getline(in, kernel_info_.version); + } + + kernel_info_.binder = fs::exists(binder_path); + kernel_info_.ashmem = fs::exists(ashmem_path); + } + + void collect_graphics_info() { + auto gl_libs = anbox::graphics::emugl::default_gl_libraries(); + if (!anbox::graphics::emugl::initialize(gl_libs, nullptr, nullptr)) { + return; + } + + auto display = s_egl.eglGetDisplay(0); + if (display != EGL_NO_DISPLAY) { + s_egl.eglInitialize(display, nullptr, nullptr); + + auto egl_safe_get_string = [display](EGLint item) { + auto str = s_egl.eglQueryString(display, item); + if (!str) + return std::string("n/a"); + return std::string(reinterpret_cast(str)); + }; + + graphics_info_.egl_vendor = egl_safe_get_string(EGL_VENDOR); + graphics_info_.egl_version = egl_safe_get_string(EGL_VERSION); + const auto egl_extensions = egl_safe_get_string(EGL_EXTENSIONS); + graphics_info_.egl_extensions = anbox::utils::string_split(egl_extensions, ' '); + + GLint config_attribs[] = {EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, + EGL_NONE}; + + EGLConfig config; + int n; + if (s_egl.eglChooseConfig(display, config_attribs, &config, 1, &n) && n > 0) { + GLint attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; + auto context = s_egl.eglCreateContext(display, config, nullptr, attribs); + if (context != EGL_NO_CONTEXT) { + // We require surfaceless-context support here for now. If eglMakeCurrent fails + // glGetString will return null below which we handle correctly. + s_egl.eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context); + + auto gl_safe_get_string = [](GLint item) { + auto str = s_gles2.glGetString(item); + if (!str) + return std::string("n/a"); + return std::string(reinterpret_cast(str)); + }; + + graphics_info_.gles2_vendor = gl_safe_get_string(GL_VENDOR); + graphics_info_.gles2_version = gl_safe_get_string(GL_VERSION); + const auto gl_extensions = gl_safe_get_string(GL_EXTENSIONS); + graphics_info_.gles2_extensions = anbox::utils::string_split(gl_extensions, ' '); + + s_egl.eglMakeCurrent(display, nullptr, nullptr, nullptr); + s_egl.eglDestroyContext(display, context); + } + } + } + } + + struct { + std::string arch; + std::string brand; + std::vector features; + } cpu_info_; + + struct { + bool snap_based = false; + std::string name = "n/a"; + std::string version = "n/a"; + } os_info_; + + struct { + std::string version = "n/a"; + bool binder = false; + bool ashmem = false; + } kernel_info_; + + struct { + std::string egl_vendor = "n/a"; + std::string egl_version = "n/a"; + std::vector egl_extensions; + std::string gles2_vendor = "n/a"; + std::string gles2_version = "n/a"; + std::vector gles2_extensions; + } graphics_info_; +}; + +std::ostream &operator<<(std::ostream &out, const SystemInformation &info) { + out << info.to_text(); + return out; +} +} + +anbox::cmds::SystemInfo::SystemInfo() + : CommandWithFlagsAndAction{ + cli::Name{"system-info"}, cli::Usage{"system-info"}, + cli::Description{"Print various information about the system we're running on"}} { + action([](const cli::Command::Context&) { + SystemInformation si; + std::cout << si; + return EXIT_SUCCESS; + }); +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.h new file mode 100644 index 0000000..795f652 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/system_info.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ + +#ifndef ANBOX_CMDS_SYSTEM_INFO_H_ +#define ANBOX_CMDS_SYSTEM_INFO_H_ + +#include +#include +#include + +#include "anbox/cli.h" + +namespace anbox { +namespace cmds { +class SystemInfo : public cli::CommandWithFlagsAndAction { + public: + SystemInfo(); +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.cpp new file mode 100644 index 0000000..b0f7e2f --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ + +#include "anbox/cmds/version.h" +#include "anbox/build/config.h" +#include "anbox/utils.h" + +anbox::cmds::Version::Version() + : CommandWithFlagsAndAction{ + cli::Name{"version"}, cli::Usage{"version"}, + cli::Description{"Print the version of the daemon"}} { + action([](const cli::Command::Context& ctxt) { + ctxt.cout << "anbox " << build::version << std::endl; + return 0; + }); +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.h new file mode 100644 index 0000000..43dab98 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/version.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ + +#ifndef ANBOX_CMDS_VERSION_H_ +#define ANBOX_CMDS_VERSION_H_ + +#include +#include +#include + +#include "anbox/cli.h" + +namespace anbox { +namespace cmds { +class Version : public cli::CommandWithFlagsAndAction { + public: + Version(); +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.cpp new file mode 100644 index 0000000..9e62ce6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ + +#include "anbox/cmds/wait_ready.h" +#include "anbox/dbus/stub/application_manager.h" + +namespace { +constexpr const unsigned int max_wait_attempts{30}; +} + +anbox::cmds::WaitReady::WaitReady() + : CommandWithFlagsAndAction{ + cli::Name{"wait-ready"}, cli::Usage{"wait-ready"}, + cli::Description{"Wait until the Android system has successfully booted"}} { + + flag(cli::make_flag(cli::Name{"use-system-dbus"}, + cli::Description{"Use system instead of session DBus"}, + use_system_dbus_)); + + action([this](const cli::Command::Context&) { + auto bus_type = anbox::dbus::Bus::Type::Session; + if (use_system_dbus_) + bus_type = anbox::dbus::Bus::Type::System; + auto bus = std::make_shared(bus_type); + + auto stub = dbus::stub::ApplicationManager::create_for_bus(bus); + + unsigned int n = 0; + while (n < max_wait_attempts) { + stub->update_properties(); + if (stub->ready().get()) + return EXIT_SUCCESS; + + std::this_thread::sleep_for(std::chrono::seconds{1}); + n++; + } + + return EXIT_FAILURE; + }); +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.h b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.h new file mode 100644 index 0000000..fa61ea6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/cmds/wait_ready.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2018 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_CMDS_WAIT_READY_H_ +#define ANBOX_CMDS_WAIT_READY_H_ + +#include +#include +#include + +#include "anbox/cli.h" + +namespace anbox { +namespace cmds { +class WaitReady : public cli::CommandWithFlagsAndAction { + public: + WaitReady(); + + private: + bool use_system_dbus_ = false; +}; +} // namespace cmds +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.cpp new file mode 100644 index 0000000..dd05edb --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2016 Thomas Voss + * Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/common/binary_writer.h" + +#include +#include + +#include +#include + +namespace { +bool is_little_endian() { + static const std::uint32_t v = 1; + return (*reinterpret_cast(&v) == 1); +} +} + +namespace anbox { +namespace common { + +BinaryWriter::BinaryWriter(std::vector::iterator begin, + std::vector::iterator end) : + begin_{begin}, current_{begin}, end_{end}, + byte_order_{is_little_endian() ? Order::Little : Order::Big} {} + +void BinaryWriter::set_byte_order(Order order) { + byte_order_ = order; +} + +void BinaryWriter::write_uint16(std::uint16_t value) { + if (current_ + sizeof(value) > end_) + throw std::out_of_range{"Write buffer exhausted"}; + + std::uint16_t v = value; + switch (byte_order_) { + case Order::Big: + v = boost::endian::native_to_big(value); + break; + case Order::Little: + v = boost::endian::native_to_little(value); + break; + default: + break; + } + + memcpy(&(*current_), &v, sizeof(std::uint16_t)); + current_ += sizeof(v); +} + +void BinaryWriter::write_uint32(std::uint32_t value) { + if (current_ + sizeof(value) > end_) + throw std::out_of_range{"Write buffer exhausted"}; + + std::uint32_t v = value; + switch (byte_order_) { + case Order::Big: + v = boost::endian::native_to_big(value); + break; + case Order::Little: + v = boost::endian::native_to_little(value); + break; + default: + break; + } + memcpy(&(*current_), &v, sizeof(std::uint32_t)); + current_ += sizeof(v); +} + +void BinaryWriter::write_string(const char *s, std::size_t size) { + if (current_ + size > end_) + throw std::out_of_range{"Write buffer exhausted"}; + + memcpy(&(*current_), s, size); + current_ += size; +} + +void BinaryWriter::write_string_with_size(const std::string &str) { + write_string_with_size(str.c_str(), str.length()); +} + +void BinaryWriter::write_string_with_size(const char *s, std::size_t size) { + write_uint16(size); + write_string(s, size); +} + +std::size_t BinaryWriter::bytes_written() const { + return current_ - begin_; +} +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.h new file mode 100644 index 0000000..23708c6 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binary_writer.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2016 Thomas Voss + * Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_COMMON_BINARY_WRITER_H_ +#define ANBOX_COMMON_BINARY_WRITER_H_ + +#include +#include +#include + +namespace anbox { +namespace common { +class BinaryWriter { + public: + enum class Order { + Big, + Little, + }; + + explicit BinaryWriter(std::vector::iterator begin_, + std::vector::iterator end_); + + void set_byte_order(Order order); + + void write_uint16(std::uint16_t value); + void write_uint32(std::uint32_t value); + void write_string(const char *s, std::size_t size); + void write_string_with_size(const std::string &str); + void write_string_with_size(const char *s, std::size_t size); + + std::size_t bytes_written() const; + + private: + std::vector::iterator begin_; + std::vector::iterator current_; + std::vector::iterator end_; + Order byte_order_; +}; +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.cpp new file mode 100644 index 0000000..892222b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/common/binder_device.h" +#include "anbox/common/binderfs.h" +#include "anbox/defer_action.h" +#include "anbox/logger.h" +#include "anbox/utils.h" + +#include + +#include +#include +#include +#include +#include + +namespace anbox { +namespace common { +std::unique_ptr BinderDevice::create(const std::string& path) { + return std::unique_ptr(new BinderDevice(path)); +} + +BinderDevice::BinderDevice(const std::string& path) : + path_{path} { + if (::chmod(path.c_str(), 0666) < 0) + ERROR("Failed to change permissions of binder node %s: %s", path, std::strerror(errno)); +} + +BinderDevice::~BinderDevice() { + if (::unlink(path_.c_str()) < 0) + ERROR("Failed to remove binder node %s: %s", path_, std::strerror(errno)); +} +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.h new file mode 100644 index 0000000..7d3b496 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2018 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_COMMON_BINDER_DEVICE_H_ +#define ANBOX_COMMON_BINDER_DEVICE_H_ + +#include "anbox/common/fd.h" + +#include + +namespace anbox { +namespace common { +class BinderDevice { + public: + static std::unique_ptr create(const std::string& path); + + ~BinderDevice(); + + boost::filesystem::path path() const { return path_; } + + private: + BinderDevice(const std::string& path); + + const std::string path_; +}; +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.cpp new file mode 100644 index 0000000..cb580de --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2018 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/common/binder_device_allocator.h" +#include "anbox/common/binder_device.h" +#include "anbox/common/binderfs.h" +#include "anbox/defer_action.h" +#include "anbox/logger.h" +#include "anbox/utils.h" + +#include + +#include +#include +#include +#include + +#include + +namespace fs = boost::filesystem; + +namespace { +const constexpr char* binderfs_base_path{BINDERFS_PATH}; +const constexpr char* binderfs_control_path{BINDERFS_PATH "/binder-control"}; +const constexpr char* default_binder_device_name{"binder"}; +} // namespace + +namespace anbox { +namespace common { +bool BinderDeviceAllocator::is_supported() { + return fs::exists(binderfs_control_path); +} + +std::unique_ptr BinderDeviceAllocator::new_device() { + static uint32_t next_id = 0; + + const auto ctl_fd = ::open(binderfs_control_path, O_RDWR); + if (ctl_fd < 0) { + ERROR("Failed to access binder control: %s", std::strerror(errno)); + return nullptr; + } + + DeferAction close_ctl_fd{[&]() { ::close(ctl_fd); }}; + + binderfs_device dev; + std::memset(&dev, 0, sizeof(binderfs_device)); + + const auto device_name = utils::string_format("%s%d", default_binder_device_name, next_id++); + if (device_name.length() > BINDERFS_MAX_NAME) { + ERROR("Invalid binder device name: %s", device_name); + return nullptr; + } + + std::memcpy(dev.name, device_name.c_str(), device_name.length()); + + if (::ioctl(ctl_fd, BINDER_CTL_ADD, &dev) < 0) { + ERROR("Failed to allocate new binder node: %s", std::strerror(errno)); + return nullptr; + } + + const auto path = utils::string_format("%s/%s", binderfs_base_path, device_name); + if (!fs::exists(path)) { + ERROR("Allocated binder device %s is missing", path); + return nullptr; + } + + return BinderDevice::create(path); +} +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.h new file mode 100644 index 0000000..4a4dfc3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binder_device_allocator.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2018 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_COMMON_BINDER_DEVICE_ALLOCATOR_H_ +#define ANBOX_COMMON_BINDER_DEVICE_ALLOCATOR_H_ + +#include + +namespace anbox { +namespace common { +class BinderDevice; +class BinderDeviceAllocator { + public: + static bool is_supported(); + static std::unique_ptr new_device(); +}; +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/binderfs.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binderfs.h new file mode 100644 index 0000000..2bf708c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/binderfs.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2018 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_COMMON_BINDERFS_H_ +#define ANBOX_COMMON_BINDERFS_H_ + +#include +#include + +#define BINDERFS_MAX_NAME 255 + +/** + * struct binderfs_device - retrieve information about a new binder device + * @name: the name to use for the new binderfs binder device + * @major: major number allocated for binderfs binder devices + * @minor: minor number allocated for the new binderfs binder device + * + */ +struct binderfs_device { + char name[BINDERFS_MAX_NAME + 1]; + __u32 major; + __u32 minor; +}; + +/** + * Allocate a new binder device. + */ +#define BINDER_CTL_ADD _IOWR('b', 1, struct binderfs_device) + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.cpp new file mode 100644 index 0000000..aaec441 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ + +#include "anbox/common/dispatcher.h" + +namespace { +struct AsioStrandDispatcher : public anbox::common::Dispatcher { + public: + AsioStrandDispatcher(const std::shared_ptr& rt) + : rt{rt}, strand{rt->service()} {} + + void dispatch(const Task& task) override { strand.post(task); } + + private: + std::shared_ptr rt; + boost::asio::io_service::strand strand; +}; +} + +std::shared_ptr +anbox::common::create_dispatcher_for_runtime( + const std::shared_ptr& rt) { + return std::make_shared(rt); +} diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.h new file mode 100644 index 0000000..53d4b43 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/dispatcher.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 Canonical, Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + * + */ + +#ifndef ANBOX_COMMON_DISPATCHER_H_ +#define ANBOX_COMMON_DISPATCHER_H_ + +#include "anbox/do_not_copy_or_move.h" +#include "anbox/runtime.h" + +#include + +namespace anbox { +namespace common { +class Dispatcher : public DoNotCopyOrMove { + public: + typedef std::function Task; + virtual void dispatch(const Task& task) = 0; + + protected: + Dispatcher() = default; +}; + +std::shared_ptr create_dispatcher_for_runtime( + const std::shared_ptr&); +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.cpp new file mode 100644 index 0000000..d7f1748 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.cpp @@ -0,0 +1,47 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Kevin DuBois + */ +#include "anbox/common/fd.h" + +#include +#include + +namespace anbox { +Fd::Fd() : Fd{invalid} {} + +Fd::Fd(IntOwnedFd fd) : fd{std::make_shared(fd.int_owned_fd)} {} + +Fd::Fd(int raw_fd) + : fd{new int{raw_fd}, + [](int* fd) { + if (!fd) return; + if (*fd > Fd::invalid) ::close(*fd); + delete fd; + }} {} + +Fd::Fd(Fd&& other) : fd{std::move(other.fd)} {} + +Fd& Fd::operator=(Fd other) { + std::swap(fd, other.fd); + return *this; +} + +Fd::operator int() const { + if (fd) return *fd; + return invalid; +} +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.h new file mode 100644 index 0000000..6b2d922 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd.h @@ -0,0 +1,50 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored by: Kevin DuBois + */ + +#ifndef ANBOX_COMMON_FD_H_ +#define ANBOX_COMMON_FD_H_ + +#include + +namespace anbox { +struct IntOwnedFd { + int int_owned_fd; +}; +class Fd { + public: + // transfer ownership of the POD-int to the object. The int no longer needs + // close()ing, + // and has the lifetime of the Fd object. + explicit Fd(int fd); + explicit Fd(IntOwnedFd); + static int const invalid{-1}; + Fd(); // Initializes fd to the anbox::Fd::invalid; + Fd(Fd&&); + Fd(Fd const&) = default; + Fd& operator=(Fd); + + // bit of a convenient kludge. take care not to close or otherwise destroy the + // FD. + operator int() const; + + private: + std::shared_ptr fd; +}; +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd_sets.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd_sets.h new file mode 100644 index 0000000..7e578f9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/fd_sets.h @@ -0,0 +1,31 @@ +/* + * Copyright © 2013 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Robert Carr + */ + +#ifndef ANBOX_COMMON_FD_SETS_H_ +#define ANBOX_COMMON_FD_SETS_H_ + +#include +#include + +#include "anbox/common/fd.h" + +namespace anbox { +typedef std::vector> FdSets; +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.cpp new file mode 100644 index 0000000..f17222d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/common/loop_device.h" +#include "anbox/defer_action.h" + +#include + +#include +#include +#include +#include + +namespace anbox { +namespace common { +std::shared_ptr LoopDevice::create(const boost::filesystem::path &path) { + const auto fd = ::open(path.c_str(), O_RDWR); + if (fd < 0) + throw std::system_error{errno, std::system_category()}; + + return std::shared_ptr(new LoopDevice(Fd{fd}, path)); +} + +LoopDevice::LoopDevice(Fd fd, const boost::filesystem::path &path) : + fd_{fd}, path_{path} {} + +LoopDevice::~LoopDevice() { + if (fd_ < 0) + return; + + ::ioctl(fd_, LOOP_CLR_FD); + ::close(fd_); +} + +bool LoopDevice::attach_file(const boost::filesystem::path &file_path) { + if (fd_ < 0) + return false; + + int file_fd = ::open(file_path.c_str(), O_RDONLY); + if (file_fd < 0) + return false; + + DeferAction close_file_fd{[&]() { ::close(file_fd); }}; + + if (::ioctl(fd_, LOOP_SET_FD, file_fd) < 0) + return false; + + return true; +} +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.h new file mode 100644 index 0000000..1895ac7 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_COMMON_LOOP_DEVICE_H_ +#define ANBOX_COMMON_LOOP_DEVICE_H_ + +#include "anbox/common/fd.h" + +#include + +namespace anbox { +namespace common { +class LoopDevice { + public: + static std::shared_ptr create(const boost::filesystem::path &path); + + ~LoopDevice(); + + bool attach_file(const boost::filesystem::path &file_path); + + boost::filesystem::path path() const { return path_; } + + private: + LoopDevice(Fd fd, const boost::filesystem::path &path); + + Fd fd_; + boost::filesystem::path path_; +}; +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.cpp new file mode 100644 index 0000000..06fefc2 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/common/loop_device_allocator.h" +#include "anbox/common/loop_device.h" +#include "anbox/defer_action.h" +#include "anbox/utils.h" + +#include + +#include +#include +#include +#include + +#include + +namespace fs = boost::filesystem; + +namespace { +const constexpr char *loop_control_path{"/dev/loop-control"}; +const constexpr char *base_loop_path{"/dev/loop"}; +} + +namespace anbox { +namespace common { +std::shared_ptr LoopDeviceAllocator::new_device() { + const auto ctl_fd = ::open(loop_control_path, O_RDWR); + if (ctl_fd < 0) + throw std::system_error{errno, std::system_category()}; + + DeferAction close_ctl_fd{[&]() { ::close(ctl_fd); }}; + + const auto device_nr = ::ioctl(ctl_fd, LOOP_CTL_GET_FREE); + if (device_nr < 0) + throw std::system_error{errno, std::system_category()}; + + return LoopDevice::create(utils::string_format("%s%d", base_loop_path, device_nr)); +} +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.h new file mode 100644 index 0000000..0ce4bad --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/loop_device_allocator.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_COMMON_LOOP_DEVICE_ALLOCATOR_H_ +#define ANBOX_COMMON_LOOP_DEVICE_ALLOCATOR_H_ + +#include + +namespace anbox { +namespace common { +class LoopDevice; +class LoopDeviceAllocator { + public: + static std::shared_ptr new_device(); +}; +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.cpp new file mode 100644 index 0000000..97c399b --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.cpp @@ -0,0 +1,64 @@ +// Copyright 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "anbox/common/message_channel.h" + +namespace anbox { +namespace common { +MessageChannelBase::MessageChannelBase(size_t capacity) : pos_(0U), + count_(0U), + capacity_(capacity), + lock_(), + can_read_(), + can_write_() {} + +MessageChannelBase::~MessageChannelBase() {} + +size_t MessageChannelBase::before_write() { + std::unique_lock l(lock_, std::defer_lock); + lock_.lock(); + + while (count_ >= capacity_) + can_write_.wait(l); + + size_t result = pos_ + count_; + if (result >= capacity_) + result -= capacity_; + + return result; +} + +void MessageChannelBase::after_write() { + count_++; + can_read_.notify_one(); + lock_.unlock(); +} + +size_t MessageChannelBase::before_read() { + std::unique_lock l(lock_, std::defer_lock); + lock_.lock(); + while (count_ == 0) + can_read_.wait(l); + return pos_; +} + +void MessageChannelBase::after_read() { + if (++pos_ == capacity_) + pos_ = 0U; + count_--; + can_write_.notify_one(); + lock_.unlock(); +} +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.h new file mode 100644 index 0000000..930d92c --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/message_channel.h @@ -0,0 +1,99 @@ +// Copyright 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef ANBOX_COMMON_MESSAGE_CHANNEL_H +#define ANBOX_COMMON_MESSAGE_CHANNEL_H + +#include + +#include +#include + +namespace anbox { +namespace common { + +// Base non-templated class used to reduce the amount of template +// specialization. +class MessageChannelBase { + public: + // Constructor. |capacity| is the buffer capacity in messages. + MessageChannelBase(size_t capacity); + + // Destructor. + ~MessageChannelBase(); + + protected: + // Call this method in the sender thread before writing a new message. + // This returns the position of the available slot in the message array + // where to copy the new fixed-size message. After the copy, call + // afterWrite(). + size_t before_write(); + + // To be called after beforeWrite() and copying a new fixed-size message + // into the array. This signal the receiver thread that there is a new + // incoming message. + void after_write(); + + // Call this method in the receiver thread before reading a new message. + // This returns the position in the message array where the new message + // can be read. Caller must process the message, then call afterRead(). + size_t before_read(); + + // To be called in the receiver thread after beforeRead() and processing + // the corresponding message. + void after_read(); + + private: + size_t pos_; + size_t count_; + size_t capacity_; + std::mutex lock_; + std::condition_variable can_read_; + std::condition_variable can_write_; +}; + +// Helper class used to implement an uni-directional IPC channel between +// two threads. The channel can be used to send fixed-size messages of type +// |T|, with an internal buffer size of |CAPACITY| items. All calls are +// blocking. +// +// Usage is pretty straightforward: +// +// - From the sender thread, call send(msg); +// - From the receiver thread, call receive(&msg); +// +template +class MessageChannel : public MessageChannelBase { + public: + MessageChannel() : MessageChannelBase(CAPACITY) {} + + void send(const T& msg) { + size_t pos = before_write(); + mItems[pos] = msg; + after_write(); + } + + void receive(T* msg) { + size_t pos = before_read(); + *msg = mItems[pos]; + after_read(); + } + + private: + T mItems[CAPACITY]; +}; +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.cpp new file mode 100644 index 0000000..4ee7eb9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/common/mount_entry.h" +#include "anbox/common/loop_device.h" +#include "anbox/logger.h" + +#include + +namespace anbox { +namespace common { +std::shared_ptr MountEntry::create(const boost::filesystem::path &src, const boost::filesystem::path &target, + const std::string &fs_type, unsigned long flags, const std::string &data) { + auto entry = std::shared_ptr(new MountEntry(target)); + if (!entry) + return nullptr; + + const void *mount_data = nullptr; + if (!data.empty()) + mount_data = reinterpret_cast(data.c_str()); + + DEBUG("Mounting %s on %s ...", src, target); + + if (::mount(src.c_str(), target.c_str(), !fs_type.empty() ? fs_type.c_str() : nullptr, flags, mount_data) < 0) { + ERROR("Failed to mount %s: %s", target, strerror(errno)); + return nullptr; + } + + entry->active_ = true; + + return entry; +} + +std::shared_ptr MountEntry::create(const std::shared_ptr &loop, const boost::filesystem::path &target, + const std::string &fs_type, unsigned long flags, const std::string &data) { + auto entry = create(loop->path(), target, fs_type, flags, data); + if (!entry) + return nullptr; + + entry->loop_ = loop; + return entry; +} + +std::shared_ptr MountEntry::create(const boost::filesystem::path &target) { + auto entry = std::shared_ptr(new MountEntry(target)); + if (!entry) + return nullptr; + + entry->active_ = true; + + return entry; +} + +MountEntry::MountEntry(const boost::filesystem::path &target) : + active_{false}, target_{target} {} + +MountEntry::~MountEntry() { + if (!active_) + return; + + ::umount(target_.c_str()); +} +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.h new file mode 100644 index 0000000..2ea95f9 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/mount_entry.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2017 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_COMMON_MOUNT_ENTRY_H_ +#define ANBOX_COMMON_MOUNT_ENTRY_H_ + +#include + +namespace anbox { +namespace common { +class LoopDevice; +class MountEntry { + public: + static std::shared_ptr create(const boost::filesystem::path &src, const boost::filesystem::path &target, + const std::string &fs_type = "", unsigned long flags = 0, const std::string &data = ""); + + static std::shared_ptr create(const std::shared_ptr &loop, const boost::filesystem::path &target, + const std::string &fs_type = "", unsigned long flags = 0, const std::string &data = ""); + + static std::shared_ptr create(const boost::filesystem::path &target); + + ~MountEntry(); + + private: + MountEntry(const boost::filesystem::path &target); + + bool active_; + std::shared_ptr loop_; + boost::filesystem::path target_; +}; +} // namespace common +} // namespace anbox + +#endif diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/scope_ptr.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/scope_ptr.h new file mode 100644 index 0000000..d59b6e3 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/scope_ptr.h @@ -0,0 +1,99 @@ +// Copyright 2014 The Android Open Source Project +// +// This software is licensed under the terms of the GNU General Public +// License version 2, as published by the Free Software Foundation, and +// may be copied, distributed, and modified under those terms. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +#pragma once + +#include "anbox/common/type_traits.h" + +#include +#include +#include + +#include + +namespace anbox { +namespace common { + +struct FreeDelete { + template + void operator()(T ptr) const { + free(ptr); + } +}; + +template +struct FuncDelete { + explicit FuncDelete(Func f = {}) : mF(f) {} + + FuncDelete(const FuncDelete& other) = default; + FuncDelete(FuncDelete&& other) = default; + FuncDelete& operator=(const FuncDelete& other) = default; + FuncDelete& operator=(FuncDelete&& other) = default; + + // To be able to copy/move from all compatible template instantiations. + template + friend struct FuncDelete; + + // Template constructors and move assignment from compatible instantiations. + template + FuncDelete(const FuncDelete& other) : mF(other.mF) {} + template + FuncDelete(FuncDelete&& other) : mF(std::move(other.mF)) {} + template + FuncDelete& operator=(const FuncDelete& other) { + mF = other.mF; + return *this; + } + template + FuncDelete& operator=(FuncDelete&& other) { + mF = std::move(other.mF); + return *this; + } + + // This is the actual deleter call. + template + void operator()(T t) const { + mF(t); + } + + private: + Func mF; +}; + +template > +using ScopedPtr = std::unique_ptr; + +template +using ScopedCPtr = std::unique_ptr; + +template +using ScopedCustomPtr = std::unique_ptr>; + +// A factory function that creates a scoped pointer with |deleter| +// function used as a deleter - it is called at the scope exit. +// Note: enable_if<> limits the scope of allowed arguments to pointers and +// std::nullptr_t (to allow makeCustomScopedPtr(nullptr, ...) calls). +template ::value || + std::is_pointer::value>> +ScopedCustomPtr< + typename std::decay::type>::type, + typename std::decay::type> +makeCustomScopedPtr(T data, Func deleter) { + return ScopedCustomPtr< + typename std::decay::type>::type, + typename std::decay::type>( + data, FuncDelete::type>(deleter)); +} + +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/small_vector.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/small_vector.h new file mode 100644 index 0000000..74f5f0d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/small_vector.h @@ -0,0 +1,376 @@ +// Copyright 2016 The Android Open Source Project +// +// This software is licensed under the terms of the GNU General Public +// License version 2, as published by the Free Software Foundation, and +// may be copied, distributed, and modified under those terms. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +#pragma once + +#include "anbox/common/type_traits.h" + +#include +#include +#include +#include +#include + +#include +#include + +// +// SmallVector, SmallFixedVector +// +// This header defines a replacement for a std::vector<> that uses small buffer +// optimization technique - for some preset number of elements |SmallSize| it +// stores them inside of the object, and falls back to the dynamically allocated +// array only if one needs to add more elements. +// This is useful for the performance-critical places where common number of +// processed items is small, but it may still be quite large for a stack array. +// +// SmallFixedVector<> is the class you use to store elements, while +// SmallVector<> is its base class that erases the small size from the type. +// +// NOTE: SmallVector<> cannot guarantee std::vector<>'s iterator invalidation +// rules for move() and swap() operations - std::vector<>s just exchange +// their iterators on swap() and pass the moved ones over, while SmallVector<> +// may leave the iterators pointing to nowhere if they were for the in-place +// array storage. +// +// Currenly only a limited subset of std::vector<>'s operations is implemented, +// but fill free to add the ones you need. +// + +namespace anbox { +namespace common { + +// +// Forward-declare the 'real' small vector class. +template +class SmallFixedVector; + +// +// SmallVector - an interface for a small-buffer-optimized vector. +// It hides the fixed size from its type, so one can use it to pass small +// vectors around and not leak the buffer size to all callers: +// +// void process(SmallVector& data); +// ... +// ... +// SmallFixedVector aLittleBitOfFoos = ...; +// process(aLittleBitOfFoos); +// ... +// SmallFixedVector moreFoos = ...; +// process(moreFoos); +// +template +class SmallVector { + // Make them friends so SmallFixedVector is able to refer to SmallVector's + // protected members in static_assert()s. + template + friend class SmallFixedVector; + + public: + // Common set of type aliases. + using value_type = T; + using iterator = T*; + using const_iterator = const T*; + using pointer = T*; + using const_pointer = const T*; + using reference = T&; + using const_reference = const T&; + using size_type = size_t; + + // It's ok to delete SmallVector<> through the base class - dtor() actually + // takes care of all living elements and the allocated memory. + ~SmallVector() { dtor(); } + + // std::vector<> interface operations. + iterator begin() { return mBegin; } + const_iterator begin() const { return mBegin; } + const_iterator cbegin() const { return mBegin; } + + iterator end() { return mEnd; } + const_iterator end() const { return mEnd; } + const_iterator cend() const { return mEnd; } + + size_type size() const { return end() - begin(); } + size_type capacity() const { return mCapacity; } + bool empty() const { return begin() == end(); } + + reference operator[](size_t i) { return *(begin() + i); } + const_reference operator[](size_t i) const { return *(cbegin() + i); } + + pointer data() { return mBegin; } + const_pointer data() const { return mBegin; } + const_pointer cdata() const { return mBegin; } + + template + void emplace_back(Args&&... args) { + grow_for_size(size() + 1); + new (mEnd) T(std::forward(args)...); + ++mEnd; + } + + void push_back(const T& t) { emplace_back(t); } + void push_back(T&& t) { emplace_back(std::move(t)); } + + void clear() { + destruct(begin(), end()); + mEnd = mBegin; + } + + void reserve(size_type newCap) { + if (newCap <= this->capacity()) { + return; + } + set_capacity(newCap); + } + + void resize(size_type newSize) { resize_impl(newSize); } + + // This version of resizing doesn't initialize the newly allocated elements + // Useful for the cases when value-initialization is noticeably slow and + // one wants to directly construct or memcpy the elements into the resized + // place. + void resize_noinit(size_type newSize) { resize_impl(newSize); } + + // Returns if the current vector's buffer is dynamically allocated. + bool isAllocated() const { return this->cbegin() != smallBufferStart(); } + + protected: + // Hide the default constructor so only SmallFixedVector can be + // instantiated. + SmallVector() = default; + + // Destroy all elements in the vector and free the array if it was allocated + // dynamically. + void dtor() { + this->destruct(this->begin(), this->end()); + if (isAllocated()) { + free(this->mBegin); + } + } + + // Just a convenience setter function to init all members at once. + void init(iterator begin, iterator end, size_type capacity) { + this->mBegin = begin; + this->mEnd = end; + this->mCapacity = capacity; + } + + // An implementation of different resizing versions. + template + void resize_impl(size_type newSize) { + if (newSize < this->size()) { + const auto newEnd = this->begin() + newSize; + this->destruct(newEnd, this->end()); + this->mEnd = newEnd; + } else if (newSize > this->size()) { + grow_for_size(newSize); + const auto newEnd = this->begin() + newSize; + if (init) { + std::uninitialized_fill(this->end(), newEnd, T()); + } + this->mEnd = newEnd; + } + } + + // Templated append operation for a range of elements. + template + void insert_back(Iter b, Iter e) { + if (b == e) { + return; + } + const auto newSize = this->size() + (e - b); + grow_for_size(newSize); + this->mEnd = std::uninitialized_copy(b, e, this->mEnd); + } + + // Multiplicative grow for the internal array so it can hold |newSize| + // elements. + // Doesn't change size(), only capacity(). + void grow_for_size(size_type newSize) { + // Grow by 1.5x by default. + if (newSize > capacity()) { + set_capacity(std::max(newSize, capacity() + capacity() / 2)); + } + } + + // Sets the capacity() to be exacly |newCap|. Allocates the array + // dynamically, moves all elements over and (potentially) deallocates the + // old array. + // Doesn't change size(), only capacity(). + void set_capacity(size_type newCap) { + // Here we can only be switching to the dynamic vector, as static one + // always has its capacity on the maximum. + const auto newBegin = static_cast(malloc(sizeof(T) * newCap)); + if (!newBegin) { + abort(); // what else can we do here? + } + const auto newEnd = + std::uninitialized_copy(std::make_move_iterator(this->begin()), + std::make_move_iterator(this->end()), newBegin); + dtor(); + this->mBegin = newBegin; + this->mEnd = newEnd; + this->mCapacity = newCap; + } + + // A convenience function to call destructor for a range of elements. + static void destruct(T* b, T* e) { + if (!std::is_trivially_destructible::value) { + for (; b != e; ++b) { + b->~T(); + } + } + } + + // By design of the class, SmallFixedVector<> will be inheriting from + // SmallVector<>, so its in-place storage array is going to be the very next + // member after the last one here. + // This function returns that address, and SmallFixedVector<> has a static + // assert to make sure it remains correct. + constexpr const void* smallBufferStart() const { + return static_cast(&mCapacity + 1); + } + + // Standard set of members for a vector - begin, end and capacity. + // These point to the currently used chunk of memory, no matter if it's a + // heap-allocated one or an in-place array. + iterator mBegin; + iterator mEnd; + size_type mCapacity; +}; + +// The implementation of a SmallVector with a fixed in-place size, |SmallSize|. +template +class SmallFixedVector : public SmallVector { + using base = SmallVector; + + public: + // Grab these from the base class. + using value_type = typename base::value_type; + using iterator = typename base::iterator; + using const_iterator = typename base::const_iterator; + using pointer = typename base::pointer; + using const_pointer = typename base::const_pointer; + using reference = typename base::reference; + using const_reference = typename base::const_reference; + using size_type = typename base::size_type; + + static constexpr size_type kSmallSize = SmallSize; + + // Default constructor - set up an empty vector with capacity at full + // internal array size. + SmallFixedVector() { + init_inplace(); + } + + // Ctor from a range of iterators + template + SmallFixedVector(Iter b, Iter e) : SmallFixedVector() { + this->insert_back(b, e); + } + + // Ctor from a range - anything that has begin and end. + // Note: template constructor is never a copy/move-ctor. + template ::value && + is_range::value>> + explicit SmallFixedVector(const Range& r) + : SmallFixedVector(std::begin(r), std::end(r)) {} + template ::value && + is_range::value>> + explicit SmallFixedVector(Range&& r) + : SmallFixedVector(std::make_move_iterator(std::begin(r)), + std::make_move_iterator(std::end(r))) {} + template > + SmallFixedVector(std::initializer_list list) + : SmallFixedVector(std::begin(list), std::end(list)) {} + + SmallFixedVector(const SmallFixedVector& other) + : SmallFixedVector(other.begin(), other.end()) {} + + SmallFixedVector(SmallFixedVector&& other) { + if (other.isAllocated()) { + // Just steal the allocated memory from the |other|. + this->mBegin = other.mBegin; + this->mEnd = other.mEnd; + this->mCapacity = other.mCapacity; + other.init_inplace(); + } else { + // Have to move individual elements. + this->mBegin = mData.array; + this->mEnd = std::uninitialized_copy( + std::make_move_iterator(other.begin()), + std::make_move_iterator(other.end()), this->begin()); + this->mCapacity = kSmallSize; + } + } + + SmallFixedVector& operator=(const SmallFixedVector& other) { + if (&other != this) { + this->clear(); + this->insert_back(other.begin(), other.end()); + } + return *this; + } + + SmallFixedVector& operator=(SmallFixedVector&& other) { + if (other.isAllocated()) { + // Steal it and we're done. + this->dtor(); + this->mBegin = other.mBegin; + this->mEnd = other.mEnd; + this->mCapacity = other.mCapacity; + other.init_inplace(); + return *this; + } + + if (this->isAllocated() && this->mCapacity < other.size()) { + // Not enough dynamic memory, switch to in-place. + this->dtor(); + init_inplace(); + } else { + // This could potentially be improved by move-assigning + // only needed items and destroying the rest, but + // destroy-all+construct-all is just simpler. For PODs it actually + // is even faster as it's always a single memcpy(). + this->destruct(this->begin(), this->end()); + } + + // Move the whole |other| into the pre-cleaned memory + const auto newEnd = std::uninitialized_copy( + std::make_move_iterator(other.begin()), + std::make_move_iterator(other.end()), this->mBegin); + this->mEnd = newEnd; + // |other| is valid as-is. + return *this; + } + + // Make sure we don't end up trying to move from an interface - it's just + // inefficient with the current code. + SmallFixedVector(base&& other) = delete; + SmallFixedVector& operator=(base&& other) = delete; + + private: + // A shortcut for initialization for in-place storage. + void init_inplace() { this->init(mData.array, mData.array, kSmallSize); } + + // A union with empty constructor and destructor makes sure that the array + // elements are not default-constructed in ctor and not destructed in dtor: + // the class needs to be able manage their lifetime more precisely. + union Data { + alignas(size_type) T array[kSmallSize]; + + Data() {} + ~Data() {} + } mData; +}; + +} // namespace common +} // namespace anbox diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/common/type_traits.h b/src/type3_AndroidCloud/anbox-master/src/anbox/common/type_traits.h new file mode 100644 index 0000000..eb7a192 --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/common/type_traits.h @@ -0,0 +1,124 @@ +// Copyright 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include + +namespace anbox { +namespace common { + +namespace details { + +// a simple helper class for SFINAE below. +template +struct dummy { + using type = X; +}; + +} // namespaces details + +// add some convenience shortcuts for an overly complex std::enable_if syntax + +// Use 'enable_if' instead of +// 'typename std::enable_if::type' +template +using enable_if = typename std::enable_if::type; + +// Use 'enable_if_c' instead of +// 'typename std::enable_if::type' +template +using enable_if_c = typename std::enable_if::type; + +// Use 'enable_if_convertible' instead of +// 'typename std::enable_if::value, Type>::type' +template +using enable_if_convertible = enable_if>; + +// ----------------------------------------------------------------------------- +// A predicate for checking if some object is callable with a specific +// signature. Examples: +// +// is_callable_as::value == false. +// is_callable_as::value == false. +// is_callable_as::value == true +// +template +struct is_callable_as : std::false_type {}; + +// This specialization is SFINAE-d out if template arguments can't be combined +// into a call expression F(), or if the result of that call is not |R| +template +struct is_callable_as< + F, R(), typename std::enable_if()())>::type, + R>::value>::type> : std::true_type {}; + +// One more specialization, for non empty argument list +template +struct is_callable_as()( + std::declval()...))>::type, + R>::value>::type> : std::true_type {}; +// ----------------------------------------------------------------------------- +// Check if a type |T| is any instantiation of a template |U|. Examples: +// +// is_template_instantiation_of::value == false +// is_template_instantiation_of< +// std::list>, std::vector>::value == false +// is_template_instantiation_of, std::vector>::value == true +// is_template_instantiation_of< +// std::vector>, std::vector>::value == true +// +template class U> +struct is_template_instantiation_of : std::false_type {}; + +template